babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  681. static readonly GEQUAL: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in right handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in right handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4940. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of float in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 of float in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 of float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets the global Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets the highlights Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets the midtones Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets the shadows Density value.
  8157. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11851. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. private _rootParticleSystem;
  11865. /**
  11866. * Gets the current list of active particles
  11867. */
  11868. get particles(): Particle[];
  11869. /**
  11870. * Returns the string "ParticleSystem"
  11871. * @returns a string containing the class name
  11872. */
  11873. getClassName(): string;
  11874. /**
  11875. * Instantiates a particle system.
  11876. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11877. * @param name The name of the particle system
  11878. * @param capacity The max number of particles alive at the same time
  11879. * @param scene The scene the particle system belongs to
  11880. * @param customEffect a custom effect used to change the way particles are rendered by default
  11881. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11882. * @param epsilon Offset used to render the particles
  11883. */
  11884. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11885. private _addFactorGradient;
  11886. private _removeFactorGradient;
  11887. /**
  11888. * Adds a new life time gradient
  11889. * @param gradient defines the gradient to use (between 0 and 1)
  11890. * @param factor defines the life time factor to affect to the specified gradient
  11891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11892. * @returns the current particle system
  11893. */
  11894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11895. /**
  11896. * Remove a specific life time gradient
  11897. * @param gradient defines the gradient to remove
  11898. * @returns the current particle system
  11899. */
  11900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11901. /**
  11902. * Adds a new size gradient
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param factor defines the size factor to affect to the specified gradient
  11905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11906. * @returns the current particle system
  11907. */
  11908. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11909. /**
  11910. * Remove a specific size gradient
  11911. * @param gradient defines the gradient to remove
  11912. * @returns the current particle system
  11913. */
  11914. removeSizeGradient(gradient: number): IParticleSystem;
  11915. /**
  11916. * Adds a new color remap gradient
  11917. * @param gradient defines the gradient to use (between 0 and 1)
  11918. * @param min defines the color remap minimal range
  11919. * @param max defines the color remap maximal range
  11920. * @returns the current particle system
  11921. */
  11922. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11923. /**
  11924. * Remove a specific color remap gradient
  11925. * @param gradient defines the gradient to remove
  11926. * @returns the current particle system
  11927. */
  11928. removeColorRemapGradient(gradient: number): IParticleSystem;
  11929. /**
  11930. * Adds a new alpha remap gradient
  11931. * @param gradient defines the gradient to use (between 0 and 1)
  11932. * @param min defines the alpha remap minimal range
  11933. * @param max defines the alpha remap maximal range
  11934. * @returns the current particle system
  11935. */
  11936. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11937. /**
  11938. * Remove a specific alpha remap gradient
  11939. * @param gradient defines the gradient to remove
  11940. * @returns the current particle system
  11941. */
  11942. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11943. /**
  11944. * Adds a new angular speed gradient
  11945. * @param gradient defines the gradient to use (between 0 and 1)
  11946. * @param factor defines the angular speed to affect to the specified gradient
  11947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11948. * @returns the current particle system
  11949. */
  11950. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11951. /**
  11952. * Remove a specific angular speed gradient
  11953. * @param gradient defines the gradient to remove
  11954. * @returns the current particle system
  11955. */
  11956. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11957. /**
  11958. * Adds a new velocity gradient
  11959. * @param gradient defines the gradient to use (between 0 and 1)
  11960. * @param factor defines the velocity to affect to the specified gradient
  11961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11962. * @returns the current particle system
  11963. */
  11964. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11965. /**
  11966. * Remove a specific velocity gradient
  11967. * @param gradient defines the gradient to remove
  11968. * @returns the current particle system
  11969. */
  11970. removeVelocityGradient(gradient: number): IParticleSystem;
  11971. /**
  11972. * Adds a new limit velocity gradient
  11973. * @param gradient defines the gradient to use (between 0 and 1)
  11974. * @param factor defines the limit velocity value to affect to the specified gradient
  11975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11976. * @returns the current particle system
  11977. */
  11978. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11979. /**
  11980. * Remove a specific limit velocity gradient
  11981. * @param gradient defines the gradient to remove
  11982. * @returns the current particle system
  11983. */
  11984. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11985. /**
  11986. * Adds a new drag gradient
  11987. * @param gradient defines the gradient to use (between 0 and 1)
  11988. * @param factor defines the drag value to affect to the specified gradient
  11989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11990. * @returns the current particle system
  11991. */
  11992. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11993. /**
  11994. * Remove a specific drag gradient
  11995. * @param gradient defines the gradient to remove
  11996. * @returns the current particle system
  11997. */
  11998. removeDragGradient(gradient: number): IParticleSystem;
  11999. /**
  12000. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12001. * @param gradient defines the gradient to use (between 0 and 1)
  12002. * @param factor defines the emit rate value to affect to the specified gradient
  12003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12004. * @returns the current particle system
  12005. */
  12006. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12007. /**
  12008. * Remove a specific emit rate gradient
  12009. * @param gradient defines the gradient to remove
  12010. * @returns the current particle system
  12011. */
  12012. removeEmitRateGradient(gradient: number): IParticleSystem;
  12013. /**
  12014. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12015. * @param gradient defines the gradient to use (between 0 and 1)
  12016. * @param factor defines the start size value to affect to the specified gradient
  12017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12018. * @returns the current particle system
  12019. */
  12020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12021. /**
  12022. * Remove a specific start size gradient
  12023. * @param gradient defines the gradient to remove
  12024. * @returns the current particle system
  12025. */
  12026. removeStartSizeGradient(gradient: number): IParticleSystem;
  12027. private _createRampGradientTexture;
  12028. /**
  12029. * Gets the current list of ramp gradients.
  12030. * You must use addRampGradient and removeRampGradient to udpate this list
  12031. * @returns the list of ramp gradients
  12032. */
  12033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12034. /**
  12035. * Adds a new ramp gradient used to remap particle colors
  12036. * @param gradient defines the gradient to use (between 0 and 1)
  12037. * @param color defines the color to affect to the specified gradient
  12038. * @returns the current particle system
  12039. */
  12040. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12041. /**
  12042. * Remove a specific ramp gradient
  12043. * @param gradient defines the gradient to remove
  12044. * @returns the current particle system
  12045. */
  12046. removeRampGradient(gradient: number): ParticleSystem;
  12047. /**
  12048. * Adds a new color gradient
  12049. * @param gradient defines the gradient to use (between 0 and 1)
  12050. * @param color1 defines the color to affect to the specified gradient
  12051. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12052. * @returns this particle system
  12053. */
  12054. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12055. /**
  12056. * Remove a specific color gradient
  12057. * @param gradient defines the gradient to remove
  12058. * @returns this particle system
  12059. */
  12060. removeColorGradient(gradient: number): IParticleSystem;
  12061. private _fetchR;
  12062. protected _reset(): void;
  12063. private _resetEffect;
  12064. private _createVertexBuffers;
  12065. private _createIndexBuffer;
  12066. /**
  12067. * Gets the maximum number of particles active at the same time.
  12068. * @returns The max number of active particles.
  12069. */
  12070. getCapacity(): number;
  12071. /**
  12072. * Gets whether there are still active particles in the system.
  12073. * @returns True if it is alive, otherwise false.
  12074. */
  12075. isAlive(): boolean;
  12076. /**
  12077. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12078. * @returns True if it has been started, otherwise false.
  12079. */
  12080. isStarted(): boolean;
  12081. private _prepareSubEmitterInternalArray;
  12082. /**
  12083. * Starts the particle system and begins to emit
  12084. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12085. */
  12086. start(delay?: number): void;
  12087. /**
  12088. * Stops the particle system.
  12089. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12090. */
  12091. stop(stopSubEmitters?: boolean): void;
  12092. /**
  12093. * Remove all active particles
  12094. */
  12095. reset(): void;
  12096. /**
  12097. * @hidden (for internal use only)
  12098. */
  12099. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12100. /**
  12101. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12102. * Its lifetime will start back at 0.
  12103. */
  12104. recycleParticle: (particle: Particle) => void;
  12105. private _stopSubEmitters;
  12106. private _createParticle;
  12107. private _removeFromRoot;
  12108. private _emitFromParticle;
  12109. private _update;
  12110. /** @hidden */
  12111. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12112. /** @hidden */
  12113. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12114. /** @hidden */
  12115. private _getEffect;
  12116. /**
  12117. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12118. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12119. */
  12120. animate(preWarmOnly?: boolean): void;
  12121. private _appendParticleVertices;
  12122. /**
  12123. * Rebuilds the particle system.
  12124. */
  12125. rebuild(): void;
  12126. /**
  12127. * Is this system ready to be used/rendered
  12128. * @return true if the system is ready
  12129. */
  12130. isReady(): boolean;
  12131. private _render;
  12132. /**
  12133. * Renders the particle system in its current state.
  12134. * @returns the current number of particles
  12135. */
  12136. render(): number;
  12137. /**
  12138. * Disposes the particle system and free the associated resources
  12139. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12140. */
  12141. dispose(disposeTexture?: boolean): void;
  12142. /**
  12143. * Clones the particle system.
  12144. * @param name The name of the cloned object
  12145. * @param newEmitter The new emitter to use
  12146. * @returns the cloned particle system
  12147. */
  12148. clone(name: string, newEmitter: any): ParticleSystem;
  12149. /**
  12150. * Serializes the particle system to a JSON object.
  12151. * @returns the JSON object
  12152. */
  12153. serialize(): any;
  12154. /** @hidden */
  12155. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12156. /** @hidden */
  12157. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12158. /**
  12159. * Parses a JSON object to create a particle system.
  12160. * @param parsedParticleSystem The JSON object to parse
  12161. * @param scene The scene to create the particle system in
  12162. * @param rootUrl The root url to use to load external dependencies like texture
  12163. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12164. * @returns the Parsed particle system
  12165. */
  12166. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12167. }
  12168. }
  12169. declare module "babylonjs/Particles/particle" {
  12170. import { Nullable } from "babylonjs/types";
  12171. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12172. import { Color4 } from "babylonjs/Maths/math.color";
  12173. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12174. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12175. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12176. /**
  12177. * A particle represents one of the element emitted by a particle system.
  12178. * This is mainly define by its coordinates, direction, velocity and age.
  12179. */
  12180. export class Particle {
  12181. /**
  12182. * The particle system the particle belongs to.
  12183. */
  12184. particleSystem: ParticleSystem;
  12185. private static _Count;
  12186. /**
  12187. * Unique ID of the particle
  12188. */
  12189. id: number;
  12190. /**
  12191. * The world position of the particle in the scene.
  12192. */
  12193. position: Vector3;
  12194. /**
  12195. * The world direction of the particle in the scene.
  12196. */
  12197. direction: Vector3;
  12198. /**
  12199. * The color of the particle.
  12200. */
  12201. color: Color4;
  12202. /**
  12203. * The color change of the particle per step.
  12204. */
  12205. colorStep: Color4;
  12206. /**
  12207. * Defines how long will the life of the particle be.
  12208. */
  12209. lifeTime: number;
  12210. /**
  12211. * The current age of the particle.
  12212. */
  12213. age: number;
  12214. /**
  12215. * The current size of the particle.
  12216. */
  12217. size: number;
  12218. /**
  12219. * The current scale of the particle.
  12220. */
  12221. scale: Vector2;
  12222. /**
  12223. * The current angle of the particle.
  12224. */
  12225. angle: number;
  12226. /**
  12227. * Defines how fast is the angle changing.
  12228. */
  12229. angularSpeed: number;
  12230. /**
  12231. * Defines the cell index used by the particle to be rendered from a sprite.
  12232. */
  12233. cellIndex: number;
  12234. /**
  12235. * The information required to support color remapping
  12236. */
  12237. remapData: Vector4;
  12238. /** @hidden */
  12239. _randomCellOffset?: number;
  12240. /** @hidden */
  12241. _initialDirection: Nullable<Vector3>;
  12242. /** @hidden */
  12243. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12244. /** @hidden */
  12245. _initialStartSpriteCellID: number;
  12246. /** @hidden */
  12247. _initialEndSpriteCellID: number;
  12248. /** @hidden */
  12249. _currentColorGradient: Nullable<ColorGradient>;
  12250. /** @hidden */
  12251. _currentColor1: Color4;
  12252. /** @hidden */
  12253. _currentColor2: Color4;
  12254. /** @hidden */
  12255. _currentSizeGradient: Nullable<FactorGradient>;
  12256. /** @hidden */
  12257. _currentSize1: number;
  12258. /** @hidden */
  12259. _currentSize2: number;
  12260. /** @hidden */
  12261. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12262. /** @hidden */
  12263. _currentAngularSpeed1: number;
  12264. /** @hidden */
  12265. _currentAngularSpeed2: number;
  12266. /** @hidden */
  12267. _currentVelocityGradient: Nullable<FactorGradient>;
  12268. /** @hidden */
  12269. _currentVelocity1: number;
  12270. /** @hidden */
  12271. _currentVelocity2: number;
  12272. /** @hidden */
  12273. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12274. /** @hidden */
  12275. _currentLimitVelocity1: number;
  12276. /** @hidden */
  12277. _currentLimitVelocity2: number;
  12278. /** @hidden */
  12279. _currentDragGradient: Nullable<FactorGradient>;
  12280. /** @hidden */
  12281. _currentDrag1: number;
  12282. /** @hidden */
  12283. _currentDrag2: number;
  12284. /** @hidden */
  12285. _randomNoiseCoordinates1: Vector3;
  12286. /** @hidden */
  12287. _randomNoiseCoordinates2: Vector3;
  12288. /**
  12289. * Creates a new instance Particle
  12290. * @param particleSystem the particle system the particle belongs to
  12291. */
  12292. constructor(
  12293. /**
  12294. * The particle system the particle belongs to.
  12295. */
  12296. particleSystem: ParticleSystem);
  12297. private updateCellInfoFromSystem;
  12298. /**
  12299. * Defines how the sprite cell index is updated for the particle
  12300. */
  12301. updateCellIndex(): void;
  12302. /** @hidden */
  12303. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12304. /** @hidden */
  12305. _inheritParticleInfoToSubEmitters(): void;
  12306. /** @hidden */
  12307. _reset(): void;
  12308. /**
  12309. * Copy the properties of particle to another one.
  12310. * @param other the particle to copy the information to.
  12311. */
  12312. copyTo(other: Particle): void;
  12313. }
  12314. }
  12315. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12316. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12317. import { Effect } from "babylonjs/Materials/effect";
  12318. import { Particle } from "babylonjs/Particles/particle";
  12319. import { Scene } from "babylonjs/scene";
  12320. /**
  12321. * Particle emitter represents a volume emitting particles.
  12322. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12323. */
  12324. export interface IParticleEmitterType {
  12325. /**
  12326. * Called by the particle System when the direction is computed for the created particle.
  12327. * @param worldMatrix is the world matrix of the particle system
  12328. * @param directionToUpdate is the direction vector to update with the result
  12329. * @param particle is the particle we are computed the direction for
  12330. */
  12331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12332. /**
  12333. * Called by the particle System when the position is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param positionToUpdate is the position vector to update with the result
  12336. * @param particle is the particle we are computed the position for
  12337. */
  12338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Clones the current emitter and returns a copy of it
  12341. * @returns the new emitter
  12342. */
  12343. clone(): IParticleEmitterType;
  12344. /**
  12345. * Called by the GPUParticleSystem to setup the update shader
  12346. * @param effect defines the update shader
  12347. */
  12348. applyToShader(effect: Effect): void;
  12349. /**
  12350. * Returns a string to use to update the GPU particles update shader
  12351. * @returns the effect defines string
  12352. */
  12353. getEffectDefines(): string;
  12354. /**
  12355. * Returns a string representing the class name
  12356. * @returns a string containing the class name
  12357. */
  12358. getClassName(): string;
  12359. /**
  12360. * Serializes the particle system to a JSON object.
  12361. * @returns the JSON object
  12362. */
  12363. serialize(): any;
  12364. /**
  12365. * Parse properties from a JSON object
  12366. * @param serializationObject defines the JSON object
  12367. * @param scene defines the hosting scene
  12368. */
  12369. parse(serializationObject: any, scene: Scene): void;
  12370. }
  12371. }
  12372. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12373. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12374. import { Effect } from "babylonjs/Materials/effect";
  12375. import { Particle } from "babylonjs/Particles/particle";
  12376. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12377. /**
  12378. * Particle emitter emitting particles from the inside of a box.
  12379. * It emits the particles randomly between 2 given directions.
  12380. */
  12381. export class BoxParticleEmitter implements IParticleEmitterType {
  12382. /**
  12383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12384. */
  12385. direction1: Vector3;
  12386. /**
  12387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12388. */
  12389. direction2: Vector3;
  12390. /**
  12391. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12392. */
  12393. minEmitBox: Vector3;
  12394. /**
  12395. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12396. */
  12397. maxEmitBox: Vector3;
  12398. /**
  12399. * Creates a new instance BoxParticleEmitter
  12400. */
  12401. constructor();
  12402. /**
  12403. * Called by the particle System when the direction is computed for the created particle.
  12404. * @param worldMatrix is the world matrix of the particle system
  12405. * @param directionToUpdate is the direction vector to update with the result
  12406. * @param particle is the particle we are computed the direction for
  12407. */
  12408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12409. /**
  12410. * Called by the particle System when the position is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param positionToUpdate is the position vector to update with the result
  12413. * @param particle is the particle we are computed the position for
  12414. */
  12415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Clones the current emitter and returns a copy of it
  12418. * @returns the new emitter
  12419. */
  12420. clone(): BoxParticleEmitter;
  12421. /**
  12422. * Called by the GPUParticleSystem to setup the update shader
  12423. * @param effect defines the update shader
  12424. */
  12425. applyToShader(effect: Effect): void;
  12426. /**
  12427. * Returns a string to use to update the GPU particles update shader
  12428. * @returns a string containng the defines string
  12429. */
  12430. getEffectDefines(): string;
  12431. /**
  12432. * Returns the string "BoxParticleEmitter"
  12433. * @returns a string containing the class name
  12434. */
  12435. getClassName(): string;
  12436. /**
  12437. * Serializes the particle system to a JSON object.
  12438. * @returns the JSON object
  12439. */
  12440. serialize(): any;
  12441. /**
  12442. * Parse properties from a JSON object
  12443. * @param serializationObject defines the JSON object
  12444. */
  12445. parse(serializationObject: any): void;
  12446. }
  12447. }
  12448. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12449. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12450. import { Effect } from "babylonjs/Materials/effect";
  12451. import { Particle } from "babylonjs/Particles/particle";
  12452. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12453. /**
  12454. * Particle emitter emitting particles from the inside of a cone.
  12455. * It emits the particles alongside the cone volume from the base to the particle.
  12456. * The emission direction might be randomized.
  12457. */
  12458. export class ConeParticleEmitter implements IParticleEmitterType {
  12459. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12460. directionRandomizer: number;
  12461. private _radius;
  12462. private _angle;
  12463. private _height;
  12464. /**
  12465. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12466. */
  12467. radiusRange: number;
  12468. /**
  12469. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12470. */
  12471. heightRange: number;
  12472. /**
  12473. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12474. */
  12475. emitFromSpawnPointOnly: boolean;
  12476. /**
  12477. * Gets or sets the radius of the emission cone
  12478. */
  12479. get radius(): number;
  12480. set radius(value: number);
  12481. /**
  12482. * Gets or sets the angle of the emission cone
  12483. */
  12484. get angle(): number;
  12485. set angle(value: number);
  12486. private _buildHeight;
  12487. /**
  12488. * Creates a new instance ConeParticleEmitter
  12489. * @param radius the radius of the emission cone (1 by default)
  12490. * @param angle the cone base angle (PI by default)
  12491. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12492. */
  12493. constructor(radius?: number, angle?: number,
  12494. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12495. directionRandomizer?: number);
  12496. /**
  12497. * Called by the particle System when the direction is computed for the created particle.
  12498. * @param worldMatrix is the world matrix of the particle system
  12499. * @param directionToUpdate is the direction vector to update with the result
  12500. * @param particle is the particle we are computed the direction for
  12501. */
  12502. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12503. /**
  12504. * Called by the particle System when the position is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param positionToUpdate is the position vector to update with the result
  12507. * @param particle is the particle we are computed the position for
  12508. */
  12509. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Clones the current emitter and returns a copy of it
  12512. * @returns the new emitter
  12513. */
  12514. clone(): ConeParticleEmitter;
  12515. /**
  12516. * Called by the GPUParticleSystem to setup the update shader
  12517. * @param effect defines the update shader
  12518. */
  12519. applyToShader(effect: Effect): void;
  12520. /**
  12521. * Returns a string to use to update the GPU particles update shader
  12522. * @returns a string containng the defines string
  12523. */
  12524. getEffectDefines(): string;
  12525. /**
  12526. * Returns the string "ConeParticleEmitter"
  12527. * @returns a string containing the class name
  12528. */
  12529. getClassName(): string;
  12530. /**
  12531. * Serializes the particle system to a JSON object.
  12532. * @returns the JSON object
  12533. */
  12534. serialize(): any;
  12535. /**
  12536. * Parse properties from a JSON object
  12537. * @param serializationObject defines the JSON object
  12538. */
  12539. parse(serializationObject: any): void;
  12540. }
  12541. }
  12542. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12543. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12544. import { Effect } from "babylonjs/Materials/effect";
  12545. import { Particle } from "babylonjs/Particles/particle";
  12546. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12547. /**
  12548. * Particle emitter emitting particles from the inside of a cylinder.
  12549. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12550. */
  12551. export class CylinderParticleEmitter implements IParticleEmitterType {
  12552. /**
  12553. * The radius of the emission cylinder.
  12554. */
  12555. radius: number;
  12556. /**
  12557. * The height of the emission cylinder.
  12558. */
  12559. height: number;
  12560. /**
  12561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12562. */
  12563. radiusRange: number;
  12564. /**
  12565. * How much to randomize the particle direction [0-1].
  12566. */
  12567. directionRandomizer: number;
  12568. /**
  12569. * Creates a new instance CylinderParticleEmitter
  12570. * @param radius the radius of the emission cylinder (1 by default)
  12571. * @param height the height of the emission cylinder (1 by default)
  12572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12574. */
  12575. constructor(
  12576. /**
  12577. * The radius of the emission cylinder.
  12578. */
  12579. radius?: number,
  12580. /**
  12581. * The height of the emission cylinder.
  12582. */
  12583. height?: number,
  12584. /**
  12585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12586. */
  12587. radiusRange?: number,
  12588. /**
  12589. * How much to randomize the particle direction [0-1].
  12590. */
  12591. directionRandomizer?: number);
  12592. /**
  12593. * Called by the particle System when the direction is computed for the created particle.
  12594. * @param worldMatrix is the world matrix of the particle system
  12595. * @param directionToUpdate is the direction vector to update with the result
  12596. * @param particle is the particle we are computed the direction for
  12597. */
  12598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12599. /**
  12600. * Called by the particle System when the position is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param positionToUpdate is the position vector to update with the result
  12603. * @param particle is the particle we are computed the position for
  12604. */
  12605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Clones the current emitter and returns a copy of it
  12608. * @returns the new emitter
  12609. */
  12610. clone(): CylinderParticleEmitter;
  12611. /**
  12612. * Called by the GPUParticleSystem to setup the update shader
  12613. * @param effect defines the update shader
  12614. */
  12615. applyToShader(effect: Effect): void;
  12616. /**
  12617. * Returns a string to use to update the GPU particles update shader
  12618. * @returns a string containng the defines string
  12619. */
  12620. getEffectDefines(): string;
  12621. /**
  12622. * Returns the string "CylinderParticleEmitter"
  12623. * @returns a string containing the class name
  12624. */
  12625. getClassName(): string;
  12626. /**
  12627. * Serializes the particle system to a JSON object.
  12628. * @returns the JSON object
  12629. */
  12630. serialize(): any;
  12631. /**
  12632. * Parse properties from a JSON object
  12633. * @param serializationObject defines the JSON object
  12634. */
  12635. parse(serializationObject: any): void;
  12636. }
  12637. /**
  12638. * Particle emitter emitting particles from the inside of a cylinder.
  12639. * It emits the particles randomly between two vectors.
  12640. */
  12641. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12642. /**
  12643. * The min limit of the emission direction.
  12644. */
  12645. direction1: Vector3;
  12646. /**
  12647. * The max limit of the emission direction.
  12648. */
  12649. direction2: Vector3;
  12650. /**
  12651. * Creates a new instance CylinderDirectedParticleEmitter
  12652. * @param radius the radius of the emission cylinder (1 by default)
  12653. * @param height the height of the emission cylinder (1 by default)
  12654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12655. * @param direction1 the min limit of the emission direction (up vector by default)
  12656. * @param direction2 the max limit of the emission direction (up vector by default)
  12657. */
  12658. constructor(radius?: number, height?: number, radiusRange?: number,
  12659. /**
  12660. * The min limit of the emission direction.
  12661. */
  12662. direction1?: Vector3,
  12663. /**
  12664. * The max limit of the emission direction.
  12665. */
  12666. direction2?: Vector3);
  12667. /**
  12668. * Called by the particle System when the direction is computed for the created particle.
  12669. * @param worldMatrix is the world matrix of the particle system
  12670. * @param directionToUpdate is the direction vector to update with the result
  12671. * @param particle is the particle we are computed the direction for
  12672. */
  12673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12674. /**
  12675. * Clones the current emitter and returns a copy of it
  12676. * @returns the new emitter
  12677. */
  12678. clone(): CylinderDirectedParticleEmitter;
  12679. /**
  12680. * Called by the GPUParticleSystem to setup the update shader
  12681. * @param effect defines the update shader
  12682. */
  12683. applyToShader(effect: Effect): void;
  12684. /**
  12685. * Returns a string to use to update the GPU particles update shader
  12686. * @returns a string containng the defines string
  12687. */
  12688. getEffectDefines(): string;
  12689. /**
  12690. * Returns the string "CylinderDirectedParticleEmitter"
  12691. * @returns a string containing the class name
  12692. */
  12693. getClassName(): string;
  12694. /**
  12695. * Serializes the particle system to a JSON object.
  12696. * @returns the JSON object
  12697. */
  12698. serialize(): any;
  12699. /**
  12700. * Parse properties from a JSON object
  12701. * @param serializationObject defines the JSON object
  12702. */
  12703. parse(serializationObject: any): void;
  12704. }
  12705. }
  12706. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12708. import { Effect } from "babylonjs/Materials/effect";
  12709. import { Particle } from "babylonjs/Particles/particle";
  12710. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12711. /**
  12712. * Particle emitter emitting particles from the inside of a hemisphere.
  12713. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12714. */
  12715. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12716. /**
  12717. * The radius of the emission hemisphere.
  12718. */
  12719. radius: number;
  12720. /**
  12721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12722. */
  12723. radiusRange: number;
  12724. /**
  12725. * How much to randomize the particle direction [0-1].
  12726. */
  12727. directionRandomizer: number;
  12728. /**
  12729. * Creates a new instance HemisphericParticleEmitter
  12730. * @param radius the radius of the emission hemisphere (1 by default)
  12731. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12733. */
  12734. constructor(
  12735. /**
  12736. * The radius of the emission hemisphere.
  12737. */
  12738. radius?: number,
  12739. /**
  12740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12741. */
  12742. radiusRange?: number,
  12743. /**
  12744. * How much to randomize the particle direction [0-1].
  12745. */
  12746. directionRandomizer?: number);
  12747. /**
  12748. * Called by the particle System when the direction is computed for the created particle.
  12749. * @param worldMatrix is the world matrix of the particle system
  12750. * @param directionToUpdate is the direction vector to update with the result
  12751. * @param particle is the particle we are computed the direction for
  12752. */
  12753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12754. /**
  12755. * Called by the particle System when the position is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param positionToUpdate is the position vector to update with the result
  12758. * @param particle is the particle we are computed the position for
  12759. */
  12760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Clones the current emitter and returns a copy of it
  12763. * @returns the new emitter
  12764. */
  12765. clone(): HemisphericParticleEmitter;
  12766. /**
  12767. * Called by the GPUParticleSystem to setup the update shader
  12768. * @param effect defines the update shader
  12769. */
  12770. applyToShader(effect: Effect): void;
  12771. /**
  12772. * Returns a string to use to update the GPU particles update shader
  12773. * @returns a string containng the defines string
  12774. */
  12775. getEffectDefines(): string;
  12776. /**
  12777. * Returns the string "HemisphericParticleEmitter"
  12778. * @returns a string containing the class name
  12779. */
  12780. getClassName(): string;
  12781. /**
  12782. * Serializes the particle system to a JSON object.
  12783. * @returns the JSON object
  12784. */
  12785. serialize(): any;
  12786. /**
  12787. * Parse properties from a JSON object
  12788. * @param serializationObject defines the JSON object
  12789. */
  12790. parse(serializationObject: any): void;
  12791. }
  12792. }
  12793. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12794. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12795. import { Effect } from "babylonjs/Materials/effect";
  12796. import { Particle } from "babylonjs/Particles/particle";
  12797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12798. /**
  12799. * Particle emitter emitting particles from a point.
  12800. * It emits the particles randomly between 2 given directions.
  12801. */
  12802. export class PointParticleEmitter implements IParticleEmitterType {
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Creates a new instance PointParticleEmitter
  12813. */
  12814. constructor();
  12815. /**
  12816. * Called by the particle System when the direction is computed for the created particle.
  12817. * @param worldMatrix is the world matrix of the particle system
  12818. * @param directionToUpdate is the direction vector to update with the result
  12819. * @param particle is the particle we are computed the direction for
  12820. */
  12821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12822. /**
  12823. * Called by the particle System when the position is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param positionToUpdate is the position vector to update with the result
  12826. * @param particle is the particle we are computed the position for
  12827. */
  12828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Clones the current emitter and returns a copy of it
  12831. * @returns the new emitter
  12832. */
  12833. clone(): PointParticleEmitter;
  12834. /**
  12835. * Called by the GPUParticleSystem to setup the update shader
  12836. * @param effect defines the update shader
  12837. */
  12838. applyToShader(effect: Effect): void;
  12839. /**
  12840. * Returns a string to use to update the GPU particles update shader
  12841. * @returns a string containng the defines string
  12842. */
  12843. getEffectDefines(): string;
  12844. /**
  12845. * Returns the string "PointParticleEmitter"
  12846. * @returns a string containing the class name
  12847. */
  12848. getClassName(): string;
  12849. /**
  12850. * Serializes the particle system to a JSON object.
  12851. * @returns the JSON object
  12852. */
  12853. serialize(): any;
  12854. /**
  12855. * Parse properties from a JSON object
  12856. * @param serializationObject defines the JSON object
  12857. */
  12858. parse(serializationObject: any): void;
  12859. }
  12860. }
  12861. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12862. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12863. import { Effect } from "babylonjs/Materials/effect";
  12864. import { Particle } from "babylonjs/Particles/particle";
  12865. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12866. /**
  12867. * Particle emitter emitting particles from the inside of a sphere.
  12868. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12869. */
  12870. export class SphereParticleEmitter implements IParticleEmitterType {
  12871. /**
  12872. * The radius of the emission sphere.
  12873. */
  12874. radius: number;
  12875. /**
  12876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12877. */
  12878. radiusRange: number;
  12879. /**
  12880. * How much to randomize the particle direction [0-1].
  12881. */
  12882. directionRandomizer: number;
  12883. /**
  12884. * Creates a new instance SphereParticleEmitter
  12885. * @param radius the radius of the emission sphere (1 by default)
  12886. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12887. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12888. */
  12889. constructor(
  12890. /**
  12891. * The radius of the emission sphere.
  12892. */
  12893. radius?: number,
  12894. /**
  12895. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12896. */
  12897. radiusRange?: number,
  12898. /**
  12899. * How much to randomize the particle direction [0-1].
  12900. */
  12901. directionRandomizer?: number);
  12902. /**
  12903. * Called by the particle System when the direction is computed for the created particle.
  12904. * @param worldMatrix is the world matrix of the particle system
  12905. * @param directionToUpdate is the direction vector to update with the result
  12906. * @param particle is the particle we are computed the direction for
  12907. */
  12908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12909. /**
  12910. * Called by the particle System when the position is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param positionToUpdate is the position vector to update with the result
  12913. * @param particle is the particle we are computed the position for
  12914. */
  12915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Clones the current emitter and returns a copy of it
  12918. * @returns the new emitter
  12919. */
  12920. clone(): SphereParticleEmitter;
  12921. /**
  12922. * Called by the GPUParticleSystem to setup the update shader
  12923. * @param effect defines the update shader
  12924. */
  12925. applyToShader(effect: Effect): void;
  12926. /**
  12927. * Returns a string to use to update the GPU particles update shader
  12928. * @returns a string containng the defines string
  12929. */
  12930. getEffectDefines(): string;
  12931. /**
  12932. * Returns the string "SphereParticleEmitter"
  12933. * @returns a string containing the class name
  12934. */
  12935. getClassName(): string;
  12936. /**
  12937. * Serializes the particle system to a JSON object.
  12938. * @returns the JSON object
  12939. */
  12940. serialize(): any;
  12941. /**
  12942. * Parse properties from a JSON object
  12943. * @param serializationObject defines the JSON object
  12944. */
  12945. parse(serializationObject: any): void;
  12946. }
  12947. /**
  12948. * Particle emitter emitting particles from the inside of a sphere.
  12949. * It emits the particles randomly between two vectors.
  12950. */
  12951. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12952. /**
  12953. * The min limit of the emission direction.
  12954. */
  12955. direction1: Vector3;
  12956. /**
  12957. * The max limit of the emission direction.
  12958. */
  12959. direction2: Vector3;
  12960. /**
  12961. * Creates a new instance SphereDirectedParticleEmitter
  12962. * @param radius the radius of the emission sphere (1 by default)
  12963. * @param direction1 the min limit of the emission direction (up vector by default)
  12964. * @param direction2 the max limit of the emission direction (up vector by default)
  12965. */
  12966. constructor(radius?: number,
  12967. /**
  12968. * The min limit of the emission direction.
  12969. */
  12970. direction1?: Vector3,
  12971. /**
  12972. * The max limit of the emission direction.
  12973. */
  12974. direction2?: Vector3);
  12975. /**
  12976. * Called by the particle System when the direction is computed for the created particle.
  12977. * @param worldMatrix is the world matrix of the particle system
  12978. * @param directionToUpdate is the direction vector to update with the result
  12979. * @param particle is the particle we are computed the direction for
  12980. */
  12981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12982. /**
  12983. * Clones the current emitter and returns a copy of it
  12984. * @returns the new emitter
  12985. */
  12986. clone(): SphereDirectedParticleEmitter;
  12987. /**
  12988. * Called by the GPUParticleSystem to setup the update shader
  12989. * @param effect defines the update shader
  12990. */
  12991. applyToShader(effect: Effect): void;
  12992. /**
  12993. * Returns a string to use to update the GPU particles update shader
  12994. * @returns a string containng the defines string
  12995. */
  12996. getEffectDefines(): string;
  12997. /**
  12998. * Returns the string "SphereDirectedParticleEmitter"
  12999. * @returns a string containing the class name
  13000. */
  13001. getClassName(): string;
  13002. /**
  13003. * Serializes the particle system to a JSON object.
  13004. * @returns the JSON object
  13005. */
  13006. serialize(): any;
  13007. /**
  13008. * Parse properties from a JSON object
  13009. * @param serializationObject defines the JSON object
  13010. */
  13011. parse(serializationObject: any): void;
  13012. }
  13013. }
  13014. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13015. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13016. import { Effect } from "babylonjs/Materials/effect";
  13017. import { Particle } from "babylonjs/Particles/particle";
  13018. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13019. import { Nullable } from "babylonjs/types";
  13020. /**
  13021. * Particle emitter emitting particles from a custom list of positions.
  13022. */
  13023. export class CustomParticleEmitter implements IParticleEmitterType {
  13024. /**
  13025. * Gets or sets the position generator that will create the inital position of each particle.
  13026. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13027. */
  13028. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13029. /**
  13030. * Gets or sets the destination generator that will create the final destination of each particle.
  13031. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13032. */
  13033. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13034. /**
  13035. * Creates a new instance CustomParticleEmitter
  13036. */
  13037. constructor();
  13038. /**
  13039. * Called by the particle System when the direction is computed for the created particle.
  13040. * @param worldMatrix is the world matrix of the particle system
  13041. * @param directionToUpdate is the direction vector to update with the result
  13042. * @param particle is the particle we are computed the direction for
  13043. */
  13044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13045. /**
  13046. * Called by the particle System when the position is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param positionToUpdate is the position vector to update with the result
  13049. * @param particle is the particle we are computed the position for
  13050. */
  13051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Clones the current emitter and returns a copy of it
  13054. * @returns the new emitter
  13055. */
  13056. clone(): CustomParticleEmitter;
  13057. /**
  13058. * Called by the GPUParticleSystem to setup the update shader
  13059. * @param effect defines the update shader
  13060. */
  13061. applyToShader(effect: Effect): void;
  13062. /**
  13063. * Returns a string to use to update the GPU particles update shader
  13064. * @returns a string containng the defines string
  13065. */
  13066. getEffectDefines(): string;
  13067. /**
  13068. * Returns the string "PointParticleEmitter"
  13069. * @returns a string containing the class name
  13070. */
  13071. getClassName(): string;
  13072. /**
  13073. * Serializes the particle system to a JSON object.
  13074. * @returns the JSON object
  13075. */
  13076. serialize(): any;
  13077. /**
  13078. * Parse properties from a JSON object
  13079. * @param serializationObject defines the JSON object
  13080. */
  13081. parse(serializationObject: any): void;
  13082. }
  13083. }
  13084. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13085. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13086. import { Effect } from "babylonjs/Materials/effect";
  13087. import { Particle } from "babylonjs/Particles/particle";
  13088. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13089. import { Scene } from "babylonjs/scene";
  13090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13091. /**
  13092. * Particle emitter emitting particles from the inside of a box.
  13093. * It emits the particles randomly between 2 given directions.
  13094. */
  13095. export class MeshParticleEmitter implements IParticleEmitterType {
  13096. /** Defines the mesh to use as source */
  13097. mesh?: AbstractMesh | undefined;
  13098. private _indices;
  13099. private _positions;
  13100. private _normals;
  13101. private _storedNormal;
  13102. /**
  13103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13104. */
  13105. direction1: Vector3;
  13106. /**
  13107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13108. */
  13109. direction2: Vector3;
  13110. /**
  13111. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13112. */
  13113. useMeshNormalsForDirection: boolean;
  13114. /**
  13115. * Creates a new instance MeshParticleEmitter
  13116. * @param mesh defines the mesh to use as source
  13117. */
  13118. constructor(
  13119. /** Defines the mesh to use as source */
  13120. mesh?: AbstractMesh | undefined);
  13121. /**
  13122. * Called by the particle System when the direction is computed for the created particle.
  13123. * @param worldMatrix is the world matrix of the particle system
  13124. * @param directionToUpdate is the direction vector to update with the result
  13125. * @param particle is the particle we are computed the direction for
  13126. */
  13127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13128. /**
  13129. * Called by the particle System when the position is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param positionToUpdate is the position vector to update with the result
  13132. * @param particle is the particle we are computed the position for
  13133. */
  13134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Clones the current emitter and returns a copy of it
  13137. * @returns the new emitter
  13138. */
  13139. clone(): MeshParticleEmitter;
  13140. /**
  13141. * Called by the GPUParticleSystem to setup the update shader
  13142. * @param effect defines the update shader
  13143. */
  13144. applyToShader(effect: Effect): void;
  13145. /**
  13146. * Returns a string to use to update the GPU particles update shader
  13147. * @returns a string containng the defines string
  13148. */
  13149. getEffectDefines(): string;
  13150. /**
  13151. * Returns the string "BoxParticleEmitter"
  13152. * @returns a string containing the class name
  13153. */
  13154. getClassName(): string;
  13155. /**
  13156. * Serializes the particle system to a JSON object.
  13157. * @returns the JSON object
  13158. */
  13159. serialize(): any;
  13160. /**
  13161. * Parse properties from a JSON object
  13162. * @param serializationObject defines the JSON object
  13163. * @param scene defines the hosting scene
  13164. */
  13165. parse(serializationObject: any, scene: Scene): void;
  13166. }
  13167. }
  13168. declare module "babylonjs/Particles/EmitterTypes/index" {
  13169. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13170. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13171. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13172. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13173. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13174. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13175. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13176. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13178. }
  13179. declare module "babylonjs/Particles/IParticleSystem" {
  13180. import { Nullable } from "babylonjs/types";
  13181. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13182. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13185. import { Texture } from "babylonjs/Materials/Textures/texture";
  13186. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13189. import { Animation } from "babylonjs/Animations/animation";
  13190. /**
  13191. * Interface representing a particle system in Babylon.js.
  13192. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13193. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13194. */
  13195. export interface IParticleSystem {
  13196. /**
  13197. * List of animations used by the particle system.
  13198. */
  13199. animations: Animation[];
  13200. /**
  13201. * The id of the Particle system.
  13202. */
  13203. id: string;
  13204. /**
  13205. * The name of the Particle system.
  13206. */
  13207. name: string;
  13208. /**
  13209. * The emitter represents the Mesh or position we are attaching the particle system to.
  13210. */
  13211. emitter: Nullable<AbstractMesh | Vector3>;
  13212. /**
  13213. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13214. */
  13215. isBillboardBased: boolean;
  13216. /**
  13217. * The rendering group used by the Particle system to chose when to render.
  13218. */
  13219. renderingGroupId: number;
  13220. /**
  13221. * The layer mask we are rendering the particles through.
  13222. */
  13223. layerMask: number;
  13224. /**
  13225. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13226. */
  13227. updateSpeed: number;
  13228. /**
  13229. * The amount of time the particle system is running (depends of the overall update speed).
  13230. */
  13231. targetStopDuration: number;
  13232. /**
  13233. * The texture used to render each particle. (this can be a spritesheet)
  13234. */
  13235. particleTexture: Nullable<Texture>;
  13236. /**
  13237. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13238. */
  13239. blendMode: number;
  13240. /**
  13241. * Minimum life time of emitting particles.
  13242. */
  13243. minLifeTime: number;
  13244. /**
  13245. * Maximum life time of emitting particles.
  13246. */
  13247. maxLifeTime: number;
  13248. /**
  13249. * Minimum Size of emitting particles.
  13250. */
  13251. minSize: number;
  13252. /**
  13253. * Maximum Size of emitting particles.
  13254. */
  13255. maxSize: number;
  13256. /**
  13257. * Minimum scale of emitting particles on X axis.
  13258. */
  13259. minScaleX: number;
  13260. /**
  13261. * Maximum scale of emitting particles on X axis.
  13262. */
  13263. maxScaleX: number;
  13264. /**
  13265. * Minimum scale of emitting particles on Y axis.
  13266. */
  13267. minScaleY: number;
  13268. /**
  13269. * Maximum scale of emitting particles on Y axis.
  13270. */
  13271. maxScaleY: number;
  13272. /**
  13273. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13274. */
  13275. color1: Color4;
  13276. /**
  13277. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13278. */
  13279. color2: Color4;
  13280. /**
  13281. * Color the particle will have at the end of its lifetime.
  13282. */
  13283. colorDead: Color4;
  13284. /**
  13285. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13286. */
  13287. emitRate: number;
  13288. /**
  13289. * You can use gravity if you want to give an orientation to your particles.
  13290. */
  13291. gravity: Vector3;
  13292. /**
  13293. * Minimum power of emitting particles.
  13294. */
  13295. minEmitPower: number;
  13296. /**
  13297. * Maximum power of emitting particles.
  13298. */
  13299. maxEmitPower: number;
  13300. /**
  13301. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13302. */
  13303. minAngularSpeed: number;
  13304. /**
  13305. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13306. */
  13307. maxAngularSpeed: number;
  13308. /**
  13309. * Gets or sets the minimal initial rotation in radians.
  13310. */
  13311. minInitialRotation: number;
  13312. /**
  13313. * Gets or sets the maximal initial rotation in radians.
  13314. */
  13315. maxInitialRotation: number;
  13316. /**
  13317. * The particle emitter type defines the emitter used by the particle system.
  13318. * It can be for example box, sphere, or cone...
  13319. */
  13320. particleEmitterType: Nullable<IParticleEmitterType>;
  13321. /**
  13322. * Defines the delay in milliseconds before starting the system (0 by default)
  13323. */
  13324. startDelay: number;
  13325. /**
  13326. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13327. */
  13328. preWarmCycles: number;
  13329. /**
  13330. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13331. */
  13332. preWarmStepOffset: number;
  13333. /**
  13334. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13335. */
  13336. spriteCellChangeSpeed: number;
  13337. /**
  13338. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13339. */
  13340. startSpriteCellID: number;
  13341. /**
  13342. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13343. */
  13344. endSpriteCellID: number;
  13345. /**
  13346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13347. */
  13348. spriteCellWidth: number;
  13349. /**
  13350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13351. */
  13352. spriteCellHeight: number;
  13353. /**
  13354. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13355. */
  13356. spriteRandomStartCell: boolean;
  13357. /**
  13358. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13359. */
  13360. isAnimationSheetEnabled: boolean;
  13361. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13362. translationPivot: Vector2;
  13363. /**
  13364. * Gets or sets a texture used to add random noise to particle positions
  13365. */
  13366. noiseTexture: Nullable<BaseTexture>;
  13367. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13368. noiseStrength: Vector3;
  13369. /**
  13370. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13371. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13372. */
  13373. billboardMode: number;
  13374. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13375. limitVelocityDamping: number;
  13376. /**
  13377. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13378. */
  13379. beginAnimationOnStart: boolean;
  13380. /**
  13381. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13382. */
  13383. beginAnimationFrom: number;
  13384. /**
  13385. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13386. */
  13387. beginAnimationTo: number;
  13388. /**
  13389. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13390. */
  13391. beginAnimationLoop: boolean;
  13392. /**
  13393. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13394. */
  13395. disposeOnStop: boolean;
  13396. /**
  13397. * Gets the maximum number of particles active at the same time.
  13398. * @returns The max number of active particles.
  13399. */
  13400. getCapacity(): number;
  13401. /**
  13402. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13403. * @returns True if it has been started, otherwise false.
  13404. */
  13405. isStarted(): boolean;
  13406. /**
  13407. * Animates the particle system for this frame.
  13408. */
  13409. animate(): void;
  13410. /**
  13411. * Renders the particle system in its current state.
  13412. * @returns the current number of particles
  13413. */
  13414. render(): number;
  13415. /**
  13416. * Dispose the particle system and frees its associated resources.
  13417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13418. */
  13419. dispose(disposeTexture?: boolean): void;
  13420. /**
  13421. * Clones the particle system.
  13422. * @param name The name of the cloned object
  13423. * @param newEmitter The new emitter to use
  13424. * @returns the cloned particle system
  13425. */
  13426. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13427. /**
  13428. * Serializes the particle system to a JSON object.
  13429. * @returns the JSON object
  13430. */
  13431. serialize(): any;
  13432. /**
  13433. * Rebuild the particle system
  13434. */
  13435. rebuild(): void;
  13436. /**
  13437. * Starts the particle system and begins to emit
  13438. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13439. */
  13440. start(delay?: number): void;
  13441. /**
  13442. * Stops the particle system.
  13443. */
  13444. stop(): void;
  13445. /**
  13446. * Remove all active particles
  13447. */
  13448. reset(): void;
  13449. /**
  13450. * Is this system ready to be used/rendered
  13451. * @return true if the system is ready
  13452. */
  13453. isReady(): boolean;
  13454. /**
  13455. * Adds a new color gradient
  13456. * @param gradient defines the gradient to use (between 0 and 1)
  13457. * @param color1 defines the color to affect to the specified gradient
  13458. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13459. * @returns the current particle system
  13460. */
  13461. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13462. /**
  13463. * Remove a specific color gradient
  13464. * @param gradient defines the gradient to remove
  13465. * @returns the current particle system
  13466. */
  13467. removeColorGradient(gradient: number): IParticleSystem;
  13468. /**
  13469. * Adds a new size gradient
  13470. * @param gradient defines the gradient to use (between 0 and 1)
  13471. * @param factor defines the size factor to affect to the specified gradient
  13472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13473. * @returns the current particle system
  13474. */
  13475. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13476. /**
  13477. * Remove a specific size gradient
  13478. * @param gradient defines the gradient to remove
  13479. * @returns the current particle system
  13480. */
  13481. removeSizeGradient(gradient: number): IParticleSystem;
  13482. /**
  13483. * Gets the current list of color gradients.
  13484. * You must use addColorGradient and removeColorGradient to udpate this list
  13485. * @returns the list of color gradients
  13486. */
  13487. getColorGradients(): Nullable<Array<ColorGradient>>;
  13488. /**
  13489. * Gets the current list of size gradients.
  13490. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13491. * @returns the list of size gradients
  13492. */
  13493. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13494. /**
  13495. * Gets the current list of angular speed gradients.
  13496. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13497. * @returns the list of angular speed gradients
  13498. */
  13499. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13500. /**
  13501. * Adds a new angular speed gradient
  13502. * @param gradient defines the gradient to use (between 0 and 1)
  13503. * @param factor defines the angular speed to affect to the specified gradient
  13504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13505. * @returns the current particle system
  13506. */
  13507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13508. /**
  13509. * Remove a specific angular speed gradient
  13510. * @param gradient defines the gradient to remove
  13511. * @returns the current particle system
  13512. */
  13513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13514. /**
  13515. * Gets the current list of velocity gradients.
  13516. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13517. * @returns the list of velocity gradients
  13518. */
  13519. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13520. /**
  13521. * Adds a new velocity gradient
  13522. * @param gradient defines the gradient to use (between 0 and 1)
  13523. * @param factor defines the velocity to affect to the specified gradient
  13524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13525. * @returns the current particle system
  13526. */
  13527. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13528. /**
  13529. * Remove a specific velocity gradient
  13530. * @param gradient defines the gradient to remove
  13531. * @returns the current particle system
  13532. */
  13533. removeVelocityGradient(gradient: number): IParticleSystem;
  13534. /**
  13535. * Gets the current list of limit velocity gradients.
  13536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13537. * @returns the list of limit velocity gradients
  13538. */
  13539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13540. /**
  13541. * Adds a new limit velocity gradient
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param factor defines the limit velocity to affect to the specified gradient
  13544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13545. * @returns the current particle system
  13546. */
  13547. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13548. /**
  13549. * Remove a specific limit velocity gradient
  13550. * @param gradient defines the gradient to remove
  13551. * @returns the current particle system
  13552. */
  13553. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13554. /**
  13555. * Adds a new drag gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param factor defines the drag to affect to the specified gradient
  13558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13559. * @returns the current particle system
  13560. */
  13561. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13562. /**
  13563. * Remove a specific drag gradient
  13564. * @param gradient defines the gradient to remove
  13565. * @returns the current particle system
  13566. */
  13567. removeDragGradient(gradient: number): IParticleSystem;
  13568. /**
  13569. * Gets the current list of drag gradients.
  13570. * You must use addDragGradient and removeDragGradient to udpate this list
  13571. * @returns the list of drag gradients
  13572. */
  13573. getDragGradients(): Nullable<Array<FactorGradient>>;
  13574. /**
  13575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13576. * @param gradient defines the gradient to use (between 0 and 1)
  13577. * @param factor defines the emit rate to affect to the specified gradient
  13578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13579. * @returns the current particle system
  13580. */
  13581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13582. /**
  13583. * Remove a specific emit rate gradient
  13584. * @param gradient defines the gradient to remove
  13585. * @returns the current particle system
  13586. */
  13587. removeEmitRateGradient(gradient: number): IParticleSystem;
  13588. /**
  13589. * Gets the current list of emit rate gradients.
  13590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13591. * @returns the list of emit rate gradients
  13592. */
  13593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13594. /**
  13595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13596. * @param gradient defines the gradient to use (between 0 and 1)
  13597. * @param factor defines the start size to affect to the specified gradient
  13598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13599. * @returns the current particle system
  13600. */
  13601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13602. /**
  13603. * Remove a specific start size gradient
  13604. * @param gradient defines the gradient to remove
  13605. * @returns the current particle system
  13606. */
  13607. removeStartSizeGradient(gradient: number): IParticleSystem;
  13608. /**
  13609. * Gets the current list of start size gradients.
  13610. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13611. * @returns the list of start size gradients
  13612. */
  13613. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13614. /**
  13615. * Adds a new life time gradient
  13616. * @param gradient defines the gradient to use (between 0 and 1)
  13617. * @param factor defines the life time factor to affect to the specified gradient
  13618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13619. * @returns the current particle system
  13620. */
  13621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13622. /**
  13623. * Remove a specific life time gradient
  13624. * @param gradient defines the gradient to remove
  13625. * @returns the current particle system
  13626. */
  13627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13628. /**
  13629. * Gets the current list of life time gradients.
  13630. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13631. * @returns the list of life time gradients
  13632. */
  13633. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13634. /**
  13635. * Gets the current list of color gradients.
  13636. * You must use addColorGradient and removeColorGradient to udpate this list
  13637. * @returns the list of color gradients
  13638. */
  13639. getColorGradients(): Nullable<Array<ColorGradient>>;
  13640. /**
  13641. * Adds a new ramp gradient used to remap particle colors
  13642. * @param gradient defines the gradient to use (between 0 and 1)
  13643. * @param color defines the color to affect to the specified gradient
  13644. * @returns the current particle system
  13645. */
  13646. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13647. /**
  13648. * Gets the current list of ramp gradients.
  13649. * You must use addRampGradient and removeRampGradient to udpate this list
  13650. * @returns the list of ramp gradients
  13651. */
  13652. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13653. /** Gets or sets a boolean indicating that ramp gradients must be used
  13654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13655. */
  13656. useRampGradients: boolean;
  13657. /**
  13658. * Adds a new color remap gradient
  13659. * @param gradient defines the gradient to use (between 0 and 1)
  13660. * @param min defines the color remap minimal range
  13661. * @param max defines the color remap maximal range
  13662. * @returns the current particle system
  13663. */
  13664. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13665. /**
  13666. * Gets the current list of color remap gradients.
  13667. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13668. * @returns the list of color remap gradients
  13669. */
  13670. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13671. /**
  13672. * Adds a new alpha remap gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param min defines the alpha remap minimal range
  13675. * @param max defines the alpha remap maximal range
  13676. * @returns the current particle system
  13677. */
  13678. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of alpha remap gradients.
  13681. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13682. * @returns the list of alpha remap gradients
  13683. */
  13684. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13689. * @returns the emitter
  13690. */
  13691. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13692. /**
  13693. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13694. * @param radius The radius of the hemisphere to emit from
  13695. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13696. * @returns the emitter
  13697. */
  13698. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13699. /**
  13700. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13701. * @param radius The radius of the sphere to emit from
  13702. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13706. /**
  13707. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13711. * @returns the emitter
  13712. */
  13713. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13714. /**
  13715. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13716. * @param radius The radius of the emission cylinder
  13717. * @param height The height of the emission cylinder
  13718. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13719. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13720. * @returns the emitter
  13721. */
  13722. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13723. /**
  13724. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13725. * @param radius The radius of the cylinder to emit from
  13726. * @param height The height of the emission cylinder
  13727. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13730. * @returns the emitter
  13731. */
  13732. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13733. /**
  13734. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13735. * @param radius The radius of the cone to emit from
  13736. * @param angle The base angle of the cone
  13737. * @returns the emitter
  13738. */
  13739. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13740. /**
  13741. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13744. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13745. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13746. * @returns the emitter
  13747. */
  13748. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13749. /**
  13750. * Get hosting scene
  13751. * @returns the scene
  13752. */
  13753. getScene(): Scene;
  13754. }
  13755. }
  13756. declare module "babylonjs/Meshes/transformNode" {
  13757. import { DeepImmutable } from "babylonjs/types";
  13758. import { Observable } from "babylonjs/Misc/observable";
  13759. import { Nullable } from "babylonjs/types";
  13760. import { Camera } from "babylonjs/Cameras/camera";
  13761. import { Scene } from "babylonjs/scene";
  13762. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13763. import { Node } from "babylonjs/node";
  13764. import { Bone } from "babylonjs/Bones/bone";
  13765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. /**
  13768. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13769. * @see https://doc.babylonjs.com/how_to/transformnode
  13770. */
  13771. export class TransformNode extends Node {
  13772. /**
  13773. * Object will not rotate to face the camera
  13774. */
  13775. static BILLBOARDMODE_NONE: number;
  13776. /**
  13777. * Object will rotate to face the camera but only on the x axis
  13778. */
  13779. static BILLBOARDMODE_X: number;
  13780. /**
  13781. * Object will rotate to face the camera but only on the y axis
  13782. */
  13783. static BILLBOARDMODE_Y: number;
  13784. /**
  13785. * Object will rotate to face the camera but only on the z axis
  13786. */
  13787. static BILLBOARDMODE_Z: number;
  13788. /**
  13789. * Object will rotate to face the camera
  13790. */
  13791. static BILLBOARDMODE_ALL: number;
  13792. /**
  13793. * Object will rotate to face the camera's position instead of orientation
  13794. */
  13795. static BILLBOARDMODE_USE_POSITION: number;
  13796. private _forward;
  13797. private _forwardInverted;
  13798. private _up;
  13799. private _right;
  13800. private _rightInverted;
  13801. private _position;
  13802. private _rotation;
  13803. private _rotationQuaternion;
  13804. protected _scaling: Vector3;
  13805. protected _isDirty: boolean;
  13806. private _transformToBoneReferal;
  13807. private _isAbsoluteSynced;
  13808. private _billboardMode;
  13809. /**
  13810. * Gets or sets the billboard mode. Default is 0.
  13811. *
  13812. * | Value | Type | Description |
  13813. * | --- | --- | --- |
  13814. * | 0 | BILLBOARDMODE_NONE | |
  13815. * | 1 | BILLBOARDMODE_X | |
  13816. * | 2 | BILLBOARDMODE_Y | |
  13817. * | 4 | BILLBOARDMODE_Z | |
  13818. * | 7 | BILLBOARDMODE_ALL | |
  13819. *
  13820. */
  13821. get billboardMode(): number;
  13822. set billboardMode(value: number);
  13823. private _preserveParentRotationForBillboard;
  13824. /**
  13825. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13826. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13827. */
  13828. get preserveParentRotationForBillboard(): boolean;
  13829. set preserveParentRotationForBillboard(value: boolean);
  13830. /**
  13831. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13832. */
  13833. scalingDeterminant: number;
  13834. private _infiniteDistance;
  13835. /**
  13836. * Gets or sets the distance of the object to max, often used by skybox
  13837. */
  13838. get infiniteDistance(): boolean;
  13839. set infiniteDistance(value: boolean);
  13840. /**
  13841. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13842. * By default the system will update normals to compensate
  13843. */
  13844. ignoreNonUniformScaling: boolean;
  13845. /**
  13846. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13847. */
  13848. reIntegrateRotationIntoRotationQuaternion: boolean;
  13849. /** @hidden */
  13850. _poseMatrix: Nullable<Matrix>;
  13851. /** @hidden */
  13852. _localMatrix: Matrix;
  13853. private _usePivotMatrix;
  13854. private _absolutePosition;
  13855. private _absoluteScaling;
  13856. private _absoluteRotationQuaternion;
  13857. private _pivotMatrix;
  13858. private _pivotMatrixInverse;
  13859. protected _postMultiplyPivotMatrix: boolean;
  13860. protected _isWorldMatrixFrozen: boolean;
  13861. /** @hidden */
  13862. _indexInSceneTransformNodesArray: number;
  13863. /**
  13864. * An event triggered after the world matrix is updated
  13865. */
  13866. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13867. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13868. /**
  13869. * Gets a string identifying the name of the class
  13870. * @returns "TransformNode" string
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13875. */
  13876. get position(): Vector3;
  13877. set position(newPosition: Vector3);
  13878. /**
  13879. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13880. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13881. */
  13882. get rotation(): Vector3;
  13883. set rotation(newRotation: Vector3);
  13884. /**
  13885. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13886. */
  13887. get scaling(): Vector3;
  13888. set scaling(newScaling: Vector3);
  13889. /**
  13890. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13891. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13892. */
  13893. get rotationQuaternion(): Nullable<Quaternion>;
  13894. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13895. /**
  13896. * The forward direction of that transform in world space.
  13897. */
  13898. get forward(): Vector3;
  13899. /**
  13900. * The up direction of that transform in world space.
  13901. */
  13902. get up(): Vector3;
  13903. /**
  13904. * The right direction of that transform in world space.
  13905. */
  13906. get right(): Vector3;
  13907. /**
  13908. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13909. * @param matrix the matrix to copy the pose from
  13910. * @returns this TransformNode.
  13911. */
  13912. updatePoseMatrix(matrix: Matrix): TransformNode;
  13913. /**
  13914. * Returns the mesh Pose matrix.
  13915. * @returns the pose matrix
  13916. */
  13917. getPoseMatrix(): Matrix;
  13918. /** @hidden */
  13919. _isSynchronized(): boolean;
  13920. /** @hidden */
  13921. _initCache(): void;
  13922. /**
  13923. * Flag the transform node as dirty (Forcing it to update everything)
  13924. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13925. * @returns this transform node
  13926. */
  13927. markAsDirty(property: string): TransformNode;
  13928. /**
  13929. * Returns the current mesh absolute position.
  13930. * Returns a Vector3.
  13931. */
  13932. get absolutePosition(): Vector3;
  13933. /**
  13934. * Returns the current mesh absolute scaling.
  13935. * Returns a Vector3.
  13936. */
  13937. get absoluteScaling(): Vector3;
  13938. /**
  13939. * Returns the current mesh absolute rotation.
  13940. * Returns a Quaternion.
  13941. */
  13942. get absoluteRotationQuaternion(): Quaternion;
  13943. /**
  13944. * Sets a new matrix to apply before all other transformation
  13945. * @param matrix defines the transform matrix
  13946. * @returns the current TransformNode
  13947. */
  13948. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13949. /**
  13950. * Sets a new pivot matrix to the current node
  13951. * @param matrix defines the new pivot matrix to use
  13952. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13953. * @returns the current TransformNode
  13954. */
  13955. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13956. /**
  13957. * Returns the mesh pivot matrix.
  13958. * Default : Identity.
  13959. * @returns the matrix
  13960. */
  13961. getPivotMatrix(): Matrix;
  13962. /**
  13963. * Instantiate (when possible) or clone that node with its hierarchy
  13964. * @param newParent defines the new parent to use for the instance (or clone)
  13965. * @param options defines options to configure how copy is done
  13966. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13967. * @returns an instance (or a clone) of the current node with its hiearchy
  13968. */
  13969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13970. doNotInstantiate: boolean;
  13971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13972. /**
  13973. * Prevents the World matrix to be computed any longer
  13974. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13975. * @returns the TransformNode.
  13976. */
  13977. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13978. /**
  13979. * Allows back the World matrix computation.
  13980. * @returns the TransformNode.
  13981. */
  13982. unfreezeWorldMatrix(): this;
  13983. /**
  13984. * True if the World matrix has been frozen.
  13985. */
  13986. get isWorldMatrixFrozen(): boolean;
  13987. /**
  13988. * Retuns the mesh absolute position in the World.
  13989. * @returns a Vector3.
  13990. */
  13991. getAbsolutePosition(): Vector3;
  13992. /**
  13993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13994. * @param absolutePosition the absolute position to set
  13995. * @returns the TransformNode.
  13996. */
  13997. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13998. /**
  13999. * Sets the mesh position in its local space.
  14000. * @param vector3 the position to set in localspace
  14001. * @returns the TransformNode.
  14002. */
  14003. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14004. /**
  14005. * Returns the mesh position in the local space from the current World matrix values.
  14006. * @returns a new Vector3.
  14007. */
  14008. getPositionExpressedInLocalSpace(): Vector3;
  14009. /**
  14010. * Translates the mesh along the passed Vector3 in its local space.
  14011. * @param vector3 the distance to translate in localspace
  14012. * @returns the TransformNode.
  14013. */
  14014. locallyTranslate(vector3: Vector3): TransformNode;
  14015. private static _lookAtVectorCache;
  14016. /**
  14017. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14018. * @param targetPoint the position (must be in same space as current mesh) to look at
  14019. * @param yawCor optional yaw (y-axis) correction in radians
  14020. * @param pitchCor optional pitch (x-axis) correction in radians
  14021. * @param rollCor optional roll (z-axis) correction in radians
  14022. * @param space the choosen space of the target
  14023. * @returns the TransformNode.
  14024. */
  14025. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14026. /**
  14027. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14028. * This Vector3 is expressed in the World space.
  14029. * @param localAxis axis to rotate
  14030. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14031. */
  14032. getDirection(localAxis: Vector3): Vector3;
  14033. /**
  14034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14035. * localAxis is expressed in the mesh local space.
  14036. * result is computed in the Wordl space from the mesh World matrix.
  14037. * @param localAxis axis to rotate
  14038. * @param result the resulting transformnode
  14039. * @returns this TransformNode.
  14040. */
  14041. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14042. /**
  14043. * Sets this transform node rotation to the given local axis.
  14044. * @param localAxis the axis in local space
  14045. * @param yawCor optional yaw (y-axis) correction in radians
  14046. * @param pitchCor optional pitch (x-axis) correction in radians
  14047. * @param rollCor optional roll (z-axis) correction in radians
  14048. * @returns this TransformNode
  14049. */
  14050. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14051. /**
  14052. * Sets a new pivot point to the current node
  14053. * @param point defines the new pivot point to use
  14054. * @param space defines if the point is in world or local space (local by default)
  14055. * @returns the current TransformNode
  14056. */
  14057. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14058. /**
  14059. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14060. * @returns the pivot point
  14061. */
  14062. getPivotPoint(): Vector3;
  14063. /**
  14064. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14065. * @param result the vector3 to store the result
  14066. * @returns this TransformNode.
  14067. */
  14068. getPivotPointToRef(result: Vector3): TransformNode;
  14069. /**
  14070. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14071. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14072. */
  14073. getAbsolutePivotPoint(): Vector3;
  14074. /**
  14075. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14076. * @param result vector3 to store the result
  14077. * @returns this TransformNode.
  14078. */
  14079. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14080. /**
  14081. * Defines the passed node as the parent of the current node.
  14082. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14083. * @see https://doc.babylonjs.com/how_to/parenting
  14084. * @param node the node ot set as the parent
  14085. * @returns this TransformNode.
  14086. */
  14087. setParent(node: Nullable<Node>): TransformNode;
  14088. private _nonUniformScaling;
  14089. /**
  14090. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14091. */
  14092. get nonUniformScaling(): boolean;
  14093. /** @hidden */
  14094. _updateNonUniformScalingState(value: boolean): boolean;
  14095. /**
  14096. * Attach the current TransformNode to another TransformNode associated with a bone
  14097. * @param bone Bone affecting the TransformNode
  14098. * @param affectedTransformNode TransformNode associated with the bone
  14099. * @returns this object
  14100. */
  14101. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14102. /**
  14103. * Detach the transform node if its associated with a bone
  14104. * @returns this object
  14105. */
  14106. detachFromBone(): TransformNode;
  14107. private static _rotationAxisCache;
  14108. /**
  14109. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14110. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14112. * The passed axis is also normalized.
  14113. * @param axis the axis to rotate around
  14114. * @param amount the amount to rotate in radians
  14115. * @param space Space to rotate in (Default: local)
  14116. * @returns the TransformNode.
  14117. */
  14118. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14119. /**
  14120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14121. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14122. * The passed axis is also normalized. .
  14123. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14124. * @param point the point to rotate around
  14125. * @param axis the axis to rotate around
  14126. * @param amount the amount to rotate in radians
  14127. * @returns the TransformNode
  14128. */
  14129. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14130. /**
  14131. * Translates the mesh along the axis vector for the passed distance in the given space.
  14132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14133. * @param axis the axis to translate in
  14134. * @param distance the distance to translate
  14135. * @param space Space to rotate in (Default: local)
  14136. * @returns the TransformNode.
  14137. */
  14138. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14139. /**
  14140. * Adds a rotation step to the mesh current rotation.
  14141. * x, y, z are Euler angles expressed in radians.
  14142. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14143. * This means this rotation is made in the mesh local space only.
  14144. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14145. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14146. * ```javascript
  14147. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14148. * ```
  14149. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14150. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14151. * @param x Rotation to add
  14152. * @param y Rotation to add
  14153. * @param z Rotation to add
  14154. * @returns the TransformNode.
  14155. */
  14156. addRotation(x: number, y: number, z: number): TransformNode;
  14157. /**
  14158. * @hidden
  14159. */
  14160. protected _getEffectiveParent(): Nullable<Node>;
  14161. /**
  14162. * Computes the world matrix of the node
  14163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14164. * @returns the world matrix
  14165. */
  14166. computeWorldMatrix(force?: boolean): Matrix;
  14167. /**
  14168. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14169. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14170. */
  14171. resetLocalMatrix(independentOfChildren?: boolean): void;
  14172. protected _afterComputeWorldMatrix(): void;
  14173. /**
  14174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14175. * @param func callback function to add
  14176. *
  14177. * @returns the TransformNode.
  14178. */
  14179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14180. /**
  14181. * Removes a registered callback function.
  14182. * @param func callback function to remove
  14183. * @returns the TransformNode.
  14184. */
  14185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14186. /**
  14187. * Gets the position of the current mesh in camera space
  14188. * @param camera defines the camera to use
  14189. * @returns a position
  14190. */
  14191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14192. /**
  14193. * Returns the distance from the mesh to the active camera
  14194. * @param camera defines the camera to use
  14195. * @returns the distance
  14196. */
  14197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14198. /**
  14199. * Clone the current transform node
  14200. * @param name Name of the new clone
  14201. * @param newParent New parent for the clone
  14202. * @param doNotCloneChildren Do not clone children hierarchy
  14203. * @returns the new transform node
  14204. */
  14205. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14206. /**
  14207. * Serializes the objects information.
  14208. * @param currentSerializationObject defines the object to serialize in
  14209. * @returns the serialized object
  14210. */
  14211. serialize(currentSerializationObject?: any): any;
  14212. /**
  14213. * Returns a new TransformNode object parsed from the source provided.
  14214. * @param parsedTransformNode is the source.
  14215. * @param scene the scne the object belongs to
  14216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14217. * @returns a new TransformNode object parsed from the source provided.
  14218. */
  14219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14220. /**
  14221. * Get all child-transformNodes of this node
  14222. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14223. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14224. * @returns an array of TransformNode
  14225. */
  14226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14227. /**
  14228. * Releases resources associated with this transform node.
  14229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14231. */
  14232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14233. /**
  14234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14238. * @returns the current mesh
  14239. */
  14240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14241. private _syncAbsoluteScalingAndRotation;
  14242. }
  14243. }
  14244. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14245. /**
  14246. * Class used to override all child animations of a given target
  14247. */
  14248. export class AnimationPropertiesOverride {
  14249. /**
  14250. * Gets or sets a value indicating if animation blending must be used
  14251. */
  14252. enableBlending: boolean;
  14253. /**
  14254. * Gets or sets the blending speed to use when enableBlending is true
  14255. */
  14256. blendingSpeed: number;
  14257. /**
  14258. * Gets or sets the default loop mode to use
  14259. */
  14260. loopMode: number;
  14261. }
  14262. }
  14263. declare module "babylonjs/Bones/bone" {
  14264. import { Skeleton } from "babylonjs/Bones/skeleton";
  14265. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14266. import { Nullable } from "babylonjs/types";
  14267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14268. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14269. import { Node } from "babylonjs/node";
  14270. import { Space } from "babylonjs/Maths/math.axis";
  14271. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14272. /**
  14273. * Class used to store bone information
  14274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14275. */
  14276. export class Bone extends Node {
  14277. /**
  14278. * defines the bone name
  14279. */
  14280. name: string;
  14281. private static _tmpVecs;
  14282. private static _tmpQuat;
  14283. private static _tmpMats;
  14284. /**
  14285. * Gets the list of child bones
  14286. */
  14287. children: Bone[];
  14288. /** Gets the animations associated with this bone */
  14289. animations: import("babylonjs/Animations/animation").Animation[];
  14290. /**
  14291. * Gets or sets bone length
  14292. */
  14293. length: number;
  14294. /**
  14295. * @hidden Internal only
  14296. * Set this value to map this bone to a different index in the transform matrices
  14297. * Set this value to -1 to exclude the bone from the transform matrices
  14298. */
  14299. _index: Nullable<number>;
  14300. private _skeleton;
  14301. private _localMatrix;
  14302. private _restPose;
  14303. private _baseMatrix;
  14304. private _absoluteTransform;
  14305. private _invertedAbsoluteTransform;
  14306. private _parent;
  14307. private _scalingDeterminant;
  14308. private _worldTransform;
  14309. private _localScaling;
  14310. private _localRotation;
  14311. private _localPosition;
  14312. private _needToDecompose;
  14313. private _needToCompose;
  14314. /** @hidden */
  14315. _linkedTransformNode: Nullable<TransformNode>;
  14316. /** @hidden */
  14317. _waitingTransformNodeId: Nullable<string>;
  14318. /** @hidden */
  14319. get _matrix(): Matrix;
  14320. /** @hidden */
  14321. set _matrix(value: Matrix);
  14322. /**
  14323. * Create a new bone
  14324. * @param name defines the bone name
  14325. * @param skeleton defines the parent skeleton
  14326. * @param parentBone defines the parent (can be null if the bone is the root)
  14327. * @param localMatrix defines the local matrix
  14328. * @param restPose defines the rest pose matrix
  14329. * @param baseMatrix defines the base matrix
  14330. * @param index defines index of the bone in the hiearchy
  14331. */
  14332. constructor(
  14333. /**
  14334. * defines the bone name
  14335. */
  14336. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14337. /**
  14338. * Gets the current object class name.
  14339. * @return the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Gets the parent skeleton
  14344. * @returns a skeleton
  14345. */
  14346. getSkeleton(): Skeleton;
  14347. /**
  14348. * Gets parent bone
  14349. * @returns a bone or null if the bone is the root of the bone hierarchy
  14350. */
  14351. getParent(): Nullable<Bone>;
  14352. /**
  14353. * Returns an array containing the root bones
  14354. * @returns an array containing the root bones
  14355. */
  14356. getChildren(): Array<Bone>;
  14357. /**
  14358. * Gets the node index in matrix array generated for rendering
  14359. * @returns the node index
  14360. */
  14361. getIndex(): number;
  14362. /**
  14363. * Sets the parent bone
  14364. * @param parent defines the parent (can be null if the bone is the root)
  14365. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14366. */
  14367. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14368. /**
  14369. * Gets the local matrix
  14370. * @returns a matrix
  14371. */
  14372. getLocalMatrix(): Matrix;
  14373. /**
  14374. * Gets the base matrix (initial matrix which remains unchanged)
  14375. * @returns a matrix
  14376. */
  14377. getBaseMatrix(): Matrix;
  14378. /**
  14379. * Gets the rest pose matrix
  14380. * @returns a matrix
  14381. */
  14382. getRestPose(): Matrix;
  14383. /**
  14384. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14385. */
  14386. getWorldMatrix(): Matrix;
  14387. /**
  14388. * Sets the local matrix to rest pose matrix
  14389. */
  14390. returnToRest(): void;
  14391. /**
  14392. * Gets the inverse of the absolute transform matrix.
  14393. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14394. * @returns a matrix
  14395. */
  14396. getInvertedAbsoluteTransform(): Matrix;
  14397. /**
  14398. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14399. * @returns a matrix
  14400. */
  14401. getAbsoluteTransform(): Matrix;
  14402. /**
  14403. * Links with the given transform node.
  14404. * The local matrix of this bone is copied from the transform node every frame.
  14405. * @param transformNode defines the transform node to link to
  14406. */
  14407. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14408. /**
  14409. * Gets the node used to drive the bone's transformation
  14410. * @returns a transform node or null
  14411. */
  14412. getTransformNode(): Nullable<TransformNode>;
  14413. /** Gets or sets current position (in local space) */
  14414. get position(): Vector3;
  14415. set position(newPosition: Vector3);
  14416. /** Gets or sets current rotation (in local space) */
  14417. get rotation(): Vector3;
  14418. set rotation(newRotation: Vector3);
  14419. /** Gets or sets current rotation quaternion (in local space) */
  14420. get rotationQuaternion(): Quaternion;
  14421. set rotationQuaternion(newRotation: Quaternion);
  14422. /** Gets or sets current scaling (in local space) */
  14423. get scaling(): Vector3;
  14424. set scaling(newScaling: Vector3);
  14425. /**
  14426. * Gets the animation properties override
  14427. */
  14428. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14429. private _decompose;
  14430. private _compose;
  14431. /**
  14432. * Update the base and local matrices
  14433. * @param matrix defines the new base or local matrix
  14434. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14435. * @param updateLocalMatrix defines if the local matrix should be updated
  14436. */
  14437. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14438. /** @hidden */
  14439. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14440. /**
  14441. * Flag the bone as dirty (Forcing it to update everything)
  14442. */
  14443. markAsDirty(): void;
  14444. /** @hidden */
  14445. _markAsDirtyAndCompose(): void;
  14446. private _markAsDirtyAndDecompose;
  14447. /**
  14448. * Translate the bone in local or world space
  14449. * @param vec The amount to translate the bone
  14450. * @param space The space that the translation is in
  14451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14452. */
  14453. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14454. /**
  14455. * Set the postion of the bone in local or world space
  14456. * @param position The position to set the bone
  14457. * @param space The space that the position is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the absolute position of the bone (world space)
  14463. * @param position The position to set the bone
  14464. * @param mesh The mesh that this bone is attached to
  14465. */
  14466. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14467. /**
  14468. * Scale the bone on the x, y and z axes (in local space)
  14469. * @param x The amount to scale the bone on the x axis
  14470. * @param y The amount to scale the bone on the y axis
  14471. * @param z The amount to scale the bone on the z axis
  14472. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14473. */
  14474. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14475. /**
  14476. * Set the bone scaling in local space
  14477. * @param scale defines the scaling vector
  14478. */
  14479. setScale(scale: Vector3): void;
  14480. /**
  14481. * Gets the current scaling in local space
  14482. * @returns the current scaling vector
  14483. */
  14484. getScale(): Vector3;
  14485. /**
  14486. * Gets the current scaling in local space and stores it in a target vector
  14487. * @param result defines the target vector
  14488. */
  14489. getScaleToRef(result: Vector3): void;
  14490. /**
  14491. * Set the yaw, pitch, and roll of the bone in local or world space
  14492. * @param yaw The rotation of the bone on the y axis
  14493. * @param pitch The rotation of the bone on the x axis
  14494. * @param roll The rotation of the bone on the z axis
  14495. * @param space The space that the axes of rotation are in
  14496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14497. */
  14498. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14499. /**
  14500. * Add a rotation to the bone on an axis in local or world space
  14501. * @param axis The axis to rotate the bone on
  14502. * @param amount The amount to rotate the bone
  14503. * @param space The space that the axis is in
  14504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14505. */
  14506. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14507. /**
  14508. * Set the rotation of the bone to a particular axis angle in local or world space
  14509. * @param axis The axis to rotate the bone on
  14510. * @param angle The angle that the bone should be rotated to
  14511. * @param space The space that the axis is in
  14512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14513. */
  14514. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14515. /**
  14516. * Set the euler rotation of the bone in local of world space
  14517. * @param rotation The euler rotation that the bone should be set to
  14518. * @param space The space that the rotation is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the quaternion rotation of the bone in local of world space
  14524. * @param quat The quaternion rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the rotation matrix of the bone in local of world space
  14531. * @param rotMat The rotation matrix that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14536. private _rotateWithMatrix;
  14537. private _getNegativeRotationToRef;
  14538. /**
  14539. * Get the position of the bone in local or world space
  14540. * @param space The space that the returned position is in
  14541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14542. * @returns The position of the bone
  14543. */
  14544. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14545. /**
  14546. * Copy the position of the bone to a vector3 in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @param result The vector3 to copy the position to
  14550. */
  14551. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14552. /**
  14553. * Get the absolute position of the bone (world space)
  14554. * @param mesh The mesh that this bone is attached to
  14555. * @returns The absolute position of the bone
  14556. */
  14557. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14558. /**
  14559. * Copy the absolute position of the bone (world space) to the result param
  14560. * @param mesh The mesh that this bone is attached to
  14561. * @param result The vector3 to copy the absolute position to
  14562. */
  14563. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14564. /**
  14565. * Compute the absolute transforms of this bone and its children
  14566. */
  14567. computeAbsoluteTransforms(): void;
  14568. /**
  14569. * Get the world direction from an axis that is in the local space of the bone
  14570. * @param localAxis The local direction that is used to compute the world direction
  14571. * @param mesh The mesh that this bone is attached to
  14572. * @returns The world direction
  14573. */
  14574. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14575. /**
  14576. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @param result The vector3 that the world direction will be copied to
  14580. */
  14581. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14582. /**
  14583. * Get the euler rotation of the bone in local or world space
  14584. * @param space The space that the rotation should be in
  14585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14586. * @returns The euler rotation
  14587. */
  14588. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14589. /**
  14590. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @param result The vector3 that the rotation should be copied to
  14594. */
  14595. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14596. /**
  14597. * Get the quaternion rotation of the bone in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @returns The quaternion rotation
  14601. */
  14602. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14603. /**
  14604. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @param result The quaternion that the rotation should be copied to
  14608. */
  14609. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14610. /**
  14611. * Get the rotation matrix of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The rotation matrix
  14615. */
  14616. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14617. /**
  14618. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The quaternion that the rotation should be copied to
  14622. */
  14623. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14624. /**
  14625. * Get the world position of a point that is in the local space of the bone
  14626. * @param position The local position
  14627. * @param mesh The mesh that this bone is attached to
  14628. * @returns The world position
  14629. */
  14630. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @param result The vector3 that the world position should be copied to
  14636. */
  14637. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14638. /**
  14639. * Get the local position of a point that is in world space
  14640. * @param position The world position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @returns The local position
  14643. */
  14644. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14645. /**
  14646. * Get the local position of a point that is in world space and copy it to the result param
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @param result The vector3 that the local position should be copied to
  14650. */
  14651. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14652. }
  14653. }
  14654. declare module "babylonjs/Animations/runtimeAnimation" {
  14655. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14656. import { Animatable } from "babylonjs/Animations/animatable";
  14657. import { Scene } from "babylonjs/scene";
  14658. /**
  14659. * Defines a runtime animation
  14660. */
  14661. export class RuntimeAnimation {
  14662. private _events;
  14663. /**
  14664. * The current frame of the runtime animation
  14665. */
  14666. private _currentFrame;
  14667. /**
  14668. * The animation used by the runtime animation
  14669. */
  14670. private _animation;
  14671. /**
  14672. * The target of the runtime animation
  14673. */
  14674. private _target;
  14675. /**
  14676. * The initiating animatable
  14677. */
  14678. private _host;
  14679. /**
  14680. * The original value of the runtime animation
  14681. */
  14682. private _originalValue;
  14683. /**
  14684. * The original blend value of the runtime animation
  14685. */
  14686. private _originalBlendValue;
  14687. /**
  14688. * The offsets cache of the runtime animation
  14689. */
  14690. private _offsetsCache;
  14691. /**
  14692. * The high limits cache of the runtime animation
  14693. */
  14694. private _highLimitsCache;
  14695. /**
  14696. * Specifies if the runtime animation has been stopped
  14697. */
  14698. private _stopped;
  14699. /**
  14700. * The blending factor of the runtime animation
  14701. */
  14702. private _blendingFactor;
  14703. /**
  14704. * The BabylonJS scene
  14705. */
  14706. private _scene;
  14707. /**
  14708. * The current value of the runtime animation
  14709. */
  14710. private _currentValue;
  14711. /** @hidden */
  14712. _animationState: _IAnimationState;
  14713. /**
  14714. * The active target of the runtime animation
  14715. */
  14716. private _activeTargets;
  14717. private _currentActiveTarget;
  14718. private _directTarget;
  14719. /**
  14720. * The target path of the runtime animation
  14721. */
  14722. private _targetPath;
  14723. /**
  14724. * The weight of the runtime animation
  14725. */
  14726. private _weight;
  14727. /**
  14728. * The ratio offset of the runtime animation
  14729. */
  14730. private _ratioOffset;
  14731. /**
  14732. * The previous delay of the runtime animation
  14733. */
  14734. private _previousDelay;
  14735. /**
  14736. * The previous ratio of the runtime animation
  14737. */
  14738. private _previousRatio;
  14739. private _enableBlending;
  14740. private _keys;
  14741. private _minFrame;
  14742. private _maxFrame;
  14743. private _minValue;
  14744. private _maxValue;
  14745. private _targetIsArray;
  14746. /**
  14747. * Gets the current frame of the runtime animation
  14748. */
  14749. get currentFrame(): number;
  14750. /**
  14751. * Gets the weight of the runtime animation
  14752. */
  14753. get weight(): number;
  14754. /**
  14755. * Gets the current value of the runtime animation
  14756. */
  14757. get currentValue(): any;
  14758. /**
  14759. * Gets the target path of the runtime animation
  14760. */
  14761. get targetPath(): string;
  14762. /**
  14763. * Gets the actual target of the runtime animation
  14764. */
  14765. get target(): any;
  14766. /** @hidden */
  14767. _onLoop: () => void;
  14768. /**
  14769. * Create a new RuntimeAnimation object
  14770. * @param target defines the target of the animation
  14771. * @param animation defines the source animation object
  14772. * @param scene defines the hosting scene
  14773. * @param host defines the initiating Animatable
  14774. */
  14775. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14776. private _preparePath;
  14777. /**
  14778. * Gets the animation from the runtime animation
  14779. */
  14780. get animation(): Animation;
  14781. /**
  14782. * Resets the runtime animation to the beginning
  14783. * @param restoreOriginal defines whether to restore the target property to the original value
  14784. */
  14785. reset(restoreOriginal?: boolean): void;
  14786. /**
  14787. * Specifies if the runtime animation is stopped
  14788. * @returns Boolean specifying if the runtime animation is stopped
  14789. */
  14790. isStopped(): boolean;
  14791. /**
  14792. * Disposes of the runtime animation
  14793. */
  14794. dispose(): void;
  14795. /**
  14796. * Apply the interpolated value to the target
  14797. * @param currentValue defines the value computed by the animation
  14798. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14799. */
  14800. setValue(currentValue: any, weight: number): void;
  14801. private _getOriginalValues;
  14802. private _setValue;
  14803. /**
  14804. * Gets the loop pmode of the runtime animation
  14805. * @returns Loop Mode
  14806. */
  14807. private _getCorrectLoopMode;
  14808. /**
  14809. * Move the current animation to a given frame
  14810. * @param frame defines the frame to move to
  14811. */
  14812. goToFrame(frame: number): void;
  14813. /**
  14814. * @hidden Internal use only
  14815. */
  14816. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14817. /**
  14818. * Execute the current animation
  14819. * @param delay defines the delay to add to the current frame
  14820. * @param from defines the lower bound of the animation range
  14821. * @param to defines the upper bound of the animation range
  14822. * @param loop defines if the current animation must loop
  14823. * @param speedRatio defines the current speed ratio
  14824. * @param weight defines the weight of the animation (default is -1 so no weight)
  14825. * @param onLoop optional callback called when animation loops
  14826. * @returns a boolean indicating if the animation is running
  14827. */
  14828. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14829. }
  14830. }
  14831. declare module "babylonjs/Animations/animatable" {
  14832. import { Animation } from "babylonjs/Animations/animation";
  14833. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14834. import { Nullable } from "babylonjs/types";
  14835. import { Observable } from "babylonjs/Misc/observable";
  14836. import { Scene } from "babylonjs/scene";
  14837. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14838. import { Node } from "babylonjs/node";
  14839. /**
  14840. * Class used to store an actual running animation
  14841. */
  14842. export class Animatable {
  14843. /** defines the target object */
  14844. target: any;
  14845. /** defines the starting frame number (default is 0) */
  14846. fromFrame: number;
  14847. /** defines the ending frame number (default is 100) */
  14848. toFrame: number;
  14849. /** defines if the animation must loop (default is false) */
  14850. loopAnimation: boolean;
  14851. /** defines a callback to call when animation ends if it is not looping */
  14852. onAnimationEnd?: (() => void) | null | undefined;
  14853. /** defines a callback to call when animation loops */
  14854. onAnimationLoop?: (() => void) | null | undefined;
  14855. private _localDelayOffset;
  14856. private _pausedDelay;
  14857. private _runtimeAnimations;
  14858. private _paused;
  14859. private _scene;
  14860. private _speedRatio;
  14861. private _weight;
  14862. private _syncRoot;
  14863. /**
  14864. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14865. * This will only apply for non looping animation (default is true)
  14866. */
  14867. disposeOnEnd: boolean;
  14868. /**
  14869. * Gets a boolean indicating if the animation has started
  14870. */
  14871. animationStarted: boolean;
  14872. /**
  14873. * Observer raised when the animation ends
  14874. */
  14875. onAnimationEndObservable: Observable<Animatable>;
  14876. /**
  14877. * Observer raised when the animation loops
  14878. */
  14879. onAnimationLoopObservable: Observable<Animatable>;
  14880. /**
  14881. * Gets the root Animatable used to synchronize and normalize animations
  14882. */
  14883. get syncRoot(): Nullable<Animatable>;
  14884. /**
  14885. * Gets the current frame of the first RuntimeAnimation
  14886. * Used to synchronize Animatables
  14887. */
  14888. get masterFrame(): number;
  14889. /**
  14890. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14891. */
  14892. get weight(): number;
  14893. set weight(value: number);
  14894. /**
  14895. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14896. */
  14897. get speedRatio(): number;
  14898. set speedRatio(value: number);
  14899. /**
  14900. * Creates a new Animatable
  14901. * @param scene defines the hosting scene
  14902. * @param target defines the target object
  14903. * @param fromFrame defines the starting frame number (default is 0)
  14904. * @param toFrame defines the ending frame number (default is 100)
  14905. * @param loopAnimation defines if the animation must loop (default is false)
  14906. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14907. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14908. * @param animations defines a group of animation to add to the new Animatable
  14909. * @param onAnimationLoop defines a callback to call when animation loops
  14910. */
  14911. constructor(scene: Scene,
  14912. /** defines the target object */
  14913. target: any,
  14914. /** defines the starting frame number (default is 0) */
  14915. fromFrame?: number,
  14916. /** defines the ending frame number (default is 100) */
  14917. toFrame?: number,
  14918. /** defines if the animation must loop (default is false) */
  14919. loopAnimation?: boolean, speedRatio?: number,
  14920. /** defines a callback to call when animation ends if it is not looping */
  14921. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14922. /** defines a callback to call when animation loops */
  14923. onAnimationLoop?: (() => void) | null | undefined);
  14924. /**
  14925. * Synchronize and normalize current Animatable with a source Animatable
  14926. * This is useful when using animation weights and when animations are not of the same length
  14927. * @param root defines the root Animatable to synchronize with
  14928. * @returns the current Animatable
  14929. */
  14930. syncWith(root: Animatable): Animatable;
  14931. /**
  14932. * Gets the list of runtime animations
  14933. * @returns an array of RuntimeAnimation
  14934. */
  14935. getAnimations(): RuntimeAnimation[];
  14936. /**
  14937. * Adds more animations to the current animatable
  14938. * @param target defines the target of the animations
  14939. * @param animations defines the new animations to add
  14940. */
  14941. appendAnimations(target: any, animations: Animation[]): void;
  14942. /**
  14943. * Gets the source animation for a specific property
  14944. * @param property defines the propertyu to look for
  14945. * @returns null or the source animation for the given property
  14946. */
  14947. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14948. /**
  14949. * Gets the runtime animation for a specific property
  14950. * @param property defines the propertyu to look for
  14951. * @returns null or the runtime animation for the given property
  14952. */
  14953. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14954. /**
  14955. * Resets the animatable to its original state
  14956. */
  14957. reset(): void;
  14958. /**
  14959. * Allows the animatable to blend with current running animations
  14960. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14961. * @param blendingSpeed defines the blending speed to use
  14962. */
  14963. enableBlending(blendingSpeed: number): void;
  14964. /**
  14965. * Disable animation blending
  14966. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14967. */
  14968. disableBlending(): void;
  14969. /**
  14970. * Jump directly to a given frame
  14971. * @param frame defines the frame to jump to
  14972. */
  14973. goToFrame(frame: number): void;
  14974. /**
  14975. * Pause the animation
  14976. */
  14977. pause(): void;
  14978. /**
  14979. * Restart the animation
  14980. */
  14981. restart(): void;
  14982. private _raiseOnAnimationEnd;
  14983. /**
  14984. * Stop and delete the current animation
  14985. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14986. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14987. */
  14988. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14989. /**
  14990. * Wait asynchronously for the animation to end
  14991. * @returns a promise which will be fullfilled when the animation ends
  14992. */
  14993. waitAsync(): Promise<Animatable>;
  14994. /** @hidden */
  14995. _animate(delay: number): boolean;
  14996. }
  14997. module "babylonjs/scene" {
  14998. interface Scene {
  14999. /** @hidden */
  15000. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15001. /** @hidden */
  15002. _processLateAnimationBindingsForMatrices(holder: {
  15003. totalWeight: number;
  15004. animations: RuntimeAnimation[];
  15005. originalValue: Matrix;
  15006. }): any;
  15007. /** @hidden */
  15008. _processLateAnimationBindingsForQuaternions(holder: {
  15009. totalWeight: number;
  15010. animations: RuntimeAnimation[];
  15011. originalValue: Quaternion;
  15012. }, refQuaternion: Quaternion): Quaternion;
  15013. /** @hidden */
  15014. _processLateAnimationBindings(): void;
  15015. /**
  15016. * Will start the animation sequence of a given target
  15017. * @param target defines the target
  15018. * @param from defines from which frame should animation start
  15019. * @param to defines until which frame should animation run.
  15020. * @param weight defines the weight to apply to the animation (1.0 by default)
  15021. * @param loop defines if the animation loops
  15022. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15023. * @param onAnimationEnd defines the function to be executed when the animation ends
  15024. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15025. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15026. * @param onAnimationLoop defines the callback to call when an animation loops
  15027. * @returns the animatable object created for this animation
  15028. */
  15029. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15030. /**
  15031. * Will start the animation sequence of a given target
  15032. * @param target defines the target
  15033. * @param from defines from which frame should animation start
  15034. * @param to defines until which frame should animation run.
  15035. * @param loop defines if the animation loops
  15036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15037. * @param onAnimationEnd defines the function to be executed when the animation ends
  15038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15039. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15040. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15041. * @param onAnimationLoop defines the callback to call when an animation loops
  15042. * @returns the animatable object created for this animation
  15043. */
  15044. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15045. /**
  15046. * Will start the animation sequence of a given target and its hierarchy
  15047. * @param target defines the target
  15048. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15049. * @param from defines from which frame should animation start
  15050. * @param to defines until which frame should animation run.
  15051. * @param loop defines if the animation loops
  15052. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15053. * @param onAnimationEnd defines the function to be executed when the animation ends
  15054. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15055. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15056. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15057. * @param onAnimationLoop defines the callback to call when an animation loops
  15058. * @returns the list of created animatables
  15059. */
  15060. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  15061. /**
  15062. * Begin a new animation on a given node
  15063. * @param target defines the target where the animation will take place
  15064. * @param animations defines the list of animations to start
  15065. * @param from defines the initial value
  15066. * @param to defines the final value
  15067. * @param loop defines if you want animation to loop (off by default)
  15068. * @param speedRatio defines the speed ratio to apply to all animations
  15069. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15070. * @param onAnimationLoop defines the callback to call when an animation loops
  15071. * @returns the list of created animatables
  15072. */
  15073. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15074. /**
  15075. * Begin a new animation on a given node and its hierarchy
  15076. * @param target defines the root node where the animation will take place
  15077. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15078. * @param animations defines the list of animations to start
  15079. * @param from defines the initial value
  15080. * @param to defines the final value
  15081. * @param loop defines if you want animation to loop (off by default)
  15082. * @param speedRatio defines the speed ratio to apply to all animations
  15083. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15084. * @param onAnimationLoop defines the callback to call when an animation loops
  15085. * @returns the list of animatables created for all nodes
  15086. */
  15087. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15088. /**
  15089. * Gets the animatable associated with a specific target
  15090. * @param target defines the target of the animatable
  15091. * @returns the required animatable if found
  15092. */
  15093. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15094. /**
  15095. * Gets all animatables associated with a given target
  15096. * @param target defines the target to look animatables for
  15097. * @returns an array of Animatables
  15098. */
  15099. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15100. /**
  15101. * Stops and removes all animations that have been applied to the scene
  15102. */
  15103. stopAllAnimations(): void;
  15104. /**
  15105. * Gets the current delta time used by animation engine
  15106. */
  15107. deltaTime: number;
  15108. }
  15109. }
  15110. module "babylonjs/Bones/bone" {
  15111. interface Bone {
  15112. /**
  15113. * Copy an animation range from another bone
  15114. * @param source defines the source bone
  15115. * @param rangeName defines the range name to copy
  15116. * @param frameOffset defines the frame offset
  15117. * @param rescaleAsRequired defines if rescaling must be applied if required
  15118. * @param skelDimensionsRatio defines the scaling ratio
  15119. * @returns true if operation was successful
  15120. */
  15121. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15122. }
  15123. }
  15124. }
  15125. declare module "babylonjs/Bones/skeleton" {
  15126. import { Bone } from "babylonjs/Bones/bone";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15129. import { Scene } from "babylonjs/scene";
  15130. import { Nullable } from "babylonjs/types";
  15131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15133. import { Animatable } from "babylonjs/Animations/animatable";
  15134. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15135. import { Animation } from "babylonjs/Animations/animation";
  15136. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15137. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15139. /**
  15140. * Class used to handle skinning animations
  15141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15142. */
  15143. export class Skeleton implements IAnimatable {
  15144. /** defines the skeleton name */
  15145. name: string;
  15146. /** defines the skeleton Id */
  15147. id: string;
  15148. /**
  15149. * Defines the list of child bones
  15150. */
  15151. bones: Bone[];
  15152. /**
  15153. * Defines an estimate of the dimension of the skeleton at rest
  15154. */
  15155. dimensionsAtRest: Vector3;
  15156. /**
  15157. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15158. */
  15159. needInitialSkinMatrix: boolean;
  15160. /**
  15161. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15162. */
  15163. overrideMesh: Nullable<AbstractMesh>;
  15164. /**
  15165. * Gets the list of animations attached to this skeleton
  15166. */
  15167. animations: Array<Animation>;
  15168. private _scene;
  15169. private _isDirty;
  15170. private _transformMatrices;
  15171. private _transformMatrixTexture;
  15172. private _meshesWithPoseMatrix;
  15173. private _animatables;
  15174. private _identity;
  15175. private _synchronizedWithMesh;
  15176. private _ranges;
  15177. private _lastAbsoluteTransformsUpdateId;
  15178. private _canUseTextureForBones;
  15179. private _uniqueId;
  15180. /** @hidden */
  15181. _numBonesWithLinkedTransformNode: number;
  15182. /** @hidden */
  15183. _hasWaitingData: Nullable<boolean>;
  15184. /**
  15185. * Specifies if the skeleton should be serialized
  15186. */
  15187. doNotSerialize: boolean;
  15188. private _useTextureToStoreBoneMatrices;
  15189. /**
  15190. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15191. * Please note that this option is not available if the hardware does not support it
  15192. */
  15193. get useTextureToStoreBoneMatrices(): boolean;
  15194. set useTextureToStoreBoneMatrices(value: boolean);
  15195. private _animationPropertiesOverride;
  15196. /**
  15197. * Gets or sets the animation properties override
  15198. */
  15199. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15200. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15201. /**
  15202. * List of inspectable custom properties (used by the Inspector)
  15203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15204. */
  15205. inspectableCustomProperties: IInspectable[];
  15206. /**
  15207. * An observable triggered before computing the skeleton's matrices
  15208. */
  15209. onBeforeComputeObservable: Observable<Skeleton>;
  15210. /**
  15211. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15212. */
  15213. get isUsingTextureForMatrices(): boolean;
  15214. /**
  15215. * Gets the unique ID of this skeleton
  15216. */
  15217. get uniqueId(): number;
  15218. /**
  15219. * Creates a new skeleton
  15220. * @param name defines the skeleton name
  15221. * @param id defines the skeleton Id
  15222. * @param scene defines the hosting scene
  15223. */
  15224. constructor(
  15225. /** defines the skeleton name */
  15226. name: string,
  15227. /** defines the skeleton Id */
  15228. id: string, scene: Scene);
  15229. /**
  15230. * Gets the current object class name.
  15231. * @return the class name
  15232. */
  15233. getClassName(): string;
  15234. /**
  15235. * Returns an array containing the root bones
  15236. * @returns an array containing the root bones
  15237. */
  15238. getChildren(): Array<Bone>;
  15239. /**
  15240. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15241. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15242. * @returns a Float32Array containing matrices data
  15243. */
  15244. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15245. /**
  15246. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15247. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15248. * @returns a raw texture containing the data
  15249. */
  15250. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15251. /**
  15252. * Gets the current hosting scene
  15253. * @returns a scene object
  15254. */
  15255. getScene(): Scene;
  15256. /**
  15257. * Gets a string representing the current skeleton data
  15258. * @param fullDetails defines a boolean indicating if we want a verbose version
  15259. * @returns a string representing the current skeleton data
  15260. */
  15261. toString(fullDetails?: boolean): string;
  15262. /**
  15263. * Get bone's index searching by name
  15264. * @param name defines bone's name to search for
  15265. * @return the indice of the bone. Returns -1 if not found
  15266. */
  15267. getBoneIndexByName(name: string): number;
  15268. /**
  15269. * Creater a new animation range
  15270. * @param name defines the name of the range
  15271. * @param from defines the start key
  15272. * @param to defines the end key
  15273. */
  15274. createAnimationRange(name: string, from: number, to: number): void;
  15275. /**
  15276. * Delete a specific animation range
  15277. * @param name defines the name of the range
  15278. * @param deleteFrames defines if frames must be removed as well
  15279. */
  15280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15281. /**
  15282. * Gets a specific animation range
  15283. * @param name defines the name of the range to look for
  15284. * @returns the requested animation range or null if not found
  15285. */
  15286. getAnimationRange(name: string): Nullable<AnimationRange>;
  15287. /**
  15288. * Gets the list of all animation ranges defined on this skeleton
  15289. * @returns an array
  15290. */
  15291. getAnimationRanges(): Nullable<AnimationRange>[];
  15292. /**
  15293. * Copy animation range from a source skeleton.
  15294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15295. * @param source defines the source skeleton
  15296. * @param name defines the name of the range to copy
  15297. * @param rescaleAsRequired defines if rescaling must be applied if required
  15298. * @returns true if operation was successful
  15299. */
  15300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15301. /**
  15302. * Forces the skeleton to go to rest pose
  15303. */
  15304. returnToRest(): void;
  15305. private _getHighestAnimationFrame;
  15306. /**
  15307. * Begin a specific animation range
  15308. * @param name defines the name of the range to start
  15309. * @param loop defines if looping must be turned on (false by default)
  15310. * @param speedRatio defines the speed ratio to apply (1 by default)
  15311. * @param onAnimationEnd defines a callback which will be called when animation will end
  15312. * @returns a new animatable
  15313. */
  15314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15315. /** @hidden */
  15316. _markAsDirty(): void;
  15317. /** @hidden */
  15318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15319. /** @hidden */
  15320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15321. private _computeTransformMatrices;
  15322. /**
  15323. * Build all resources required to render a skeleton
  15324. */
  15325. prepare(): void;
  15326. /**
  15327. * Gets the list of animatables currently running for this skeleton
  15328. * @returns an array of animatables
  15329. */
  15330. getAnimatables(): IAnimatable[];
  15331. /**
  15332. * Clone the current skeleton
  15333. * @param name defines the name of the new skeleton
  15334. * @param id defines the id of the new skeleton
  15335. * @returns the new skeleton
  15336. */
  15337. clone(name: string, id?: string): Skeleton;
  15338. /**
  15339. * Enable animation blending for this skeleton
  15340. * @param blendingSpeed defines the blending speed to apply
  15341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15342. */
  15343. enableBlending(blendingSpeed?: number): void;
  15344. /**
  15345. * Releases all resources associated with the current skeleton
  15346. */
  15347. dispose(): void;
  15348. /**
  15349. * Serialize the skeleton in a JSON object
  15350. * @returns a JSON object
  15351. */
  15352. serialize(): any;
  15353. /**
  15354. * Creates a new skeleton from serialized data
  15355. * @param parsedSkeleton defines the serialized data
  15356. * @param scene defines the hosting scene
  15357. * @returns a new skeleton
  15358. */
  15359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15360. /**
  15361. * Compute all node absolute transforms
  15362. * @param forceUpdate defines if computation must be done even if cache is up to date
  15363. */
  15364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15365. /**
  15366. * Gets the root pose matrix
  15367. * @returns a matrix
  15368. */
  15369. getPoseMatrix(): Nullable<Matrix>;
  15370. /**
  15371. * Sorts bones per internal index
  15372. */
  15373. sortBones(): void;
  15374. private _sortBones;
  15375. }
  15376. }
  15377. declare module "babylonjs/Meshes/instancedMesh" {
  15378. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15380. import { Camera } from "babylonjs/Cameras/camera";
  15381. import { Node } from "babylonjs/node";
  15382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15383. import { Mesh } from "babylonjs/Meshes/mesh";
  15384. import { Material } from "babylonjs/Materials/material";
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Light } from "babylonjs/Lights/light";
  15387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15388. /**
  15389. * Creates an instance based on a source mesh.
  15390. */
  15391. export class InstancedMesh extends AbstractMesh {
  15392. private _sourceMesh;
  15393. private _currentLOD;
  15394. /** @hidden */
  15395. _indexInSourceMeshInstanceArray: number;
  15396. constructor(name: string, source: Mesh);
  15397. /**
  15398. * Returns the string "InstancedMesh".
  15399. */
  15400. getClassName(): string;
  15401. /** Gets the list of lights affecting that mesh */
  15402. get lightSources(): Light[];
  15403. _resyncLightSources(): void;
  15404. _resyncLightSource(light: Light): void;
  15405. _removeLightSource(light: Light, dispose: boolean): void;
  15406. /**
  15407. * If the source mesh receives shadows
  15408. */
  15409. get receiveShadows(): boolean;
  15410. /**
  15411. * The material of the source mesh
  15412. */
  15413. get material(): Nullable<Material>;
  15414. /**
  15415. * Visibility of the source mesh
  15416. */
  15417. get visibility(): number;
  15418. /**
  15419. * Skeleton of the source mesh
  15420. */
  15421. get skeleton(): Nullable<Skeleton>;
  15422. /**
  15423. * Rendering ground id of the source mesh
  15424. */
  15425. get renderingGroupId(): number;
  15426. set renderingGroupId(value: number);
  15427. /**
  15428. * Returns the total number of vertices (integer).
  15429. */
  15430. getTotalVertices(): number;
  15431. /**
  15432. * Returns a positive integer : the total number of indices in this mesh geometry.
  15433. * @returns the numner of indices or zero if the mesh has no geometry.
  15434. */
  15435. getTotalIndices(): number;
  15436. /**
  15437. * The source mesh of the instance
  15438. */
  15439. get sourceMesh(): Mesh;
  15440. /**
  15441. * Is this node ready to be used/rendered
  15442. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15443. * @return {boolean} is it ready
  15444. */
  15445. isReady(completeCheck?: boolean): boolean;
  15446. /**
  15447. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15448. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15449. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15450. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15451. */
  15452. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15453. /**
  15454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15456. * The `data` are either a numeric array either a Float32Array.
  15457. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15458. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15459. * Note that a new underlying VertexBuffer object is created each call.
  15460. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15461. *
  15462. * Possible `kind` values :
  15463. * - VertexBuffer.PositionKind
  15464. * - VertexBuffer.UVKind
  15465. * - VertexBuffer.UV2Kind
  15466. * - VertexBuffer.UV3Kind
  15467. * - VertexBuffer.UV4Kind
  15468. * - VertexBuffer.UV5Kind
  15469. * - VertexBuffer.UV6Kind
  15470. * - VertexBuffer.ColorKind
  15471. * - VertexBuffer.MatricesIndicesKind
  15472. * - VertexBuffer.MatricesIndicesExtraKind
  15473. * - VertexBuffer.MatricesWeightsKind
  15474. * - VertexBuffer.MatricesWeightsExtraKind
  15475. *
  15476. * Returns the Mesh.
  15477. */
  15478. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15479. /**
  15480. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15481. * If the mesh has no geometry, it is simply returned as it is.
  15482. * The `data` are either a numeric array either a Float32Array.
  15483. * No new underlying VertexBuffer object is created.
  15484. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15485. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15486. *
  15487. * Possible `kind` values :
  15488. * - VertexBuffer.PositionKind
  15489. * - VertexBuffer.UVKind
  15490. * - VertexBuffer.UV2Kind
  15491. * - VertexBuffer.UV3Kind
  15492. * - VertexBuffer.UV4Kind
  15493. * - VertexBuffer.UV5Kind
  15494. * - VertexBuffer.UV6Kind
  15495. * - VertexBuffer.ColorKind
  15496. * - VertexBuffer.MatricesIndicesKind
  15497. * - VertexBuffer.MatricesIndicesExtraKind
  15498. * - VertexBuffer.MatricesWeightsKind
  15499. * - VertexBuffer.MatricesWeightsExtraKind
  15500. *
  15501. * Returns the Mesh.
  15502. */
  15503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15504. /**
  15505. * Sets the mesh indices.
  15506. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15508. * This method creates a new index buffer each call.
  15509. * Returns the Mesh.
  15510. */
  15511. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15512. /**
  15513. * Boolean : True if the mesh owns the requested kind of data.
  15514. */
  15515. isVerticesDataPresent(kind: string): boolean;
  15516. /**
  15517. * Returns an array of indices (IndicesArray).
  15518. */
  15519. getIndices(): Nullable<IndicesArray>;
  15520. get _positions(): Nullable<Vector3[]>;
  15521. /**
  15522. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15523. * This means the mesh underlying bounding box and sphere are recomputed.
  15524. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15525. * @returns the current mesh
  15526. */
  15527. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15528. /** @hidden */
  15529. _preActivate(): InstancedMesh;
  15530. /** @hidden */
  15531. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15532. /** @hidden */
  15533. _postActivate(): void;
  15534. getWorldMatrix(): Matrix;
  15535. get isAnInstance(): boolean;
  15536. /**
  15537. * Returns the current associated LOD AbstractMesh.
  15538. */
  15539. getLOD(camera: Camera): AbstractMesh;
  15540. /** @hidden */
  15541. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15542. /** @hidden */
  15543. _syncSubMeshes(): InstancedMesh;
  15544. /** @hidden */
  15545. _generatePointsArray(): boolean;
  15546. /**
  15547. * Creates a new InstancedMesh from the current mesh.
  15548. * - name (string) : the cloned mesh name
  15549. * - newParent (optional Node) : the optional Node to parent the clone to.
  15550. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15551. *
  15552. * Returns the clone.
  15553. */
  15554. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15555. /**
  15556. * Disposes the InstancedMesh.
  15557. * Returns nothing.
  15558. */
  15559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15560. }
  15561. module "babylonjs/Meshes/mesh" {
  15562. interface Mesh {
  15563. /**
  15564. * Register a custom buffer that will be instanced
  15565. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15566. * @param kind defines the buffer kind
  15567. * @param stride defines the stride in floats
  15568. */
  15569. registerInstancedBuffer(kind: string, stride: number): void;
  15570. /** @hidden */
  15571. _userInstancedBuffersStorage: {
  15572. data: {
  15573. [key: string]: Float32Array;
  15574. };
  15575. sizes: {
  15576. [key: string]: number;
  15577. };
  15578. vertexBuffers: {
  15579. [key: string]: Nullable<VertexBuffer>;
  15580. };
  15581. strides: {
  15582. [key: string]: number;
  15583. };
  15584. };
  15585. }
  15586. }
  15587. module "babylonjs/Meshes/abstractMesh" {
  15588. interface AbstractMesh {
  15589. /**
  15590. * Object used to store instanced buffers defined by user
  15591. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15592. */
  15593. instancedBuffers: {
  15594. [key: string]: any;
  15595. };
  15596. }
  15597. }
  15598. }
  15599. declare module "babylonjs/Materials/shaderMaterial" {
  15600. import { Scene } from "babylonjs/scene";
  15601. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15603. import { Mesh } from "babylonjs/Meshes/mesh";
  15604. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15606. import { Texture } from "babylonjs/Materials/Textures/texture";
  15607. import { Material } from "babylonjs/Materials/material";
  15608. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15609. /**
  15610. * Defines the options associated with the creation of a shader material.
  15611. */
  15612. export interface IShaderMaterialOptions {
  15613. /**
  15614. * Does the material work in alpha blend mode
  15615. */
  15616. needAlphaBlending: boolean;
  15617. /**
  15618. * Does the material work in alpha test mode
  15619. */
  15620. needAlphaTesting: boolean;
  15621. /**
  15622. * The list of attribute names used in the shader
  15623. */
  15624. attributes: string[];
  15625. /**
  15626. * The list of unifrom names used in the shader
  15627. */
  15628. uniforms: string[];
  15629. /**
  15630. * The list of UBO names used in the shader
  15631. */
  15632. uniformBuffers: string[];
  15633. /**
  15634. * The list of sampler names used in the shader
  15635. */
  15636. samplers: string[];
  15637. /**
  15638. * The list of defines used in the shader
  15639. */
  15640. defines: string[];
  15641. }
  15642. /**
  15643. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15644. *
  15645. * This returned material effects how the mesh will look based on the code in the shaders.
  15646. *
  15647. * @see http://doc.babylonjs.com/how_to/shader_material
  15648. */
  15649. export class ShaderMaterial extends Material {
  15650. private _shaderPath;
  15651. private _options;
  15652. private _textures;
  15653. private _textureArrays;
  15654. private _floats;
  15655. private _ints;
  15656. private _floatsArrays;
  15657. private _colors3;
  15658. private _colors3Arrays;
  15659. private _colors4;
  15660. private _colors4Arrays;
  15661. private _vectors2;
  15662. private _vectors3;
  15663. private _vectors4;
  15664. private _matrices;
  15665. private _matrixArrays;
  15666. private _matrices3x3;
  15667. private _matrices2x2;
  15668. private _vectors2Arrays;
  15669. private _vectors3Arrays;
  15670. private _vectors4Arrays;
  15671. private _cachedWorldViewMatrix;
  15672. private _cachedWorldViewProjectionMatrix;
  15673. private _renderId;
  15674. private _multiview;
  15675. /**
  15676. * Instantiate a new shader material.
  15677. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15678. * This returned material effects how the mesh will look based on the code in the shaders.
  15679. * @see http://doc.babylonjs.com/how_to/shader_material
  15680. * @param name Define the name of the material in the scene
  15681. * @param scene Define the scene the material belongs to
  15682. * @param shaderPath Defines the route to the shader code in one of three ways:
  15683. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15684. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15685. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15686. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15687. * @param options Define the options used to create the shader
  15688. */
  15689. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15690. /**
  15691. * Gets the shader path used to define the shader code
  15692. * It can be modified to trigger a new compilation
  15693. */
  15694. get shaderPath(): any;
  15695. /**
  15696. * Sets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. set shaderPath(shaderPath: any);
  15700. /**
  15701. * Gets the options used to compile the shader.
  15702. * They can be modified to trigger a new compilation
  15703. */
  15704. get options(): IShaderMaterialOptions;
  15705. /**
  15706. * Gets the current class name of the material e.g. "ShaderMaterial"
  15707. * Mainly use in serialization.
  15708. * @returns the class name
  15709. */
  15710. getClassName(): string;
  15711. /**
  15712. * Specifies if the material will require alpha blending
  15713. * @returns a boolean specifying if alpha blending is needed
  15714. */
  15715. needAlphaBlending(): boolean;
  15716. /**
  15717. * Specifies if this material should be rendered in alpha test mode
  15718. * @returns a boolean specifying if an alpha test is needed.
  15719. */
  15720. needAlphaTesting(): boolean;
  15721. private _checkUniform;
  15722. /**
  15723. * Set a texture in the shader.
  15724. * @param name Define the name of the uniform samplers as defined in the shader
  15725. * @param texture Define the texture to bind to this sampler
  15726. * @return the material itself allowing "fluent" like uniform updates
  15727. */
  15728. setTexture(name: string, texture: Texture): ShaderMaterial;
  15729. /**
  15730. * Set a texture array in the shader.
  15731. * @param name Define the name of the uniform sampler array as defined in the shader
  15732. * @param textures Define the list of textures to bind to this sampler
  15733. * @return the material itself allowing "fluent" like uniform updates
  15734. */
  15735. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15736. /**
  15737. * Set a float in the shader.
  15738. * @param name Define the name of the uniform as defined in the shader
  15739. * @param value Define the value to give to the uniform
  15740. * @return the material itself allowing "fluent" like uniform updates
  15741. */
  15742. setFloat(name: string, value: number): ShaderMaterial;
  15743. /**
  15744. * Set a int in the shader.
  15745. * @param name Define the name of the uniform as defined in the shader
  15746. * @param value Define the value to give to the uniform
  15747. * @return the material itself allowing "fluent" like uniform updates
  15748. */
  15749. setInt(name: string, value: number): ShaderMaterial;
  15750. /**
  15751. * Set an array of floats in the shader.
  15752. * @param name Define the name of the uniform as defined in the shader
  15753. * @param value Define the value to give to the uniform
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setFloats(name: string, value: number[]): ShaderMaterial;
  15757. /**
  15758. * Set a vec3 in the shader from a Color3.
  15759. * @param name Define the name of the uniform as defined in the shader
  15760. * @param value Define the value to give to the uniform
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setColor3(name: string, value: Color3): ShaderMaterial;
  15764. /**
  15765. * Set a vec3 array in the shader from a Color3 array.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15771. /**
  15772. * Set a vec4 in the shader from a Color4.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setColor4(name: string, value: Color4): ShaderMaterial;
  15778. /**
  15779. * Set a vec4 array in the shader from a Color4 array.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec2 in the shader from a Vector2.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setVector2(name: string, value: Vector2): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 in the shader from a Vector3.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setVector3(name: string, value: Vector3): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Vector4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setVector4(name: string, value: Vector4): ShaderMaterial;
  15806. /**
  15807. * Set a mat4 in the shader from a Matrix.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15813. /**
  15814. * Set a float32Array in the shader from a matrix array.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15820. /**
  15821. * Set a mat3 in the shader from a Float32Array.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15827. /**
  15828. * Set a mat2 in the shader from a Float32Array.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15834. /**
  15835. * Set a vec2 array in the shader from a number array.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setArray2(name: string, value: number[]): ShaderMaterial;
  15841. /**
  15842. * Set a vec3 array in the shader from a number array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setArray3(name: string, value: number[]): ShaderMaterial;
  15848. /**
  15849. * Set a vec4 array in the shader from a number array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setArray4(name: string, value: number[]): ShaderMaterial;
  15855. private _checkCache;
  15856. /**
  15857. * Specifies that the submesh is ready to be used
  15858. * @param mesh defines the mesh to check
  15859. * @param subMesh defines which submesh to check
  15860. * @param useInstances specifies that instances should be used
  15861. * @returns a boolean indicating that the submesh is ready or not
  15862. */
  15863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15864. /**
  15865. * Checks if the material is ready to render the requested mesh
  15866. * @param mesh Define the mesh to render
  15867. * @param useInstances Define whether or not the material is used with instances
  15868. * @returns true if ready, otherwise false
  15869. */
  15870. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15871. /**
  15872. * Binds the world matrix to the material
  15873. * @param world defines the world transformation matrix
  15874. */
  15875. bindOnlyWorldMatrix(world: Matrix): void;
  15876. /**
  15877. * Binds the material to the mesh
  15878. * @param world defines the world transformation matrix
  15879. * @param mesh defines the mesh to bind the material to
  15880. */
  15881. bind(world: Matrix, mesh?: Mesh): void;
  15882. /**
  15883. * Gets the active textures from the material
  15884. * @returns an array of textures
  15885. */
  15886. getActiveTextures(): BaseTexture[];
  15887. /**
  15888. * Specifies if the material uses a texture
  15889. * @param texture defines the texture to check against the material
  15890. * @returns a boolean specifying if the material uses the texture
  15891. */
  15892. hasTexture(texture: BaseTexture): boolean;
  15893. /**
  15894. * Makes a duplicate of the material, and gives it a new name
  15895. * @param name defines the new name for the duplicated material
  15896. * @returns the cloned material
  15897. */
  15898. clone(name: string): ShaderMaterial;
  15899. /**
  15900. * Disposes the material
  15901. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15902. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15903. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15904. */
  15905. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15906. /**
  15907. * Serializes this material in a JSON representation
  15908. * @returns the serialized material object
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Creates a shader material from parsed shader material data
  15913. * @param source defines the JSON represnetation of the material
  15914. * @param scene defines the hosting scene
  15915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15916. * @returns a new material
  15917. */
  15918. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15919. }
  15920. }
  15921. declare module "babylonjs/Shaders/color.fragment" {
  15922. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15924. /** @hidden */
  15925. export var colorPixelShader: {
  15926. name: string;
  15927. shader: string;
  15928. };
  15929. }
  15930. declare module "babylonjs/Shaders/color.vertex" {
  15931. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15932. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15933. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15936. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15937. /** @hidden */
  15938. export var colorVertexShader: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module "babylonjs/Meshes/linesMesh" {
  15944. import { Nullable } from "babylonjs/types";
  15945. import { Scene } from "babylonjs/scene";
  15946. import { Color3 } from "babylonjs/Maths/math.color";
  15947. import { Node } from "babylonjs/node";
  15948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15949. import { Mesh } from "babylonjs/Meshes/mesh";
  15950. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15951. import { Effect } from "babylonjs/Materials/effect";
  15952. import { Material } from "babylonjs/Materials/material";
  15953. import "babylonjs/Shaders/color.fragment";
  15954. import "babylonjs/Shaders/color.vertex";
  15955. /**
  15956. * Line mesh
  15957. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15958. */
  15959. export class LinesMesh extends Mesh {
  15960. /**
  15961. * If vertex color should be applied to the mesh
  15962. */
  15963. readonly useVertexColor?: boolean | undefined;
  15964. /**
  15965. * If vertex alpha should be applied to the mesh
  15966. */
  15967. readonly useVertexAlpha?: boolean | undefined;
  15968. /**
  15969. * Color of the line (Default: White)
  15970. */
  15971. color: Color3;
  15972. /**
  15973. * Alpha of the line (Default: 1)
  15974. */
  15975. alpha: number;
  15976. /**
  15977. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15978. * This margin is expressed in world space coordinates, so its value may vary.
  15979. * Default value is 0.1
  15980. */
  15981. intersectionThreshold: number;
  15982. private _colorShader;
  15983. private color4;
  15984. /**
  15985. * Creates a new LinesMesh
  15986. * @param name defines the name
  15987. * @param scene defines the hosting scene
  15988. * @param parent defines the parent mesh if any
  15989. * @param source defines the optional source LinesMesh used to clone data from
  15990. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15991. * When false, achieved by calling a clone(), also passing False.
  15992. * This will make creation of children, recursive.
  15993. * @param useVertexColor defines if this LinesMesh supports vertex color
  15994. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15995. */
  15996. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15997. /**
  15998. * If vertex color should be applied to the mesh
  15999. */
  16000. useVertexColor?: boolean | undefined,
  16001. /**
  16002. * If vertex alpha should be applied to the mesh
  16003. */
  16004. useVertexAlpha?: boolean | undefined);
  16005. private _addClipPlaneDefine;
  16006. private _removeClipPlaneDefine;
  16007. isReady(): boolean;
  16008. /**
  16009. * Returns the string "LineMesh"
  16010. */
  16011. getClassName(): string;
  16012. /**
  16013. * @hidden
  16014. */
  16015. get material(): Material;
  16016. /**
  16017. * @hidden
  16018. */
  16019. set material(value: Material);
  16020. /**
  16021. * @hidden
  16022. */
  16023. get checkCollisions(): boolean;
  16024. /** @hidden */
  16025. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16026. /** @hidden */
  16027. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16028. /**
  16029. * Disposes of the line mesh
  16030. * @param doNotRecurse If children should be disposed
  16031. */
  16032. dispose(doNotRecurse?: boolean): void;
  16033. /**
  16034. * Returns a new LineMesh object cloned from the current one.
  16035. */
  16036. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16037. /**
  16038. * Creates a new InstancedLinesMesh object from the mesh model.
  16039. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16040. * @param name defines the name of the new instance
  16041. * @returns a new InstancedLinesMesh
  16042. */
  16043. createInstance(name: string): InstancedLinesMesh;
  16044. }
  16045. /**
  16046. * Creates an instance based on a source LinesMesh
  16047. */
  16048. export class InstancedLinesMesh extends InstancedMesh {
  16049. /**
  16050. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16051. * This margin is expressed in world space coordinates, so its value may vary.
  16052. * Initilized with the intersectionThreshold value of the source LinesMesh
  16053. */
  16054. intersectionThreshold: number;
  16055. constructor(name: string, source: LinesMesh);
  16056. /**
  16057. * Returns the string "InstancedLinesMesh".
  16058. */
  16059. getClassName(): string;
  16060. }
  16061. }
  16062. declare module "babylonjs/Shaders/line.fragment" {
  16063. /** @hidden */
  16064. export var linePixelShader: {
  16065. name: string;
  16066. shader: string;
  16067. };
  16068. }
  16069. declare module "babylonjs/Shaders/line.vertex" {
  16070. /** @hidden */
  16071. export var lineVertexShader: {
  16072. name: string;
  16073. shader: string;
  16074. };
  16075. }
  16076. declare module "babylonjs/Rendering/edgesRenderer" {
  16077. import { Nullable } from "babylonjs/types";
  16078. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16080. import { Vector3 } from "babylonjs/Maths/math.vector";
  16081. import { IDisposable } from "babylonjs/scene";
  16082. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16083. import "babylonjs/Shaders/line.fragment";
  16084. import "babylonjs/Shaders/line.vertex";
  16085. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16086. module "babylonjs/Meshes/abstractMesh" {
  16087. interface AbstractMesh {
  16088. /**
  16089. * Gets the edgesRenderer associated with the mesh
  16090. */
  16091. edgesRenderer: Nullable<EdgesRenderer>;
  16092. }
  16093. }
  16094. module "babylonjs/Meshes/linesMesh" {
  16095. interface LinesMesh {
  16096. /**
  16097. * Enables the edge rendering mode on the mesh.
  16098. * This mode makes the mesh edges visible
  16099. * @param epsilon defines the maximal distance between two angles to detect a face
  16100. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16101. * @returns the currentAbstractMesh
  16102. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16103. */
  16104. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16105. }
  16106. }
  16107. module "babylonjs/Meshes/linesMesh" {
  16108. interface InstancedLinesMesh {
  16109. /**
  16110. * Enables the edge rendering mode on the mesh.
  16111. * This mode makes the mesh edges visible
  16112. * @param epsilon defines the maximal distance between two angles to detect a face
  16113. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16114. * @returns the current InstancedLinesMesh
  16115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16116. */
  16117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16118. }
  16119. }
  16120. /**
  16121. * Defines the minimum contract an Edges renderer should follow.
  16122. */
  16123. export interface IEdgesRenderer extends IDisposable {
  16124. /**
  16125. * Gets or sets a boolean indicating if the edgesRenderer is active
  16126. */
  16127. isEnabled: boolean;
  16128. /**
  16129. * Renders the edges of the attached mesh,
  16130. */
  16131. render(): void;
  16132. /**
  16133. * Checks wether or not the edges renderer is ready to render.
  16134. * @return true if ready, otherwise false.
  16135. */
  16136. isReady(): boolean;
  16137. }
  16138. /**
  16139. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16140. */
  16141. export class EdgesRenderer implements IEdgesRenderer {
  16142. /**
  16143. * Define the size of the edges with an orthographic camera
  16144. */
  16145. edgesWidthScalerForOrthographic: number;
  16146. /**
  16147. * Define the size of the edges with a perspective camera
  16148. */
  16149. edgesWidthScalerForPerspective: number;
  16150. protected _source: AbstractMesh;
  16151. protected _linesPositions: number[];
  16152. protected _linesNormals: number[];
  16153. protected _linesIndices: number[];
  16154. protected _epsilon: number;
  16155. protected _indicesCount: number;
  16156. protected _lineShader: ShaderMaterial;
  16157. protected _ib: DataBuffer;
  16158. protected _buffers: {
  16159. [key: string]: Nullable<VertexBuffer>;
  16160. };
  16161. protected _checkVerticesInsteadOfIndices: boolean;
  16162. private _meshRebuildObserver;
  16163. private _meshDisposeObserver;
  16164. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16165. isEnabled: boolean;
  16166. /**
  16167. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16168. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16169. * @param source Mesh used to create edges
  16170. * @param epsilon sum of angles in adjacency to check for edge
  16171. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16172. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16173. */
  16174. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16175. protected _prepareRessources(): void;
  16176. /** @hidden */
  16177. _rebuild(): void;
  16178. /**
  16179. * Releases the required resources for the edges renderer
  16180. */
  16181. dispose(): void;
  16182. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16183. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16184. /**
  16185. * Checks if the pair of p0 and p1 is en edge
  16186. * @param faceIndex
  16187. * @param edge
  16188. * @param faceNormals
  16189. * @param p0
  16190. * @param p1
  16191. * @private
  16192. */
  16193. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16194. /**
  16195. * push line into the position, normal and index buffer
  16196. * @protected
  16197. */
  16198. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16199. /**
  16200. * Generates lines edges from adjacencjes
  16201. * @private
  16202. */
  16203. _generateEdgesLines(): void;
  16204. /**
  16205. * Checks wether or not the edges renderer is ready to render.
  16206. * @return true if ready, otherwise false.
  16207. */
  16208. isReady(): boolean;
  16209. /**
  16210. * Renders the edges of the attached mesh,
  16211. */
  16212. render(): void;
  16213. }
  16214. /**
  16215. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16216. */
  16217. export class LineEdgesRenderer extends EdgesRenderer {
  16218. /**
  16219. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16220. * @param source LineMesh used to generate edges
  16221. * @param epsilon not important (specified angle for edge detection)
  16222. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16223. */
  16224. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16225. /**
  16226. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16227. */
  16228. _generateEdgesLines(): void;
  16229. }
  16230. }
  16231. declare module "babylonjs/Rendering/renderingGroup" {
  16232. import { SmartArray } from "babylonjs/Misc/smartArray";
  16233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16235. import { Nullable } from "babylonjs/types";
  16236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16237. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16238. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16239. import { Material } from "babylonjs/Materials/material";
  16240. import { Scene } from "babylonjs/scene";
  16241. /**
  16242. * This represents the object necessary to create a rendering group.
  16243. * This is exclusively used and created by the rendering manager.
  16244. * To modify the behavior, you use the available helpers in your scene or meshes.
  16245. * @hidden
  16246. */
  16247. export class RenderingGroup {
  16248. index: number;
  16249. private static _zeroVector;
  16250. private _scene;
  16251. private _opaqueSubMeshes;
  16252. private _transparentSubMeshes;
  16253. private _alphaTestSubMeshes;
  16254. private _depthOnlySubMeshes;
  16255. private _particleSystems;
  16256. private _spriteManagers;
  16257. private _opaqueSortCompareFn;
  16258. private _alphaTestSortCompareFn;
  16259. private _transparentSortCompareFn;
  16260. private _renderOpaque;
  16261. private _renderAlphaTest;
  16262. private _renderTransparent;
  16263. /** @hidden */
  16264. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16265. onBeforeTransparentRendering: () => void;
  16266. /**
  16267. * Set the opaque sort comparison function.
  16268. * If null the sub meshes will be render in the order they were created
  16269. */
  16270. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16271. /**
  16272. * Set the alpha test sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the transparent sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Creates a new rendering group.
  16283. * @param index The rendering group index
  16284. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16285. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16286. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16287. */
  16288. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16289. /**
  16290. * Render all the sub meshes contained in the group.
  16291. * @param customRenderFunction Used to override the default render behaviour of the group.
  16292. * @returns true if rendered some submeshes.
  16293. */
  16294. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16295. /**
  16296. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16297. * @param subMeshes The submeshes to render
  16298. */
  16299. private renderOpaqueSorted;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderAlphaTestSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderTransparentSorted;
  16310. /**
  16311. * Renders the submeshes in a specified order.
  16312. * @param subMeshes The submeshes to sort before render
  16313. * @param sortCompareFn The comparison function use to sort
  16314. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16315. * @param transparent Specifies to activate blending if true
  16316. */
  16317. private static renderSorted;
  16318. /**
  16319. * Renders the submeshes in the order they were dispatched (no sort applied).
  16320. * @param subMeshes The submeshes to render
  16321. */
  16322. private static renderUnsorted;
  16323. /**
  16324. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16325. * are rendered back to front if in the same alpha index.
  16326. *
  16327. * @param a The first submesh
  16328. * @param b The second submesh
  16329. * @returns The result of the comparison
  16330. */
  16331. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16332. /**
  16333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16334. * are rendered back to front.
  16335. *
  16336. * @param a The first submesh
  16337. * @param b The second submesh
  16338. * @returns The result of the comparison
  16339. */
  16340. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16341. /**
  16342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16343. * are rendered front to back (prevent overdraw).
  16344. *
  16345. * @param a The first submesh
  16346. * @param b The second submesh
  16347. * @returns The result of the comparison
  16348. */
  16349. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16350. /**
  16351. * Resets the different lists of submeshes to prepare a new frame.
  16352. */
  16353. prepare(): void;
  16354. dispose(): void;
  16355. /**
  16356. * Inserts the submesh in its correct queue depending on its material.
  16357. * @param subMesh The submesh to dispatch
  16358. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16359. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16360. */
  16361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16362. dispatchSprites(spriteManager: ISpriteManager): void;
  16363. dispatchParticles(particleSystem: IParticleSystem): void;
  16364. private _renderParticles;
  16365. private _renderSprites;
  16366. }
  16367. }
  16368. declare module "babylonjs/Rendering/renderingManager" {
  16369. import { Nullable } from "babylonjs/types";
  16370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16371. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16372. import { SmartArray } from "babylonjs/Misc/smartArray";
  16373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16375. import { Material } from "babylonjs/Materials/material";
  16376. import { Scene } from "babylonjs/scene";
  16377. import { Camera } from "babylonjs/Cameras/camera";
  16378. /**
  16379. * Interface describing the different options available in the rendering manager
  16380. * regarding Auto Clear between groups.
  16381. */
  16382. export interface IRenderingManagerAutoClearSetup {
  16383. /**
  16384. * Defines whether or not autoclear is enable.
  16385. */
  16386. autoClear: boolean;
  16387. /**
  16388. * Defines whether or not to autoclear the depth buffer.
  16389. */
  16390. depth: boolean;
  16391. /**
  16392. * Defines whether or not to autoclear the stencil buffer.
  16393. */
  16394. stencil: boolean;
  16395. }
  16396. /**
  16397. * This class is used by the onRenderingGroupObservable
  16398. */
  16399. export class RenderingGroupInfo {
  16400. /**
  16401. * The Scene that being rendered
  16402. */
  16403. scene: Scene;
  16404. /**
  16405. * The camera currently used for the rendering pass
  16406. */
  16407. camera: Nullable<Camera>;
  16408. /**
  16409. * The ID of the renderingGroup being processed
  16410. */
  16411. renderingGroupId: number;
  16412. }
  16413. /**
  16414. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16415. * It is enable to manage the different groups as well as the different necessary sort functions.
  16416. * This should not be used directly aside of the few static configurations
  16417. */
  16418. export class RenderingManager {
  16419. /**
  16420. * The max id used for rendering groups (not included)
  16421. */
  16422. static MAX_RENDERINGGROUPS: number;
  16423. /**
  16424. * The min id used for rendering groups (included)
  16425. */
  16426. static MIN_RENDERINGGROUPS: number;
  16427. /**
  16428. * Used to globally prevent autoclearing scenes.
  16429. */
  16430. static AUTOCLEAR: boolean;
  16431. /**
  16432. * @hidden
  16433. */
  16434. _useSceneAutoClearSetup: boolean;
  16435. private _scene;
  16436. private _renderingGroups;
  16437. private _depthStencilBufferAlreadyCleaned;
  16438. private _autoClearDepthStencil;
  16439. private _customOpaqueSortCompareFn;
  16440. private _customAlphaTestSortCompareFn;
  16441. private _customTransparentSortCompareFn;
  16442. private _renderingGroupInfo;
  16443. /**
  16444. * Instantiates a new rendering group for a particular scene
  16445. * @param scene Defines the scene the groups belongs to
  16446. */
  16447. constructor(scene: Scene);
  16448. private _clearDepthStencilBuffer;
  16449. /**
  16450. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16451. * @hidden
  16452. */
  16453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16454. /**
  16455. * Resets the different information of the group to prepare a new frame
  16456. * @hidden
  16457. */
  16458. reset(): void;
  16459. /**
  16460. * Dispose and release the group and its associated resources.
  16461. * @hidden
  16462. */
  16463. dispose(): void;
  16464. /**
  16465. * Clear the info related to rendering groups preventing retention points during dispose.
  16466. */
  16467. freeRenderingGroups(): void;
  16468. private _prepareRenderingGroup;
  16469. /**
  16470. * Add a sprite manager to the rendering manager in order to render it this frame.
  16471. * @param spriteManager Define the sprite manager to render
  16472. */
  16473. dispatchSprites(spriteManager: ISpriteManager): void;
  16474. /**
  16475. * Add a particle system to the rendering manager in order to render it this frame.
  16476. * @param particleSystem Define the particle system to render
  16477. */
  16478. dispatchParticles(particleSystem: IParticleSystem): void;
  16479. /**
  16480. * Add a submesh to the manager in order to render it this frame
  16481. * @param subMesh The submesh to dispatch
  16482. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16483. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16484. */
  16485. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16486. /**
  16487. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16488. * This allowed control for front to back rendering or reversly depending of the special needs.
  16489. *
  16490. * @param renderingGroupId The rendering group id corresponding to its index
  16491. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16492. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16493. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16494. */
  16495. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16496. /**
  16497. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16498. *
  16499. * @param renderingGroupId The rendering group id corresponding to its index
  16500. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16501. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16502. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16503. */
  16504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16505. /**
  16506. * Gets the current auto clear configuration for one rendering group of the rendering
  16507. * manager.
  16508. * @param index the rendering group index to get the information for
  16509. * @returns The auto clear setup for the requested rendering group
  16510. */
  16511. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16512. }
  16513. }
  16514. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16515. import { SmartArray } from "babylonjs/Misc/smartArray";
  16516. import { Nullable } from "babylonjs/types";
  16517. import { Scene } from "babylonjs/scene";
  16518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16521. import { Mesh } from "babylonjs/Meshes/mesh";
  16522. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16524. import { Effect } from "babylonjs/Materials/effect";
  16525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16527. import "babylonjs/Shaders/shadowMap.fragment";
  16528. import "babylonjs/Shaders/shadowMap.vertex";
  16529. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16530. import { Observable } from "babylonjs/Misc/observable";
  16531. /**
  16532. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16533. */
  16534. export interface ICustomShaderOptions {
  16535. /**
  16536. * Gets or sets the custom shader name to use
  16537. */
  16538. shaderName: string;
  16539. /**
  16540. * The list of attribute names used in the shader
  16541. */
  16542. attributes?: string[];
  16543. /**
  16544. * The list of unifrom names used in the shader
  16545. */
  16546. uniforms?: string[];
  16547. /**
  16548. * The list of sampler names used in the shader
  16549. */
  16550. samplers?: string[];
  16551. /**
  16552. * The list of defines used in the shader
  16553. */
  16554. defines?: string[];
  16555. }
  16556. /**
  16557. * Interface to implement to create a shadow generator compatible with BJS.
  16558. */
  16559. export interface IShadowGenerator {
  16560. /**
  16561. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16562. * @returns The render target texture if present otherwise, null
  16563. */
  16564. getShadowMap(): Nullable<RenderTargetTexture>;
  16565. /**
  16566. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16567. * @param subMesh The submesh we want to render in the shadow map
  16568. * @param useInstances Defines wether will draw in the map using instances
  16569. * @returns true if ready otherwise, false
  16570. */
  16571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16572. /**
  16573. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16574. * @param defines Defines of the material we want to update
  16575. * @param lightIndex Index of the light in the enabled light list of the material
  16576. */
  16577. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16578. /**
  16579. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16580. * defined in the generator but impacting the effect).
  16581. * It implies the unifroms available on the materials are the standard BJS ones.
  16582. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16583. * @param effect The effect we are binfing the information for
  16584. */
  16585. bindShadowLight(lightIndex: string, effect: Effect): void;
  16586. /**
  16587. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16588. * (eq to shadow prjection matrix * light transform matrix)
  16589. * @returns The transform matrix used to create the shadow map
  16590. */
  16591. getTransformMatrix(): Matrix;
  16592. /**
  16593. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16594. * Cube and 2D textures for instance.
  16595. */
  16596. recreateShadowMap(): void;
  16597. /**
  16598. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16599. * @param onCompiled Callback triggered at the and of the effects compilation
  16600. * @param options Sets of optional options forcing the compilation with different modes
  16601. */
  16602. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16603. useInstances: boolean;
  16604. }>): void;
  16605. /**
  16606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16607. * @param options Sets of optional options forcing the compilation with different modes
  16608. * @returns A promise that resolves when the compilation completes
  16609. */
  16610. forceCompilationAsync(options?: Partial<{
  16611. useInstances: boolean;
  16612. }>): Promise<void>;
  16613. /**
  16614. * Serializes the shadow generator setup to a json object.
  16615. * @returns The serialized JSON object
  16616. */
  16617. serialize(): any;
  16618. /**
  16619. * Disposes the Shadow map and related Textures and effects.
  16620. */
  16621. dispose(): void;
  16622. }
  16623. /**
  16624. * Default implementation IShadowGenerator.
  16625. * This is the main object responsible of generating shadows in the framework.
  16626. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16627. */
  16628. export class ShadowGenerator implements IShadowGenerator {
  16629. /**
  16630. * Name of the shadow generator class
  16631. */
  16632. static CLASSNAME: string;
  16633. /**
  16634. * Shadow generator mode None: no filtering applied.
  16635. */
  16636. static readonly FILTER_NONE: number;
  16637. /**
  16638. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16639. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16640. */
  16641. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16642. /**
  16643. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16644. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16645. */
  16646. static readonly FILTER_POISSONSAMPLING: number;
  16647. /**
  16648. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16649. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16650. */
  16651. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16652. /**
  16653. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16654. * edge artifacts on steep falloff.
  16655. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16656. */
  16657. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16658. /**
  16659. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16660. * edge artifacts on steep falloff.
  16661. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16662. */
  16663. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16664. /**
  16665. * Shadow generator mode PCF: Percentage Closer Filtering
  16666. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16667. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16668. */
  16669. static readonly FILTER_PCF: number;
  16670. /**
  16671. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16672. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16673. * Contact Hardening
  16674. */
  16675. static readonly FILTER_PCSS: number;
  16676. /**
  16677. * Reserved for PCF and PCSS
  16678. * Highest Quality.
  16679. *
  16680. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16681. *
  16682. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16683. */
  16684. static readonly QUALITY_HIGH: number;
  16685. /**
  16686. * Reserved for PCF and PCSS
  16687. * Good tradeoff for quality/perf cross devices
  16688. *
  16689. * Execute PCF on a 3*3 kernel.
  16690. *
  16691. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16692. */
  16693. static readonly QUALITY_MEDIUM: number;
  16694. /**
  16695. * Reserved for PCF and PCSS
  16696. * The lowest quality but the fastest.
  16697. *
  16698. * Execute PCF on a 1*1 kernel.
  16699. *
  16700. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16701. */
  16702. static readonly QUALITY_LOW: number;
  16703. /** Gets or sets the custom shader name to use */
  16704. customShaderOptions: ICustomShaderOptions;
  16705. /**
  16706. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16707. */
  16708. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16709. /**
  16710. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16711. */
  16712. onAfterShadowMapRenderObservable: Observable<Effect>;
  16713. /**
  16714. * Observable triggered before a mesh is rendered in the shadow map.
  16715. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16716. */
  16717. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16718. /**
  16719. * Observable triggered after a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16721. */
  16722. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. protected _bias: number;
  16724. /**
  16725. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16726. */
  16727. get bias(): number;
  16728. /**
  16729. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16730. */
  16731. set bias(bias: number);
  16732. protected _normalBias: number;
  16733. /**
  16734. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16735. */
  16736. get normalBias(): number;
  16737. /**
  16738. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16739. */
  16740. set normalBias(normalBias: number);
  16741. protected _blurBoxOffset: number;
  16742. /**
  16743. * Gets the blur box offset: offset applied during the blur pass.
  16744. * Only useful if useKernelBlur = false
  16745. */
  16746. get blurBoxOffset(): number;
  16747. /**
  16748. * Sets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. set blurBoxOffset(value: number);
  16752. protected _blurScale: number;
  16753. /**
  16754. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16755. * 2 means half of the size.
  16756. */
  16757. get blurScale(): number;
  16758. /**
  16759. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. set blurScale(value: number);
  16763. protected _blurKernel: number;
  16764. /**
  16765. * Gets the blur kernel: kernel size of the blur pass.
  16766. * Only useful if useKernelBlur = true
  16767. */
  16768. get blurKernel(): number;
  16769. /**
  16770. * Sets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. set blurKernel(value: number);
  16774. protected _useKernelBlur: boolean;
  16775. /**
  16776. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16778. */
  16779. get useKernelBlur(): boolean;
  16780. /**
  16781. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. set useKernelBlur(value: boolean);
  16785. protected _depthScale: number;
  16786. /**
  16787. * Gets the depth scale used in ESM mode.
  16788. */
  16789. get depthScale(): number;
  16790. /**
  16791. * Sets the depth scale used in ESM mode.
  16792. * This can override the scale stored on the light.
  16793. */
  16794. set depthScale(value: number);
  16795. protected _validateFilter(filter: number): number;
  16796. protected _filter: number;
  16797. /**
  16798. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16800. */
  16801. get filter(): number;
  16802. /**
  16803. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. set filter(value: number);
  16807. /**
  16808. * Gets if the current filter is set to Poisson Sampling.
  16809. */
  16810. get usePoissonSampling(): boolean;
  16811. /**
  16812. * Sets the current filter to Poisson Sampling.
  16813. */
  16814. set usePoissonSampling(value: boolean);
  16815. /**
  16816. * Gets if the current filter is set to ESM.
  16817. */
  16818. get useExponentialShadowMap(): boolean;
  16819. /**
  16820. * Sets the current filter is to ESM.
  16821. */
  16822. set useExponentialShadowMap(value: boolean);
  16823. /**
  16824. * Gets if the current filter is set to filtered ESM.
  16825. */
  16826. get useBlurExponentialShadowMap(): boolean;
  16827. /**
  16828. * Gets if the current filter is set to filtered ESM.
  16829. */
  16830. set useBlurExponentialShadowMap(value: boolean);
  16831. /**
  16832. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16833. * exponential to prevent steep falloff artifacts).
  16834. */
  16835. get useCloseExponentialShadowMap(): boolean;
  16836. /**
  16837. * Sets the current filter to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. set useCloseExponentialShadowMap(value: boolean);
  16841. /**
  16842. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. get useBlurCloseExponentialShadowMap(): boolean;
  16846. /**
  16847. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. set useBlurCloseExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16853. */
  16854. get usePercentageCloserFiltering(): boolean;
  16855. /**
  16856. * Sets the current filter to "PCF" (percentage closer filtering).
  16857. */
  16858. set usePercentageCloserFiltering(value: boolean);
  16859. protected _filteringQuality: number;
  16860. /**
  16861. * Gets the PCF or PCSS Quality.
  16862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16863. */
  16864. get filteringQuality(): number;
  16865. /**
  16866. * Sets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. set filteringQuality(filteringQuality: number);
  16870. /**
  16871. * Gets if the current filter is set to "PCSS" (contact hardening).
  16872. */
  16873. get useContactHardeningShadow(): boolean;
  16874. /**
  16875. * Sets the current filter to "PCSS" (contact hardening).
  16876. */
  16877. set useContactHardeningShadow(value: boolean);
  16878. protected _contactHardeningLightSizeUVRatio: number;
  16879. /**
  16880. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16881. * Using a ratio helps keeping shape stability independently of the map size.
  16882. *
  16883. * It does not account for the light projection as it was having too much
  16884. * instability during the light setup or during light position changes.
  16885. *
  16886. * Only valid if useContactHardeningShadow is true.
  16887. */
  16888. get contactHardeningLightSizeUVRatio(): number;
  16889. /**
  16890. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16891. * Using a ratio helps keeping shape stability independently of the map size.
  16892. *
  16893. * It does not account for the light projection as it was having too much
  16894. * instability during the light setup or during light position changes.
  16895. *
  16896. * Only valid if useContactHardeningShadow is true.
  16897. */
  16898. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16899. protected _darkness: number;
  16900. /** Gets or sets the actual darkness of a shadow */
  16901. get darkness(): number;
  16902. set darkness(value: number);
  16903. /**
  16904. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16905. * 0 means strongest and 1 would means no shadow.
  16906. * @returns the darkness.
  16907. */
  16908. getDarkness(): number;
  16909. /**
  16910. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16911. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16912. * @returns the shadow generator allowing fluent coding.
  16913. */
  16914. setDarkness(darkness: number): ShadowGenerator;
  16915. protected _transparencyShadow: boolean;
  16916. /** Gets or sets the ability to have transparent shadow */
  16917. get transparencyShadow(): boolean;
  16918. set transparencyShadow(value: boolean);
  16919. /**
  16920. * Sets the ability to have transparent shadow (boolean).
  16921. * @param transparent True if transparent else False
  16922. * @returns the shadow generator allowing fluent coding
  16923. */
  16924. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16925. protected _shadowMap: Nullable<RenderTargetTexture>;
  16926. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16927. /**
  16928. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16929. * @returns The render target texture if present otherwise, null
  16930. */
  16931. getShadowMap(): Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16934. * @returns The render target texture if the shadow map is present otherwise, null
  16935. */
  16936. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the class name of that object
  16939. * @returns "ShadowGenerator"
  16940. */
  16941. getClassName(): string;
  16942. /**
  16943. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16944. * @param mesh Mesh to add
  16945. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16946. * @returns the Shadow Generator itself
  16947. */
  16948. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16949. /**
  16950. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16951. * @param mesh Mesh to remove
  16952. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16953. * @returns the Shadow Generator itself
  16954. */
  16955. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16956. /**
  16957. * Controls the extent to which the shadows fade out at the edge of the frustum
  16958. */
  16959. frustumEdgeFalloff: number;
  16960. protected _light: IShadowLight;
  16961. /**
  16962. * Returns the associated light object.
  16963. * @returns the light generating the shadow
  16964. */
  16965. getLight(): IShadowLight;
  16966. /**
  16967. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16968. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16969. * It might on the other hand introduce peter panning.
  16970. */
  16971. forceBackFacesOnly: boolean;
  16972. protected _scene: Scene;
  16973. protected _lightDirection: Vector3;
  16974. protected _effect: Effect;
  16975. protected _viewMatrix: Matrix;
  16976. protected _projectionMatrix: Matrix;
  16977. protected _transformMatrix: Matrix;
  16978. protected _cachedPosition: Vector3;
  16979. protected _cachedDirection: Vector3;
  16980. protected _cachedDefines: string;
  16981. protected _currentRenderID: number;
  16982. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16983. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16984. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16985. protected _blurPostProcesses: PostProcess[];
  16986. protected _mapSize: number;
  16987. protected _currentFaceIndex: number;
  16988. protected _currentFaceIndexCache: number;
  16989. protected _textureType: number;
  16990. protected _defaultTextureMatrix: Matrix;
  16991. protected _storedUniqueId: Nullable<number>;
  16992. /** @hidden */
  16993. static _SceneComponentInitialization: (scene: Scene) => void;
  16994. /**
  16995. * Creates a ShadowGenerator object.
  16996. * A ShadowGenerator is the required tool to use the shadows.
  16997. * Each light casting shadows needs to use its own ShadowGenerator.
  16998. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16999. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17000. * @param light The light object generating the shadows.
  17001. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17002. */
  17003. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17004. protected _initializeGenerator(): void;
  17005. protected _createTargetRenderTexture(): void;
  17006. protected _initializeShadowMap(): void;
  17007. protected _initializeBlurRTTAndPostProcesses(): void;
  17008. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17009. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17010. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17011. protected _applyFilterValues(): void;
  17012. /**
  17013. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17014. * @param onCompiled Callback triggered at the and of the effects compilation
  17015. * @param options Sets of optional options forcing the compilation with different modes
  17016. */
  17017. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17018. useInstances: boolean;
  17019. }>): void;
  17020. /**
  17021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17022. * @param options Sets of optional options forcing the compilation with different modes
  17023. * @returns A promise that resolves when the compilation completes
  17024. */
  17025. forceCompilationAsync(options?: Partial<{
  17026. useInstances: boolean;
  17027. }>): Promise<void>;
  17028. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17029. /**
  17030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17031. * @param subMesh The submesh we want to render in the shadow map
  17032. * @param useInstances Defines wether will draw in the map using instances
  17033. * @returns true if ready otherwise, false
  17034. */
  17035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17036. /**
  17037. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17038. * @param defines Defines of the material we want to update
  17039. * @param lightIndex Index of the light in the enabled light list of the material
  17040. */
  17041. prepareDefines(defines: any, lightIndex: number): void;
  17042. /**
  17043. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17044. * defined in the generator but impacting the effect).
  17045. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17046. * @param effect The effect we are binfing the information for
  17047. */
  17048. bindShadowLight(lightIndex: string, effect: Effect): void;
  17049. /**
  17050. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17051. * (eq to shadow prjection matrix * light transform matrix)
  17052. * @returns The transform matrix used to create the shadow map
  17053. */
  17054. getTransformMatrix(): Matrix;
  17055. /**
  17056. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17057. * Cube and 2D textures for instance.
  17058. */
  17059. recreateShadowMap(): void;
  17060. protected _disposeBlurPostProcesses(): void;
  17061. protected _disposeRTTandPostProcesses(): void;
  17062. /**
  17063. * Disposes the ShadowGenerator.
  17064. * Returns nothing.
  17065. */
  17066. dispose(): void;
  17067. /**
  17068. * Serializes the shadow generator setup to a json object.
  17069. * @returns The serialized JSON object
  17070. */
  17071. serialize(): any;
  17072. /**
  17073. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17074. * @param parsedShadowGenerator The JSON object to parse
  17075. * @param scene The scene to create the shadow map for
  17076. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17077. * @returns The parsed shadow generator
  17078. */
  17079. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17080. }
  17081. }
  17082. declare module "babylonjs/Lights/light" {
  17083. import { Nullable } from "babylonjs/types";
  17084. import { Scene } from "babylonjs/scene";
  17085. import { Vector3 } from "babylonjs/Maths/math.vector";
  17086. import { Color3 } from "babylonjs/Maths/math.color";
  17087. import { Node } from "babylonjs/node";
  17088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17089. import { Effect } from "babylonjs/Materials/effect";
  17090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17091. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17092. /**
  17093. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17094. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17095. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17096. */
  17097. export abstract class Light extends Node {
  17098. /**
  17099. * Falloff Default: light is falling off following the material specification:
  17100. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17101. */
  17102. static readonly FALLOFF_DEFAULT: number;
  17103. /**
  17104. * Falloff Physical: light is falling off following the inverse squared distance law.
  17105. */
  17106. static readonly FALLOFF_PHYSICAL: number;
  17107. /**
  17108. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17109. * to enhance interoperability with other engines.
  17110. */
  17111. static readonly FALLOFF_GLTF: number;
  17112. /**
  17113. * Falloff Standard: light is falling off like in the standard material
  17114. * to enhance interoperability with other materials.
  17115. */
  17116. static readonly FALLOFF_STANDARD: number;
  17117. /**
  17118. * If every light affecting the material is in this lightmapMode,
  17119. * material.lightmapTexture adds or multiplies
  17120. * (depends on material.useLightmapAsShadowmap)
  17121. * after every other light calculations.
  17122. */
  17123. static readonly LIGHTMAP_DEFAULT: number;
  17124. /**
  17125. * material.lightmapTexture as only diffuse lighting from this light
  17126. * adds only specular lighting from this light
  17127. * adds dynamic shadows
  17128. */
  17129. static readonly LIGHTMAP_SPECULAR: number;
  17130. /**
  17131. * material.lightmapTexture as only lighting
  17132. * no light calculation from this light
  17133. * only adds dynamic shadows from this light
  17134. */
  17135. static readonly LIGHTMAP_SHADOWSONLY: number;
  17136. /**
  17137. * Each light type uses the default quantity according to its type:
  17138. * point/spot lights use luminous intensity
  17139. * directional lights use illuminance
  17140. */
  17141. static readonly INTENSITYMODE_AUTOMATIC: number;
  17142. /**
  17143. * lumen (lm)
  17144. */
  17145. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17146. /**
  17147. * candela (lm/sr)
  17148. */
  17149. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17150. /**
  17151. * lux (lm/m^2)
  17152. */
  17153. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17154. /**
  17155. * nit (cd/m^2)
  17156. */
  17157. static readonly INTENSITYMODE_LUMINANCE: number;
  17158. /**
  17159. * Light type const id of the point light.
  17160. */
  17161. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17162. /**
  17163. * Light type const id of the directional light.
  17164. */
  17165. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17166. /**
  17167. * Light type const id of the spot light.
  17168. */
  17169. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17170. /**
  17171. * Light type const id of the hemispheric light.
  17172. */
  17173. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17174. /**
  17175. * Diffuse gives the basic color to an object.
  17176. */
  17177. diffuse: Color3;
  17178. /**
  17179. * Specular produces a highlight color on an object.
  17180. * Note: This is note affecting PBR materials.
  17181. */
  17182. specular: Color3;
  17183. /**
  17184. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17185. * falling off base on range or angle.
  17186. * This can be set to any values in Light.FALLOFF_x.
  17187. *
  17188. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17189. * other types of materials.
  17190. */
  17191. falloffType: number;
  17192. /**
  17193. * Strength of the light.
  17194. * Note: By default it is define in the framework own unit.
  17195. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17196. */
  17197. intensity: number;
  17198. private _range;
  17199. protected _inverseSquaredRange: number;
  17200. /**
  17201. * Defines how far from the source the light is impacting in scene units.
  17202. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17203. */
  17204. get range(): number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. set range(value: number);
  17210. /**
  17211. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17212. * of light.
  17213. */
  17214. private _photometricScale;
  17215. private _intensityMode;
  17216. /**
  17217. * Gets the photometric scale used to interpret the intensity.
  17218. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17219. */
  17220. get intensityMode(): number;
  17221. /**
  17222. * Sets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. set intensityMode(value: number);
  17226. private _radius;
  17227. /**
  17228. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17229. */
  17230. get radius(): number;
  17231. /**
  17232. * sets the light radius used by PBR Materials to simulate soft area lights.
  17233. */
  17234. set radius(value: number);
  17235. private _renderPriority;
  17236. /**
  17237. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17238. * exceeding the number allowed of the materials.
  17239. */
  17240. renderPriority: number;
  17241. private _shadowEnabled;
  17242. /**
  17243. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17244. * the current shadow generator.
  17245. */
  17246. get shadowEnabled(): boolean;
  17247. /**
  17248. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. set shadowEnabled(value: boolean);
  17252. private _includedOnlyMeshes;
  17253. /**
  17254. * Gets the only meshes impacted by this light.
  17255. */
  17256. get includedOnlyMeshes(): AbstractMesh[];
  17257. /**
  17258. * Sets the only meshes impacted by this light.
  17259. */
  17260. set includedOnlyMeshes(value: AbstractMesh[]);
  17261. private _excludedMeshes;
  17262. /**
  17263. * Gets the meshes not impacted by this light.
  17264. */
  17265. get excludedMeshes(): AbstractMesh[];
  17266. /**
  17267. * Sets the meshes not impacted by this light.
  17268. */
  17269. set excludedMeshes(value: AbstractMesh[]);
  17270. private _excludeWithLayerMask;
  17271. /**
  17272. * Gets the layer id use to find what meshes are not impacted by the light.
  17273. * Inactive if 0
  17274. */
  17275. get excludeWithLayerMask(): number;
  17276. /**
  17277. * Sets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. set excludeWithLayerMask(value: number);
  17281. private _includeOnlyWithLayerMask;
  17282. /**
  17283. * Gets the layer id use to find what meshes are impacted by the light.
  17284. * Inactive if 0
  17285. */
  17286. get includeOnlyWithLayerMask(): number;
  17287. /**
  17288. * Sets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. set includeOnlyWithLayerMask(value: number);
  17292. private _lightmapMode;
  17293. /**
  17294. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17295. */
  17296. get lightmapMode(): number;
  17297. /**
  17298. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17299. */
  17300. set lightmapMode(value: number);
  17301. /**
  17302. * Shadow generator associted to the light.
  17303. * @hidden Internal use only.
  17304. */
  17305. _shadowGenerator: Nullable<IShadowGenerator>;
  17306. /**
  17307. * @hidden Internal use only.
  17308. */
  17309. _excludedMeshesIds: string[];
  17310. /**
  17311. * @hidden Internal use only.
  17312. */
  17313. _includedOnlyMeshesIds: string[];
  17314. /**
  17315. * The current light unifom buffer.
  17316. * @hidden Internal use only.
  17317. */
  17318. _uniformBuffer: UniformBuffer;
  17319. /** @hidden */
  17320. _renderId: number;
  17321. /**
  17322. * Creates a Light object in the scene.
  17323. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17324. * @param name The firendly name of the light
  17325. * @param scene The scene the light belongs too
  17326. */
  17327. constructor(name: string, scene: Scene);
  17328. protected abstract _buildUniformLayout(): void;
  17329. /**
  17330. * Sets the passed Effect "effect" with the Light information.
  17331. * @param effect The effect to update
  17332. * @param lightIndex The index of the light in the effect to update
  17333. * @returns The light
  17334. */
  17335. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17336. /**
  17337. * Sets the passed Effect "effect" with the Light textures.
  17338. * @param effect The effect to update
  17339. * @param lightIndex The index of the light in the effect to update
  17340. * @returns The light
  17341. */
  17342. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17343. /**
  17344. * Binds the lights information from the scene to the effect for the given mesh.
  17345. * @param lightIndex Light index
  17346. * @param scene The scene where the light belongs to
  17347. * @param effect The effect we are binding the data to
  17348. * @param useSpecular Defines if specular is supported
  17349. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17350. */
  17351. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17352. /**
  17353. * Sets the passed Effect "effect" with the Light information.
  17354. * @param effect The effect to update
  17355. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17356. * @returns The light
  17357. */
  17358. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17359. /**
  17360. * Returns the string "Light".
  17361. * @returns the class name
  17362. */
  17363. getClassName(): string;
  17364. /** @hidden */
  17365. readonly _isLight: boolean;
  17366. /**
  17367. * Converts the light information to a readable string for debug purpose.
  17368. * @param fullDetails Supports for multiple levels of logging within scene loading
  17369. * @returns the human readable light info
  17370. */
  17371. toString(fullDetails?: boolean): string;
  17372. /** @hidden */
  17373. protected _syncParentEnabledState(): void;
  17374. /**
  17375. * Set the enabled state of this node.
  17376. * @param value - the new enabled state
  17377. */
  17378. setEnabled(value: boolean): void;
  17379. /**
  17380. * Returns the Light associated shadow generator if any.
  17381. * @return the associated shadow generator.
  17382. */
  17383. getShadowGenerator(): Nullable<IShadowGenerator>;
  17384. /**
  17385. * Returns a Vector3, the absolute light position in the World.
  17386. * @returns the world space position of the light
  17387. */
  17388. getAbsolutePosition(): Vector3;
  17389. /**
  17390. * Specifies if the light will affect the passed mesh.
  17391. * @param mesh The mesh to test against the light
  17392. * @return true the mesh is affected otherwise, false.
  17393. */
  17394. canAffectMesh(mesh: AbstractMesh): boolean;
  17395. /**
  17396. * Sort function to order lights for rendering.
  17397. * @param a First Light object to compare to second.
  17398. * @param b Second Light object to compare first.
  17399. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17400. */
  17401. static CompareLightsPriority(a: Light, b: Light): number;
  17402. /**
  17403. * Releases resources associated with this node.
  17404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17406. */
  17407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17408. /**
  17409. * Returns the light type ID (integer).
  17410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17411. */
  17412. getTypeID(): number;
  17413. /**
  17414. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17415. * @returns the scaled intensity in intensity mode unit
  17416. */
  17417. getScaledIntensity(): number;
  17418. /**
  17419. * Returns a new Light object, named "name", from the current one.
  17420. * @param name The name of the cloned light
  17421. * @returns the new created light
  17422. */
  17423. clone(name: string): Nullable<Light>;
  17424. /**
  17425. * Serializes the current light into a Serialization object.
  17426. * @returns the serialized object.
  17427. */
  17428. serialize(): any;
  17429. /**
  17430. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17431. * This new light is named "name" and added to the passed scene.
  17432. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17433. * @param name The friendly name of the light
  17434. * @param scene The scene the new light will belong to
  17435. * @returns the constructor function
  17436. */
  17437. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17438. /**
  17439. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17440. * @param parsedLight The JSON representation of the light
  17441. * @param scene The scene to create the parsed light in
  17442. * @returns the created light after parsing
  17443. */
  17444. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17445. private _hookArrayForExcluded;
  17446. private _hookArrayForIncludedOnly;
  17447. private _resyncMeshes;
  17448. /**
  17449. * Forces the meshes to update their light related information in their rendering used effects
  17450. * @hidden Internal Use Only
  17451. */
  17452. _markMeshesAsLightDirty(): void;
  17453. /**
  17454. * Recomputes the cached photometric scale if needed.
  17455. */
  17456. private _computePhotometricScale;
  17457. /**
  17458. * Returns the Photometric Scale according to the light type and intensity mode.
  17459. */
  17460. private _getPhotometricScale;
  17461. /**
  17462. * Reorder the light in the scene according to their defined priority.
  17463. * @hidden Internal Use Only
  17464. */
  17465. _reorderLightsInScene(): void;
  17466. /**
  17467. * Prepares the list of defines specific to the light type.
  17468. * @param defines the list of defines
  17469. * @param lightIndex defines the index of the light for the effect
  17470. */
  17471. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17472. }
  17473. }
  17474. declare module "babylonjs/Actions/action" {
  17475. import { Observable } from "babylonjs/Misc/observable";
  17476. import { Condition } from "babylonjs/Actions/condition";
  17477. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17478. import { ActionManager } from "babylonjs/Actions/actionManager";
  17479. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17480. /**
  17481. * Interface used to define Action
  17482. */
  17483. export interface IAction {
  17484. /**
  17485. * Trigger for the action
  17486. */
  17487. trigger: number;
  17488. /** Options of the trigger */
  17489. triggerOptions: any;
  17490. /**
  17491. * Gets the trigger parameters
  17492. * @returns the trigger parameters
  17493. */
  17494. getTriggerParameter(): any;
  17495. /**
  17496. * Internal only - executes current action event
  17497. * @hidden
  17498. */
  17499. _executeCurrent(evt?: ActionEvent): void;
  17500. /**
  17501. * Serialize placeholder for child classes
  17502. * @param parent of child
  17503. * @returns the serialized object
  17504. */
  17505. serialize(parent: any): any;
  17506. /**
  17507. * Internal only
  17508. * @hidden
  17509. */
  17510. _prepare(): void;
  17511. /**
  17512. * Internal only - manager for action
  17513. * @hidden
  17514. */
  17515. _actionManager: AbstractActionManager;
  17516. /**
  17517. * Adds action to chain of actions, may be a DoNothingAction
  17518. * @param action defines the next action to execute
  17519. * @returns The action passed in
  17520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17521. */
  17522. then(action: IAction): IAction;
  17523. }
  17524. /**
  17525. * The action to be carried out following a trigger
  17526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17527. */
  17528. export class Action implements IAction {
  17529. /** the trigger, with or without parameters, for the action */
  17530. triggerOptions: any;
  17531. /**
  17532. * Trigger for the action
  17533. */
  17534. trigger: number;
  17535. /**
  17536. * Internal only - manager for action
  17537. * @hidden
  17538. */
  17539. _actionManager: ActionManager;
  17540. private _nextActiveAction;
  17541. private _child;
  17542. private _condition?;
  17543. private _triggerParameter;
  17544. /**
  17545. * An event triggered prior to action being executed.
  17546. */
  17547. onBeforeExecuteObservable: Observable<Action>;
  17548. /**
  17549. * Creates a new Action
  17550. * @param triggerOptions the trigger, with or without parameters, for the action
  17551. * @param condition an optional determinant of action
  17552. */
  17553. constructor(
  17554. /** the trigger, with or without parameters, for the action */
  17555. triggerOptions: any, condition?: Condition);
  17556. /**
  17557. * Internal only
  17558. * @hidden
  17559. */
  17560. _prepare(): void;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Execute placeholder for child classes
  17573. * @param evt optional action event
  17574. */
  17575. execute(evt?: ActionEvent): void;
  17576. /**
  17577. * Skips to next active action
  17578. */
  17579. skipToNextActiveAction(): void;
  17580. /**
  17581. * Adds action to chain of actions, may be a DoNothingAction
  17582. * @param action defines the next action to execute
  17583. * @returns The action passed in
  17584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17585. */
  17586. then(action: Action): Action;
  17587. /**
  17588. * Internal only
  17589. * @hidden
  17590. */
  17591. _getProperty(propertyPath: string): string;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getEffectiveTarget(target: any, propertyPath: string): any;
  17597. /**
  17598. * Serialize placeholder for child classes
  17599. * @param parent of child
  17600. * @returns the serialized object
  17601. */
  17602. serialize(parent: any): any;
  17603. /**
  17604. * Internal only called by serialize
  17605. * @hidden
  17606. */
  17607. protected _serialize(serializedAction: any, parent?: any): any;
  17608. /**
  17609. * Internal only
  17610. * @hidden
  17611. */
  17612. static _SerializeValueAsString: (value: any) => string;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17618. name: string;
  17619. targetType: string;
  17620. value: string;
  17621. };
  17622. }
  17623. }
  17624. declare module "babylonjs/Actions/condition" {
  17625. import { ActionManager } from "babylonjs/Actions/actionManager";
  17626. /**
  17627. * A Condition applied to an Action
  17628. */
  17629. export class Condition {
  17630. /**
  17631. * Internal only - manager for action
  17632. * @hidden
  17633. */
  17634. _actionManager: ActionManager;
  17635. /**
  17636. * Internal only
  17637. * @hidden
  17638. */
  17639. _evaluationId: number;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _currentResult: boolean;
  17645. /**
  17646. * Creates a new Condition
  17647. * @param actionManager the manager of the action the condition is applied to
  17648. */
  17649. constructor(actionManager: ActionManager);
  17650. /**
  17651. * Check if the current condition is valid
  17652. * @returns a boolean
  17653. */
  17654. isValid(): boolean;
  17655. /**
  17656. * Internal only
  17657. * @hidden
  17658. */
  17659. _getProperty(propertyPath: string): string;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getEffectiveTarget(target: any, propertyPath: string): any;
  17665. /**
  17666. * Serialize placeholder for child classes
  17667. * @returns the serialized object
  17668. */
  17669. serialize(): any;
  17670. /**
  17671. * Internal only
  17672. * @hidden
  17673. */
  17674. protected _serialize(serializedCondition: any): any;
  17675. }
  17676. /**
  17677. * Defines specific conditional operators as extensions of Condition
  17678. */
  17679. export class ValueCondition extends Condition {
  17680. /** path to specify the property of the target the conditional operator uses */
  17681. propertyPath: string;
  17682. /** the value compared by the conditional operator against the current value of the property */
  17683. value: any;
  17684. /** the conditional operator, default ValueCondition.IsEqual */
  17685. operator: number;
  17686. /**
  17687. * Internal only
  17688. * @hidden
  17689. */
  17690. private static _IsEqual;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsDifferent;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsGreater;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsLesser;
  17706. /**
  17707. * returns the number for IsEqual
  17708. */
  17709. static get IsEqual(): number;
  17710. /**
  17711. * Returns the number for IsDifferent
  17712. */
  17713. static get IsDifferent(): number;
  17714. /**
  17715. * Returns the number for IsGreater
  17716. */
  17717. static get IsGreater(): number;
  17718. /**
  17719. * Returns the number for IsLesser
  17720. */
  17721. static get IsLesser(): number;
  17722. /**
  17723. * Internal only The action manager for the condition
  17724. * @hidden
  17725. */
  17726. _actionManager: ActionManager;
  17727. /**
  17728. * Internal only
  17729. * @hidden
  17730. */
  17731. private _target;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _effectiveTarget;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _property;
  17742. /**
  17743. * Creates a new ValueCondition
  17744. * @param actionManager manager for the action the condition applies to
  17745. * @param target for the action
  17746. * @param propertyPath path to specify the property of the target the conditional operator uses
  17747. * @param value the value compared by the conditional operator against the current value of the property
  17748. * @param operator the conditional operator, default ValueCondition.IsEqual
  17749. */
  17750. constructor(actionManager: ActionManager, target: any,
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string,
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any,
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator?: number);
  17757. /**
  17758. * Compares the given value with the property value for the specified conditional operator
  17759. * @returns the result of the comparison
  17760. */
  17761. isValid(): boolean;
  17762. /**
  17763. * Serialize the ValueCondition into a JSON compatible object
  17764. * @returns serialization object
  17765. */
  17766. serialize(): any;
  17767. /**
  17768. * Gets the name of the conditional operator for the ValueCondition
  17769. * @param operator the conditional operator
  17770. * @returns the name
  17771. */
  17772. static GetOperatorName(operator: number): string;
  17773. }
  17774. /**
  17775. * Defines a predicate condition as an extension of Condition
  17776. */
  17777. export class PredicateCondition extends Condition {
  17778. /** defines the predicate function used to validate the condition */
  17779. predicate: () => boolean;
  17780. /**
  17781. * Internal only - manager for action
  17782. * @hidden
  17783. */
  17784. _actionManager: ActionManager;
  17785. /**
  17786. * Creates a new PredicateCondition
  17787. * @param actionManager manager for the action the condition applies to
  17788. * @param predicate defines the predicate function used to validate the condition
  17789. */
  17790. constructor(actionManager: ActionManager,
  17791. /** defines the predicate function used to validate the condition */
  17792. predicate: () => boolean);
  17793. /**
  17794. * @returns the validity of the predicate condition
  17795. */
  17796. isValid(): boolean;
  17797. }
  17798. /**
  17799. * Defines a state condition as an extension of Condition
  17800. */
  17801. export class StateCondition extends Condition {
  17802. /** Value to compare with target state */
  17803. value: string;
  17804. /**
  17805. * Internal only - manager for action
  17806. * @hidden
  17807. */
  17808. _actionManager: ActionManager;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. private _target;
  17814. /**
  17815. * Creates a new StateCondition
  17816. * @param actionManager manager for the action the condition applies to
  17817. * @param target of the condition
  17818. * @param value to compare with target state
  17819. */
  17820. constructor(actionManager: ActionManager, target: any,
  17821. /** Value to compare with target state */
  17822. value: string);
  17823. /**
  17824. * Gets a boolean indicating if the current condition is met
  17825. * @returns the validity of the state
  17826. */
  17827. isValid(): boolean;
  17828. /**
  17829. * Serialize the StateCondition into a JSON compatible object
  17830. * @returns serialization object
  17831. */
  17832. serialize(): any;
  17833. }
  17834. }
  17835. declare module "babylonjs/Actions/directActions" {
  17836. import { Action } from "babylonjs/Actions/action";
  17837. import { Condition } from "babylonjs/Actions/condition";
  17838. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17839. /**
  17840. * This defines an action responsible to toggle a boolean once triggered.
  17841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17842. */
  17843. export class SwitchBooleanAction extends Action {
  17844. /**
  17845. * The path to the boolean property in the target object
  17846. */
  17847. propertyPath: string;
  17848. private _target;
  17849. private _effectiveTarget;
  17850. private _property;
  17851. /**
  17852. * Instantiate the action
  17853. * @param triggerOptions defines the trigger options
  17854. * @param target defines the object containing the boolean
  17855. * @param propertyPath defines the path to the boolean property in the target object
  17856. * @param condition defines the trigger related conditions
  17857. */
  17858. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17859. /** @hidden */
  17860. _prepare(): void;
  17861. /**
  17862. * Execute the action toggle the boolean value.
  17863. */
  17864. execute(): void;
  17865. /**
  17866. * Serializes the actions and its related information.
  17867. * @param parent defines the object to serialize in
  17868. * @returns the serialized object
  17869. */
  17870. serialize(parent: any): any;
  17871. }
  17872. /**
  17873. * This defines an action responsible to set a the state field of the target
  17874. * to a desired value once triggered.
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17876. */
  17877. export class SetStateAction extends Action {
  17878. /**
  17879. * The value to store in the state field.
  17880. */
  17881. value: string;
  17882. private _target;
  17883. /**
  17884. * Instantiate the action
  17885. * @param triggerOptions defines the trigger options
  17886. * @param target defines the object containing the state property
  17887. * @param value defines the value to store in the state field
  17888. * @param condition defines the trigger related conditions
  17889. */
  17890. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17891. /**
  17892. * Execute the action and store the value on the target state property.
  17893. */
  17894. execute(): void;
  17895. /**
  17896. * Serializes the actions and its related information.
  17897. * @param parent defines the object to serialize in
  17898. * @returns the serialized object
  17899. */
  17900. serialize(parent: any): any;
  17901. }
  17902. /**
  17903. * This defines an action responsible to set a property of the target
  17904. * to a desired value once triggered.
  17905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17906. */
  17907. export class SetValueAction extends Action {
  17908. /**
  17909. * The path of the property to set in the target.
  17910. */
  17911. propertyPath: string;
  17912. /**
  17913. * The value to set in the property
  17914. */
  17915. value: any;
  17916. private _target;
  17917. private _effectiveTarget;
  17918. private _property;
  17919. /**
  17920. * Instantiate the action
  17921. * @param triggerOptions defines the trigger options
  17922. * @param target defines the object containing the property
  17923. * @param propertyPath defines the path of the property to set in the target
  17924. * @param value defines the value to set in the property
  17925. * @param condition defines the trigger related conditions
  17926. */
  17927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17928. /** @hidden */
  17929. _prepare(): void;
  17930. /**
  17931. * Execute the action and set the targetted property to the desired value.
  17932. */
  17933. execute(): void;
  17934. /**
  17935. * Serializes the actions and its related information.
  17936. * @param parent defines the object to serialize in
  17937. * @returns the serialized object
  17938. */
  17939. serialize(parent: any): any;
  17940. }
  17941. /**
  17942. * This defines an action responsible to increment the target value
  17943. * to a desired value once triggered.
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17945. */
  17946. export class IncrementValueAction extends Action {
  17947. /**
  17948. * The path of the property to increment in the target.
  17949. */
  17950. propertyPath: string;
  17951. /**
  17952. * The value we should increment the property by.
  17953. */
  17954. value: any;
  17955. private _target;
  17956. private _effectiveTarget;
  17957. private _property;
  17958. /**
  17959. * Instantiate the action
  17960. * @param triggerOptions defines the trigger options
  17961. * @param target defines the object containing the property
  17962. * @param propertyPath defines the path of the property to increment in the target
  17963. * @param value defines the value value we should increment the property by
  17964. * @param condition defines the trigger related conditions
  17965. */
  17966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17967. /** @hidden */
  17968. _prepare(): void;
  17969. /**
  17970. * Execute the action and increment the target of the value amount.
  17971. */
  17972. execute(): void;
  17973. /**
  17974. * Serializes the actions and its related information.
  17975. * @param parent defines the object to serialize in
  17976. * @returns the serialized object
  17977. */
  17978. serialize(parent: any): any;
  17979. }
  17980. /**
  17981. * This defines an action responsible to start an animation once triggered.
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17983. */
  17984. export class PlayAnimationAction extends Action {
  17985. /**
  17986. * Where the animation should start (animation frame)
  17987. */
  17988. from: number;
  17989. /**
  17990. * Where the animation should stop (animation frame)
  17991. */
  17992. to: number;
  17993. /**
  17994. * Define if the animation should loop or stop after the first play.
  17995. */
  17996. loop?: boolean;
  17997. private _target;
  17998. /**
  17999. * Instantiate the action
  18000. * @param triggerOptions defines the trigger options
  18001. * @param target defines the target animation or animation name
  18002. * @param from defines from where the animation should start (animation frame)
  18003. * @param end defines where the animation should stop (animation frame)
  18004. * @param loop defines if the animation should loop or stop after the first play
  18005. * @param condition defines the trigger related conditions
  18006. */
  18007. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18008. /** @hidden */
  18009. _prepare(): void;
  18010. /**
  18011. * Execute the action and play the animation.
  18012. */
  18013. execute(): void;
  18014. /**
  18015. * Serializes the actions and its related information.
  18016. * @param parent defines the object to serialize in
  18017. * @returns the serialized object
  18018. */
  18019. serialize(parent: any): any;
  18020. }
  18021. /**
  18022. * This defines an action responsible to stop an animation once triggered.
  18023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18024. */
  18025. export class StopAnimationAction extends Action {
  18026. private _target;
  18027. /**
  18028. * Instantiate the action
  18029. * @param triggerOptions defines the trigger options
  18030. * @param target defines the target animation or animation name
  18031. * @param condition defines the trigger related conditions
  18032. */
  18033. constructor(triggerOptions: any, target: any, condition?: Condition);
  18034. /** @hidden */
  18035. _prepare(): void;
  18036. /**
  18037. * Execute the action and stop the animation.
  18038. */
  18039. execute(): void;
  18040. /**
  18041. * Serializes the actions and its related information.
  18042. * @param parent defines the object to serialize in
  18043. * @returns the serialized object
  18044. */
  18045. serialize(parent: any): any;
  18046. }
  18047. /**
  18048. * This defines an action responsible that does nothing once triggered.
  18049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18050. */
  18051. export class DoNothingAction extends Action {
  18052. /**
  18053. * Instantiate the action
  18054. * @param triggerOptions defines the trigger options
  18055. * @param condition defines the trigger related conditions
  18056. */
  18057. constructor(triggerOptions?: any, condition?: Condition);
  18058. /**
  18059. * Execute the action and do nothing.
  18060. */
  18061. execute(): void;
  18062. /**
  18063. * Serializes the actions and its related information.
  18064. * @param parent defines the object to serialize in
  18065. * @returns the serialized object
  18066. */
  18067. serialize(parent: any): any;
  18068. }
  18069. /**
  18070. * This defines an action responsible to trigger several actions once triggered.
  18071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18072. */
  18073. export class CombineAction extends Action {
  18074. /**
  18075. * The list of aggregated animations to run.
  18076. */
  18077. children: Action[];
  18078. /**
  18079. * Instantiate the action
  18080. * @param triggerOptions defines the trigger options
  18081. * @param children defines the list of aggregated animations to run
  18082. * @param condition defines the trigger related conditions
  18083. */
  18084. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18085. /** @hidden */
  18086. _prepare(): void;
  18087. /**
  18088. * Execute the action and executes all the aggregated actions.
  18089. */
  18090. execute(evt: ActionEvent): void;
  18091. /**
  18092. * Serializes the actions and its related information.
  18093. * @param parent defines the object to serialize in
  18094. * @returns the serialized object
  18095. */
  18096. serialize(parent: any): any;
  18097. }
  18098. /**
  18099. * This defines an action responsible to run code (external event) once triggered.
  18100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18101. */
  18102. export class ExecuteCodeAction extends Action {
  18103. /**
  18104. * The callback function to run.
  18105. */
  18106. func: (evt: ActionEvent) => void;
  18107. /**
  18108. * Instantiate the action
  18109. * @param triggerOptions defines the trigger options
  18110. * @param func defines the callback function to run
  18111. * @param condition defines the trigger related conditions
  18112. */
  18113. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18114. /**
  18115. * Execute the action and run the attached code.
  18116. */
  18117. execute(evt: ActionEvent): void;
  18118. }
  18119. /**
  18120. * This defines an action responsible to set the parent property of the target once triggered.
  18121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18122. */
  18123. export class SetParentAction extends Action {
  18124. private _parent;
  18125. private _target;
  18126. /**
  18127. * Instantiate the action
  18128. * @param triggerOptions defines the trigger options
  18129. * @param target defines the target containing the parent property
  18130. * @param parent defines from where the animation should start (animation frame)
  18131. * @param condition defines the trigger related conditions
  18132. */
  18133. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18134. /** @hidden */
  18135. _prepare(): void;
  18136. /**
  18137. * Execute the action and set the parent property.
  18138. */
  18139. execute(): void;
  18140. /**
  18141. * Serializes the actions and its related information.
  18142. * @param parent defines the object to serialize in
  18143. * @returns the serialized object
  18144. */
  18145. serialize(parent: any): any;
  18146. }
  18147. }
  18148. declare module "babylonjs/Actions/actionManager" {
  18149. import { Nullable } from "babylonjs/types";
  18150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18151. import { Scene } from "babylonjs/scene";
  18152. import { IAction } from "babylonjs/Actions/action";
  18153. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18154. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18155. /**
  18156. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18157. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18159. */
  18160. export class ActionManager extends AbstractActionManager {
  18161. /**
  18162. * Nothing
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18164. */
  18165. static readonly NothingTrigger: number;
  18166. /**
  18167. * On pick
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly OnPickTrigger: number;
  18171. /**
  18172. * On left pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnLeftPickTrigger: number;
  18176. /**
  18177. * On right pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnRightPickTrigger: number;
  18181. /**
  18182. * On center pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnCenterPickTrigger: number;
  18186. /**
  18187. * On pick down
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnPickDownTrigger: number;
  18191. /**
  18192. * On double pick
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnDoublePickTrigger: number;
  18196. /**
  18197. * On pick up
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnPickUpTrigger: number;
  18201. /**
  18202. * On pick out.
  18203. * This trigger will only be raised if you also declared a OnPickDown
  18204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18205. */
  18206. static readonly OnPickOutTrigger: number;
  18207. /**
  18208. * On long press
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnLongPressTrigger: number;
  18212. /**
  18213. * On pointer over
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnPointerOverTrigger: number;
  18217. /**
  18218. * On pointer out
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOutTrigger: number;
  18222. /**
  18223. * On every frame
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnEveryFrameTrigger: number;
  18227. /**
  18228. * On intersection enter
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnIntersectionEnterTrigger: number;
  18232. /**
  18233. * On intersection exit
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionExitTrigger: number;
  18237. /**
  18238. * On key down
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnKeyDownTrigger: number;
  18242. /**
  18243. * On key up
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyUpTrigger: number;
  18247. private _scene;
  18248. /**
  18249. * Creates a new action manager
  18250. * @param scene defines the hosting scene
  18251. */
  18252. constructor(scene: Scene);
  18253. /**
  18254. * Releases all associated resources
  18255. */
  18256. dispose(): void;
  18257. /**
  18258. * Gets hosting scene
  18259. * @returns the hosting scene
  18260. */
  18261. getScene(): Scene;
  18262. /**
  18263. * Does this action manager handles actions of any of the given triggers
  18264. * @param triggers defines the triggers to be tested
  18265. * @return a boolean indicating whether one (or more) of the triggers is handled
  18266. */
  18267. hasSpecificTriggers(triggers: number[]): boolean;
  18268. /**
  18269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18270. * speed.
  18271. * @param triggerA defines the trigger to be tested
  18272. * @param triggerB defines the trigger to be tested
  18273. * @return a boolean indicating whether one (or more) of the triggers is handled
  18274. */
  18275. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18276. /**
  18277. * Does this action manager handles actions of a given trigger
  18278. * @param trigger defines the trigger to be tested
  18279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18280. * @return whether the trigger is handled
  18281. */
  18282. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18283. /**
  18284. * Does this action manager has pointer triggers
  18285. */
  18286. get hasPointerTriggers(): boolean;
  18287. /**
  18288. * Does this action manager has pick triggers
  18289. */
  18290. get hasPickTriggers(): boolean;
  18291. /**
  18292. * Registers an action to this action manager
  18293. * @param action defines the action to be registered
  18294. * @return the action amended (prepared) after registration
  18295. */
  18296. registerAction(action: IAction): Nullable<IAction>;
  18297. /**
  18298. * Unregisters an action to this action manager
  18299. * @param action defines the action to be unregistered
  18300. * @return a boolean indicating whether the action has been unregistered
  18301. */
  18302. unregisterAction(action: IAction): Boolean;
  18303. /**
  18304. * Process a specific trigger
  18305. * @param trigger defines the trigger to process
  18306. * @param evt defines the event details to be processed
  18307. */
  18308. processTrigger(trigger: number, evt?: IActionEvent): void;
  18309. /** @hidden */
  18310. _getEffectiveTarget(target: any, propertyPath: string): any;
  18311. /** @hidden */
  18312. _getProperty(propertyPath: string): string;
  18313. /**
  18314. * Serialize this manager to a JSON object
  18315. * @param name defines the property name to store this manager
  18316. * @returns a JSON representation of this manager
  18317. */
  18318. serialize(name: string): any;
  18319. /**
  18320. * Creates a new ActionManager from a JSON data
  18321. * @param parsedActions defines the JSON data to read from
  18322. * @param object defines the hosting mesh
  18323. * @param scene defines the hosting scene
  18324. */
  18325. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18326. /**
  18327. * Get a trigger name by index
  18328. * @param trigger defines the trigger index
  18329. * @returns a trigger name
  18330. */
  18331. static GetTriggerName(trigger: number): string;
  18332. }
  18333. }
  18334. declare module "babylonjs/Sprites/sprite" {
  18335. import { Vector3 } from "babylonjs/Maths/math.vector";
  18336. import { Nullable } from "babylonjs/types";
  18337. import { ActionManager } from "babylonjs/Actions/actionManager";
  18338. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18339. import { Color4 } from "babylonjs/Maths/math.color";
  18340. /**
  18341. * Class used to represent a sprite
  18342. * @see http://doc.babylonjs.com/babylon101/sprites
  18343. */
  18344. export class Sprite {
  18345. /** defines the name */
  18346. name: string;
  18347. /** Gets or sets the current world position */
  18348. position: Vector3;
  18349. /** Gets or sets the main color */
  18350. color: Color4;
  18351. /** Gets or sets the width */
  18352. width: number;
  18353. /** Gets or sets the height */
  18354. height: number;
  18355. /** Gets or sets rotation angle */
  18356. angle: number;
  18357. /** Gets or sets the cell index in the sprite sheet */
  18358. cellIndex: number;
  18359. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18360. cellRef: string;
  18361. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18362. invertU: number;
  18363. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18364. invertV: number;
  18365. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18366. disposeWhenFinishedAnimating: boolean;
  18367. /** Gets the list of attached animations */
  18368. animations: Animation[];
  18369. /** Gets or sets a boolean indicating if the sprite can be picked */
  18370. isPickable: boolean;
  18371. /**
  18372. * Gets or sets the associated action manager
  18373. */
  18374. actionManager: Nullable<ActionManager>;
  18375. private _animationStarted;
  18376. private _loopAnimation;
  18377. private _fromIndex;
  18378. private _toIndex;
  18379. private _delay;
  18380. private _direction;
  18381. private _manager;
  18382. private _time;
  18383. private _onAnimationEnd;
  18384. /**
  18385. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18386. */
  18387. isVisible: boolean;
  18388. /**
  18389. * Gets or sets the sprite size
  18390. */
  18391. get size(): number;
  18392. set size(value: number);
  18393. /**
  18394. * Creates a new Sprite
  18395. * @param name defines the name
  18396. * @param manager defines the manager
  18397. */
  18398. constructor(
  18399. /** defines the name */
  18400. name: string, manager: ISpriteManager);
  18401. /**
  18402. * Starts an animation
  18403. * @param from defines the initial key
  18404. * @param to defines the end key
  18405. * @param loop defines if the animation must loop
  18406. * @param delay defines the start delay (in ms)
  18407. * @param onAnimationEnd defines a callback to call when animation ends
  18408. */
  18409. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18410. /** Stops current animation (if any) */
  18411. stopAnimation(): void;
  18412. /** @hidden */
  18413. _animate(deltaTime: number): void;
  18414. /** Release associated resources */
  18415. dispose(): void;
  18416. }
  18417. }
  18418. declare module "babylonjs/Collisions/pickingInfo" {
  18419. import { Nullable } from "babylonjs/types";
  18420. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18422. import { Sprite } from "babylonjs/Sprites/sprite";
  18423. import { Ray } from "babylonjs/Culling/ray";
  18424. /**
  18425. * Information about the result of picking within a scene
  18426. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18427. */
  18428. export class PickingInfo {
  18429. /** @hidden */
  18430. _pickingUnavailable: boolean;
  18431. /**
  18432. * If the pick collided with an object
  18433. */
  18434. hit: boolean;
  18435. /**
  18436. * Distance away where the pick collided
  18437. */
  18438. distance: number;
  18439. /**
  18440. * The location of pick collision
  18441. */
  18442. pickedPoint: Nullable<Vector3>;
  18443. /**
  18444. * The mesh corresponding the the pick collision
  18445. */
  18446. pickedMesh: Nullable<AbstractMesh>;
  18447. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18448. bu: number;
  18449. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18450. bv: number;
  18451. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18452. faceId: number;
  18453. /** Id of the the submesh that was picked */
  18454. subMeshId: number;
  18455. /** If a sprite was picked, this will be the sprite the pick collided with */
  18456. pickedSprite: Nullable<Sprite>;
  18457. /**
  18458. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18459. */
  18460. originMesh: Nullable<AbstractMesh>;
  18461. /**
  18462. * The ray that was used to perform the picking.
  18463. */
  18464. ray: Nullable<Ray>;
  18465. /**
  18466. * Gets the normal correspodning to the face the pick collided with
  18467. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18468. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18469. * @returns The normal correspodning to the face the pick collided with
  18470. */
  18471. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18472. /**
  18473. * Gets the texture coordinates of where the pick occured
  18474. * @returns the vector containing the coordnates of the texture
  18475. */
  18476. getTextureCoordinates(): Nullable<Vector2>;
  18477. }
  18478. }
  18479. declare module "babylonjs/Events/pointerEvents" {
  18480. import { Nullable } from "babylonjs/types";
  18481. import { Vector2 } from "babylonjs/Maths/math.vector";
  18482. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18483. import { Ray } from "babylonjs/Culling/ray";
  18484. /**
  18485. * Gather the list of pointer event types as constants.
  18486. */
  18487. export class PointerEventTypes {
  18488. /**
  18489. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18490. */
  18491. static readonly POINTERDOWN: number;
  18492. /**
  18493. * The pointerup event is fired when a pointer is no longer active.
  18494. */
  18495. static readonly POINTERUP: number;
  18496. /**
  18497. * The pointermove event is fired when a pointer changes coordinates.
  18498. */
  18499. static readonly POINTERMOVE: number;
  18500. /**
  18501. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18502. */
  18503. static readonly POINTERWHEEL: number;
  18504. /**
  18505. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18506. */
  18507. static readonly POINTERPICK: number;
  18508. /**
  18509. * The pointertap event is fired when a the object has been touched and released without drag.
  18510. */
  18511. static readonly POINTERTAP: number;
  18512. /**
  18513. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18514. */
  18515. static readonly POINTERDOUBLETAP: number;
  18516. }
  18517. /**
  18518. * Base class of pointer info types.
  18519. */
  18520. export class PointerInfoBase {
  18521. /**
  18522. * Defines the type of event (PointerEventTypes)
  18523. */
  18524. type: number;
  18525. /**
  18526. * Defines the related dom event
  18527. */
  18528. event: PointerEvent | MouseWheelEvent;
  18529. /**
  18530. * Instantiates the base class of pointers info.
  18531. * @param type Defines the type of event (PointerEventTypes)
  18532. * @param event Defines the related dom event
  18533. */
  18534. constructor(
  18535. /**
  18536. * Defines the type of event (PointerEventTypes)
  18537. */
  18538. type: number,
  18539. /**
  18540. * Defines the related dom event
  18541. */
  18542. event: PointerEvent | MouseWheelEvent);
  18543. }
  18544. /**
  18545. * This class is used to store pointer related info for the onPrePointerObservable event.
  18546. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18547. */
  18548. export class PointerInfoPre extends PointerInfoBase {
  18549. /**
  18550. * Ray from a pointer if availible (eg. 6dof controller)
  18551. */
  18552. ray: Nullable<Ray>;
  18553. /**
  18554. * Defines the local position of the pointer on the canvas.
  18555. */
  18556. localPosition: Vector2;
  18557. /**
  18558. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18559. */
  18560. skipOnPointerObservable: boolean;
  18561. /**
  18562. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18563. * @param type Defines the type of event (PointerEventTypes)
  18564. * @param event Defines the related dom event
  18565. * @param localX Defines the local x coordinates of the pointer when the event occured
  18566. * @param localY Defines the local y coordinates of the pointer when the event occured
  18567. */
  18568. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18569. }
  18570. /**
  18571. * This type contains all the data related to a pointer event in Babylon.js.
  18572. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18573. */
  18574. export class PointerInfo extends PointerInfoBase {
  18575. /**
  18576. * Defines the picking info associated to the info (if any)\
  18577. */
  18578. pickInfo: Nullable<PickingInfo>;
  18579. /**
  18580. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18581. * @param type Defines the type of event (PointerEventTypes)
  18582. * @param event Defines the related dom event
  18583. * @param pickInfo Defines the picking info associated to the info (if any)\
  18584. */
  18585. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18586. /**
  18587. * Defines the picking info associated to the info (if any)\
  18588. */
  18589. pickInfo: Nullable<PickingInfo>);
  18590. }
  18591. /**
  18592. * Data relating to a touch event on the screen.
  18593. */
  18594. export interface PointerTouch {
  18595. /**
  18596. * X coordinate of touch.
  18597. */
  18598. x: number;
  18599. /**
  18600. * Y coordinate of touch.
  18601. */
  18602. y: number;
  18603. /**
  18604. * Id of touch. Unique for each finger.
  18605. */
  18606. pointerId: number;
  18607. /**
  18608. * Event type passed from DOM.
  18609. */
  18610. type: any;
  18611. }
  18612. }
  18613. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18614. import { Observable } from "babylonjs/Misc/observable";
  18615. import { Nullable } from "babylonjs/types";
  18616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18618. /**
  18619. * Manage the mouse inputs to control the movement of a free camera.
  18620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18621. */
  18622. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18623. /**
  18624. * Define if touch is enabled in the mouse input
  18625. */
  18626. touchEnabled: boolean;
  18627. /**
  18628. * Defines the camera the input is attached to.
  18629. */
  18630. camera: FreeCamera;
  18631. /**
  18632. * Defines the buttons associated with the input to handle camera move.
  18633. */
  18634. buttons: number[];
  18635. /**
  18636. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18637. */
  18638. angularSensibility: number;
  18639. private _pointerInput;
  18640. private _onMouseMove;
  18641. private _observer;
  18642. private previousPosition;
  18643. /**
  18644. * Observable for when a pointer move event occurs containing the move offset
  18645. */
  18646. onPointerMovedObservable: Observable<{
  18647. offsetX: number;
  18648. offsetY: number;
  18649. }>;
  18650. /**
  18651. * @hidden
  18652. * If the camera should be rotated automatically based on pointer movement
  18653. */
  18654. _allowCameraRotation: boolean;
  18655. /**
  18656. * Manage the mouse inputs to control the movement of a free camera.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. * @param touchEnabled Defines if touch is enabled or not
  18659. */
  18660. constructor(
  18661. /**
  18662. * Define if touch is enabled in the mouse input
  18663. */
  18664. touchEnabled?: boolean);
  18665. /**
  18666. * Attach the input controls to a specific dom element to get the input from.
  18667. * @param element Defines the element the controls should be listened from
  18668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18669. */
  18670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18671. /**
  18672. * Called on JS contextmenu event.
  18673. * Override this method to provide functionality.
  18674. */
  18675. protected onContextMenu(evt: PointerEvent): void;
  18676. /**
  18677. * Detach the current controls from the specified dom element.
  18678. * @param element Defines the element to stop listening the inputs from
  18679. */
  18680. detachControl(element: Nullable<HTMLElement>): void;
  18681. /**
  18682. * Gets the class name of the current intput.
  18683. * @returns the class name
  18684. */
  18685. getClassName(): string;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18694. import { Nullable } from "babylonjs/types";
  18695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18697. /**
  18698. * Manage the touch inputs to control the movement of a free camera.
  18699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18700. */
  18701. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18702. /**
  18703. * Defines the camera the input is attached to.
  18704. */
  18705. camera: FreeCamera;
  18706. /**
  18707. * Defines the touch sensibility for rotation.
  18708. * The higher the faster.
  18709. */
  18710. touchAngularSensibility: number;
  18711. /**
  18712. * Defines the touch sensibility for move.
  18713. * The higher the faster.
  18714. */
  18715. touchMoveSensibility: number;
  18716. private _offsetX;
  18717. private _offsetY;
  18718. private _pointerPressed;
  18719. private _pointerInput;
  18720. private _observer;
  18721. private _onLostFocus;
  18722. /**
  18723. * Attach the input controls to a specific dom element to get the input from.
  18724. * @param element Defines the element the controls should be listened from
  18725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18726. */
  18727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18728. /**
  18729. * Detach the current controls from the specified dom element.
  18730. * @param element Defines the element to stop listening the inputs from
  18731. */
  18732. detachControl(element: Nullable<HTMLElement>): void;
  18733. /**
  18734. * Update the current camera state depending on the inputs that have been used this frame.
  18735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18736. */
  18737. checkInputs(): void;
  18738. /**
  18739. * Gets the class name of the current intput.
  18740. * @returns the class name
  18741. */
  18742. getClassName(): string;
  18743. /**
  18744. * Get the friendly name associated with the input class.
  18745. * @returns the input friendly name
  18746. */
  18747. getSimpleName(): string;
  18748. }
  18749. }
  18750. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18751. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18752. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18753. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18754. import { Nullable } from "babylonjs/types";
  18755. /**
  18756. * Default Inputs manager for the FreeCamera.
  18757. * It groups all the default supported inputs for ease of use.
  18758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18759. */
  18760. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18761. /**
  18762. * @hidden
  18763. */
  18764. _mouseInput: Nullable<FreeCameraMouseInput>;
  18765. /**
  18766. * Instantiates a new FreeCameraInputsManager.
  18767. * @param camera Defines the camera the inputs belong to
  18768. */
  18769. constructor(camera: FreeCamera);
  18770. /**
  18771. * Add keyboard input support to the input manager.
  18772. * @returns the current input manager
  18773. */
  18774. addKeyboard(): FreeCameraInputsManager;
  18775. /**
  18776. * Add mouse input support to the input manager.
  18777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18778. * @returns the current input manager
  18779. */
  18780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18781. /**
  18782. * Removes the mouse input support from the manager
  18783. * @returns the current input manager
  18784. */
  18785. removeMouse(): FreeCameraInputsManager;
  18786. /**
  18787. * Add touch input support to the input manager.
  18788. * @returns the current input manager
  18789. */
  18790. addTouch(): FreeCameraInputsManager;
  18791. /**
  18792. * Remove all attached input methods from a camera
  18793. */
  18794. clear(): void;
  18795. }
  18796. }
  18797. declare module "babylonjs/Cameras/freeCamera" {
  18798. import { Vector3 } from "babylonjs/Maths/math.vector";
  18799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18800. import { Scene } from "babylonjs/scene";
  18801. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18802. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18803. /**
  18804. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18805. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18807. */
  18808. export class FreeCamera extends TargetCamera {
  18809. /**
  18810. * Define the collision ellipsoid of the camera.
  18811. * This is helpful to simulate a camera body like the player body around the camera
  18812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18813. */
  18814. ellipsoid: Vector3;
  18815. /**
  18816. * Define an offset for the position of the ellipsoid around the camera.
  18817. * This can be helpful to determine the center of the body near the gravity center of the body
  18818. * instead of its head.
  18819. */
  18820. ellipsoidOffset: Vector3;
  18821. /**
  18822. * Enable or disable collisions of the camera with the rest of the scene objects.
  18823. */
  18824. checkCollisions: boolean;
  18825. /**
  18826. * Enable or disable gravity on the camera.
  18827. */
  18828. applyGravity: boolean;
  18829. /**
  18830. * Define the input manager associated to the camera.
  18831. */
  18832. inputs: FreeCameraInputsManager;
  18833. /**
  18834. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18835. * Higher values reduce sensitivity.
  18836. */
  18837. get angularSensibility(): number;
  18838. /**
  18839. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. set angularSensibility(value: number);
  18843. /**
  18844. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18845. */
  18846. get keysUp(): number[];
  18847. set keysUp(value: number[]);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18850. */
  18851. get keysDown(): number[];
  18852. set keysDown(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. get keysLeft(): number[];
  18857. set keysLeft(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18860. */
  18861. get keysRight(): number[];
  18862. set keysRight(value: number[]);
  18863. /**
  18864. * Event raised when the camera collide with a mesh in the scene.
  18865. */
  18866. onCollide: (collidedMesh: AbstractMesh) => void;
  18867. private _collider;
  18868. private _needMoveForGravity;
  18869. private _oldPosition;
  18870. private _diffPosition;
  18871. private _newPosition;
  18872. /** @hidden */
  18873. _localDirection: Vector3;
  18874. /** @hidden */
  18875. _transformedDirection: Vector3;
  18876. /**
  18877. * Instantiates a Free Camera.
  18878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18879. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18881. * @param name Define the name of the camera in the scene
  18882. * @param position Define the start position of the camera in the scene
  18883. * @param scene Define the scene the camera belongs to
  18884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18885. */
  18886. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18887. /**
  18888. * Attached controls to the current camera.
  18889. * @param element Defines the element the controls should be listened from
  18890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18891. */
  18892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18893. /**
  18894. * Detach the current controls from the camera.
  18895. * The camera will stop reacting to inputs.
  18896. * @param element Defines the element to stop listening the inputs from
  18897. */
  18898. detachControl(element: HTMLElement): void;
  18899. private _collisionMask;
  18900. /**
  18901. * Define a collision mask to limit the list of object the camera can collide with
  18902. */
  18903. get collisionMask(): number;
  18904. set collisionMask(mask: number);
  18905. /** @hidden */
  18906. _collideWithWorld(displacement: Vector3): void;
  18907. private _onCollisionPositionChange;
  18908. /** @hidden */
  18909. _checkInputs(): void;
  18910. /** @hidden */
  18911. _decideIfNeedsToMove(): boolean;
  18912. /** @hidden */
  18913. _updatePosition(): void;
  18914. /**
  18915. * Destroy the camera and release the current resources hold by it.
  18916. */
  18917. dispose(): void;
  18918. /**
  18919. * Gets the current object class name.
  18920. * @return the class name
  18921. */
  18922. getClassName(): string;
  18923. }
  18924. }
  18925. declare module "babylonjs/Gamepads/gamepad" {
  18926. import { Observable } from "babylonjs/Misc/observable";
  18927. /**
  18928. * Represents a gamepad control stick position
  18929. */
  18930. export class StickValues {
  18931. /**
  18932. * The x component of the control stick
  18933. */
  18934. x: number;
  18935. /**
  18936. * The y component of the control stick
  18937. */
  18938. y: number;
  18939. /**
  18940. * Initializes the gamepad x and y control stick values
  18941. * @param x The x component of the gamepad control stick value
  18942. * @param y The y component of the gamepad control stick value
  18943. */
  18944. constructor(
  18945. /**
  18946. * The x component of the control stick
  18947. */
  18948. x: number,
  18949. /**
  18950. * The y component of the control stick
  18951. */
  18952. y: number);
  18953. }
  18954. /**
  18955. * An interface which manages callbacks for gamepad button changes
  18956. */
  18957. export interface GamepadButtonChanges {
  18958. /**
  18959. * Called when a gamepad has been changed
  18960. */
  18961. changed: boolean;
  18962. /**
  18963. * Called when a gamepad press event has been triggered
  18964. */
  18965. pressChanged: boolean;
  18966. /**
  18967. * Called when a touch event has been triggered
  18968. */
  18969. touchChanged: boolean;
  18970. /**
  18971. * Called when a value has changed
  18972. */
  18973. valueChanged: boolean;
  18974. }
  18975. /**
  18976. * Represents a gamepad
  18977. */
  18978. export class Gamepad {
  18979. /**
  18980. * The id of the gamepad
  18981. */
  18982. id: string;
  18983. /**
  18984. * The index of the gamepad
  18985. */
  18986. index: number;
  18987. /**
  18988. * The browser gamepad
  18989. */
  18990. browserGamepad: any;
  18991. /**
  18992. * Specifies what type of gamepad this represents
  18993. */
  18994. type: number;
  18995. private _leftStick;
  18996. private _rightStick;
  18997. /** @hidden */
  18998. _isConnected: boolean;
  18999. private _leftStickAxisX;
  19000. private _leftStickAxisY;
  19001. private _rightStickAxisX;
  19002. private _rightStickAxisY;
  19003. /**
  19004. * Triggered when the left control stick has been changed
  19005. */
  19006. private _onleftstickchanged;
  19007. /**
  19008. * Triggered when the right control stick has been changed
  19009. */
  19010. private _onrightstickchanged;
  19011. /**
  19012. * Represents a gamepad controller
  19013. */
  19014. static GAMEPAD: number;
  19015. /**
  19016. * Represents a generic controller
  19017. */
  19018. static GENERIC: number;
  19019. /**
  19020. * Represents an XBox controller
  19021. */
  19022. static XBOX: number;
  19023. /**
  19024. * Represents a pose-enabled controller
  19025. */
  19026. static POSE_ENABLED: number;
  19027. /**
  19028. * Represents an Dual Shock controller
  19029. */
  19030. static DUALSHOCK: number;
  19031. /**
  19032. * Specifies whether the left control stick should be Y-inverted
  19033. */
  19034. protected _invertLeftStickY: boolean;
  19035. /**
  19036. * Specifies if the gamepad has been connected
  19037. */
  19038. get isConnected(): boolean;
  19039. /**
  19040. * Initializes the gamepad
  19041. * @param id The id of the gamepad
  19042. * @param index The index of the gamepad
  19043. * @param browserGamepad The browser gamepad
  19044. * @param leftStickX The x component of the left joystick
  19045. * @param leftStickY The y component of the left joystick
  19046. * @param rightStickX The x component of the right joystick
  19047. * @param rightStickY The y component of the right joystick
  19048. */
  19049. constructor(
  19050. /**
  19051. * The id of the gamepad
  19052. */
  19053. id: string,
  19054. /**
  19055. * The index of the gamepad
  19056. */
  19057. index: number,
  19058. /**
  19059. * The browser gamepad
  19060. */
  19061. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19062. /**
  19063. * Callback triggered when the left joystick has changed
  19064. * @param callback
  19065. */
  19066. onleftstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Callback triggered when the right joystick has changed
  19069. * @param callback
  19070. */
  19071. onrightstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Gets the left joystick
  19074. */
  19075. get leftStick(): StickValues;
  19076. /**
  19077. * Sets the left joystick values
  19078. */
  19079. set leftStick(newValues: StickValues);
  19080. /**
  19081. * Gets the right joystick
  19082. */
  19083. get rightStick(): StickValues;
  19084. /**
  19085. * Sets the right joystick value
  19086. */
  19087. set rightStick(newValues: StickValues);
  19088. /**
  19089. * Updates the gamepad joystick positions
  19090. */
  19091. update(): void;
  19092. /**
  19093. * Disposes the gamepad
  19094. */
  19095. dispose(): void;
  19096. }
  19097. /**
  19098. * Represents a generic gamepad
  19099. */
  19100. export class GenericPad extends Gamepad {
  19101. private _buttons;
  19102. private _onbuttondown;
  19103. private _onbuttonup;
  19104. /**
  19105. * Observable triggered when a button has been pressed
  19106. */
  19107. onButtonDownObservable: Observable<number>;
  19108. /**
  19109. * Observable triggered when a button has been released
  19110. */
  19111. onButtonUpObservable: Observable<number>;
  19112. /**
  19113. * Callback triggered when a button has been pressed
  19114. * @param callback Called when a button has been pressed
  19115. */
  19116. onbuttondown(callback: (buttonPressed: number) => void): void;
  19117. /**
  19118. * Callback triggered when a button has been released
  19119. * @param callback Called when a button has been released
  19120. */
  19121. onbuttonup(callback: (buttonReleased: number) => void): void;
  19122. /**
  19123. * Initializes the generic gamepad
  19124. * @param id The id of the generic gamepad
  19125. * @param index The index of the generic gamepad
  19126. * @param browserGamepad The browser gamepad
  19127. */
  19128. constructor(id: string, index: number, browserGamepad: any);
  19129. private _setButtonValue;
  19130. /**
  19131. * Updates the generic gamepad
  19132. */
  19133. update(): void;
  19134. /**
  19135. * Disposes the generic gamepad
  19136. */
  19137. dispose(): void;
  19138. }
  19139. }
  19140. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19141. import { Observable } from "babylonjs/Misc/observable";
  19142. import { Nullable } from "babylonjs/types";
  19143. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19146. import { Ray } from "babylonjs/Culling/ray";
  19147. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19148. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19149. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19150. /**
  19151. * Defines the types of pose enabled controllers that are supported
  19152. */
  19153. export enum PoseEnabledControllerType {
  19154. /**
  19155. * HTC Vive
  19156. */
  19157. VIVE = 0,
  19158. /**
  19159. * Oculus Rift
  19160. */
  19161. OCULUS = 1,
  19162. /**
  19163. * Windows mixed reality
  19164. */
  19165. WINDOWS = 2,
  19166. /**
  19167. * Samsung gear VR
  19168. */
  19169. GEAR_VR = 3,
  19170. /**
  19171. * Google Daydream
  19172. */
  19173. DAYDREAM = 4,
  19174. /**
  19175. * Generic
  19176. */
  19177. GENERIC = 5
  19178. }
  19179. /**
  19180. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19181. */
  19182. export interface MutableGamepadButton {
  19183. /**
  19184. * Value of the button/trigger
  19185. */
  19186. value: number;
  19187. /**
  19188. * If the button/trigger is currently touched
  19189. */
  19190. touched: boolean;
  19191. /**
  19192. * If the button/trigger is currently pressed
  19193. */
  19194. pressed: boolean;
  19195. }
  19196. /**
  19197. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19198. * @hidden
  19199. */
  19200. export interface ExtendedGamepadButton extends GamepadButton {
  19201. /**
  19202. * If the button/trigger is currently pressed
  19203. */
  19204. readonly pressed: boolean;
  19205. /**
  19206. * If the button/trigger is currently touched
  19207. */
  19208. readonly touched: boolean;
  19209. /**
  19210. * Value of the button/trigger
  19211. */
  19212. readonly value: number;
  19213. }
  19214. /** @hidden */
  19215. export interface _GamePadFactory {
  19216. /**
  19217. * Returns whether or not the current gamepad can be created for this type of controller.
  19218. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19219. * @returns true if it can be created, otherwise false
  19220. */
  19221. canCreate(gamepadInfo: any): boolean;
  19222. /**
  19223. * Creates a new instance of the Gamepad.
  19224. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19225. * @returns the new gamepad instance
  19226. */
  19227. create(gamepadInfo: any): Gamepad;
  19228. }
  19229. /**
  19230. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19231. */
  19232. export class PoseEnabledControllerHelper {
  19233. /** @hidden */
  19234. static _ControllerFactories: _GamePadFactory[];
  19235. /** @hidden */
  19236. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19237. /**
  19238. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19239. * @param vrGamepad the gamepad to initialized
  19240. * @returns a vr controller of the type the gamepad identified as
  19241. */
  19242. static InitiateController(vrGamepad: any): Gamepad;
  19243. }
  19244. /**
  19245. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19246. */
  19247. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19248. /**
  19249. * If the controller is used in a webXR session
  19250. */
  19251. isXR: boolean;
  19252. private _deviceRoomPosition;
  19253. private _deviceRoomRotationQuaternion;
  19254. /**
  19255. * The device position in babylon space
  19256. */
  19257. devicePosition: Vector3;
  19258. /**
  19259. * The device rotation in babylon space
  19260. */
  19261. deviceRotationQuaternion: Quaternion;
  19262. /**
  19263. * The scale factor of the device in babylon space
  19264. */
  19265. deviceScaleFactor: number;
  19266. /**
  19267. * (Likely devicePosition should be used instead) The device position in its room space
  19268. */
  19269. position: Vector3;
  19270. /**
  19271. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19272. */
  19273. rotationQuaternion: Quaternion;
  19274. /**
  19275. * The type of controller (Eg. Windows mixed reality)
  19276. */
  19277. controllerType: PoseEnabledControllerType;
  19278. protected _calculatedPosition: Vector3;
  19279. private _calculatedRotation;
  19280. /**
  19281. * The raw pose from the device
  19282. */
  19283. rawPose: DevicePose;
  19284. private _trackPosition;
  19285. private _maxRotationDistFromHeadset;
  19286. private _draggedRoomRotation;
  19287. /**
  19288. * @hidden
  19289. */
  19290. _disableTrackPosition(fixedPosition: Vector3): void;
  19291. /**
  19292. * Internal, the mesh attached to the controller
  19293. * @hidden
  19294. */
  19295. _mesh: Nullable<AbstractMesh>;
  19296. private _poseControlledCamera;
  19297. private _leftHandSystemQuaternion;
  19298. /**
  19299. * Internal, matrix used to convert room space to babylon space
  19300. * @hidden
  19301. */
  19302. _deviceToWorld: Matrix;
  19303. /**
  19304. * Node to be used when casting a ray from the controller
  19305. * @hidden
  19306. */
  19307. _pointingPoseNode: Nullable<TransformNode>;
  19308. /**
  19309. * Name of the child mesh that can be used to cast a ray from the controller
  19310. */
  19311. static readonly POINTING_POSE: string;
  19312. /**
  19313. * Creates a new PoseEnabledController from a gamepad
  19314. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19315. */
  19316. constructor(browserGamepad: any);
  19317. private _workingMatrix;
  19318. /**
  19319. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19320. */
  19321. update(): void;
  19322. /**
  19323. * Updates only the pose device and mesh without doing any button event checking
  19324. */
  19325. protected _updatePoseAndMesh(): void;
  19326. /**
  19327. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19328. * @param poseData raw pose fromthe device
  19329. */
  19330. updateFromDevice(poseData: DevicePose): void;
  19331. /**
  19332. * @hidden
  19333. */
  19334. _meshAttachedObservable: Observable<AbstractMesh>;
  19335. /**
  19336. * Attaches a mesh to the controller
  19337. * @param mesh the mesh to be attached
  19338. */
  19339. attachToMesh(mesh: AbstractMesh): void;
  19340. /**
  19341. * Attaches the controllers mesh to a camera
  19342. * @param camera the camera the mesh should be attached to
  19343. */
  19344. attachToPoseControlledCamera(camera: TargetCamera): void;
  19345. /**
  19346. * Disposes of the controller
  19347. */
  19348. dispose(): void;
  19349. /**
  19350. * The mesh that is attached to the controller
  19351. */
  19352. get mesh(): Nullable<AbstractMesh>;
  19353. /**
  19354. * Gets the ray of the controller in the direction the controller is pointing
  19355. * @param length the length the resulting ray should be
  19356. * @returns a ray in the direction the controller is pointing
  19357. */
  19358. getForwardRay(length?: number): Ray;
  19359. }
  19360. }
  19361. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19362. import { Observable } from "babylonjs/Misc/observable";
  19363. import { Scene } from "babylonjs/scene";
  19364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19365. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19366. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19367. import { Nullable } from "babylonjs/types";
  19368. /**
  19369. * Defines the WebVRController object that represents controllers tracked in 3D space
  19370. */
  19371. export abstract class WebVRController extends PoseEnabledController {
  19372. /**
  19373. * Internal, the default controller model for the controller
  19374. */
  19375. protected _defaultModel: Nullable<AbstractMesh>;
  19376. /**
  19377. * Fired when the trigger state has changed
  19378. */
  19379. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19380. /**
  19381. * Fired when the main button state has changed
  19382. */
  19383. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19384. /**
  19385. * Fired when the secondary button state has changed
  19386. */
  19387. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19388. /**
  19389. * Fired when the pad state has changed
  19390. */
  19391. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when controllers stick values have changed
  19394. */
  19395. onPadValuesChangedObservable: Observable<StickValues>;
  19396. /**
  19397. * Array of button availible on the controller
  19398. */
  19399. protected _buttons: Array<MutableGamepadButton>;
  19400. private _onButtonStateChange;
  19401. /**
  19402. * Fired when a controller button's state has changed
  19403. * @param callback the callback containing the button that was modified
  19404. */
  19405. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19406. /**
  19407. * X and Y axis corresponding to the controllers joystick
  19408. */
  19409. pad: StickValues;
  19410. /**
  19411. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19412. */
  19413. hand: string;
  19414. /**
  19415. * The default controller model for the controller
  19416. */
  19417. get defaultModel(): Nullable<AbstractMesh>;
  19418. /**
  19419. * Creates a new WebVRController from a gamepad
  19420. * @param vrGamepad the gamepad that the WebVRController should be created from
  19421. */
  19422. constructor(vrGamepad: any);
  19423. /**
  19424. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19425. */
  19426. update(): void;
  19427. /**
  19428. * Function to be called when a button is modified
  19429. */
  19430. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19431. /**
  19432. * Loads a mesh and attaches it to the controller
  19433. * @param scene the scene the mesh should be added to
  19434. * @param meshLoaded callback for when the mesh has been loaded
  19435. */
  19436. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19437. private _setButtonValue;
  19438. private _changes;
  19439. private _checkChanges;
  19440. /**
  19441. * Disposes of th webVRCOntroller
  19442. */
  19443. dispose(): void;
  19444. }
  19445. }
  19446. declare module "babylonjs/Lights/hemisphericLight" {
  19447. import { Nullable } from "babylonjs/types";
  19448. import { Scene } from "babylonjs/scene";
  19449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19450. import { Color3 } from "babylonjs/Maths/math.color";
  19451. import { Effect } from "babylonjs/Materials/effect";
  19452. import { Light } from "babylonjs/Lights/light";
  19453. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19454. /**
  19455. * The HemisphericLight simulates the ambient environment light,
  19456. * so the passed direction is the light reflection direction, not the incoming direction.
  19457. */
  19458. export class HemisphericLight extends Light {
  19459. /**
  19460. * The groundColor is the light in the opposite direction to the one specified during creation.
  19461. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19462. */
  19463. groundColor: Color3;
  19464. /**
  19465. * The light reflection direction, not the incoming direction.
  19466. */
  19467. direction: Vector3;
  19468. /**
  19469. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19470. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19471. * The HemisphericLight can't cast shadows.
  19472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19473. * @param name The friendly name of the light
  19474. * @param direction The direction of the light reflection
  19475. * @param scene The scene the light belongs to
  19476. */
  19477. constructor(name: string, direction: Vector3, scene: Scene);
  19478. protected _buildUniformLayout(): void;
  19479. /**
  19480. * Returns the string "HemisphericLight".
  19481. * @return The class name
  19482. */
  19483. getClassName(): string;
  19484. /**
  19485. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19486. * Returns the updated direction.
  19487. * @param target The target the direction should point to
  19488. * @return The computed direction
  19489. */
  19490. setDirectionToTarget(target: Vector3): Vector3;
  19491. /**
  19492. * Returns the shadow generator associated to the light.
  19493. * @returns Always null for hemispheric lights because it does not support shadows.
  19494. */
  19495. getShadowGenerator(): Nullable<IShadowGenerator>;
  19496. /**
  19497. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19498. * @param effect The effect to update
  19499. * @param lightIndex The index of the light in the effect to update
  19500. * @returns The hemispheric light
  19501. */
  19502. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19503. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19504. /**
  19505. * Computes the world matrix of the node
  19506. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19507. * @param useWasUpdatedFlag defines a reserved property
  19508. * @returns the world matrix
  19509. */
  19510. computeWorldMatrix(): Matrix;
  19511. /**
  19512. * Returns the integer 3.
  19513. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19514. */
  19515. getTypeID(): number;
  19516. /**
  19517. * Prepares the list of defines specific to the light type.
  19518. * @param defines the list of defines
  19519. * @param lightIndex defines the index of the light for the effect
  19520. */
  19521. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19522. }
  19523. }
  19524. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19525. /** @hidden */
  19526. export var vrMultiviewToSingleviewPixelShader: {
  19527. name: string;
  19528. shader: string;
  19529. };
  19530. }
  19531. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19533. import { Scene } from "babylonjs/scene";
  19534. /**
  19535. * Renders to multiple views with a single draw call
  19536. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19537. */
  19538. export class MultiviewRenderTarget extends RenderTargetTexture {
  19539. /**
  19540. * Creates a multiview render target
  19541. * @param scene scene used with the render target
  19542. * @param size the size of the render target (used for each view)
  19543. */
  19544. constructor(scene: Scene, size?: number | {
  19545. width: number;
  19546. height: number;
  19547. } | {
  19548. ratio: number;
  19549. });
  19550. /**
  19551. * @hidden
  19552. * @param faceIndex the face index, if its a cube texture
  19553. */
  19554. _bindFrameBuffer(faceIndex?: number): void;
  19555. /**
  19556. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19557. * @returns the view count
  19558. */
  19559. getViewCount(): number;
  19560. }
  19561. }
  19562. declare module "babylonjs/Maths/math.frustum" {
  19563. import { Matrix } from "babylonjs/Maths/math.vector";
  19564. import { DeepImmutable } from "babylonjs/types";
  19565. import { Plane } from "babylonjs/Maths/math.plane";
  19566. /**
  19567. * Represents a camera frustum
  19568. */
  19569. export class Frustum {
  19570. /**
  19571. * Gets the planes representing the frustum
  19572. * @param transform matrix to be applied to the returned planes
  19573. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19574. */
  19575. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19576. /**
  19577. * Gets the near frustum plane transformed by the transform matrix
  19578. * @param transform transformation matrix to be applied to the resulting frustum plane
  19579. * @param frustumPlane the resuling frustum plane
  19580. */
  19581. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19582. /**
  19583. * Gets the far frustum plane transformed by the transform matrix
  19584. * @param transform transformation matrix to be applied to the resulting frustum plane
  19585. * @param frustumPlane the resuling frustum plane
  19586. */
  19587. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19588. /**
  19589. * Gets the left frustum plane transformed by the transform matrix
  19590. * @param transform transformation matrix to be applied to the resulting frustum plane
  19591. * @param frustumPlane the resuling frustum plane
  19592. */
  19593. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19594. /**
  19595. * Gets the right frustum plane transformed by the transform matrix
  19596. * @param transform transformation matrix to be applied to the resulting frustum plane
  19597. * @param frustumPlane the resuling frustum plane
  19598. */
  19599. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19600. /**
  19601. * Gets the top frustum plane transformed by the transform matrix
  19602. * @param transform transformation matrix to be applied to the resulting frustum plane
  19603. * @param frustumPlane the resuling frustum plane
  19604. */
  19605. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19606. /**
  19607. * Gets the bottom frustum plane transformed by the transform matrix
  19608. * @param transform transformation matrix to be applied to the resulting frustum plane
  19609. * @param frustumPlane the resuling frustum plane
  19610. */
  19611. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19612. /**
  19613. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19614. * @param transform transformation matrix to be applied to the resulting frustum planes
  19615. * @param frustumPlanes the resuling frustum planes
  19616. */
  19617. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19618. }
  19619. }
  19620. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19621. import { Camera } from "babylonjs/Cameras/camera";
  19622. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19623. import { Nullable } from "babylonjs/types";
  19624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19625. import { Matrix } from "babylonjs/Maths/math.vector";
  19626. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19627. module "babylonjs/Engines/engine" {
  19628. interface Engine {
  19629. /**
  19630. * Creates a new multiview render target
  19631. * @param width defines the width of the texture
  19632. * @param height defines the height of the texture
  19633. * @returns the created multiview texture
  19634. */
  19635. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19636. /**
  19637. * Binds a multiview framebuffer to be drawn to
  19638. * @param multiviewTexture texture to bind
  19639. */
  19640. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19641. }
  19642. }
  19643. module "babylonjs/Cameras/camera" {
  19644. interface Camera {
  19645. /**
  19646. * @hidden
  19647. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19648. */
  19649. _useMultiviewToSingleView: boolean;
  19650. /**
  19651. * @hidden
  19652. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19653. */
  19654. _multiviewTexture: Nullable<RenderTargetTexture>;
  19655. /**
  19656. * @hidden
  19657. * ensures the multiview texture of the camera exists and has the specified width/height
  19658. * @param width height to set on the multiview texture
  19659. * @param height width to set on the multiview texture
  19660. */
  19661. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19662. }
  19663. }
  19664. module "babylonjs/scene" {
  19665. interface Scene {
  19666. /** @hidden */
  19667. _transformMatrixR: Matrix;
  19668. /** @hidden */
  19669. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19670. /** @hidden */
  19671. _createMultiviewUbo(): void;
  19672. /** @hidden */
  19673. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19674. /** @hidden */
  19675. _renderMultiviewToSingleView(camera: Camera): void;
  19676. }
  19677. }
  19678. }
  19679. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19680. import { Camera } from "babylonjs/Cameras/camera";
  19681. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19682. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19683. import "babylonjs/Engines/Extensions/engine.multiview";
  19684. /**
  19685. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19686. * This will not be used for webXR as it supports displaying texture arrays directly
  19687. */
  19688. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19689. /**
  19690. * Initializes a VRMultiviewToSingleview
  19691. * @param name name of the post process
  19692. * @param camera camera to be applied to
  19693. * @param scaleFactor scaling factor to the size of the output texture
  19694. */
  19695. constructor(name: string, camera: Camera, scaleFactor: number);
  19696. }
  19697. }
  19698. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19699. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Size } from "babylonjs/Maths/math.size";
  19702. import { Observable } from "babylonjs/Misc/observable";
  19703. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19704. /**
  19705. * Interface used to define additional presentation attributes
  19706. */
  19707. export interface IVRPresentationAttributes {
  19708. /**
  19709. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19710. */
  19711. highRefreshRate: boolean;
  19712. /**
  19713. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19714. */
  19715. foveationLevel: number;
  19716. }
  19717. module "babylonjs/Engines/engine" {
  19718. interface Engine {
  19719. /** @hidden */
  19720. _vrDisplay: any;
  19721. /** @hidden */
  19722. _vrSupported: boolean;
  19723. /** @hidden */
  19724. _oldSize: Size;
  19725. /** @hidden */
  19726. _oldHardwareScaleFactor: number;
  19727. /** @hidden */
  19728. _vrExclusivePointerMode: boolean;
  19729. /** @hidden */
  19730. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19731. /** @hidden */
  19732. _onVRDisplayPointerRestricted: () => void;
  19733. /** @hidden */
  19734. _onVRDisplayPointerUnrestricted: () => void;
  19735. /** @hidden */
  19736. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19737. /** @hidden */
  19738. _onVrDisplayDisconnect: Nullable<() => void>;
  19739. /** @hidden */
  19740. _onVrDisplayPresentChange: Nullable<() => void>;
  19741. /**
  19742. * Observable signaled when VR display mode changes
  19743. */
  19744. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19745. /**
  19746. * Observable signaled when VR request present is complete
  19747. */
  19748. onVRRequestPresentComplete: Observable<boolean>;
  19749. /**
  19750. * Observable signaled when VR request present starts
  19751. */
  19752. onVRRequestPresentStart: Observable<Engine>;
  19753. /**
  19754. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19755. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19756. */
  19757. isInVRExclusivePointerMode: boolean;
  19758. /**
  19759. * Gets a boolean indicating if a webVR device was detected
  19760. * @returns true if a webVR device was detected
  19761. */
  19762. isVRDevicePresent(): boolean;
  19763. /**
  19764. * Gets the current webVR device
  19765. * @returns the current webVR device (or null)
  19766. */
  19767. getVRDevice(): any;
  19768. /**
  19769. * Initializes a webVR display and starts listening to display change events
  19770. * The onVRDisplayChangedObservable will be notified upon these changes
  19771. * @returns A promise containing a VRDisplay and if vr is supported
  19772. */
  19773. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19774. /** @hidden */
  19775. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19776. /**
  19777. * Gets or sets the presentation attributes used to configure VR rendering
  19778. */
  19779. vrPresentationAttributes?: IVRPresentationAttributes;
  19780. /**
  19781. * Call this function to switch to webVR mode
  19782. * Will do nothing if webVR is not supported or if there is no webVR device
  19783. * @param options the webvr options provided to the camera. mainly used for multiview
  19784. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19785. */
  19786. enableVR(options: WebVROptions): void;
  19787. /** @hidden */
  19788. _onVRFullScreenTriggered(): void;
  19789. }
  19790. }
  19791. }
  19792. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19793. import { Nullable } from "babylonjs/types";
  19794. import { Observable } from "babylonjs/Misc/observable";
  19795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19796. import { Scene } from "babylonjs/scene";
  19797. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19799. import { Node } from "babylonjs/node";
  19800. import { Ray } from "babylonjs/Culling/ray";
  19801. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19802. import "babylonjs/Engines/Extensions/engine.webVR";
  19803. /**
  19804. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19805. * IMPORTANT!! The data is right-hand data.
  19806. * @export
  19807. * @interface DevicePose
  19808. */
  19809. export interface DevicePose {
  19810. /**
  19811. * The position of the device, values in array are [x,y,z].
  19812. */
  19813. readonly position: Nullable<Float32Array>;
  19814. /**
  19815. * The linearVelocity of the device, values in array are [x,y,z].
  19816. */
  19817. readonly linearVelocity: Nullable<Float32Array>;
  19818. /**
  19819. * The linearAcceleration of the device, values in array are [x,y,z].
  19820. */
  19821. readonly linearAcceleration: Nullable<Float32Array>;
  19822. /**
  19823. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19824. */
  19825. readonly orientation: Nullable<Float32Array>;
  19826. /**
  19827. * The angularVelocity of the device, values in array are [x,y,z].
  19828. */
  19829. readonly angularVelocity: Nullable<Float32Array>;
  19830. /**
  19831. * The angularAcceleration of the device, values in array are [x,y,z].
  19832. */
  19833. readonly angularAcceleration: Nullable<Float32Array>;
  19834. }
  19835. /**
  19836. * Interface representing a pose controlled object in Babylon.
  19837. * A pose controlled object has both regular pose values as well as pose values
  19838. * from an external device such as a VR head mounted display
  19839. */
  19840. export interface PoseControlled {
  19841. /**
  19842. * The position of the object in babylon space.
  19843. */
  19844. position: Vector3;
  19845. /**
  19846. * The rotation quaternion of the object in babylon space.
  19847. */
  19848. rotationQuaternion: Quaternion;
  19849. /**
  19850. * The position of the device in babylon space.
  19851. */
  19852. devicePosition?: Vector3;
  19853. /**
  19854. * The rotation quaternion of the device in babylon space.
  19855. */
  19856. deviceRotationQuaternion: Quaternion;
  19857. /**
  19858. * The raw pose coming from the device.
  19859. */
  19860. rawPose: Nullable<DevicePose>;
  19861. /**
  19862. * The scale of the device to be used when translating from device space to babylon space.
  19863. */
  19864. deviceScaleFactor: number;
  19865. /**
  19866. * Updates the poseControlled values based on the input device pose.
  19867. * @param poseData the pose data to update the object with
  19868. */
  19869. updateFromDevice(poseData: DevicePose): void;
  19870. }
  19871. /**
  19872. * Set of options to customize the webVRCamera
  19873. */
  19874. export interface WebVROptions {
  19875. /**
  19876. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19877. */
  19878. trackPosition?: boolean;
  19879. /**
  19880. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19881. */
  19882. positionScale?: number;
  19883. /**
  19884. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19885. */
  19886. displayName?: string;
  19887. /**
  19888. * Should the native controller meshes be initialized. (default: true)
  19889. */
  19890. controllerMeshes?: boolean;
  19891. /**
  19892. * Creating a default HemiLight only on controllers. (default: true)
  19893. */
  19894. defaultLightingOnControllers?: boolean;
  19895. /**
  19896. * If you don't want to use the default VR button of the helper. (default: false)
  19897. */
  19898. useCustomVRButton?: boolean;
  19899. /**
  19900. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19901. */
  19902. customVRButton?: HTMLButtonElement;
  19903. /**
  19904. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19905. */
  19906. rayLength?: number;
  19907. /**
  19908. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19909. */
  19910. defaultHeight?: number;
  19911. /**
  19912. * If multiview should be used if availible (default: false)
  19913. */
  19914. useMultiview?: boolean;
  19915. }
  19916. /**
  19917. * This represents a WebVR camera.
  19918. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19919. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19920. */
  19921. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19922. private webVROptions;
  19923. /**
  19924. * @hidden
  19925. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19926. */
  19927. _vrDevice: any;
  19928. /**
  19929. * The rawPose of the vrDevice.
  19930. */
  19931. rawPose: Nullable<DevicePose>;
  19932. private _onVREnabled;
  19933. private _specsVersion;
  19934. private _attached;
  19935. private _frameData;
  19936. protected _descendants: Array<Node>;
  19937. private _deviceRoomPosition;
  19938. /** @hidden */
  19939. _deviceRoomRotationQuaternion: Quaternion;
  19940. private _standingMatrix;
  19941. /**
  19942. * Represents device position in babylon space.
  19943. */
  19944. devicePosition: Vector3;
  19945. /**
  19946. * Represents device rotation in babylon space.
  19947. */
  19948. deviceRotationQuaternion: Quaternion;
  19949. /**
  19950. * The scale of the device to be used when translating from device space to babylon space.
  19951. */
  19952. deviceScaleFactor: number;
  19953. private _deviceToWorld;
  19954. private _worldToDevice;
  19955. /**
  19956. * References to the webVR controllers for the vrDevice.
  19957. */
  19958. controllers: Array<WebVRController>;
  19959. /**
  19960. * Emits an event when a controller is attached.
  19961. */
  19962. onControllersAttachedObservable: Observable<WebVRController[]>;
  19963. /**
  19964. * Emits an event when a controller's mesh has been loaded;
  19965. */
  19966. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19967. /**
  19968. * Emits an event when the HMD's pose has been updated.
  19969. */
  19970. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19971. private _poseSet;
  19972. /**
  19973. * If the rig cameras be used as parent instead of this camera.
  19974. */
  19975. rigParenting: boolean;
  19976. private _lightOnControllers;
  19977. private _defaultHeight?;
  19978. /**
  19979. * Instantiates a WebVRFreeCamera.
  19980. * @param name The name of the WebVRFreeCamera
  19981. * @param position The starting anchor position for the camera
  19982. * @param scene The scene the camera belongs to
  19983. * @param webVROptions a set of customizable options for the webVRCamera
  19984. */
  19985. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19986. /**
  19987. * Gets the device distance from the ground in meters.
  19988. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19989. */
  19990. deviceDistanceToRoomGround(): number;
  19991. /**
  19992. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19993. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19994. */
  19995. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @returns A promise with a boolean set to if the standing matrix is supported.
  19999. */
  20000. useStandingMatrixAsync(): Promise<boolean>;
  20001. /**
  20002. * Disposes the camera
  20003. */
  20004. dispose(): void;
  20005. /**
  20006. * Gets a vrController by name.
  20007. * @param name The name of the controller to retreive
  20008. * @returns the controller matching the name specified or null if not found
  20009. */
  20010. getControllerByName(name: string): Nullable<WebVRController>;
  20011. private _leftController;
  20012. /**
  20013. * The controller corresponding to the users left hand.
  20014. */
  20015. get leftController(): Nullable<WebVRController>;
  20016. private _rightController;
  20017. /**
  20018. * The controller corresponding to the users right hand.
  20019. */
  20020. get rightController(): Nullable<WebVRController>;
  20021. /**
  20022. * Casts a ray forward from the vrCamera's gaze.
  20023. * @param length Length of the ray (default: 100)
  20024. * @returns the ray corresponding to the gaze
  20025. */
  20026. getForwardRay(length?: number): Ray;
  20027. /**
  20028. * @hidden
  20029. * Updates the camera based on device's frame data
  20030. */
  20031. _checkInputs(): void;
  20032. /**
  20033. * Updates the poseControlled values based on the input device pose.
  20034. * @param poseData Pose coming from the device
  20035. */
  20036. updateFromDevice(poseData: DevicePose): void;
  20037. private _htmlElementAttached;
  20038. private _detachIfAttached;
  20039. /**
  20040. * WebVR's attach control will start broadcasting frames to the device.
  20041. * Note that in certain browsers (chrome for example) this function must be called
  20042. * within a user-interaction callback. Example:
  20043. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20044. *
  20045. * @param element html element to attach the vrDevice to
  20046. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20047. */
  20048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20049. /**
  20050. * Detaches the camera from the html element and disables VR
  20051. *
  20052. * @param element html element to detach from
  20053. */
  20054. detachControl(element: HTMLElement): void;
  20055. /**
  20056. * @returns the name of this class
  20057. */
  20058. getClassName(): string;
  20059. /**
  20060. * Calls resetPose on the vrDisplay
  20061. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20062. */
  20063. resetToCurrentRotation(): void;
  20064. /**
  20065. * @hidden
  20066. * Updates the rig cameras (left and right eye)
  20067. */
  20068. _updateRigCameras(): void;
  20069. private _workingVector;
  20070. private _oneVector;
  20071. private _workingMatrix;
  20072. private updateCacheCalled;
  20073. private _correctPositionIfNotTrackPosition;
  20074. /**
  20075. * @hidden
  20076. * Updates the cached values of the camera
  20077. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20078. */
  20079. _updateCache(ignoreParentClass?: boolean): void;
  20080. /**
  20081. * @hidden
  20082. * Get current device position in babylon world
  20083. */
  20084. _computeDevicePosition(): void;
  20085. /**
  20086. * Updates the current device position and rotation in the babylon world
  20087. */
  20088. update(): void;
  20089. /**
  20090. * @hidden
  20091. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20092. * @returns an identity matrix
  20093. */
  20094. _getViewMatrix(): Matrix;
  20095. private _tmpMatrix;
  20096. /**
  20097. * This function is called by the two RIG cameras.
  20098. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20099. * @hidden
  20100. */
  20101. _getWebVRViewMatrix(): Matrix;
  20102. /** @hidden */
  20103. _getWebVRProjectionMatrix(): Matrix;
  20104. private _onGamepadConnectedObserver;
  20105. private _onGamepadDisconnectedObserver;
  20106. private _updateCacheWhenTrackingDisabledObserver;
  20107. /**
  20108. * Initializes the controllers and their meshes
  20109. */
  20110. initControllers(): void;
  20111. }
  20112. }
  20113. declare module "babylonjs/PostProcesses/postProcess" {
  20114. import { Nullable } from "babylonjs/types";
  20115. import { SmartArray } from "babylonjs/Misc/smartArray";
  20116. import { Observable } from "babylonjs/Misc/observable";
  20117. import { Vector2 } from "babylonjs/Maths/math.vector";
  20118. import { Camera } from "babylonjs/Cameras/camera";
  20119. import { Effect } from "babylonjs/Materials/effect";
  20120. import "babylonjs/Shaders/postprocess.vertex";
  20121. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20122. import { Engine } from "babylonjs/Engines/engine";
  20123. import { Color4 } from "babylonjs/Maths/math.color";
  20124. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20126. /**
  20127. * Size options for a post process
  20128. */
  20129. export type PostProcessOptions = {
  20130. width: number;
  20131. height: number;
  20132. };
  20133. /**
  20134. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20135. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20136. */
  20137. export class PostProcess {
  20138. /** Name of the PostProcess. */
  20139. name: string;
  20140. /**
  20141. * Gets or sets the unique id of the post process
  20142. */
  20143. uniqueId: number;
  20144. /**
  20145. * Width of the texture to apply the post process on
  20146. */
  20147. width: number;
  20148. /**
  20149. * Height of the texture to apply the post process on
  20150. */
  20151. height: number;
  20152. /**
  20153. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20154. * @hidden
  20155. */
  20156. _outputTexture: Nullable<InternalTexture>;
  20157. /**
  20158. * Sampling mode used by the shader
  20159. * See https://doc.babylonjs.com/classes/3.1/texture
  20160. */
  20161. renderTargetSamplingMode: number;
  20162. /**
  20163. * Clear color to use when screen clearing
  20164. */
  20165. clearColor: Color4;
  20166. /**
  20167. * If the buffer needs to be cleared before applying the post process. (default: true)
  20168. * Should be set to false if shader will overwrite all previous pixels.
  20169. */
  20170. autoClear: boolean;
  20171. /**
  20172. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20173. */
  20174. alphaMode: number;
  20175. /**
  20176. * Sets the setAlphaBlendConstants of the babylon engine
  20177. */
  20178. alphaConstants: Color4;
  20179. /**
  20180. * Animations to be used for the post processing
  20181. */
  20182. animations: import("babylonjs/Animations/animation").Animation[];
  20183. /**
  20184. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20185. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20186. */
  20187. enablePixelPerfectMode: boolean;
  20188. /**
  20189. * Force the postprocess to be applied without taking in account viewport
  20190. */
  20191. forceFullscreenViewport: boolean;
  20192. /**
  20193. * List of inspectable custom properties (used by the Inspector)
  20194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20195. */
  20196. inspectableCustomProperties: IInspectable[];
  20197. /**
  20198. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20199. *
  20200. * | Value | Type | Description |
  20201. * | ----- | ----------------------------------- | ----------- |
  20202. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20203. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20204. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20205. *
  20206. */
  20207. scaleMode: number;
  20208. /**
  20209. * Force textures to be a power of two (default: false)
  20210. */
  20211. alwaysForcePOT: boolean;
  20212. private _samples;
  20213. /**
  20214. * Number of sample textures (default: 1)
  20215. */
  20216. get samples(): number;
  20217. set samples(n: number);
  20218. /**
  20219. * Modify the scale of the post process to be the same as the viewport (default: false)
  20220. */
  20221. adaptScaleToCurrentViewport: boolean;
  20222. private _camera;
  20223. private _scene;
  20224. private _engine;
  20225. private _options;
  20226. private _reusable;
  20227. private _textureType;
  20228. private _textureFormat;
  20229. /**
  20230. * Smart array of input and output textures for the post process.
  20231. * @hidden
  20232. */
  20233. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20234. /**
  20235. * The index in _textures that corresponds to the output texture.
  20236. * @hidden
  20237. */
  20238. _currentRenderTextureInd: number;
  20239. private _effect;
  20240. private _samplers;
  20241. private _fragmentUrl;
  20242. private _vertexUrl;
  20243. private _parameters;
  20244. private _scaleRatio;
  20245. protected _indexParameters: any;
  20246. private _shareOutputWithPostProcess;
  20247. private _texelSize;
  20248. private _forcedOutputTexture;
  20249. /**
  20250. * Returns the fragment url or shader name used in the post process.
  20251. * @returns the fragment url or name in the shader store.
  20252. */
  20253. getEffectName(): string;
  20254. /**
  20255. * An event triggered when the postprocess is activated.
  20256. */
  20257. onActivateObservable: Observable<Camera>;
  20258. private _onActivateObserver;
  20259. /**
  20260. * A function that is added to the onActivateObservable
  20261. */
  20262. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20263. /**
  20264. * An event triggered when the postprocess changes its size.
  20265. */
  20266. onSizeChangedObservable: Observable<PostProcess>;
  20267. private _onSizeChangedObserver;
  20268. /**
  20269. * A function that is added to the onSizeChangedObservable
  20270. */
  20271. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20272. /**
  20273. * An event triggered when the postprocess applies its effect.
  20274. */
  20275. onApplyObservable: Observable<Effect>;
  20276. private _onApplyObserver;
  20277. /**
  20278. * A function that is added to the onApplyObservable
  20279. */
  20280. set onApply(callback: (effect: Effect) => void);
  20281. /**
  20282. * An event triggered before rendering the postprocess
  20283. */
  20284. onBeforeRenderObservable: Observable<Effect>;
  20285. private _onBeforeRenderObserver;
  20286. /**
  20287. * A function that is added to the onBeforeRenderObservable
  20288. */
  20289. set onBeforeRender(callback: (effect: Effect) => void);
  20290. /**
  20291. * An event triggered after rendering the postprocess
  20292. */
  20293. onAfterRenderObservable: Observable<Effect>;
  20294. private _onAfterRenderObserver;
  20295. /**
  20296. * A function that is added to the onAfterRenderObservable
  20297. */
  20298. set onAfterRender(callback: (efect: Effect) => void);
  20299. /**
  20300. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  20301. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20302. */
  20303. get inputTexture(): InternalTexture;
  20304. set inputTexture(value: InternalTexture);
  20305. /**
  20306. * Gets the camera which post process is applied to.
  20307. * @returns The camera the post process is applied to.
  20308. */
  20309. getCamera(): Camera;
  20310. /**
  20311. * Gets the texel size of the postprocess.
  20312. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20313. */
  20314. get texelSize(): Vector2;
  20315. /**
  20316. * Creates a new instance PostProcess
  20317. * @param name The name of the PostProcess.
  20318. * @param fragmentUrl The url of the fragment shader to be used.
  20319. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20320. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20321. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20322. * @param camera The camera to apply the render pass to.
  20323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20324. * @param engine The engine which the post process will be applied. (default: current engine)
  20325. * @param reusable If the post process can be reused on the same frame. (default: false)
  20326. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20327. * @param textureType Type of textures used when performing the post process. (default: 0)
  20328. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20329. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20330. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20331. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20332. */
  20333. constructor(
  20334. /** Name of the PostProcess. */
  20335. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20336. /**
  20337. * Gets a string idenfifying the name of the class
  20338. * @returns "PostProcess" string
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Gets the engine which this post process belongs to.
  20343. * @returns The engine the post process was enabled with.
  20344. */
  20345. getEngine(): Engine;
  20346. /**
  20347. * The effect that is created when initializing the post process.
  20348. * @returns The created effect corresponding the the postprocess.
  20349. */
  20350. getEffect(): Effect;
  20351. /**
  20352. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20353. * @param postProcess The post process to share the output with.
  20354. * @returns This post process.
  20355. */
  20356. shareOutputWith(postProcess: PostProcess): PostProcess;
  20357. /**
  20358. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20359. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20360. */
  20361. useOwnOutput(): void;
  20362. /**
  20363. * Updates the effect with the current post process compile time values and recompiles the shader.
  20364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20367. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20368. * @param onCompiled Called when the shader has been compiled.
  20369. * @param onError Called if there is an error when compiling a shader.
  20370. */
  20371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20372. /**
  20373. * The post process is reusable if it can be used multiple times within one frame.
  20374. * @returns If the post process is reusable
  20375. */
  20376. isReusable(): boolean;
  20377. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20378. markTextureDirty(): void;
  20379. /**
  20380. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20381. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20382. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20383. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20384. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20385. * @returns The target texture that was bound to be written to.
  20386. */
  20387. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20388. /**
  20389. * If the post process is supported.
  20390. */
  20391. get isSupported(): boolean;
  20392. /**
  20393. * The aspect ratio of the output texture.
  20394. */
  20395. get aspectRatio(): number;
  20396. /**
  20397. * Get a value indicating if the post-process is ready to be used
  20398. * @returns true if the post-process is ready (shader is compiled)
  20399. */
  20400. isReady(): boolean;
  20401. /**
  20402. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20403. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20404. */
  20405. apply(): Nullable<Effect>;
  20406. private _disposeTextures;
  20407. /**
  20408. * Disposes the post process.
  20409. * @param camera The camera to dispose the post process on.
  20410. */
  20411. dispose(camera?: Camera): void;
  20412. }
  20413. }
  20414. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20415. /** @hidden */
  20416. export var kernelBlurVaryingDeclaration: {
  20417. name: string;
  20418. shader: string;
  20419. };
  20420. }
  20421. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20422. /** @hidden */
  20423. export var kernelBlurFragment: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20429. /** @hidden */
  20430. export var kernelBlurFragment2: {
  20431. name: string;
  20432. shader: string;
  20433. };
  20434. }
  20435. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20436. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20437. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20438. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20439. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20440. /** @hidden */
  20441. export var kernelBlurPixelShader: {
  20442. name: string;
  20443. shader: string;
  20444. };
  20445. }
  20446. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20447. /** @hidden */
  20448. export var kernelBlurVertex: {
  20449. name: string;
  20450. shader: string;
  20451. };
  20452. }
  20453. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20454. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20455. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20456. /** @hidden */
  20457. export var kernelBlurVertexShader: {
  20458. name: string;
  20459. shader: string;
  20460. };
  20461. }
  20462. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20463. import { Vector2 } from "babylonjs/Maths/math.vector";
  20464. import { Nullable } from "babylonjs/types";
  20465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20466. import { Camera } from "babylonjs/Cameras/camera";
  20467. import { Effect } from "babylonjs/Materials/effect";
  20468. import { Engine } from "babylonjs/Engines/engine";
  20469. import "babylonjs/Shaders/kernelBlur.fragment";
  20470. import "babylonjs/Shaders/kernelBlur.vertex";
  20471. /**
  20472. * The Blur Post Process which blurs an image based on a kernel and direction.
  20473. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20474. */
  20475. export class BlurPostProcess extends PostProcess {
  20476. /** The direction in which to blur the image. */
  20477. direction: Vector2;
  20478. private blockCompilation;
  20479. protected _kernel: number;
  20480. protected _idealKernel: number;
  20481. protected _packedFloat: boolean;
  20482. private _staticDefines;
  20483. /**
  20484. * Sets the length in pixels of the blur sample region
  20485. */
  20486. set kernel(v: number);
  20487. /**
  20488. * Gets the length in pixels of the blur sample region
  20489. */
  20490. get kernel(): number;
  20491. /**
  20492. * Sets wether or not the blur needs to unpack/repack floats
  20493. */
  20494. set packedFloat(v: boolean);
  20495. /**
  20496. * Gets wether or not the blur is unpacking/repacking floats
  20497. */
  20498. get packedFloat(): boolean;
  20499. /**
  20500. * Creates a new instance BlurPostProcess
  20501. * @param name The name of the effect.
  20502. * @param direction The direction in which to blur the image.
  20503. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20504. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20505. * @param camera The camera to apply the render pass to.
  20506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20507. * @param engine The engine which the post process will be applied. (default: current engine)
  20508. * @param reusable If the post process can be reused on the same frame. (default: false)
  20509. * @param textureType Type of textures used when performing the post process. (default: 0)
  20510. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20511. */
  20512. constructor(name: string,
  20513. /** The direction in which to blur the image. */
  20514. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20515. /**
  20516. * Updates the effect with the current post process compile time values and recompiles the shader.
  20517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20520. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20521. * @param onCompiled Called when the shader has been compiled.
  20522. * @param onError Called if there is an error when compiling a shader.
  20523. */
  20524. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20525. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20526. /**
  20527. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20528. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20529. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20530. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20531. * The gaps between physical kernels are compensated for in the weighting of the samples
  20532. * @param idealKernel Ideal blur kernel.
  20533. * @return Nearest best kernel.
  20534. */
  20535. protected _nearestBestKernel(idealKernel: number): number;
  20536. /**
  20537. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20538. * @param x The point on the Gaussian distribution to sample.
  20539. * @return the value of the Gaussian function at x.
  20540. */
  20541. protected _gaussianWeight(x: number): number;
  20542. /**
  20543. * Generates a string that can be used as a floating point number in GLSL.
  20544. * @param x Value to print.
  20545. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20546. * @return GLSL float string.
  20547. */
  20548. protected _glslFloat(x: number, decimalFigures?: number): string;
  20549. }
  20550. }
  20551. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20552. import { Scene } from "babylonjs/scene";
  20553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20554. import { Plane } from "babylonjs/Maths/math.plane";
  20555. /**
  20556. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20557. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20558. * You can then easily use it as a reflectionTexture on a flat surface.
  20559. * In case the surface is not a plane, please consider relying on reflection probes.
  20560. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20561. */
  20562. export class MirrorTexture extends RenderTargetTexture {
  20563. private scene;
  20564. /**
  20565. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20566. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20567. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20568. */
  20569. mirrorPlane: Plane;
  20570. /**
  20571. * Define the blur ratio used to blur the reflection if needed.
  20572. */
  20573. set blurRatio(value: number);
  20574. get blurRatio(): number;
  20575. /**
  20576. * Define the adaptive blur kernel used to blur the reflection if needed.
  20577. * This will autocompute the closest best match for the `blurKernel`
  20578. */
  20579. set adaptiveBlurKernel(value: number);
  20580. /**
  20581. * Define the blur kernel used to blur the reflection if needed.
  20582. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20583. */
  20584. set blurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernelX(value: number);
  20590. get blurKernelX(): number;
  20591. /**
  20592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20594. */
  20595. set blurKernelY(value: number);
  20596. get blurKernelY(): number;
  20597. private _autoComputeBlurKernel;
  20598. protected _onRatioRescale(): void;
  20599. private _updateGammaSpace;
  20600. private _imageProcessingConfigChangeObserver;
  20601. private _transformMatrix;
  20602. private _mirrorMatrix;
  20603. private _savedViewMatrix;
  20604. private _blurX;
  20605. private _blurY;
  20606. private _adaptiveBlurKernel;
  20607. private _blurKernelX;
  20608. private _blurKernelY;
  20609. private _blurRatio;
  20610. /**
  20611. * Instantiates a Mirror Texture.
  20612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20614. * You can then easily use it as a reflectionTexture on a flat surface.
  20615. * In case the surface is not a plane, please consider relying on reflection probes.
  20616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20617. * @param name
  20618. * @param size
  20619. * @param scene
  20620. * @param generateMipMaps
  20621. * @param type
  20622. * @param samplingMode
  20623. * @param generateDepthBuffer
  20624. */
  20625. constructor(name: string, size: number | {
  20626. width: number;
  20627. height: number;
  20628. } | {
  20629. ratio: number;
  20630. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20631. private _preparePostProcesses;
  20632. /**
  20633. * Clone the mirror texture.
  20634. * @returns the cloned texture
  20635. */
  20636. clone(): MirrorTexture;
  20637. /**
  20638. * Serialize the texture to a JSON representation you could use in Parse later on
  20639. * @returns the serialized JSON representation
  20640. */
  20641. serialize(): any;
  20642. /**
  20643. * Dispose the texture and release its associated resources.
  20644. */
  20645. dispose(): void;
  20646. }
  20647. }
  20648. declare module "babylonjs/Materials/Textures/texture" {
  20649. import { Observable } from "babylonjs/Misc/observable";
  20650. import { Nullable } from "babylonjs/types";
  20651. import { Matrix } from "babylonjs/Maths/math.vector";
  20652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20653. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20654. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20655. import { Scene } from "babylonjs/scene";
  20656. /**
  20657. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20658. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20659. */
  20660. export class Texture extends BaseTexture {
  20661. /**
  20662. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20663. */
  20664. static SerializeBuffers: boolean;
  20665. /** @hidden */
  20666. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20667. /** @hidden */
  20668. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20669. /** @hidden */
  20670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20671. /** nearest is mag = nearest and min = nearest and mip = linear */
  20672. static readonly NEAREST_SAMPLINGMODE: number;
  20673. /** nearest is mag = nearest and min = nearest and mip = linear */
  20674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20676. static readonly BILINEAR_SAMPLINGMODE: number;
  20677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20679. /** Trilinear is mag = linear and min = linear and mip = linear */
  20680. static readonly TRILINEAR_SAMPLINGMODE: number;
  20681. /** Trilinear is mag = linear and min = linear and mip = linear */
  20682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20683. /** mag = nearest and min = nearest and mip = nearest */
  20684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20685. /** mag = nearest and min = linear and mip = nearest */
  20686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20687. /** mag = nearest and min = linear and mip = linear */
  20688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20689. /** mag = nearest and min = linear and mip = none */
  20690. static readonly NEAREST_LINEAR: number;
  20691. /** mag = nearest and min = nearest and mip = none */
  20692. static readonly NEAREST_NEAREST: number;
  20693. /** mag = linear and min = nearest and mip = nearest */
  20694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20695. /** mag = linear and min = nearest and mip = linear */
  20696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20697. /** mag = linear and min = linear and mip = none */
  20698. static readonly LINEAR_LINEAR: number;
  20699. /** mag = linear and min = nearest and mip = none */
  20700. static readonly LINEAR_NEAREST: number;
  20701. /** Explicit coordinates mode */
  20702. static readonly EXPLICIT_MODE: number;
  20703. /** Spherical coordinates mode */
  20704. static readonly SPHERICAL_MODE: number;
  20705. /** Planar coordinates mode */
  20706. static readonly PLANAR_MODE: number;
  20707. /** Cubic coordinates mode */
  20708. static readonly CUBIC_MODE: number;
  20709. /** Projection coordinates mode */
  20710. static readonly PROJECTION_MODE: number;
  20711. /** Inverse Cubic coordinates mode */
  20712. static readonly SKYBOX_MODE: number;
  20713. /** Inverse Cubic coordinates mode */
  20714. static readonly INVCUBIC_MODE: number;
  20715. /** Equirectangular coordinates mode */
  20716. static readonly EQUIRECTANGULAR_MODE: number;
  20717. /** Equirectangular Fixed coordinates mode */
  20718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20719. /** Equirectangular Fixed Mirrored coordinates mode */
  20720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20721. /** Texture is not repeating outside of 0..1 UVs */
  20722. static readonly CLAMP_ADDRESSMODE: number;
  20723. /** Texture is repeating outside of 0..1 UVs */
  20724. static readonly WRAP_ADDRESSMODE: number;
  20725. /** Texture is repeating and mirrored */
  20726. static readonly MIRROR_ADDRESSMODE: number;
  20727. /**
  20728. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20729. */
  20730. static UseSerializedUrlIfAny: boolean;
  20731. /**
  20732. * Define the url of the texture.
  20733. */
  20734. url: Nullable<string>;
  20735. /**
  20736. * Define an offset on the texture to offset the u coordinates of the UVs
  20737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20738. */
  20739. uOffset: number;
  20740. /**
  20741. * Define an offset on the texture to offset the v coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. vOffset: number;
  20745. /**
  20746. * Define an offset on the texture to scale the u coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20748. */
  20749. uScale: number;
  20750. /**
  20751. * Define an offset on the texture to scale the v coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. vScale: number;
  20755. /**
  20756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials
  20758. */
  20759. uAng: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. vAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. wAng: number;
  20770. /**
  20771. * Defines the center of rotation (U)
  20772. */
  20773. uRotationCenter: number;
  20774. /**
  20775. * Defines the center of rotation (V)
  20776. */
  20777. vRotationCenter: number;
  20778. /**
  20779. * Defines the center of rotation (W)
  20780. */
  20781. wRotationCenter: number;
  20782. /**
  20783. * Are mip maps generated for this texture or not.
  20784. */
  20785. get noMipmap(): boolean;
  20786. /**
  20787. * List of inspectable custom properties (used by the Inspector)
  20788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20789. */
  20790. inspectableCustomProperties: Nullable<IInspectable[]>;
  20791. private _noMipmap;
  20792. /** @hidden */
  20793. _invertY: boolean;
  20794. private _rowGenerationMatrix;
  20795. private _cachedTextureMatrix;
  20796. private _projectionModeMatrix;
  20797. private _t0;
  20798. private _t1;
  20799. private _t2;
  20800. private _cachedUOffset;
  20801. private _cachedVOffset;
  20802. private _cachedUScale;
  20803. private _cachedVScale;
  20804. private _cachedUAng;
  20805. private _cachedVAng;
  20806. private _cachedWAng;
  20807. private _cachedProjectionMatrixId;
  20808. private _cachedCoordinatesMode;
  20809. /** @hidden */
  20810. protected _initialSamplingMode: number;
  20811. /** @hidden */
  20812. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20813. private _deleteBuffer;
  20814. protected _format: Nullable<number>;
  20815. private _delayedOnLoad;
  20816. private _delayedOnError;
  20817. private _mimeType?;
  20818. /**
  20819. * Observable triggered once the texture has been loaded.
  20820. */
  20821. onLoadObservable: Observable<Texture>;
  20822. protected _isBlocking: boolean;
  20823. /**
  20824. * Is the texture preventing material to render while loading.
  20825. * If false, a default texture will be used instead of the loading one during the preparation step.
  20826. */
  20827. set isBlocking(value: boolean);
  20828. get isBlocking(): boolean;
  20829. /**
  20830. * Get the current sampling mode associated with the texture.
  20831. */
  20832. get samplingMode(): number;
  20833. /**
  20834. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20835. */
  20836. get invertY(): boolean;
  20837. /**
  20838. * Instantiates a new texture.
  20839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20841. * @param url defines the url of the picture to load as a texture
  20842. * @param scene defines the scene or engine the texture will belong to
  20843. * @param noMipmap defines if the texture will require mip maps or not
  20844. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20845. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20846. * @param onLoad defines a callback triggered when the texture has been loaded
  20847. * @param onError defines a callback triggered when an error occurred during the loading session
  20848. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20849. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20850. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20851. * @param mimeType defines an optional mime type information
  20852. */
  20853. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20854. /**
  20855. * Update the url (and optional buffer) of this texture if url was null during construction.
  20856. * @param url the url of the texture
  20857. * @param buffer the buffer of the texture (defaults to null)
  20858. * @param onLoad callback called when the texture is loaded (defaults to null)
  20859. */
  20860. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20861. /**
  20862. * Finish the loading sequence of a texture flagged as delayed load.
  20863. * @hidden
  20864. */
  20865. delayLoad(): void;
  20866. private _prepareRowForTextureGeneration;
  20867. /**
  20868. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20869. * @returns the transform matrix of the texture.
  20870. */
  20871. getTextureMatrix(uBase?: number): Matrix;
  20872. /**
  20873. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20874. * @returns The reflection texture transform
  20875. */
  20876. getReflectionTextureMatrix(): Matrix;
  20877. /**
  20878. * Clones the texture.
  20879. * @returns the cloned texture
  20880. */
  20881. clone(): Texture;
  20882. /**
  20883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20884. * @returns The JSON representation of the texture
  20885. */
  20886. serialize(): any;
  20887. /**
  20888. * Get the current class name of the texture useful for serialization or dynamic coding.
  20889. * @returns "Texture"
  20890. */
  20891. getClassName(): string;
  20892. /**
  20893. * Dispose the texture and release its associated resources.
  20894. */
  20895. dispose(): void;
  20896. /**
  20897. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20898. * @param parsedTexture Define the JSON representation of the texture
  20899. * @param scene Define the scene the parsed texture should be instantiated in
  20900. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20901. * @returns The parsed texture if successful
  20902. */
  20903. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20904. /**
  20905. * Creates a texture from its base 64 representation.
  20906. * @param data Define the base64 payload without the data: prefix
  20907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20908. * @param scene Define the scene the texture should belong to
  20909. * @param noMipmap Forces the texture to not create mip map information if true
  20910. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20911. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20912. * @param onLoad define a callback triggered when the texture has been loaded
  20913. * @param onError define a callback triggered when an error occurred during the loading session
  20914. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20915. * @returns the created texture
  20916. */
  20917. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20918. /**
  20919. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20920. * @param data Define the base64 payload without the data: prefix
  20921. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20922. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20923. * @param scene Define the scene the texture should belong to
  20924. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20925. * @param noMipmap Forces the texture to not create mip map information if true
  20926. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20927. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20928. * @param onLoad define a callback triggered when the texture has been loaded
  20929. * @param onError define a callback triggered when an error occurred during the loading session
  20930. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20931. * @returns the created texture
  20932. */
  20933. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  20934. }
  20935. }
  20936. declare module "babylonjs/PostProcesses/postProcessManager" {
  20937. import { Nullable } from "babylonjs/types";
  20938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20940. import { Scene } from "babylonjs/scene";
  20941. /**
  20942. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20943. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20944. */
  20945. export class PostProcessManager {
  20946. private _scene;
  20947. private _indexBuffer;
  20948. private _vertexBuffers;
  20949. /**
  20950. * Creates a new instance PostProcess
  20951. * @param scene The scene that the post process is associated with.
  20952. */
  20953. constructor(scene: Scene);
  20954. private _prepareBuffers;
  20955. private _buildIndexBuffer;
  20956. /**
  20957. * Rebuilds the vertex buffers of the manager.
  20958. * @hidden
  20959. */
  20960. _rebuild(): void;
  20961. /**
  20962. * Prepares a frame to be run through a post process.
  20963. * @param sourceTexture The input texture to the post procesess. (default: null)
  20964. * @param postProcesses An array of post processes to be run. (default: null)
  20965. * @returns True if the post processes were able to be run.
  20966. * @hidden
  20967. */
  20968. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20969. /**
  20970. * Manually render a set of post processes to a texture.
  20971. * @param postProcesses An array of post processes to be run.
  20972. * @param targetTexture The target texture to render to.
  20973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20975. * @param lodLevel defines which lod of the texture to render to
  20976. */
  20977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20978. /**
  20979. * Finalize the result of the output of the postprocesses.
  20980. * @param doNotPresent If true the result will not be displayed to the screen.
  20981. * @param targetTexture The target texture to render to.
  20982. * @param faceIndex The index of the face to bind the target texture to.
  20983. * @param postProcesses The array of post processes to render.
  20984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20985. * @hidden
  20986. */
  20987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20988. /**
  20989. * Disposes of the post process manager.
  20990. */
  20991. dispose(): void;
  20992. }
  20993. }
  20994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20995. import { Observable } from "babylonjs/Misc/observable";
  20996. import { SmartArray } from "babylonjs/Misc/smartArray";
  20997. import { Nullable, Immutable } from "babylonjs/types";
  20998. import { Camera } from "babylonjs/Cameras/camera";
  20999. import { Scene } from "babylonjs/scene";
  21000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21001. import { Color4 } from "babylonjs/Maths/math.color";
  21002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21006. import { Texture } from "babylonjs/Materials/Textures/texture";
  21007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21011. import { Engine } from "babylonjs/Engines/engine";
  21012. /**
  21013. * This Helps creating a texture that will be created from a camera in your scene.
  21014. * It is basically a dynamic texture that could be used to create special effects for instance.
  21015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21016. */
  21017. export class RenderTargetTexture extends Texture {
  21018. isCube: boolean;
  21019. /**
  21020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21021. */
  21022. static readonly REFRESHRATE_RENDER_ONCE: number;
  21023. /**
  21024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21025. */
  21026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21027. /**
  21028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21029. * the central point of your effect and can save a lot of performances.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21032. /**
  21033. * Use this predicate to dynamically define the list of mesh you want to render.
  21034. * If set, the renderList property will be overwritten.
  21035. */
  21036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21037. private _renderList;
  21038. /**
  21039. * Use this list to define the list of mesh you want to render.
  21040. */
  21041. get renderList(): Nullable<Array<AbstractMesh>>;
  21042. set renderList(value: Nullable<Array<AbstractMesh>>);
  21043. /**
  21044. * Use this function to overload the renderList array at rendering time.
  21045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21047. * the cube (if the RTT is a cube, else layerOrFace=0).
  21048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21049. */
  21050. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21051. private _hookArray;
  21052. /**
  21053. * Define if particles should be rendered in your texture.
  21054. */
  21055. renderParticles: boolean;
  21056. /**
  21057. * Define if sprites should be rendered in your texture.
  21058. */
  21059. renderSprites: boolean;
  21060. /**
  21061. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21062. */
  21063. coordinatesMode: number;
  21064. /**
  21065. * Define the camera used to render the texture.
  21066. */
  21067. activeCamera: Nullable<Camera>;
  21068. /**
  21069. * Override the render function of the texture with your own one.
  21070. */
  21071. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21072. /**
  21073. * Define if camera post processes should be use while rendering the texture.
  21074. */
  21075. useCameraPostProcesses: boolean;
  21076. /**
  21077. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21078. */
  21079. ignoreCameraViewport: boolean;
  21080. private _postProcessManager;
  21081. private _postProcesses;
  21082. private _resizeObserver;
  21083. /**
  21084. * An event triggered when the texture is unbind.
  21085. */
  21086. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21087. /**
  21088. * An event triggered when the texture is unbind.
  21089. */
  21090. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21091. private _onAfterUnbindObserver;
  21092. /**
  21093. * Set a after unbind callback in the texture.
  21094. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21095. */
  21096. set onAfterUnbind(callback: () => void);
  21097. /**
  21098. * An event triggered before rendering the texture
  21099. */
  21100. onBeforeRenderObservable: Observable<number>;
  21101. private _onBeforeRenderObserver;
  21102. /**
  21103. * Set a before render callback in the texture.
  21104. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21105. */
  21106. set onBeforeRender(callback: (faceIndex: number) => void);
  21107. /**
  21108. * An event triggered after rendering the texture
  21109. */
  21110. onAfterRenderObservable: Observable<number>;
  21111. private _onAfterRenderObserver;
  21112. /**
  21113. * Set a after render callback in the texture.
  21114. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21115. */
  21116. set onAfterRender(callback: (faceIndex: number) => void);
  21117. /**
  21118. * An event triggered after the texture clear
  21119. */
  21120. onClearObservable: Observable<Engine>;
  21121. private _onClearObserver;
  21122. /**
  21123. * Set a clear callback in the texture.
  21124. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21125. */
  21126. set onClear(callback: (Engine: Engine) => void);
  21127. /**
  21128. * An event triggered when the texture is resized.
  21129. */
  21130. onResizeObservable: Observable<RenderTargetTexture>;
  21131. /**
  21132. * Define the clear color of the Render Target if it should be different from the scene.
  21133. */
  21134. clearColor: Color4;
  21135. protected _size: number | {
  21136. width: number;
  21137. height: number;
  21138. layers?: number;
  21139. };
  21140. protected _initialSizeParameter: number | {
  21141. width: number;
  21142. height: number;
  21143. } | {
  21144. ratio: number;
  21145. };
  21146. protected _sizeRatio: Nullable<number>;
  21147. /** @hidden */
  21148. _generateMipMaps: boolean;
  21149. protected _renderingManager: RenderingManager;
  21150. /** @hidden */
  21151. _waitingRenderList: string[];
  21152. protected _doNotChangeAspectRatio: boolean;
  21153. protected _currentRefreshId: number;
  21154. protected _refreshRate: number;
  21155. protected _textureMatrix: Matrix;
  21156. protected _samples: number;
  21157. protected _renderTargetOptions: RenderTargetCreationOptions;
  21158. /**
  21159. * Gets render target creation options that were used.
  21160. */
  21161. get renderTargetOptions(): RenderTargetCreationOptions;
  21162. protected _engine: Engine;
  21163. protected _onRatioRescale(): void;
  21164. /**
  21165. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21166. * It must define where the camera used to render the texture is set
  21167. */
  21168. boundingBoxPosition: Vector3;
  21169. private _boundingBoxSize;
  21170. /**
  21171. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21172. * When defined, the cubemap will switch to local mode
  21173. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21174. * @example https://www.babylonjs-playground.com/#RNASML
  21175. */
  21176. set boundingBoxSize(value: Vector3);
  21177. get boundingBoxSize(): Vector3;
  21178. /**
  21179. * In case the RTT has been created with a depth texture, get the associated
  21180. * depth texture.
  21181. * Otherwise, return null.
  21182. */
  21183. get depthStencilTexture(): Nullable<InternalTexture>;
  21184. /**
  21185. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21186. * or used a shadow, depth texture...
  21187. * @param name The friendly name of the texture
  21188. * @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)
  21189. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21190. * @param generateMipMaps True if mip maps need to be generated after render.
  21191. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21192. * @param type The type of the buffer in the RTT (int, half float, float...)
  21193. * @param isCube True if a cube texture needs to be created
  21194. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21195. * @param generateDepthBuffer True to generate a depth buffer
  21196. * @param generateStencilBuffer True to generate a stencil buffer
  21197. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21198. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21199. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21200. */
  21201. constructor(name: string, size: number | {
  21202. width: number;
  21203. height: number;
  21204. layers?: number;
  21205. } | {
  21206. ratio: number;
  21207. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21208. /**
  21209. * Creates a depth stencil texture.
  21210. * This is only available in WebGL 2 or with the depth texture extension available.
  21211. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21212. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21213. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21214. */
  21215. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21216. private _processSizeParameter;
  21217. /**
  21218. * Define the number of samples to use in case of MSAA.
  21219. * It defaults to one meaning no MSAA has been enabled.
  21220. */
  21221. get samples(): number;
  21222. set samples(value: number);
  21223. /**
  21224. * Resets the refresh counter of the texture and start bak from scratch.
  21225. * Could be useful to regenerate the texture if it is setup to render only once.
  21226. */
  21227. resetRefreshCounter(): void;
  21228. /**
  21229. * Define the refresh rate of the texture or the rendering frequency.
  21230. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21231. */
  21232. get refreshRate(): number;
  21233. set refreshRate(value: number);
  21234. /**
  21235. * Adds a post process to the render target rendering passes.
  21236. * @param postProcess define the post process to add
  21237. */
  21238. addPostProcess(postProcess: PostProcess): void;
  21239. /**
  21240. * Clear all the post processes attached to the render target
  21241. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21242. */
  21243. clearPostProcesses(dispose?: boolean): void;
  21244. /**
  21245. * Remove one of the post process from the list of attached post processes to the texture
  21246. * @param postProcess define the post process to remove from the list
  21247. */
  21248. removePostProcess(postProcess: PostProcess): void;
  21249. /** @hidden */
  21250. _shouldRender(): boolean;
  21251. /**
  21252. * Gets the actual render size of the texture.
  21253. * @returns the width of the render size
  21254. */
  21255. getRenderSize(): number;
  21256. /**
  21257. * Gets the actual render width of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderWidth(): number;
  21261. /**
  21262. * Gets the actual render height of the texture.
  21263. * @returns the height of the render size
  21264. */
  21265. getRenderHeight(): number;
  21266. /**
  21267. * Gets the actual number of layers of the texture.
  21268. * @returns the number of layers
  21269. */
  21270. getRenderLayers(): number;
  21271. /**
  21272. * Get if the texture can be rescaled or not.
  21273. */
  21274. get canRescale(): boolean;
  21275. /**
  21276. * Resize the texture using a ratio.
  21277. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21278. */
  21279. scale(ratio: number): void;
  21280. /**
  21281. * Get the texture reflection matrix used to rotate/transform the reflection.
  21282. * @returns the reflection matrix
  21283. */
  21284. getReflectionTextureMatrix(): Matrix;
  21285. /**
  21286. * Resize the texture to a new desired size.
  21287. * Be carrefull as it will recreate all the data in the new texture.
  21288. * @param size Define the new size. It can be:
  21289. * - a number for squared texture,
  21290. * - an object containing { width: number, height: number }
  21291. * - or an object containing a ratio { ratio: number }
  21292. */
  21293. resize(size: number | {
  21294. width: number;
  21295. height: number;
  21296. } | {
  21297. ratio: number;
  21298. }): void;
  21299. private _defaultRenderListPrepared;
  21300. /**
  21301. * Renders all the objects from the render list into the texture.
  21302. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21303. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21304. */
  21305. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21306. private _bestReflectionRenderTargetDimension;
  21307. private _prepareRenderingManager;
  21308. /**
  21309. * @hidden
  21310. * @param faceIndex face index to bind to if this is a cubetexture
  21311. * @param layer defines the index of the texture to bind in the array
  21312. */
  21313. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21315. private renderToTarget;
  21316. /**
  21317. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21318. * This allowed control for front to back rendering or reversly depending of the special needs.
  21319. *
  21320. * @param renderingGroupId The rendering group id corresponding to its index
  21321. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21322. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21323. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21324. */
  21325. 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;
  21326. /**
  21327. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21328. *
  21329. * @param renderingGroupId The rendering group id corresponding to its index
  21330. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21331. */
  21332. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21333. /**
  21334. * Clones the texture.
  21335. * @returns the cloned texture
  21336. */
  21337. clone(): RenderTargetTexture;
  21338. /**
  21339. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21340. * @returns The JSON representation of the texture
  21341. */
  21342. serialize(): any;
  21343. /**
  21344. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21345. */
  21346. disposeFramebufferObjects(): void;
  21347. /**
  21348. * Dispose the texture and release its associated resources.
  21349. */
  21350. dispose(): void;
  21351. /** @hidden */
  21352. _rebuild(): void;
  21353. /**
  21354. * Clear the info related to rendering groups preventing retention point in material dispose.
  21355. */
  21356. freeRenderingGroups(): void;
  21357. /**
  21358. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21359. * @returns the view count
  21360. */
  21361. getViewCount(): number;
  21362. }
  21363. }
  21364. declare module "babylonjs/Materials/material" {
  21365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21366. import { SmartArray } from "babylonjs/Misc/smartArray";
  21367. import { Observable } from "babylonjs/Misc/observable";
  21368. import { Nullable } from "babylonjs/types";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { Matrix } from "babylonjs/Maths/math.vector";
  21371. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21373. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21374. import { Effect } from "babylonjs/Materials/effect";
  21375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21377. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21378. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21379. import { Mesh } from "babylonjs/Meshes/mesh";
  21380. import { Animation } from "babylonjs/Animations/animation";
  21381. /**
  21382. * Options for compiling materials.
  21383. */
  21384. export interface IMaterialCompilationOptions {
  21385. /**
  21386. * Defines whether clip planes are enabled.
  21387. */
  21388. clipPlane: boolean;
  21389. /**
  21390. * Defines whether instances are enabled.
  21391. */
  21392. useInstances: boolean;
  21393. }
  21394. /**
  21395. * Base class for the main features of a material in Babylon.js
  21396. */
  21397. export class Material implements IAnimatable {
  21398. /**
  21399. * Returns the triangle fill mode
  21400. */
  21401. static readonly TriangleFillMode: number;
  21402. /**
  21403. * Returns the wireframe mode
  21404. */
  21405. static readonly WireFrameFillMode: number;
  21406. /**
  21407. * Returns the point fill mode
  21408. */
  21409. static readonly PointFillMode: number;
  21410. /**
  21411. * Returns the point list draw mode
  21412. */
  21413. static readonly PointListDrawMode: number;
  21414. /**
  21415. * Returns the line list draw mode
  21416. */
  21417. static readonly LineListDrawMode: number;
  21418. /**
  21419. * Returns the line loop draw mode
  21420. */
  21421. static readonly LineLoopDrawMode: number;
  21422. /**
  21423. * Returns the line strip draw mode
  21424. */
  21425. static readonly LineStripDrawMode: number;
  21426. /**
  21427. * Returns the triangle strip draw mode
  21428. */
  21429. static readonly TriangleStripDrawMode: number;
  21430. /**
  21431. * Returns the triangle fan draw mode
  21432. */
  21433. static readonly TriangleFanDrawMode: number;
  21434. /**
  21435. * Stores the clock-wise side orientation
  21436. */
  21437. static readonly ClockWiseSideOrientation: number;
  21438. /**
  21439. * Stores the counter clock-wise side orientation
  21440. */
  21441. static readonly CounterClockWiseSideOrientation: number;
  21442. /**
  21443. * The dirty texture flag value
  21444. */
  21445. static readonly TextureDirtyFlag: number;
  21446. /**
  21447. * The dirty light flag value
  21448. */
  21449. static readonly LightDirtyFlag: number;
  21450. /**
  21451. * The dirty fresnel flag value
  21452. */
  21453. static readonly FresnelDirtyFlag: number;
  21454. /**
  21455. * The dirty attribute flag value
  21456. */
  21457. static readonly AttributesDirtyFlag: number;
  21458. /**
  21459. * The dirty misc flag value
  21460. */
  21461. static readonly MiscDirtyFlag: number;
  21462. /**
  21463. * The all dirty flag value
  21464. */
  21465. static readonly AllDirtyFlag: number;
  21466. /**
  21467. * The ID of the material
  21468. */
  21469. id: string;
  21470. /**
  21471. * Gets or sets the unique id of the material
  21472. */
  21473. uniqueId: number;
  21474. /**
  21475. * The name of the material
  21476. */
  21477. name: string;
  21478. /**
  21479. * Gets or sets user defined metadata
  21480. */
  21481. metadata: any;
  21482. /**
  21483. * For internal use only. Please do not use.
  21484. */
  21485. reservedDataStore: any;
  21486. /**
  21487. * Specifies if the ready state should be checked on each call
  21488. */
  21489. checkReadyOnEveryCall: boolean;
  21490. /**
  21491. * Specifies if the ready state should be checked once
  21492. */
  21493. checkReadyOnlyOnce: boolean;
  21494. /**
  21495. * The state of the material
  21496. */
  21497. state: string;
  21498. /**
  21499. * The alpha value of the material
  21500. */
  21501. protected _alpha: number;
  21502. /**
  21503. * List of inspectable custom properties (used by the Inspector)
  21504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21505. */
  21506. inspectableCustomProperties: IInspectable[];
  21507. /**
  21508. * Sets the alpha value of the material
  21509. */
  21510. set alpha(value: number);
  21511. /**
  21512. * Gets the alpha value of the material
  21513. */
  21514. get alpha(): number;
  21515. /**
  21516. * Specifies if back face culling is enabled
  21517. */
  21518. protected _backFaceCulling: boolean;
  21519. /**
  21520. * Sets the back-face culling state
  21521. */
  21522. set backFaceCulling(value: boolean);
  21523. /**
  21524. * Gets the back-face culling state
  21525. */
  21526. get backFaceCulling(): boolean;
  21527. /**
  21528. * Stores the value for side orientation
  21529. */
  21530. sideOrientation: number;
  21531. /**
  21532. * Callback triggered when the material is compiled
  21533. */
  21534. onCompiled: Nullable<(effect: Effect) => void>;
  21535. /**
  21536. * Callback triggered when an error occurs
  21537. */
  21538. onError: Nullable<(effect: Effect, errors: string) => void>;
  21539. /**
  21540. * Callback triggered to get the render target textures
  21541. */
  21542. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21543. /**
  21544. * Gets a boolean indicating that current material needs to register RTT
  21545. */
  21546. get hasRenderTargetTextures(): boolean;
  21547. /**
  21548. * Specifies if the material should be serialized
  21549. */
  21550. doNotSerialize: boolean;
  21551. /**
  21552. * @hidden
  21553. */
  21554. _storeEffectOnSubMeshes: boolean;
  21555. /**
  21556. * Stores the animations for the material
  21557. */
  21558. animations: Nullable<Array<Animation>>;
  21559. /**
  21560. * An event triggered when the material is disposed
  21561. */
  21562. onDisposeObservable: Observable<Material>;
  21563. /**
  21564. * An observer which watches for dispose events
  21565. */
  21566. private _onDisposeObserver;
  21567. private _onUnBindObservable;
  21568. /**
  21569. * Called during a dispose event
  21570. */
  21571. set onDispose(callback: () => void);
  21572. private _onBindObservable;
  21573. /**
  21574. * An event triggered when the material is bound
  21575. */
  21576. get onBindObservable(): Observable<AbstractMesh>;
  21577. /**
  21578. * An observer which watches for bind events
  21579. */
  21580. private _onBindObserver;
  21581. /**
  21582. * Called during a bind event
  21583. */
  21584. set onBind(callback: (Mesh: AbstractMesh) => void);
  21585. /**
  21586. * An event triggered when the material is unbound
  21587. */
  21588. get onUnBindObservable(): Observable<Material>;
  21589. /**
  21590. * Stores the value of the alpha mode
  21591. */
  21592. private _alphaMode;
  21593. /**
  21594. * Sets the value of the alpha mode.
  21595. *
  21596. * | Value | Type | Description |
  21597. * | --- | --- | --- |
  21598. * | 0 | ALPHA_DISABLE | |
  21599. * | 1 | ALPHA_ADD | |
  21600. * | 2 | ALPHA_COMBINE | |
  21601. * | 3 | ALPHA_SUBTRACT | |
  21602. * | 4 | ALPHA_MULTIPLY | |
  21603. * | 5 | ALPHA_MAXIMIZED | |
  21604. * | 6 | ALPHA_ONEONE | |
  21605. * | 7 | ALPHA_PREMULTIPLIED | |
  21606. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21607. * | 9 | ALPHA_INTERPOLATE | |
  21608. * | 10 | ALPHA_SCREENMODE | |
  21609. *
  21610. */
  21611. set alphaMode(value: number);
  21612. /**
  21613. * Gets the value of the alpha mode
  21614. */
  21615. get alphaMode(): number;
  21616. /**
  21617. * Stores the state of the need depth pre-pass value
  21618. */
  21619. private _needDepthPrePass;
  21620. /**
  21621. * Sets the need depth pre-pass value
  21622. */
  21623. set needDepthPrePass(value: boolean);
  21624. /**
  21625. * Gets the depth pre-pass value
  21626. */
  21627. get needDepthPrePass(): boolean;
  21628. /**
  21629. * Specifies if depth writing should be disabled
  21630. */
  21631. disableDepthWrite: boolean;
  21632. /**
  21633. * Specifies if depth writing should be forced
  21634. */
  21635. forceDepthWrite: boolean;
  21636. /**
  21637. * Specifies the depth function that should be used. 0 means the default engine function
  21638. */
  21639. depthFunction: number;
  21640. /**
  21641. * Specifies if there should be a separate pass for culling
  21642. */
  21643. separateCullingPass: boolean;
  21644. /**
  21645. * Stores the state specifing if fog should be enabled
  21646. */
  21647. private _fogEnabled;
  21648. /**
  21649. * Sets the state for enabling fog
  21650. */
  21651. set fogEnabled(value: boolean);
  21652. /**
  21653. * Gets the value of the fog enabled state
  21654. */
  21655. get fogEnabled(): boolean;
  21656. /**
  21657. * Stores the size of points
  21658. */
  21659. pointSize: number;
  21660. /**
  21661. * Stores the z offset value
  21662. */
  21663. zOffset: number;
  21664. /**
  21665. * Gets a value specifying if wireframe mode is enabled
  21666. */
  21667. get wireframe(): boolean;
  21668. /**
  21669. * Sets the state of wireframe mode
  21670. */
  21671. set wireframe(value: boolean);
  21672. /**
  21673. * Gets the value specifying if point clouds are enabled
  21674. */
  21675. get pointsCloud(): boolean;
  21676. /**
  21677. * Sets the state of point cloud mode
  21678. */
  21679. set pointsCloud(value: boolean);
  21680. /**
  21681. * Gets the material fill mode
  21682. */
  21683. get fillMode(): number;
  21684. /**
  21685. * Sets the material fill mode
  21686. */
  21687. set fillMode(value: number);
  21688. /**
  21689. * @hidden
  21690. * Stores the effects for the material
  21691. */
  21692. _effect: Nullable<Effect>;
  21693. /**
  21694. * Specifies if uniform buffers should be used
  21695. */
  21696. private _useUBO;
  21697. /**
  21698. * Stores a reference to the scene
  21699. */
  21700. private _scene;
  21701. /**
  21702. * Stores the fill mode state
  21703. */
  21704. private _fillMode;
  21705. /**
  21706. * Specifies if the depth write state should be cached
  21707. */
  21708. private _cachedDepthWriteState;
  21709. /**
  21710. * Specifies if the depth function state should be cached
  21711. */
  21712. private _cachedDepthFunctionState;
  21713. /**
  21714. * Stores the uniform buffer
  21715. */
  21716. protected _uniformBuffer: UniformBuffer;
  21717. /** @hidden */
  21718. _indexInSceneMaterialArray: number;
  21719. /** @hidden */
  21720. meshMap: Nullable<{
  21721. [id: string]: AbstractMesh | undefined;
  21722. }>;
  21723. /**
  21724. * Creates a material instance
  21725. * @param name defines the name of the material
  21726. * @param scene defines the scene to reference
  21727. * @param doNotAdd specifies if the material should be added to the scene
  21728. */
  21729. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21730. /**
  21731. * Returns a string representation of the current material
  21732. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21733. * @returns a string with material information
  21734. */
  21735. toString(fullDetails?: boolean): string;
  21736. /**
  21737. * Gets the class name of the material
  21738. * @returns a string with the class name of the material
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Specifies if updates for the material been locked
  21743. */
  21744. get isFrozen(): boolean;
  21745. /**
  21746. * Locks updates for the material
  21747. */
  21748. freeze(): void;
  21749. /**
  21750. * Unlocks updates for the material
  21751. */
  21752. unfreeze(): void;
  21753. /**
  21754. * Specifies if the material is ready to be used
  21755. * @param mesh defines the mesh to check
  21756. * @param useInstances specifies if instances should be used
  21757. * @returns a boolean indicating if the material is ready to be used
  21758. */
  21759. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21760. /**
  21761. * Specifies that the submesh is ready to be used
  21762. * @param mesh defines the mesh to check
  21763. * @param subMesh defines which submesh to check
  21764. * @param useInstances specifies that instances should be used
  21765. * @returns a boolean indicating that the submesh is ready or not
  21766. */
  21767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21768. /**
  21769. * Returns the material effect
  21770. * @returns the effect associated with the material
  21771. */
  21772. getEffect(): Nullable<Effect>;
  21773. /**
  21774. * Returns the current scene
  21775. * @returns a Scene
  21776. */
  21777. getScene(): Scene;
  21778. /**
  21779. * Specifies if the material will require alpha blending
  21780. * @returns a boolean specifying if alpha blending is needed
  21781. */
  21782. needAlphaBlending(): boolean;
  21783. /**
  21784. * Specifies if the mesh will require alpha blending
  21785. * @param mesh defines the mesh to check
  21786. * @returns a boolean specifying if alpha blending is needed for the mesh
  21787. */
  21788. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21789. /**
  21790. * Specifies if this material should be rendered in alpha test mode
  21791. * @returns a boolean specifying if an alpha test is needed.
  21792. */
  21793. needAlphaTesting(): boolean;
  21794. /**
  21795. * Gets the texture used for the alpha test
  21796. * @returns the texture to use for alpha testing
  21797. */
  21798. getAlphaTestTexture(): Nullable<BaseTexture>;
  21799. /**
  21800. * Marks the material to indicate that it needs to be re-calculated
  21801. */
  21802. markDirty(): void;
  21803. /** @hidden */
  21804. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21805. /**
  21806. * Binds the material to the mesh
  21807. * @param world defines the world transformation matrix
  21808. * @param mesh defines the mesh to bind the material to
  21809. */
  21810. bind(world: Matrix, mesh?: Mesh): void;
  21811. /**
  21812. * Binds the submesh to the material
  21813. * @param world defines the world transformation matrix
  21814. * @param mesh defines the mesh containing the submesh
  21815. * @param subMesh defines the submesh to bind the material to
  21816. */
  21817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21818. /**
  21819. * Binds the world matrix to the material
  21820. * @param world defines the world transformation matrix
  21821. */
  21822. bindOnlyWorldMatrix(world: Matrix): void;
  21823. /**
  21824. * Binds the scene's uniform buffer to the effect.
  21825. * @param effect defines the effect to bind to the scene uniform buffer
  21826. * @param sceneUbo defines the uniform buffer storing scene data
  21827. */
  21828. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21829. /**
  21830. * Binds the view matrix to the effect
  21831. * @param effect defines the effect to bind the view matrix to
  21832. */
  21833. bindView(effect: Effect): void;
  21834. /**
  21835. * Binds the view projection matrix to the effect
  21836. * @param effect defines the effect to bind the view projection matrix to
  21837. */
  21838. bindViewProjection(effect: Effect): void;
  21839. /**
  21840. * Specifies if material alpha testing should be turned on for the mesh
  21841. * @param mesh defines the mesh to check
  21842. */
  21843. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21844. /**
  21845. * Processes to execute after binding the material to a mesh
  21846. * @param mesh defines the rendered mesh
  21847. */
  21848. protected _afterBind(mesh?: Mesh): void;
  21849. /**
  21850. * Unbinds the material from the mesh
  21851. */
  21852. unbind(): void;
  21853. /**
  21854. * Gets the active textures from the material
  21855. * @returns an array of textures
  21856. */
  21857. getActiveTextures(): BaseTexture[];
  21858. /**
  21859. * Specifies if the material uses a texture
  21860. * @param texture defines the texture to check against the material
  21861. * @returns a boolean specifying if the material uses the texture
  21862. */
  21863. hasTexture(texture: BaseTexture): boolean;
  21864. /**
  21865. * Makes a duplicate of the material, and gives it a new name
  21866. * @param name defines the new name for the duplicated material
  21867. * @returns the cloned material
  21868. */
  21869. clone(name: string): Nullable<Material>;
  21870. /**
  21871. * Gets the meshes bound to the material
  21872. * @returns an array of meshes bound to the material
  21873. */
  21874. getBindedMeshes(): AbstractMesh[];
  21875. /**
  21876. * Force shader compilation
  21877. * @param mesh defines the mesh associated with this material
  21878. * @param onCompiled defines a function to execute once the material is compiled
  21879. * @param options defines the options to configure the compilation
  21880. * @param onError defines a function to execute if the material fails compiling
  21881. */
  21882. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21883. /**
  21884. * Force shader compilation
  21885. * @param mesh defines the mesh that will use this material
  21886. * @param options defines additional options for compiling the shaders
  21887. * @returns a promise that resolves when the compilation completes
  21888. */
  21889. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21890. private static readonly _AllDirtyCallBack;
  21891. private static readonly _ImageProcessingDirtyCallBack;
  21892. private static readonly _TextureDirtyCallBack;
  21893. private static readonly _FresnelDirtyCallBack;
  21894. private static readonly _MiscDirtyCallBack;
  21895. private static readonly _LightsDirtyCallBack;
  21896. private static readonly _AttributeDirtyCallBack;
  21897. private static _FresnelAndMiscDirtyCallBack;
  21898. private static _TextureAndMiscDirtyCallBack;
  21899. private static readonly _DirtyCallbackArray;
  21900. private static readonly _RunDirtyCallBacks;
  21901. /**
  21902. * Marks a define in the material to indicate that it needs to be re-computed
  21903. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21904. */
  21905. markAsDirty(flag: number): void;
  21906. /**
  21907. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21908. * @param func defines a function which checks material defines against the submeshes
  21909. */
  21910. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21911. /**
  21912. * Indicates that we need to re-calculated for all submeshes
  21913. */
  21914. protected _markAllSubMeshesAsAllDirty(): void;
  21915. /**
  21916. * Indicates that image processing needs to be re-calculated for all submeshes
  21917. */
  21918. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21919. /**
  21920. * Indicates that textures need to be re-calculated for all submeshes
  21921. */
  21922. protected _markAllSubMeshesAsTexturesDirty(): void;
  21923. /**
  21924. * Indicates that fresnel needs to be re-calculated for all submeshes
  21925. */
  21926. protected _markAllSubMeshesAsFresnelDirty(): void;
  21927. /**
  21928. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21929. */
  21930. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21931. /**
  21932. * Indicates that lights need to be re-calculated for all submeshes
  21933. */
  21934. protected _markAllSubMeshesAsLightsDirty(): void;
  21935. /**
  21936. * Indicates that attributes need to be re-calculated for all submeshes
  21937. */
  21938. protected _markAllSubMeshesAsAttributesDirty(): void;
  21939. /**
  21940. * Indicates that misc needs to be re-calculated for all submeshes
  21941. */
  21942. protected _markAllSubMeshesAsMiscDirty(): void;
  21943. /**
  21944. * Indicates that textures and misc need to be re-calculated for all submeshes
  21945. */
  21946. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21947. /**
  21948. * Disposes the material
  21949. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21950. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21951. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21952. */
  21953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21954. /** @hidden */
  21955. private releaseVertexArrayObject;
  21956. /**
  21957. * Serializes this material
  21958. * @returns the serialized material object
  21959. */
  21960. serialize(): any;
  21961. /**
  21962. * Creates a material from parsed material data
  21963. * @param parsedMaterial defines parsed material data
  21964. * @param scene defines the hosting scene
  21965. * @param rootUrl defines the root URL to use to load textures
  21966. * @returns a new material
  21967. */
  21968. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21969. }
  21970. }
  21971. declare module "babylonjs/Materials/multiMaterial" {
  21972. import { Nullable } from "babylonjs/types";
  21973. import { Scene } from "babylonjs/scene";
  21974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21975. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21977. import { Material } from "babylonjs/Materials/material";
  21978. /**
  21979. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21980. * separate meshes. This can be use to improve performances.
  21981. * @see http://doc.babylonjs.com/how_to/multi_materials
  21982. */
  21983. export class MultiMaterial extends Material {
  21984. private _subMaterials;
  21985. /**
  21986. * Gets or Sets the list of Materials used within the multi material.
  21987. * They need to be ordered according to the submeshes order in the associated mesh
  21988. */
  21989. get subMaterials(): Nullable<Material>[];
  21990. set subMaterials(value: Nullable<Material>[]);
  21991. /**
  21992. * Function used to align with Node.getChildren()
  21993. * @returns the list of Materials used within the multi material
  21994. */
  21995. getChildren(): Nullable<Material>[];
  21996. /**
  21997. * Instantiates a new Multi Material
  21998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21999. * separate meshes. This can be use to improve performances.
  22000. * @see http://doc.babylonjs.com/how_to/multi_materials
  22001. * @param name Define the name in the scene
  22002. * @param scene Define the scene the material belongs to
  22003. */
  22004. constructor(name: string, scene: Scene);
  22005. private _hookArray;
  22006. /**
  22007. * Get one of the submaterial by its index in the submaterials array
  22008. * @param index The index to look the sub material at
  22009. * @returns The Material if the index has been defined
  22010. */
  22011. getSubMaterial(index: number): Nullable<Material>;
  22012. /**
  22013. * Get the list of active textures for the whole sub materials list.
  22014. * @returns All the textures that will be used during the rendering
  22015. */
  22016. getActiveTextures(): BaseTexture[];
  22017. /**
  22018. * Gets the current class name of the material e.g. "MultiMaterial"
  22019. * Mainly use in serialization.
  22020. * @returns the class name
  22021. */
  22022. getClassName(): string;
  22023. /**
  22024. * Checks if the material is ready to render the requested sub mesh
  22025. * @param mesh Define the mesh the submesh belongs to
  22026. * @param subMesh Define the sub mesh to look readyness for
  22027. * @param useInstances Define whether or not the material is used with instances
  22028. * @returns true if ready, otherwise false
  22029. */
  22030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22031. /**
  22032. * Clones the current material and its related sub materials
  22033. * @param name Define the name of the newly cloned material
  22034. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22035. * @returns the cloned material
  22036. */
  22037. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22038. /**
  22039. * Serializes the materials into a JSON representation.
  22040. * @returns the JSON representation
  22041. */
  22042. serialize(): any;
  22043. /**
  22044. * Dispose the material and release its associated resources
  22045. * @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)
  22046. * @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)
  22047. * @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)
  22048. */
  22049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22050. /**
  22051. * Creates a MultiMaterial from parsed MultiMaterial data.
  22052. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22053. * @param scene defines the hosting scene
  22054. * @returns a new MultiMaterial
  22055. */
  22056. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22057. }
  22058. }
  22059. declare module "babylonjs/Meshes/subMesh" {
  22060. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22062. import { Engine } from "babylonjs/Engines/engine";
  22063. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22064. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22065. import { Effect } from "babylonjs/Materials/effect";
  22066. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22067. import { Plane } from "babylonjs/Maths/math.plane";
  22068. import { Collider } from "babylonjs/Collisions/collider";
  22069. import { Material } from "babylonjs/Materials/material";
  22070. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22072. import { Mesh } from "babylonjs/Meshes/mesh";
  22073. import { Ray } from "babylonjs/Culling/ray";
  22074. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22075. /**
  22076. * Base class for submeshes
  22077. */
  22078. export class BaseSubMesh {
  22079. /** @hidden */
  22080. _materialDefines: Nullable<MaterialDefines>;
  22081. /** @hidden */
  22082. _materialEffect: Nullable<Effect>;
  22083. /**
  22084. * Gets material defines used by the effect associated to the sub mesh
  22085. */
  22086. get materialDefines(): Nullable<MaterialDefines>;
  22087. /**
  22088. * Sets material defines used by the effect associated to the sub mesh
  22089. */
  22090. set materialDefines(defines: Nullable<MaterialDefines>);
  22091. /**
  22092. * Gets associated effect
  22093. */
  22094. get effect(): Nullable<Effect>;
  22095. /**
  22096. * Sets associated effect (effect used to render this submesh)
  22097. * @param effect defines the effect to associate with
  22098. * @param defines defines the set of defines used to compile this effect
  22099. */
  22100. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22101. }
  22102. /**
  22103. * Defines a subdivision inside a mesh
  22104. */
  22105. export class SubMesh extends BaseSubMesh implements ICullable {
  22106. /** the material index to use */
  22107. materialIndex: number;
  22108. /** vertex index start */
  22109. verticesStart: number;
  22110. /** vertices count */
  22111. verticesCount: number;
  22112. /** index start */
  22113. indexStart: number;
  22114. /** indices count */
  22115. indexCount: number;
  22116. /** @hidden */
  22117. _linesIndexCount: number;
  22118. private _mesh;
  22119. private _renderingMesh;
  22120. private _boundingInfo;
  22121. private _linesIndexBuffer;
  22122. /** @hidden */
  22123. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22124. /** @hidden */
  22125. _trianglePlanes: Plane[];
  22126. /** @hidden */
  22127. _lastColliderTransformMatrix: Nullable<Matrix>;
  22128. /** @hidden */
  22129. _renderId: number;
  22130. /** @hidden */
  22131. _alphaIndex: number;
  22132. /** @hidden */
  22133. _distanceToCamera: number;
  22134. /** @hidden */
  22135. _id: number;
  22136. private _currentMaterial;
  22137. /**
  22138. * Add a new submesh to a mesh
  22139. * @param materialIndex defines the material index to use
  22140. * @param verticesStart defines vertex index start
  22141. * @param verticesCount defines vertices count
  22142. * @param indexStart defines index start
  22143. * @param indexCount defines indices count
  22144. * @param mesh defines the parent mesh
  22145. * @param renderingMesh defines an optional rendering mesh
  22146. * @param createBoundingBox defines if bounding box should be created for this submesh
  22147. * @returns the new submesh
  22148. */
  22149. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22150. /**
  22151. * Creates a new submesh
  22152. * @param materialIndex defines the material index to use
  22153. * @param verticesStart defines vertex index start
  22154. * @param verticesCount defines vertices count
  22155. * @param indexStart defines index start
  22156. * @param indexCount defines indices count
  22157. * @param mesh defines the parent mesh
  22158. * @param renderingMesh defines an optional rendering mesh
  22159. * @param createBoundingBox defines if bounding box should be created for this submesh
  22160. */
  22161. constructor(
  22162. /** the material index to use */
  22163. materialIndex: number,
  22164. /** vertex index start */
  22165. verticesStart: number,
  22166. /** vertices count */
  22167. verticesCount: number,
  22168. /** index start */
  22169. indexStart: number,
  22170. /** indices count */
  22171. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22172. /**
  22173. * Returns true if this submesh covers the entire parent mesh
  22174. * @ignorenaming
  22175. */
  22176. get IsGlobal(): boolean;
  22177. /**
  22178. * Returns the submesh BoudingInfo object
  22179. * @returns current bounding info (or mesh's one if the submesh is global)
  22180. */
  22181. getBoundingInfo(): BoundingInfo;
  22182. /**
  22183. * Sets the submesh BoundingInfo
  22184. * @param boundingInfo defines the new bounding info to use
  22185. * @returns the SubMesh
  22186. */
  22187. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22188. /**
  22189. * Returns the mesh of the current submesh
  22190. * @return the parent mesh
  22191. */
  22192. getMesh(): AbstractMesh;
  22193. /**
  22194. * Returns the rendering mesh of the submesh
  22195. * @returns the rendering mesh (could be different from parent mesh)
  22196. */
  22197. getRenderingMesh(): Mesh;
  22198. /**
  22199. * Returns the submesh material
  22200. * @returns null or the current material
  22201. */
  22202. getMaterial(): Nullable<Material>;
  22203. /**
  22204. * Sets a new updated BoundingInfo object to the submesh
  22205. * @param data defines an optional position array to use to determine the bounding info
  22206. * @returns the SubMesh
  22207. */
  22208. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22209. /** @hidden */
  22210. _checkCollision(collider: Collider): boolean;
  22211. /**
  22212. * Updates the submesh BoundingInfo
  22213. * @param world defines the world matrix to use to update the bounding info
  22214. * @returns the submesh
  22215. */
  22216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22217. /**
  22218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22219. * @param frustumPlanes defines the frustum planes
  22220. * @returns true if the submesh is intersecting with the frustum
  22221. */
  22222. isInFrustum(frustumPlanes: Plane[]): boolean;
  22223. /**
  22224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22225. * @param frustumPlanes defines the frustum planes
  22226. * @returns true if the submesh is inside the frustum
  22227. */
  22228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22229. /**
  22230. * Renders the submesh
  22231. * @param enableAlphaMode defines if alpha needs to be used
  22232. * @returns the submesh
  22233. */
  22234. render(enableAlphaMode: boolean): SubMesh;
  22235. /**
  22236. * @hidden
  22237. */
  22238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22239. /**
  22240. * Checks if the submesh intersects with a ray
  22241. * @param ray defines the ray to test
  22242. * @returns true is the passed ray intersects the submesh bounding box
  22243. */
  22244. canIntersects(ray: Ray): boolean;
  22245. /**
  22246. * Intersects current submesh with a ray
  22247. * @param ray defines the ray to test
  22248. * @param positions defines mesh's positions array
  22249. * @param indices defines mesh's indices array
  22250. * @param fastCheck defines if only bounding info should be used
  22251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22252. * @returns intersection info or null if no intersection
  22253. */
  22254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22255. /** @hidden */
  22256. private _intersectLines;
  22257. /** @hidden */
  22258. private _intersectUnIndexedLines;
  22259. /** @hidden */
  22260. private _intersectTriangles;
  22261. /** @hidden */
  22262. private _intersectUnIndexedTriangles;
  22263. /** @hidden */
  22264. _rebuild(): void;
  22265. /**
  22266. * Creates a new submesh from the passed mesh
  22267. * @param newMesh defines the new hosting mesh
  22268. * @param newRenderingMesh defines an optional rendering mesh
  22269. * @returns the new submesh
  22270. */
  22271. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22272. /**
  22273. * Release associated resources
  22274. */
  22275. dispose(): void;
  22276. /**
  22277. * Gets the class name
  22278. * @returns the string "SubMesh".
  22279. */
  22280. getClassName(): string;
  22281. /**
  22282. * Creates a new submesh from indices data
  22283. * @param materialIndex the index of the main mesh material
  22284. * @param startIndex the index where to start the copy in the mesh indices array
  22285. * @param indexCount the number of indices to copy then from the startIndex
  22286. * @param mesh the main mesh to create the submesh from
  22287. * @param renderingMesh the optional rendering mesh
  22288. * @returns a new submesh
  22289. */
  22290. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22291. }
  22292. }
  22293. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22294. /**
  22295. * Class used to represent data loading progression
  22296. */
  22297. export class SceneLoaderFlags {
  22298. private static _ForceFullSceneLoadingForIncremental;
  22299. private static _ShowLoadingScreen;
  22300. private static _CleanBoneMatrixWeights;
  22301. private static _loggingLevel;
  22302. /**
  22303. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22304. */
  22305. static get ForceFullSceneLoadingForIncremental(): boolean;
  22306. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22307. /**
  22308. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22309. */
  22310. static get ShowLoadingScreen(): boolean;
  22311. static set ShowLoadingScreen(value: boolean);
  22312. /**
  22313. * Defines the current logging level (while loading the scene)
  22314. * @ignorenaming
  22315. */
  22316. static get loggingLevel(): number;
  22317. static set loggingLevel(value: number);
  22318. /**
  22319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22320. */
  22321. static get CleanBoneMatrixWeights(): boolean;
  22322. static set CleanBoneMatrixWeights(value: boolean);
  22323. }
  22324. }
  22325. declare module "babylonjs/Meshes/geometry" {
  22326. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22327. import { Scene } from "babylonjs/scene";
  22328. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22329. import { Engine } from "babylonjs/Engines/engine";
  22330. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22331. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22332. import { Effect } from "babylonjs/Materials/effect";
  22333. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22335. import { Mesh } from "babylonjs/Meshes/mesh";
  22336. /**
  22337. * Class used to store geometry data (vertex buffers + index buffer)
  22338. */
  22339. export class Geometry implements IGetSetVerticesData {
  22340. /**
  22341. * Gets or sets the ID of the geometry
  22342. */
  22343. id: string;
  22344. /**
  22345. * Gets or sets the unique ID of the geometry
  22346. */
  22347. uniqueId: number;
  22348. /**
  22349. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22350. */
  22351. delayLoadState: number;
  22352. /**
  22353. * Gets the file containing the data to load when running in delay load state
  22354. */
  22355. delayLoadingFile: Nullable<string>;
  22356. /**
  22357. * Callback called when the geometry is updated
  22358. */
  22359. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22360. private _scene;
  22361. private _engine;
  22362. private _meshes;
  22363. private _totalVertices;
  22364. /** @hidden */
  22365. _indices: IndicesArray;
  22366. /** @hidden */
  22367. _vertexBuffers: {
  22368. [key: string]: VertexBuffer;
  22369. };
  22370. private _isDisposed;
  22371. private _extend;
  22372. private _boundingBias;
  22373. /** @hidden */
  22374. _delayInfo: Array<string>;
  22375. private _indexBuffer;
  22376. private _indexBufferIsUpdatable;
  22377. /** @hidden */
  22378. _boundingInfo: Nullable<BoundingInfo>;
  22379. /** @hidden */
  22380. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22381. /** @hidden */
  22382. _softwareSkinningFrameId: number;
  22383. private _vertexArrayObjects;
  22384. private _updatable;
  22385. /** @hidden */
  22386. _positions: Nullable<Vector3[]>;
  22387. /**
  22388. * 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
  22389. */
  22390. get boundingBias(): Vector2;
  22391. /**
  22392. * 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
  22393. */
  22394. set boundingBias(value: Vector2);
  22395. /**
  22396. * Static function used to attach a new empty geometry to a mesh
  22397. * @param mesh defines the mesh to attach the geometry to
  22398. * @returns the new Geometry
  22399. */
  22400. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22401. /**
  22402. * Creates a new geometry
  22403. * @param id defines the unique ID
  22404. * @param scene defines the hosting scene
  22405. * @param vertexData defines the VertexData used to get geometry data
  22406. * @param updatable defines if geometry must be updatable (false by default)
  22407. * @param mesh defines the mesh that will be associated with the geometry
  22408. */
  22409. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22410. /**
  22411. * Gets the current extend of the geometry
  22412. */
  22413. get extend(): {
  22414. minimum: Vector3;
  22415. maximum: Vector3;
  22416. };
  22417. /**
  22418. * Gets the hosting scene
  22419. * @returns the hosting Scene
  22420. */
  22421. getScene(): Scene;
  22422. /**
  22423. * Gets the hosting engine
  22424. * @returns the hosting Engine
  22425. */
  22426. getEngine(): Engine;
  22427. /**
  22428. * Defines if the geometry is ready to use
  22429. * @returns true if the geometry is ready to be used
  22430. */
  22431. isReady(): boolean;
  22432. /**
  22433. * Gets a value indicating that the geometry should not be serialized
  22434. */
  22435. get doNotSerialize(): boolean;
  22436. /** @hidden */
  22437. _rebuild(): void;
  22438. /**
  22439. * Affects all geometry data in one call
  22440. * @param vertexData defines the geometry data
  22441. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22442. */
  22443. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22444. /**
  22445. * Set specific vertex data
  22446. * @param kind defines the data kind (Position, normal, etc...)
  22447. * @param data defines the vertex data to use
  22448. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22449. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22450. */
  22451. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22452. /**
  22453. * Removes a specific vertex data
  22454. * @param kind defines the data kind (Position, normal, etc...)
  22455. */
  22456. removeVerticesData(kind: string): void;
  22457. /**
  22458. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22459. * @param buffer defines the vertex buffer to use
  22460. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22461. */
  22462. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22463. /**
  22464. * Update a specific vertex buffer
  22465. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22466. * It will do nothing if the buffer is not updatable
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @param data defines the data to use
  22469. * @param offset defines the offset in the target buffer where to store the data
  22470. * @param useBytes set to true if the offset is in bytes
  22471. */
  22472. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22473. /**
  22474. * Update a specific vertex buffer
  22475. * This function will create a new buffer if the current one is not updatable
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param data defines the data to use
  22478. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22479. */
  22480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22481. private _updateBoundingInfo;
  22482. /** @hidden */
  22483. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22484. /**
  22485. * Gets total number of vertices
  22486. * @returns the total number of vertices
  22487. */
  22488. getTotalVertices(): number;
  22489. /**
  22490. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22491. * @param kind defines the data kind (Position, normal, etc...)
  22492. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22493. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22494. * @returns a float array containing vertex data
  22495. */
  22496. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22497. /**
  22498. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22499. * @param kind defines the data kind (Position, normal, etc...)
  22500. * @returns true if the vertex buffer with the specified kind is updatable
  22501. */
  22502. isVertexBufferUpdatable(kind: string): boolean;
  22503. /**
  22504. * Gets a specific vertex buffer
  22505. * @param kind defines the data kind (Position, normal, etc...)
  22506. * @returns a VertexBuffer
  22507. */
  22508. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22509. /**
  22510. * Returns all vertex buffers
  22511. * @return an object holding all vertex buffers indexed by kind
  22512. */
  22513. getVertexBuffers(): Nullable<{
  22514. [key: string]: VertexBuffer;
  22515. }>;
  22516. /**
  22517. * Gets a boolean indicating if specific vertex buffer is present
  22518. * @param kind defines the data kind (Position, normal, etc...)
  22519. * @returns true if data is present
  22520. */
  22521. isVerticesDataPresent(kind: string): boolean;
  22522. /**
  22523. * Gets a list of all attached data kinds (Position, normal, etc...)
  22524. * @returns a list of string containing all kinds
  22525. */
  22526. getVerticesDataKinds(): string[];
  22527. /**
  22528. * Update index buffer
  22529. * @param indices defines the indices to store in the index buffer
  22530. * @param offset defines the offset in the target buffer where to store the data
  22531. * @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)
  22532. */
  22533. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22534. /**
  22535. * Creates a new index buffer
  22536. * @param indices defines the indices to store in the index buffer
  22537. * @param totalVertices defines the total number of vertices (could be null)
  22538. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22539. */
  22540. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22541. /**
  22542. * Return the total number of indices
  22543. * @returns the total number of indices
  22544. */
  22545. getTotalIndices(): number;
  22546. /**
  22547. * Gets the index buffer array
  22548. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22550. * @returns the index buffer array
  22551. */
  22552. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22553. /**
  22554. * Gets the index buffer
  22555. * @return the index buffer
  22556. */
  22557. getIndexBuffer(): Nullable<DataBuffer>;
  22558. /** @hidden */
  22559. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22560. /**
  22561. * Release the associated resources for a specific mesh
  22562. * @param mesh defines the source mesh
  22563. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22564. */
  22565. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22566. /**
  22567. * Apply current geometry to a given mesh
  22568. * @param mesh defines the mesh to apply geometry to
  22569. */
  22570. applyToMesh(mesh: Mesh): void;
  22571. private _updateExtend;
  22572. private _applyToMesh;
  22573. private notifyUpdate;
  22574. /**
  22575. * Load the geometry if it was flagged as delay loaded
  22576. * @param scene defines the hosting scene
  22577. * @param onLoaded defines a callback called when the geometry is loaded
  22578. */
  22579. load(scene: Scene, onLoaded?: () => void): void;
  22580. private _queueLoad;
  22581. /**
  22582. * Invert the geometry to move from a right handed system to a left handed one.
  22583. */
  22584. toLeftHanded(): void;
  22585. /** @hidden */
  22586. _resetPointsArrayCache(): void;
  22587. /** @hidden */
  22588. _generatePointsArray(): boolean;
  22589. /**
  22590. * Gets a value indicating if the geometry is disposed
  22591. * @returns true if the geometry was disposed
  22592. */
  22593. isDisposed(): boolean;
  22594. private _disposeVertexArrayObjects;
  22595. /**
  22596. * Free all associated resources
  22597. */
  22598. dispose(): void;
  22599. /**
  22600. * Clone the current geometry into a new geometry
  22601. * @param id defines the unique ID of the new geometry
  22602. * @returns a new geometry object
  22603. */
  22604. copy(id: string): Geometry;
  22605. /**
  22606. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22607. * @return a JSON representation of the current geometry data (without the vertices data)
  22608. */
  22609. serialize(): any;
  22610. private toNumberArray;
  22611. /**
  22612. * Serialize all vertices data into a JSON oject
  22613. * @returns a JSON representation of the current geometry data
  22614. */
  22615. serializeVerticeData(): any;
  22616. /**
  22617. * Extracts a clone of a mesh geometry
  22618. * @param mesh defines the source mesh
  22619. * @param id defines the unique ID of the new geometry object
  22620. * @returns the new geometry object
  22621. */
  22622. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22623. /**
  22624. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22625. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22626. * Be aware Math.random() could cause collisions, but:
  22627. * "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"
  22628. * @returns a string containing a new GUID
  22629. */
  22630. static RandomId(): string;
  22631. /** @hidden */
  22632. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22633. private static _CleanMatricesWeights;
  22634. /**
  22635. * Create a new geometry from persisted data (Using .babylon file format)
  22636. * @param parsedVertexData defines the persisted data
  22637. * @param scene defines the hosting scene
  22638. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22639. * @returns the new geometry object
  22640. */
  22641. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22642. }
  22643. }
  22644. declare module "babylonjs/Meshes/mesh.vertexData" {
  22645. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22646. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22647. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22648. import { Geometry } from "babylonjs/Meshes/geometry";
  22649. import { Mesh } from "babylonjs/Meshes/mesh";
  22650. /**
  22651. * Define an interface for all classes that will get and set the data on vertices
  22652. */
  22653. export interface IGetSetVerticesData {
  22654. /**
  22655. * Gets a boolean indicating if specific vertex data is present
  22656. * @param kind defines the vertex data kind to use
  22657. * @returns true is data kind is present
  22658. */
  22659. isVerticesDataPresent(kind: string): boolean;
  22660. /**
  22661. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22662. * @param kind defines the data kind (Position, normal, etc...)
  22663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22665. * @returns a float array containing vertex data
  22666. */
  22667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22668. /**
  22669. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22670. * @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.
  22671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22672. * @returns the indices array or an empty array if the mesh has no geometry
  22673. */
  22674. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22675. /**
  22676. * Set specific vertex data
  22677. * @param kind defines the data kind (Position, normal, etc...)
  22678. * @param data defines the vertex data to use
  22679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22681. */
  22682. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22683. /**
  22684. * Update a specific associated vertex buffer
  22685. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22686. * - VertexBuffer.PositionKind
  22687. * - VertexBuffer.UVKind
  22688. * - VertexBuffer.UV2Kind
  22689. * - VertexBuffer.UV3Kind
  22690. * - VertexBuffer.UV4Kind
  22691. * - VertexBuffer.UV5Kind
  22692. * - VertexBuffer.UV6Kind
  22693. * - VertexBuffer.ColorKind
  22694. * - VertexBuffer.MatricesIndicesKind
  22695. * - VertexBuffer.MatricesIndicesExtraKind
  22696. * - VertexBuffer.MatricesWeightsKind
  22697. * - VertexBuffer.MatricesWeightsExtraKind
  22698. * @param data defines the data source
  22699. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22700. * @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)
  22701. */
  22702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22703. /**
  22704. * Creates a new index buffer
  22705. * @param indices defines the indices to store in the index buffer
  22706. * @param totalVertices defines the total number of vertices (could be null)
  22707. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22708. */
  22709. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22710. }
  22711. /**
  22712. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22713. */
  22714. export class VertexData {
  22715. /**
  22716. * Mesh side orientation : usually the external or front surface
  22717. */
  22718. static readonly FRONTSIDE: number;
  22719. /**
  22720. * Mesh side orientation : usually the internal or back surface
  22721. */
  22722. static readonly BACKSIDE: number;
  22723. /**
  22724. * Mesh side orientation : both internal and external or front and back surfaces
  22725. */
  22726. static readonly DOUBLESIDE: number;
  22727. /**
  22728. * Mesh side orientation : by default, `FRONTSIDE`
  22729. */
  22730. static readonly DEFAULTSIDE: number;
  22731. /**
  22732. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22733. */
  22734. positions: Nullable<FloatArray>;
  22735. /**
  22736. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22737. */
  22738. normals: Nullable<FloatArray>;
  22739. /**
  22740. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22741. */
  22742. tangents: Nullable<FloatArray>;
  22743. /**
  22744. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22745. */
  22746. uvs: Nullable<FloatArray>;
  22747. /**
  22748. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22749. */
  22750. uvs2: Nullable<FloatArray>;
  22751. /**
  22752. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22753. */
  22754. uvs3: Nullable<FloatArray>;
  22755. /**
  22756. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22757. */
  22758. uvs4: Nullable<FloatArray>;
  22759. /**
  22760. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22761. */
  22762. uvs5: Nullable<FloatArray>;
  22763. /**
  22764. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22765. */
  22766. uvs6: Nullable<FloatArray>;
  22767. /**
  22768. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22769. */
  22770. colors: Nullable<FloatArray>;
  22771. /**
  22772. * 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).
  22773. */
  22774. matricesIndices: Nullable<FloatArray>;
  22775. /**
  22776. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22777. */
  22778. matricesWeights: Nullable<FloatArray>;
  22779. /**
  22780. * An array extending the number of possible indices
  22781. */
  22782. matricesIndicesExtra: Nullable<FloatArray>;
  22783. /**
  22784. * An array extending the number of possible weights when the number of indices is extended
  22785. */
  22786. matricesWeightsExtra: Nullable<FloatArray>;
  22787. /**
  22788. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22789. */
  22790. indices: Nullable<IndicesArray>;
  22791. /**
  22792. * Uses the passed data array to set the set the values for the specified kind of data
  22793. * @param data a linear array of floating numbers
  22794. * @param kind the type of data that is being set, eg positions, colors etc
  22795. */
  22796. set(data: FloatArray, kind: string): void;
  22797. /**
  22798. * Associates the vertexData to the passed Mesh.
  22799. * Sets it as updatable or not (default `false`)
  22800. * @param mesh the mesh the vertexData is applied to
  22801. * @param updatable when used and having the value true allows new data to update the vertexData
  22802. * @returns the VertexData
  22803. */
  22804. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22805. /**
  22806. * Associates the vertexData to the passed Geometry.
  22807. * Sets it as updatable or not (default `false`)
  22808. * @param geometry the geometry the vertexData is applied to
  22809. * @param updatable when used and having the value true allows new data to update the vertexData
  22810. * @returns VertexData
  22811. */
  22812. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22813. /**
  22814. * Updates the associated mesh
  22815. * @param mesh the mesh to be updated
  22816. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22817. * @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
  22818. * @returns VertexData
  22819. */
  22820. updateMesh(mesh: Mesh): VertexData;
  22821. /**
  22822. * Updates the associated geometry
  22823. * @param geometry the geometry to be updated
  22824. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22825. * @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
  22826. * @returns VertexData.
  22827. */
  22828. updateGeometry(geometry: Geometry): VertexData;
  22829. private _applyTo;
  22830. private _update;
  22831. /**
  22832. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22833. * @param matrix the transforming matrix
  22834. * @returns the VertexData
  22835. */
  22836. transform(matrix: Matrix): VertexData;
  22837. /**
  22838. * Merges the passed VertexData into the current one
  22839. * @param other the VertexData to be merged into the current one
  22840. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22841. * @returns the modified VertexData
  22842. */
  22843. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22844. private _mergeElement;
  22845. private _validate;
  22846. /**
  22847. * Serializes the VertexData
  22848. * @returns a serialized object
  22849. */
  22850. serialize(): any;
  22851. /**
  22852. * Extracts the vertexData from a mesh
  22853. * @param mesh the mesh from which to extract the VertexData
  22854. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22855. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22856. * @returns the object VertexData associated to the passed mesh
  22857. */
  22858. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22859. /**
  22860. * Extracts the vertexData from the geometry
  22861. * @param geometry the geometry from which to extract the VertexData
  22862. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22863. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22864. * @returns the object VertexData associated to the passed mesh
  22865. */
  22866. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22867. private static _ExtractFrom;
  22868. /**
  22869. * Creates the VertexData for a Ribbon
  22870. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22871. * * pathArray array of paths, each of which an array of successive Vector3
  22872. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22873. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22874. * * 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
  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. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22879. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22880. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22881. * @returns the VertexData of the ribbon
  22882. */
  22883. static CreateRibbon(options: {
  22884. pathArray: Vector3[][];
  22885. closeArray?: boolean;
  22886. closePath?: boolean;
  22887. offset?: number;
  22888. sideOrientation?: number;
  22889. frontUVs?: Vector4;
  22890. backUVs?: Vector4;
  22891. invertUV?: boolean;
  22892. uvs?: Vector2[];
  22893. colors?: Color4[];
  22894. }): VertexData;
  22895. /**
  22896. * Creates the VertexData for a box
  22897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22898. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22899. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22900. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22901. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22902. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22903. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  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 box
  22908. */
  22909. static CreateBox(options: {
  22910. size?: number;
  22911. width?: number;
  22912. height?: number;
  22913. depth?: number;
  22914. faceUV?: Vector4[];
  22915. faceColors?: Color4[];
  22916. sideOrientation?: number;
  22917. frontUVs?: Vector4;
  22918. backUVs?: Vector4;
  22919. }): VertexData;
  22920. /**
  22921. * Creates the VertexData for a tiled box
  22922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22923. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22924. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22925. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22927. * @returns the VertexData of the box
  22928. */
  22929. static CreateTiledBox(options: {
  22930. pattern?: number;
  22931. width?: number;
  22932. height?: number;
  22933. depth?: number;
  22934. tileSize?: number;
  22935. tileWidth?: number;
  22936. tileHeight?: number;
  22937. alignHorizontal?: number;
  22938. alignVertical?: number;
  22939. faceUV?: Vector4[];
  22940. faceColors?: Color4[];
  22941. sideOrientation?: number;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData for a tiled plane
  22945. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22946. * * pattern a limited pattern arrangement depending on the number
  22947. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22948. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22949. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22951. * * 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)
  22952. * * 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)
  22953. * @returns the VertexData of the tiled plane
  22954. */
  22955. static CreateTiledPlane(options: {
  22956. pattern?: number;
  22957. tileSize?: number;
  22958. tileWidth?: number;
  22959. tileHeight?: number;
  22960. size?: number;
  22961. width?: number;
  22962. height?: number;
  22963. alignHorizontal?: number;
  22964. alignVertical?: number;
  22965. sideOrientation?: number;
  22966. frontUVs?: Vector4;
  22967. backUVs?: Vector4;
  22968. }): VertexData;
  22969. /**
  22970. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22972. * * segments sets the number of horizontal strips optional, default 32
  22973. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22974. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22975. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22976. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22977. * * 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
  22978. * * 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
  22979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22980. * * 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)
  22981. * * 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)
  22982. * @returns the VertexData of the ellipsoid
  22983. */
  22984. static CreateSphere(options: {
  22985. segments?: number;
  22986. diameter?: number;
  22987. diameterX?: number;
  22988. diameterY?: number;
  22989. diameterZ?: number;
  22990. arc?: number;
  22991. slice?: number;
  22992. sideOrientation?: number;
  22993. frontUVs?: Vector4;
  22994. backUVs?: Vector4;
  22995. }): VertexData;
  22996. /**
  22997. * Creates the VertexData for a cylinder, cone or prism
  22998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22999. * * height sets the height (y direction) of the cylinder, optional, default 2
  23000. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23001. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23002. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23003. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23004. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23005. * * 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
  23006. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23007. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23008. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23009. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23011. * * 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)
  23012. * * 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)
  23013. * @returns the VertexData of the cylinder, cone or prism
  23014. */
  23015. static CreateCylinder(options: {
  23016. height?: number;
  23017. diameterTop?: number;
  23018. diameterBottom?: number;
  23019. diameter?: number;
  23020. tessellation?: number;
  23021. subdivisions?: number;
  23022. arc?: number;
  23023. faceColors?: Color4[];
  23024. faceUV?: Vector4[];
  23025. hasRings?: boolean;
  23026. enclose?: boolean;
  23027. sideOrientation?: number;
  23028. frontUVs?: Vector4;
  23029. backUVs?: Vector4;
  23030. }): VertexData;
  23031. /**
  23032. * Creates the VertexData for a torus
  23033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23034. * * diameter the diameter of the torus, optional default 1
  23035. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23036. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23038. * * 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)
  23039. * * 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)
  23040. * @returns the VertexData of the torus
  23041. */
  23042. static CreateTorus(options: {
  23043. diameter?: number;
  23044. thickness?: number;
  23045. tessellation?: number;
  23046. sideOrientation?: number;
  23047. frontUVs?: Vector4;
  23048. backUVs?: Vector4;
  23049. }): VertexData;
  23050. /**
  23051. * Creates the VertexData of the LineSystem
  23052. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23053. * - lines an array of lines, each line being an array of successive Vector3
  23054. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23055. * @returns the VertexData of the LineSystem
  23056. */
  23057. static CreateLineSystem(options: {
  23058. lines: Vector3[][];
  23059. colors?: Nullable<Color4[][]>;
  23060. }): VertexData;
  23061. /**
  23062. * Create the VertexData for a DashedLines
  23063. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23064. * - points an array successive Vector3
  23065. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23066. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23067. * - dashNb the intended total number of dashes, optional, default 200
  23068. * @returns the VertexData for the DashedLines
  23069. */
  23070. static CreateDashedLines(options: {
  23071. points: Vector3[];
  23072. dashSize?: number;
  23073. gapSize?: number;
  23074. dashNb?: number;
  23075. }): VertexData;
  23076. /**
  23077. * Creates the VertexData for a Ground
  23078. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23079. * - width the width (x direction) of the ground, optional, default 1
  23080. * - height the height (z direction) of the ground, optional, default 1
  23081. * - subdivisions the number of subdivisions per side, optional, default 1
  23082. * @returns the VertexData of the Ground
  23083. */
  23084. static CreateGround(options: {
  23085. width?: number;
  23086. height?: number;
  23087. subdivisions?: number;
  23088. subdivisionsX?: number;
  23089. subdivisionsY?: number;
  23090. }): VertexData;
  23091. /**
  23092. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23093. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23094. * * xmin the ground minimum X coordinate, optional, default -1
  23095. * * zmin the ground minimum Z coordinate, optional, default -1
  23096. * * xmax the ground maximum X coordinate, optional, default 1
  23097. * * zmax the ground maximum Z coordinate, optional, default 1
  23098. * * 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}
  23099. * * 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}
  23100. * @returns the VertexData of the TiledGround
  23101. */
  23102. static CreateTiledGround(options: {
  23103. xmin: number;
  23104. zmin: number;
  23105. xmax: number;
  23106. zmax: number;
  23107. subdivisions?: {
  23108. w: number;
  23109. h: number;
  23110. };
  23111. precision?: {
  23112. w: number;
  23113. h: number;
  23114. };
  23115. }): VertexData;
  23116. /**
  23117. * Creates the VertexData of the Ground designed from a heightmap
  23118. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23119. * * width the width (x direction) of the ground
  23120. * * height the height (z direction) of the ground
  23121. * * subdivisions the number of subdivisions per side
  23122. * * minHeight the minimum altitude on the ground, optional, default 0
  23123. * * maxHeight the maximum altitude on the ground, optional default 1
  23124. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23125. * * buffer the array holding the image color data
  23126. * * bufferWidth the width of image
  23127. * * bufferHeight the height of image
  23128. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23129. * @returns the VertexData of the Ground designed from a heightmap
  23130. */
  23131. static CreateGroundFromHeightMap(options: {
  23132. width: number;
  23133. height: number;
  23134. subdivisions: number;
  23135. minHeight: number;
  23136. maxHeight: number;
  23137. colorFilter: Color3;
  23138. buffer: Uint8Array;
  23139. bufferWidth: number;
  23140. bufferHeight: number;
  23141. alphaFilter: number;
  23142. }): VertexData;
  23143. /**
  23144. * Creates the VertexData for a Plane
  23145. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23146. * * size sets the width and height of the plane to the value of size, optional default 1
  23147. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23148. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * 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)
  23151. * * 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)
  23152. * @returns the VertexData of the box
  23153. */
  23154. static CreatePlane(options: {
  23155. size?: number;
  23156. width?: number;
  23157. height?: number;
  23158. sideOrientation?: number;
  23159. frontUVs?: Vector4;
  23160. backUVs?: Vector4;
  23161. }): VertexData;
  23162. /**
  23163. * Creates the VertexData of the Disc or regular Polygon
  23164. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23165. * * radius the radius of the disc, optional default 0.5
  23166. * * tessellation the number of polygon sides, optional, default 64
  23167. * * 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
  23168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23169. * * 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)
  23170. * * 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)
  23171. * @returns the VertexData of the box
  23172. */
  23173. static CreateDisc(options: {
  23174. radius?: number;
  23175. tessellation?: number;
  23176. arc?: number;
  23177. sideOrientation?: number;
  23178. frontUVs?: Vector4;
  23179. backUVs?: Vector4;
  23180. }): VertexData;
  23181. /**
  23182. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23183. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23184. * @param polygon a mesh built from polygonTriangulation.build()
  23185. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23187. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23188. * @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)
  23189. * @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)
  23190. * @returns the VertexData of the Polygon
  23191. */
  23192. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23193. /**
  23194. * Creates the VertexData of the IcoSphere
  23195. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23196. * * radius the radius of the IcoSphere, optional default 1
  23197. * * radiusX allows stretching in the x direction, optional, default radius
  23198. * * radiusY allows stretching in the y direction, optional, default radius
  23199. * * radiusZ allows stretching in the z direction, optional, default radius
  23200. * * flat when true creates a flat shaded mesh, optional, default true
  23201. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23203. * * 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)
  23204. * * 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)
  23205. * @returns the VertexData of the IcoSphere
  23206. */
  23207. static CreateIcoSphere(options: {
  23208. radius?: number;
  23209. radiusX?: number;
  23210. radiusY?: number;
  23211. radiusZ?: number;
  23212. flat?: boolean;
  23213. subdivisions?: number;
  23214. sideOrientation?: number;
  23215. frontUVs?: Vector4;
  23216. backUVs?: Vector4;
  23217. }): VertexData;
  23218. /**
  23219. * Creates the VertexData for a Polyhedron
  23220. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23221. * * type provided types are:
  23222. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23223. * * 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)
  23224. * * size the size of the IcoSphere, optional default 1
  23225. * * sizeX allows stretching in the x direction, optional, default size
  23226. * * sizeY allows stretching in the y direction, optional, default size
  23227. * * sizeZ allows stretching in the z direction, optional, default size
  23228. * * 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
  23229. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23230. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23231. * * flat when true creates a flat shaded mesh, optional, default true
  23232. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23234. * * 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)
  23235. * * 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)
  23236. * @returns the VertexData of the Polyhedron
  23237. */
  23238. static CreatePolyhedron(options: {
  23239. type?: number;
  23240. size?: number;
  23241. sizeX?: number;
  23242. sizeY?: number;
  23243. sizeZ?: number;
  23244. custom?: any;
  23245. faceUV?: Vector4[];
  23246. faceColors?: Color4[];
  23247. flat?: boolean;
  23248. sideOrientation?: number;
  23249. frontUVs?: Vector4;
  23250. backUVs?: Vector4;
  23251. }): VertexData;
  23252. /**
  23253. * Creates the VertexData for a TorusKnot
  23254. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23255. * * radius the radius of the torus knot, optional, default 2
  23256. * * tube the thickness of the tube, optional, default 0.5
  23257. * * radialSegments the number of sides on each tube segments, optional, default 32
  23258. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23259. * * p the number of windings around the z axis, optional, default 2
  23260. * * q the number of windings around the x axis, optional, default 3
  23261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23262. * * 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)
  23263. * * 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)
  23264. * @returns the VertexData of the Torus Knot
  23265. */
  23266. static CreateTorusKnot(options: {
  23267. radius?: number;
  23268. tube?: number;
  23269. radialSegments?: number;
  23270. tubularSegments?: number;
  23271. p?: number;
  23272. q?: number;
  23273. sideOrientation?: number;
  23274. frontUVs?: Vector4;
  23275. backUVs?: Vector4;
  23276. }): VertexData;
  23277. /**
  23278. * Compute normals for given positions and indices
  23279. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23280. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23281. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23282. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23283. * * facetNormals : optional array of facet normals (vector3)
  23284. * * facetPositions : optional array of facet positions (vector3)
  23285. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23286. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23287. * * bInfo : optional bounding info, required for facetPartitioning computation
  23288. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23289. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23290. * * useRightHandedSystem: optional boolean to for right handed system computation
  23291. * * depthSort : optional boolean to enable the facet depth sort computation
  23292. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23293. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23294. */
  23295. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23296. facetNormals?: any;
  23297. facetPositions?: any;
  23298. facetPartitioning?: any;
  23299. ratio?: number;
  23300. bInfo?: any;
  23301. bbSize?: Vector3;
  23302. subDiv?: any;
  23303. useRightHandedSystem?: boolean;
  23304. depthSort?: boolean;
  23305. distanceTo?: Vector3;
  23306. depthSortedFacets?: any;
  23307. }): void;
  23308. /** @hidden */
  23309. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23310. /**
  23311. * Applies VertexData created from the imported parameters to the geometry
  23312. * @param parsedVertexData the parsed data from an imported file
  23313. * @param geometry the geometry to apply the VertexData to
  23314. */
  23315. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23316. }
  23317. }
  23318. declare module "babylonjs/Morph/morphTarget" {
  23319. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23320. import { Observable } from "babylonjs/Misc/observable";
  23321. import { Nullable, FloatArray } from "babylonjs/types";
  23322. import { Scene } from "babylonjs/scene";
  23323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23324. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23325. /**
  23326. * Defines a target to use with MorphTargetManager
  23327. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23328. */
  23329. export class MorphTarget implements IAnimatable {
  23330. /** defines the name of the target */
  23331. name: string;
  23332. /**
  23333. * Gets or sets the list of animations
  23334. */
  23335. animations: import("babylonjs/Animations/animation").Animation[];
  23336. private _scene;
  23337. private _positions;
  23338. private _normals;
  23339. private _tangents;
  23340. private _uvs;
  23341. private _influence;
  23342. private _uniqueId;
  23343. /**
  23344. * Observable raised when the influence changes
  23345. */
  23346. onInfluenceChanged: Observable<boolean>;
  23347. /** @hidden */
  23348. _onDataLayoutChanged: Observable<void>;
  23349. /**
  23350. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23351. */
  23352. get influence(): number;
  23353. set influence(influence: number);
  23354. /**
  23355. * Gets or sets the id of the morph Target
  23356. */
  23357. id: string;
  23358. private _animationPropertiesOverride;
  23359. /**
  23360. * Gets or sets the animation properties override
  23361. */
  23362. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23363. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23364. /**
  23365. * Creates a new MorphTarget
  23366. * @param name defines the name of the target
  23367. * @param influence defines the influence to use
  23368. * @param scene defines the scene the morphtarget belongs to
  23369. */
  23370. constructor(
  23371. /** defines the name of the target */
  23372. name: string, influence?: number, scene?: Nullable<Scene>);
  23373. /**
  23374. * Gets the unique ID of this manager
  23375. */
  23376. get uniqueId(): number;
  23377. /**
  23378. * Gets a boolean defining if the target contains position data
  23379. */
  23380. get hasPositions(): boolean;
  23381. /**
  23382. * Gets a boolean defining if the target contains normal data
  23383. */
  23384. get hasNormals(): boolean;
  23385. /**
  23386. * Gets a boolean defining if the target contains tangent data
  23387. */
  23388. get hasTangents(): boolean;
  23389. /**
  23390. * Gets a boolean defining if the target contains texture coordinates data
  23391. */
  23392. get hasUVs(): boolean;
  23393. /**
  23394. * Affects position data to this target
  23395. * @param data defines the position data to use
  23396. */
  23397. setPositions(data: Nullable<FloatArray>): void;
  23398. /**
  23399. * Gets the position data stored in this target
  23400. * @returns a FloatArray containing the position data (or null if not present)
  23401. */
  23402. getPositions(): Nullable<FloatArray>;
  23403. /**
  23404. * Affects normal data to this target
  23405. * @param data defines the normal data to use
  23406. */
  23407. setNormals(data: Nullable<FloatArray>): void;
  23408. /**
  23409. * Gets the normal data stored in this target
  23410. * @returns a FloatArray containing the normal data (or null if not present)
  23411. */
  23412. getNormals(): Nullable<FloatArray>;
  23413. /**
  23414. * Affects tangent data to this target
  23415. * @param data defines the tangent data to use
  23416. */
  23417. setTangents(data: Nullable<FloatArray>): void;
  23418. /**
  23419. * Gets the tangent data stored in this target
  23420. * @returns a FloatArray containing the tangent data (or null if not present)
  23421. */
  23422. getTangents(): Nullable<FloatArray>;
  23423. /**
  23424. * Affects texture coordinates data to this target
  23425. * @param data defines the texture coordinates data to use
  23426. */
  23427. setUVs(data: Nullable<FloatArray>): void;
  23428. /**
  23429. * Gets the texture coordinates data stored in this target
  23430. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23431. */
  23432. getUVs(): Nullable<FloatArray>;
  23433. /**
  23434. * Clone the current target
  23435. * @returns a new MorphTarget
  23436. */
  23437. clone(): MorphTarget;
  23438. /**
  23439. * Serializes the current target into a Serialization object
  23440. * @returns the serialized object
  23441. */
  23442. serialize(): any;
  23443. /**
  23444. * Returns the string "MorphTarget"
  23445. * @returns "MorphTarget"
  23446. */
  23447. getClassName(): string;
  23448. /**
  23449. * Creates a new target from serialized data
  23450. * @param serializationObject defines the serialized data to use
  23451. * @returns a new MorphTarget
  23452. */
  23453. static Parse(serializationObject: any): MorphTarget;
  23454. /**
  23455. * Creates a MorphTarget from mesh data
  23456. * @param mesh defines the source mesh
  23457. * @param name defines the name to use for the new target
  23458. * @param influence defines the influence to attach to the target
  23459. * @returns a new MorphTarget
  23460. */
  23461. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23462. }
  23463. }
  23464. declare module "babylonjs/Morph/morphTargetManager" {
  23465. import { Nullable } from "babylonjs/types";
  23466. import { Scene } from "babylonjs/scene";
  23467. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23468. /**
  23469. * This class is used to deform meshes using morphing between different targets
  23470. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23471. */
  23472. export class MorphTargetManager {
  23473. private _targets;
  23474. private _targetInfluenceChangedObservers;
  23475. private _targetDataLayoutChangedObservers;
  23476. private _activeTargets;
  23477. private _scene;
  23478. private _influences;
  23479. private _supportsNormals;
  23480. private _supportsTangents;
  23481. private _supportsUVs;
  23482. private _vertexCount;
  23483. private _uniqueId;
  23484. private _tempInfluences;
  23485. /**
  23486. * Gets or sets a boolean indicating if normals must be morphed
  23487. */
  23488. enableNormalMorphing: boolean;
  23489. /**
  23490. * Gets or sets a boolean indicating if tangents must be morphed
  23491. */
  23492. enableTangentMorphing: boolean;
  23493. /**
  23494. * Gets or sets a boolean indicating if UV must be morphed
  23495. */
  23496. enableUVMorphing: boolean;
  23497. /**
  23498. * Creates a new MorphTargetManager
  23499. * @param scene defines the current scene
  23500. */
  23501. constructor(scene?: Nullable<Scene>);
  23502. /**
  23503. * Gets the unique ID of this manager
  23504. */
  23505. get uniqueId(): number;
  23506. /**
  23507. * Gets the number of vertices handled by this manager
  23508. */
  23509. get vertexCount(): number;
  23510. /**
  23511. * Gets a boolean indicating if this manager supports morphing of normals
  23512. */
  23513. get supportsNormals(): boolean;
  23514. /**
  23515. * Gets a boolean indicating if this manager supports morphing of tangents
  23516. */
  23517. get supportsTangents(): boolean;
  23518. /**
  23519. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23520. */
  23521. get supportsUVs(): boolean;
  23522. /**
  23523. * Gets the number of targets stored in this manager
  23524. */
  23525. get numTargets(): number;
  23526. /**
  23527. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23528. */
  23529. get numInfluencers(): number;
  23530. /**
  23531. * Gets the list of influences (one per target)
  23532. */
  23533. get influences(): Float32Array;
  23534. /**
  23535. * Gets the active target at specified index. An active target is a target with an influence > 0
  23536. * @param index defines the index to check
  23537. * @returns the requested target
  23538. */
  23539. getActiveTarget(index: number): MorphTarget;
  23540. /**
  23541. * Gets the target at specified index
  23542. * @param index defines the index to check
  23543. * @returns the requested target
  23544. */
  23545. getTarget(index: number): MorphTarget;
  23546. /**
  23547. * Add a new target to this manager
  23548. * @param target defines the target to add
  23549. */
  23550. addTarget(target: MorphTarget): void;
  23551. /**
  23552. * Removes a target from the manager
  23553. * @param target defines the target to remove
  23554. */
  23555. removeTarget(target: MorphTarget): void;
  23556. /**
  23557. * Clone the current manager
  23558. * @returns a new MorphTargetManager
  23559. */
  23560. clone(): MorphTargetManager;
  23561. /**
  23562. * Serializes the current manager into a Serialization object
  23563. * @returns the serialized object
  23564. */
  23565. serialize(): any;
  23566. private _syncActiveTargets;
  23567. /**
  23568. * Syncrhonize the targets with all the meshes using this morph target manager
  23569. */
  23570. synchronize(): void;
  23571. /**
  23572. * Creates a new MorphTargetManager from serialized data
  23573. * @param serializationObject defines the serialized data
  23574. * @param scene defines the hosting scene
  23575. * @returns the new MorphTargetManager
  23576. */
  23577. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23578. }
  23579. }
  23580. declare module "babylonjs/Meshes/meshLODLevel" {
  23581. import { Mesh } from "babylonjs/Meshes/mesh";
  23582. import { Nullable } from "babylonjs/types";
  23583. /**
  23584. * Class used to represent a specific level of detail of a mesh
  23585. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23586. */
  23587. export class MeshLODLevel {
  23588. /** Defines the distance where this level should start being displayed */
  23589. distance: number;
  23590. /** Defines the mesh to use to render this level */
  23591. mesh: Nullable<Mesh>;
  23592. /**
  23593. * Creates a new LOD level
  23594. * @param distance defines the distance where this level should star being displayed
  23595. * @param mesh defines the mesh to use to render this level
  23596. */
  23597. constructor(
  23598. /** Defines the distance where this level should start being displayed */
  23599. distance: number,
  23600. /** Defines the mesh to use to render this level */
  23601. mesh: Nullable<Mesh>);
  23602. }
  23603. }
  23604. declare module "babylonjs/Meshes/groundMesh" {
  23605. import { Scene } from "babylonjs/scene";
  23606. import { Vector3 } from "babylonjs/Maths/math.vector";
  23607. import { Mesh } from "babylonjs/Meshes/mesh";
  23608. /**
  23609. * Mesh representing the gorund
  23610. */
  23611. export class GroundMesh extends Mesh {
  23612. /** If octree should be generated */
  23613. generateOctree: boolean;
  23614. private _heightQuads;
  23615. /** @hidden */
  23616. _subdivisionsX: number;
  23617. /** @hidden */
  23618. _subdivisionsY: number;
  23619. /** @hidden */
  23620. _width: number;
  23621. /** @hidden */
  23622. _height: number;
  23623. /** @hidden */
  23624. _minX: number;
  23625. /** @hidden */
  23626. _maxX: number;
  23627. /** @hidden */
  23628. _minZ: number;
  23629. /** @hidden */
  23630. _maxZ: number;
  23631. constructor(name: string, scene: Scene);
  23632. /**
  23633. * "GroundMesh"
  23634. * @returns "GroundMesh"
  23635. */
  23636. getClassName(): string;
  23637. /**
  23638. * The minimum of x and y subdivisions
  23639. */
  23640. get subdivisions(): number;
  23641. /**
  23642. * X subdivisions
  23643. */
  23644. get subdivisionsX(): number;
  23645. /**
  23646. * Y subdivisions
  23647. */
  23648. get subdivisionsY(): number;
  23649. /**
  23650. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23651. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23652. * @param chunksCount the number of subdivisions for x and y
  23653. * @param octreeBlocksSize (Default: 32)
  23654. */
  23655. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23656. /**
  23657. * Returns a height (y) value in the Worl system :
  23658. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23659. * @param x x coordinate
  23660. * @param z z coordinate
  23661. * @returns the ground y position if (x, z) are outside the ground surface.
  23662. */
  23663. getHeightAtCoordinates(x: number, z: number): number;
  23664. /**
  23665. * Returns a normalized vector (Vector3) orthogonal to the ground
  23666. * at the ground coordinates (x, z) expressed in the World system.
  23667. * @param x x coordinate
  23668. * @param z z coordinate
  23669. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23670. */
  23671. getNormalAtCoordinates(x: number, z: number): Vector3;
  23672. /**
  23673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23674. * at the ground coordinates (x, z) expressed in the World system.
  23675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23676. * @param x x coordinate
  23677. * @param z z coordinate
  23678. * @param ref vector to store the result
  23679. * @returns the GroundMesh.
  23680. */
  23681. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23682. /**
  23683. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23684. * if the ground has been updated.
  23685. * This can be used in the render loop.
  23686. * @returns the GroundMesh.
  23687. */
  23688. updateCoordinateHeights(): GroundMesh;
  23689. private _getFacetAt;
  23690. private _initHeightQuads;
  23691. private _computeHeightQuads;
  23692. /**
  23693. * Serializes this ground mesh
  23694. * @param serializationObject object to write serialization to
  23695. */
  23696. serialize(serializationObject: any): void;
  23697. /**
  23698. * Parses a serialized ground mesh
  23699. * @param parsedMesh the serialized mesh
  23700. * @param scene the scene to create the ground mesh in
  23701. * @returns the created ground mesh
  23702. */
  23703. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23704. }
  23705. }
  23706. declare module "babylonjs/Physics/physicsJoint" {
  23707. import { Vector3 } from "babylonjs/Maths/math.vector";
  23708. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23709. /**
  23710. * Interface for Physics-Joint data
  23711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23712. */
  23713. export interface PhysicsJointData {
  23714. /**
  23715. * The main pivot of the joint
  23716. */
  23717. mainPivot?: Vector3;
  23718. /**
  23719. * The connected pivot of the joint
  23720. */
  23721. connectedPivot?: Vector3;
  23722. /**
  23723. * The main axis of the joint
  23724. */
  23725. mainAxis?: Vector3;
  23726. /**
  23727. * The connected axis of the joint
  23728. */
  23729. connectedAxis?: Vector3;
  23730. /**
  23731. * The collision of the joint
  23732. */
  23733. collision?: boolean;
  23734. /**
  23735. * Native Oimo/Cannon/Energy data
  23736. */
  23737. nativeParams?: any;
  23738. }
  23739. /**
  23740. * This is a holder class for the physics joint created by the physics plugin
  23741. * It holds a set of functions to control the underlying joint
  23742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23743. */
  23744. export class PhysicsJoint {
  23745. /**
  23746. * The type of the physics joint
  23747. */
  23748. type: number;
  23749. /**
  23750. * The data for the physics joint
  23751. */
  23752. jointData: PhysicsJointData;
  23753. private _physicsJoint;
  23754. protected _physicsPlugin: IPhysicsEnginePlugin;
  23755. /**
  23756. * Initializes the physics joint
  23757. * @param type The type of the physics joint
  23758. * @param jointData The data for the physics joint
  23759. */
  23760. constructor(
  23761. /**
  23762. * The type of the physics joint
  23763. */
  23764. type: number,
  23765. /**
  23766. * The data for the physics joint
  23767. */
  23768. jointData: PhysicsJointData);
  23769. /**
  23770. * Gets the physics joint
  23771. */
  23772. get physicsJoint(): any;
  23773. /**
  23774. * Sets the physics joint
  23775. */
  23776. set physicsJoint(newJoint: any);
  23777. /**
  23778. * Sets the physics plugin
  23779. */
  23780. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23781. /**
  23782. * Execute a function that is physics-plugin specific.
  23783. * @param {Function} func the function that will be executed.
  23784. * It accepts two parameters: the physics world and the physics joint
  23785. */
  23786. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23787. /**
  23788. * Distance-Joint type
  23789. */
  23790. static DistanceJoint: number;
  23791. /**
  23792. * Hinge-Joint type
  23793. */
  23794. static HingeJoint: number;
  23795. /**
  23796. * Ball-and-Socket joint type
  23797. */
  23798. static BallAndSocketJoint: number;
  23799. /**
  23800. * Wheel-Joint type
  23801. */
  23802. static WheelJoint: number;
  23803. /**
  23804. * Slider-Joint type
  23805. */
  23806. static SliderJoint: number;
  23807. /**
  23808. * Prismatic-Joint type
  23809. */
  23810. static PrismaticJoint: number;
  23811. /**
  23812. * Universal-Joint type
  23813. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23814. */
  23815. static UniversalJoint: number;
  23816. /**
  23817. * Hinge-Joint 2 type
  23818. */
  23819. static Hinge2Joint: number;
  23820. /**
  23821. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23822. */
  23823. static PointToPointJoint: number;
  23824. /**
  23825. * Spring-Joint type
  23826. */
  23827. static SpringJoint: number;
  23828. /**
  23829. * Lock-Joint type
  23830. */
  23831. static LockJoint: number;
  23832. }
  23833. /**
  23834. * A class representing a physics distance joint
  23835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23836. */
  23837. export class DistanceJoint extends PhysicsJoint {
  23838. /**
  23839. *
  23840. * @param jointData The data for the Distance-Joint
  23841. */
  23842. constructor(jointData: DistanceJointData);
  23843. /**
  23844. * Update the predefined distance.
  23845. * @param maxDistance The maximum preferred distance
  23846. * @param minDistance The minimum preferred distance
  23847. */
  23848. updateDistance(maxDistance: number, minDistance?: number): void;
  23849. }
  23850. /**
  23851. * Represents a Motor-Enabled Joint
  23852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23853. */
  23854. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23855. /**
  23856. * Initializes the Motor-Enabled Joint
  23857. * @param type The type of the joint
  23858. * @param jointData The physica joint data for the joint
  23859. */
  23860. constructor(type: number, jointData: PhysicsJointData);
  23861. /**
  23862. * Set the motor values.
  23863. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23864. * @param force the force to apply
  23865. * @param maxForce max force for this motor.
  23866. */
  23867. setMotor(force?: number, maxForce?: number): void;
  23868. /**
  23869. * Set the motor's limits.
  23870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23871. * @param upperLimit The upper limit of the motor
  23872. * @param lowerLimit The lower limit of the motor
  23873. */
  23874. setLimit(upperLimit: number, lowerLimit?: number): void;
  23875. }
  23876. /**
  23877. * This class represents a single physics Hinge-Joint
  23878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23879. */
  23880. export class HingeJoint extends MotorEnabledJoint {
  23881. /**
  23882. * Initializes the Hinge-Joint
  23883. * @param jointData The joint data for the Hinge-Joint
  23884. */
  23885. constructor(jointData: PhysicsJointData);
  23886. /**
  23887. * Set the motor values.
  23888. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23889. * @param {number} force the force to apply
  23890. * @param {number} maxForce max force for this motor.
  23891. */
  23892. setMotor(force?: number, maxForce?: number): void;
  23893. /**
  23894. * Set the motor's limits.
  23895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23896. * @param upperLimit The upper limit of the motor
  23897. * @param lowerLimit The lower limit of the motor
  23898. */
  23899. setLimit(upperLimit: number, lowerLimit?: number): void;
  23900. }
  23901. /**
  23902. * This class represents a dual hinge physics joint (same as wheel joint)
  23903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23904. */
  23905. export class Hinge2Joint extends MotorEnabledJoint {
  23906. /**
  23907. * Initializes the Hinge2-Joint
  23908. * @param jointData The joint data for the Hinge2-Joint
  23909. */
  23910. constructor(jointData: PhysicsJointData);
  23911. /**
  23912. * Set the motor values.
  23913. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23914. * @param {number} targetSpeed the speed the motor is to reach
  23915. * @param {number} maxForce max force for this motor.
  23916. * @param {motorIndex} the motor's index, 0 or 1.
  23917. */
  23918. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23919. /**
  23920. * Set the motor limits.
  23921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23922. * @param {number} upperLimit the upper limit
  23923. * @param {number} lowerLimit lower limit
  23924. * @param {motorIndex} the motor's index, 0 or 1.
  23925. */
  23926. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23927. }
  23928. /**
  23929. * Interface for a motor enabled joint
  23930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23931. */
  23932. export interface IMotorEnabledJoint {
  23933. /**
  23934. * Physics joint
  23935. */
  23936. physicsJoint: any;
  23937. /**
  23938. * Sets the motor of the motor-enabled joint
  23939. * @param force The force of the motor
  23940. * @param maxForce The maximum force of the motor
  23941. * @param motorIndex The index of the motor
  23942. */
  23943. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23944. /**
  23945. * Sets the limit of the motor
  23946. * @param upperLimit The upper limit of the motor
  23947. * @param lowerLimit The lower limit of the motor
  23948. * @param motorIndex The index of the motor
  23949. */
  23950. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23951. }
  23952. /**
  23953. * Joint data for a Distance-Joint
  23954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23955. */
  23956. export interface DistanceJointData extends PhysicsJointData {
  23957. /**
  23958. * Max distance the 2 joint objects can be apart
  23959. */
  23960. maxDistance: number;
  23961. }
  23962. /**
  23963. * Joint data from a spring joint
  23964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23965. */
  23966. export interface SpringJointData extends PhysicsJointData {
  23967. /**
  23968. * Length of the spring
  23969. */
  23970. length: number;
  23971. /**
  23972. * Stiffness of the spring
  23973. */
  23974. stiffness: number;
  23975. /**
  23976. * Damping of the spring
  23977. */
  23978. damping: number;
  23979. /** this callback will be called when applying the force to the impostors. */
  23980. forceApplicationCallback: () => void;
  23981. }
  23982. }
  23983. declare module "babylonjs/Physics/physicsRaycastResult" {
  23984. import { Vector3 } from "babylonjs/Maths/math.vector";
  23985. /**
  23986. * Holds the data for the raycast result
  23987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23988. */
  23989. export class PhysicsRaycastResult {
  23990. private _hasHit;
  23991. private _hitDistance;
  23992. private _hitNormalWorld;
  23993. private _hitPointWorld;
  23994. private _rayFromWorld;
  23995. private _rayToWorld;
  23996. /**
  23997. * Gets if there was a hit
  23998. */
  23999. get hasHit(): boolean;
  24000. /**
  24001. * Gets the distance from the hit
  24002. */
  24003. get hitDistance(): number;
  24004. /**
  24005. * Gets the hit normal/direction in the world
  24006. */
  24007. get hitNormalWorld(): Vector3;
  24008. /**
  24009. * Gets the hit point in the world
  24010. */
  24011. get hitPointWorld(): Vector3;
  24012. /**
  24013. * Gets the ray "start point" of the ray in the world
  24014. */
  24015. get rayFromWorld(): Vector3;
  24016. /**
  24017. * Gets the ray "end point" of the ray in the world
  24018. */
  24019. get rayToWorld(): Vector3;
  24020. /**
  24021. * Sets the hit data (normal & point in world space)
  24022. * @param hitNormalWorld defines the normal in world space
  24023. * @param hitPointWorld defines the point in world space
  24024. */
  24025. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24026. /**
  24027. * Sets the distance from the start point to the hit point
  24028. * @param distance
  24029. */
  24030. setHitDistance(distance: number): void;
  24031. /**
  24032. * Calculates the distance manually
  24033. */
  24034. calculateHitDistance(): void;
  24035. /**
  24036. * Resets all the values to default
  24037. * @param from The from point on world space
  24038. * @param to The to point on world space
  24039. */
  24040. reset(from?: Vector3, to?: Vector3): void;
  24041. }
  24042. /**
  24043. * Interface for the size containing width and height
  24044. */
  24045. interface IXYZ {
  24046. /**
  24047. * X
  24048. */
  24049. x: number;
  24050. /**
  24051. * Y
  24052. */
  24053. y: number;
  24054. /**
  24055. * Z
  24056. */
  24057. z: number;
  24058. }
  24059. }
  24060. declare module "babylonjs/Physics/IPhysicsEngine" {
  24061. import { Nullable } from "babylonjs/types";
  24062. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24064. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24065. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24066. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24067. /**
  24068. * Interface used to describe a physics joint
  24069. */
  24070. export interface PhysicsImpostorJoint {
  24071. /** Defines the main impostor to which the joint is linked */
  24072. mainImpostor: PhysicsImpostor;
  24073. /** Defines the impostor that is connected to the main impostor using this joint */
  24074. connectedImpostor: PhysicsImpostor;
  24075. /** Defines the joint itself */
  24076. joint: PhysicsJoint;
  24077. }
  24078. /** @hidden */
  24079. export interface IPhysicsEnginePlugin {
  24080. world: any;
  24081. name: string;
  24082. setGravity(gravity: Vector3): void;
  24083. setTimeStep(timeStep: number): void;
  24084. getTimeStep(): number;
  24085. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24089. removePhysicsBody(impostor: PhysicsImpostor): void;
  24090. generateJoint(joint: PhysicsImpostorJoint): void;
  24091. removeJoint(joint: PhysicsImpostorJoint): void;
  24092. isSupported(): boolean;
  24093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24094. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24095. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24096. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24097. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24098. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24100. getBodyMass(impostor: PhysicsImpostor): number;
  24101. getBodyFriction(impostor: PhysicsImpostor): number;
  24102. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24103. getBodyRestitution(impostor: PhysicsImpostor): number;
  24104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24105. getBodyPressure?(impostor: PhysicsImpostor): number;
  24106. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24107. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24108. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24109. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24110. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24111. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24112. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24113. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24114. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24115. sleepBody(impostor: PhysicsImpostor): void;
  24116. wakeUpBody(impostor: PhysicsImpostor): void;
  24117. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24119. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24120. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24121. getRadius(impostor: PhysicsImpostor): number;
  24122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24124. dispose(): void;
  24125. }
  24126. /**
  24127. * Interface used to define a physics engine
  24128. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24129. */
  24130. export interface IPhysicsEngine {
  24131. /**
  24132. * Gets the gravity vector used by the simulation
  24133. */
  24134. gravity: Vector3;
  24135. /**
  24136. * Sets the gravity vector used by the simulation
  24137. * @param gravity defines the gravity vector to use
  24138. */
  24139. setGravity(gravity: Vector3): void;
  24140. /**
  24141. * Set the time step of the physics engine.
  24142. * Default is 1/60.
  24143. * To slow it down, enter 1/600 for example.
  24144. * To speed it up, 1/30
  24145. * @param newTimeStep the new timestep to apply to this world.
  24146. */
  24147. setTimeStep(newTimeStep: number): void;
  24148. /**
  24149. * Get the time step of the physics engine.
  24150. * @returns the current time step
  24151. */
  24152. getTimeStep(): number;
  24153. /**
  24154. * Set the sub time step of the physics engine.
  24155. * Default is 0 meaning there is no sub steps
  24156. * To increase physics resolution precision, set a small value (like 1 ms)
  24157. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24158. */
  24159. setSubTimeStep(subTimeStep: number): void;
  24160. /**
  24161. * Get the sub time step of the physics engine.
  24162. * @returns the current sub time step
  24163. */
  24164. getSubTimeStep(): number;
  24165. /**
  24166. * Release all resources
  24167. */
  24168. dispose(): void;
  24169. /**
  24170. * Gets the name of the current physics plugin
  24171. * @returns the name of the plugin
  24172. */
  24173. getPhysicsPluginName(): string;
  24174. /**
  24175. * Adding a new impostor for the impostor tracking.
  24176. * This will be done by the impostor itself.
  24177. * @param impostor the impostor to add
  24178. */
  24179. addImpostor(impostor: PhysicsImpostor): void;
  24180. /**
  24181. * Remove an impostor from the engine.
  24182. * This impostor and its mesh will not longer be updated by the physics engine.
  24183. * @param impostor the impostor to remove
  24184. */
  24185. removeImpostor(impostor: PhysicsImpostor): void;
  24186. /**
  24187. * Add a joint to the physics engine
  24188. * @param mainImpostor defines the main impostor to which the joint is added.
  24189. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24190. * @param joint defines the joint that will connect both impostors.
  24191. */
  24192. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24193. /**
  24194. * Removes a joint from the simulation
  24195. * @param mainImpostor defines the impostor used with the joint
  24196. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24197. * @param joint defines the joint to remove
  24198. */
  24199. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24200. /**
  24201. * Gets the current plugin used to run the simulation
  24202. * @returns current plugin
  24203. */
  24204. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24205. /**
  24206. * Gets the list of physic impostors
  24207. * @returns an array of PhysicsImpostor
  24208. */
  24209. getImpostors(): Array<PhysicsImpostor>;
  24210. /**
  24211. * Gets the impostor for a physics enabled object
  24212. * @param object defines the object impersonated by the impostor
  24213. * @returns the PhysicsImpostor or null if not found
  24214. */
  24215. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24216. /**
  24217. * Gets the impostor for a physics body object
  24218. * @param body defines physics body used by the impostor
  24219. * @returns the PhysicsImpostor or null if not found
  24220. */
  24221. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24222. /**
  24223. * Does a raycast in the physics world
  24224. * @param from when should the ray start?
  24225. * @param to when should the ray end?
  24226. * @returns PhysicsRaycastResult
  24227. */
  24228. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24229. /**
  24230. * Called by the scene. No need to call it.
  24231. * @param delta defines the timespam between frames
  24232. */
  24233. _step(delta: number): void;
  24234. }
  24235. }
  24236. declare module "babylonjs/Physics/physicsImpostor" {
  24237. import { Nullable, IndicesArray } from "babylonjs/types";
  24238. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24241. import { Scene } from "babylonjs/scene";
  24242. import { Bone } from "babylonjs/Bones/bone";
  24243. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24244. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24245. import { Space } from "babylonjs/Maths/math.axis";
  24246. /**
  24247. * The interface for the physics imposter parameters
  24248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24249. */
  24250. export interface PhysicsImpostorParameters {
  24251. /**
  24252. * The mass of the physics imposter
  24253. */
  24254. mass: number;
  24255. /**
  24256. * The friction of the physics imposter
  24257. */
  24258. friction?: number;
  24259. /**
  24260. * The coefficient of restitution of the physics imposter
  24261. */
  24262. restitution?: number;
  24263. /**
  24264. * The native options of the physics imposter
  24265. */
  24266. nativeOptions?: any;
  24267. /**
  24268. * Specifies if the parent should be ignored
  24269. */
  24270. ignoreParent?: boolean;
  24271. /**
  24272. * Specifies if bi-directional transformations should be disabled
  24273. */
  24274. disableBidirectionalTransformation?: boolean;
  24275. /**
  24276. * The pressure inside the physics imposter, soft object only
  24277. */
  24278. pressure?: number;
  24279. /**
  24280. * The stiffness the physics imposter, soft object only
  24281. */
  24282. stiffness?: number;
  24283. /**
  24284. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24285. */
  24286. velocityIterations?: number;
  24287. /**
  24288. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24289. */
  24290. positionIterations?: number;
  24291. /**
  24292. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24293. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24294. * Add to fix multiple points
  24295. */
  24296. fixedPoints?: number;
  24297. /**
  24298. * The collision margin around a soft object
  24299. */
  24300. margin?: number;
  24301. /**
  24302. * The collision margin around a soft object
  24303. */
  24304. damping?: number;
  24305. /**
  24306. * The path for a rope based on an extrusion
  24307. */
  24308. path?: any;
  24309. /**
  24310. * The shape of an extrusion used for a rope based on an extrusion
  24311. */
  24312. shape?: any;
  24313. }
  24314. /**
  24315. * Interface for a physics-enabled object
  24316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24317. */
  24318. export interface IPhysicsEnabledObject {
  24319. /**
  24320. * The position of the physics-enabled object
  24321. */
  24322. position: Vector3;
  24323. /**
  24324. * The rotation of the physics-enabled object
  24325. */
  24326. rotationQuaternion: Nullable<Quaternion>;
  24327. /**
  24328. * The scale of the physics-enabled object
  24329. */
  24330. scaling: Vector3;
  24331. /**
  24332. * The rotation of the physics-enabled object
  24333. */
  24334. rotation?: Vector3;
  24335. /**
  24336. * The parent of the physics-enabled object
  24337. */
  24338. parent?: any;
  24339. /**
  24340. * The bounding info of the physics-enabled object
  24341. * @returns The bounding info of the physics-enabled object
  24342. */
  24343. getBoundingInfo(): BoundingInfo;
  24344. /**
  24345. * Computes the world matrix
  24346. * @param force Specifies if the world matrix should be computed by force
  24347. * @returns A world matrix
  24348. */
  24349. computeWorldMatrix(force: boolean): Matrix;
  24350. /**
  24351. * Gets the world matrix
  24352. * @returns A world matrix
  24353. */
  24354. getWorldMatrix?(): Matrix;
  24355. /**
  24356. * Gets the child meshes
  24357. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24358. * @returns An array of abstract meshes
  24359. */
  24360. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24361. /**
  24362. * Gets the vertex data
  24363. * @param kind The type of vertex data
  24364. * @returns A nullable array of numbers, or a float32 array
  24365. */
  24366. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24367. /**
  24368. * Gets the indices from the mesh
  24369. * @returns A nullable array of index arrays
  24370. */
  24371. getIndices?(): Nullable<IndicesArray>;
  24372. /**
  24373. * Gets the scene from the mesh
  24374. * @returns the indices array or null
  24375. */
  24376. getScene?(): Scene;
  24377. /**
  24378. * Gets the absolute position from the mesh
  24379. * @returns the absolute position
  24380. */
  24381. getAbsolutePosition(): Vector3;
  24382. /**
  24383. * Gets the absolute pivot point from the mesh
  24384. * @returns the absolute pivot point
  24385. */
  24386. getAbsolutePivotPoint(): Vector3;
  24387. /**
  24388. * Rotates the mesh
  24389. * @param axis The axis of rotation
  24390. * @param amount The amount of rotation
  24391. * @param space The space of the rotation
  24392. * @returns The rotation transform node
  24393. */
  24394. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24395. /**
  24396. * Translates the mesh
  24397. * @param axis The axis of translation
  24398. * @param distance The distance of translation
  24399. * @param space The space of the translation
  24400. * @returns The transform node
  24401. */
  24402. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24403. /**
  24404. * Sets the absolute position of the mesh
  24405. * @param absolutePosition The absolute position of the mesh
  24406. * @returns The transform node
  24407. */
  24408. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24409. /**
  24410. * Gets the class name of the mesh
  24411. * @returns The class name
  24412. */
  24413. getClassName(): string;
  24414. }
  24415. /**
  24416. * Represents a physics imposter
  24417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24418. */
  24419. export class PhysicsImpostor {
  24420. /**
  24421. * The physics-enabled object used as the physics imposter
  24422. */
  24423. object: IPhysicsEnabledObject;
  24424. /**
  24425. * The type of the physics imposter
  24426. */
  24427. type: number;
  24428. private _options;
  24429. private _scene?;
  24430. /**
  24431. * The default object size of the imposter
  24432. */
  24433. static DEFAULT_OBJECT_SIZE: Vector3;
  24434. /**
  24435. * The identity quaternion of the imposter
  24436. */
  24437. static IDENTITY_QUATERNION: Quaternion;
  24438. /** @hidden */
  24439. _pluginData: any;
  24440. private _physicsEngine;
  24441. private _physicsBody;
  24442. private _bodyUpdateRequired;
  24443. private _onBeforePhysicsStepCallbacks;
  24444. private _onAfterPhysicsStepCallbacks;
  24445. /** @hidden */
  24446. _onPhysicsCollideCallbacks: Array<{
  24447. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24448. otherImpostors: Array<PhysicsImpostor>;
  24449. }>;
  24450. private _deltaPosition;
  24451. private _deltaRotation;
  24452. private _deltaRotationConjugated;
  24453. /** @hidden */
  24454. _isFromLine: boolean;
  24455. private _parent;
  24456. private _isDisposed;
  24457. private static _tmpVecs;
  24458. private static _tmpQuat;
  24459. /**
  24460. * Specifies if the physics imposter is disposed
  24461. */
  24462. get isDisposed(): boolean;
  24463. /**
  24464. * Gets the mass of the physics imposter
  24465. */
  24466. get mass(): number;
  24467. set mass(value: number);
  24468. /**
  24469. * Gets the coefficient of friction
  24470. */
  24471. get friction(): number;
  24472. /**
  24473. * Sets the coefficient of friction
  24474. */
  24475. set friction(value: number);
  24476. /**
  24477. * Gets the coefficient of restitution
  24478. */
  24479. get restitution(): number;
  24480. /**
  24481. * Sets the coefficient of restitution
  24482. */
  24483. set restitution(value: number);
  24484. /**
  24485. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24486. */
  24487. get pressure(): number;
  24488. /**
  24489. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24490. */
  24491. set pressure(value: number);
  24492. /**
  24493. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24494. */
  24495. get stiffness(): number;
  24496. /**
  24497. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24498. */
  24499. set stiffness(value: number);
  24500. /**
  24501. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24502. */
  24503. get velocityIterations(): number;
  24504. /**
  24505. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24506. */
  24507. set velocityIterations(value: number);
  24508. /**
  24509. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24510. */
  24511. get positionIterations(): number;
  24512. /**
  24513. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24514. */
  24515. set positionIterations(value: number);
  24516. /**
  24517. * The unique id of the physics imposter
  24518. * set by the physics engine when adding this impostor to the array
  24519. */
  24520. uniqueId: number;
  24521. /**
  24522. * @hidden
  24523. */
  24524. soft: boolean;
  24525. /**
  24526. * @hidden
  24527. */
  24528. segments: number;
  24529. private _joints;
  24530. /**
  24531. * Initializes the physics imposter
  24532. * @param object The physics-enabled object used as the physics imposter
  24533. * @param type The type of the physics imposter
  24534. * @param _options The options for the physics imposter
  24535. * @param _scene The Babylon scene
  24536. */
  24537. constructor(
  24538. /**
  24539. * The physics-enabled object used as the physics imposter
  24540. */
  24541. object: IPhysicsEnabledObject,
  24542. /**
  24543. * The type of the physics imposter
  24544. */
  24545. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24546. /**
  24547. * This function will completly initialize this impostor.
  24548. * It will create a new body - but only if this mesh has no parent.
  24549. * If it has, this impostor will not be used other than to define the impostor
  24550. * of the child mesh.
  24551. * @hidden
  24552. */
  24553. _init(): void;
  24554. private _getPhysicsParent;
  24555. /**
  24556. * Should a new body be generated.
  24557. * @returns boolean specifying if body initialization is required
  24558. */
  24559. isBodyInitRequired(): boolean;
  24560. /**
  24561. * Sets the updated scaling
  24562. * @param updated Specifies if the scaling is updated
  24563. */
  24564. setScalingUpdated(): void;
  24565. /**
  24566. * Force a regeneration of this or the parent's impostor's body.
  24567. * Use under cautious - This will remove all joints already implemented.
  24568. */
  24569. forceUpdate(): void;
  24570. /**
  24571. * Gets the body that holds this impostor. Either its own, or its parent.
  24572. */
  24573. get physicsBody(): any;
  24574. /**
  24575. * Get the parent of the physics imposter
  24576. * @returns Physics imposter or null
  24577. */
  24578. get parent(): Nullable<PhysicsImpostor>;
  24579. /**
  24580. * Sets the parent of the physics imposter
  24581. */
  24582. set parent(value: Nullable<PhysicsImpostor>);
  24583. /**
  24584. * Set the physics body. Used mainly by the physics engine/plugin
  24585. */
  24586. set physicsBody(physicsBody: any);
  24587. /**
  24588. * Resets the update flags
  24589. */
  24590. resetUpdateFlags(): void;
  24591. /**
  24592. * Gets the object extend size
  24593. * @returns the object extend size
  24594. */
  24595. getObjectExtendSize(): Vector3;
  24596. /**
  24597. * Gets the object center
  24598. * @returns The object center
  24599. */
  24600. getObjectCenter(): Vector3;
  24601. /**
  24602. * Get a specific parameter from the options parameters
  24603. * @param paramName The object parameter name
  24604. * @returns The object parameter
  24605. */
  24606. getParam(paramName: string): any;
  24607. /**
  24608. * Sets a specific parameter in the options given to the physics plugin
  24609. * @param paramName The parameter name
  24610. * @param value The value of the parameter
  24611. */
  24612. setParam(paramName: string, value: number): void;
  24613. /**
  24614. * Specifically change the body's mass option. Won't recreate the physics body object
  24615. * @param mass The mass of the physics imposter
  24616. */
  24617. setMass(mass: number): void;
  24618. /**
  24619. * Gets the linear velocity
  24620. * @returns linear velocity or null
  24621. */
  24622. getLinearVelocity(): Nullable<Vector3>;
  24623. /**
  24624. * Sets the linear velocity
  24625. * @param velocity linear velocity or null
  24626. */
  24627. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24628. /**
  24629. * Gets the angular velocity
  24630. * @returns angular velocity or null
  24631. */
  24632. getAngularVelocity(): Nullable<Vector3>;
  24633. /**
  24634. * Sets the angular velocity
  24635. * @param velocity The velocity or null
  24636. */
  24637. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24638. /**
  24639. * Execute a function with the physics plugin native code
  24640. * Provide a function the will have two variables - the world object and the physics body object
  24641. * @param func The function to execute with the physics plugin native code
  24642. */
  24643. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24644. /**
  24645. * Register a function that will be executed before the physics world is stepping forward
  24646. * @param func The function to execute before the physics world is stepped forward
  24647. */
  24648. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24649. /**
  24650. * Unregister a function that will be executed before the physics world is stepping forward
  24651. * @param func The function to execute before the physics world is stepped forward
  24652. */
  24653. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Register a function that will be executed after the physics step
  24656. * @param func The function to execute after physics step
  24657. */
  24658. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Unregisters a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * register a function that will be executed when this impostor collides against a different body
  24666. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24667. * @param func Callback that is executed on collision
  24668. */
  24669. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24670. /**
  24671. * Unregisters the physics imposter on contact
  24672. * @param collideAgainst The physics object to collide against
  24673. * @param func Callback to execute on collision
  24674. */
  24675. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24676. private _tmpQuat;
  24677. private _tmpQuat2;
  24678. /**
  24679. * Get the parent rotation
  24680. * @returns The parent rotation
  24681. */
  24682. getParentsRotation(): Quaternion;
  24683. /**
  24684. * this function is executed by the physics engine.
  24685. */
  24686. beforeStep: () => void;
  24687. /**
  24688. * this function is executed by the physics engine
  24689. */
  24690. afterStep: () => void;
  24691. /**
  24692. * Legacy collision detection event support
  24693. */
  24694. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24695. /**
  24696. * event and body object due to cannon's event-based architecture.
  24697. */
  24698. onCollide: (e: {
  24699. body: any;
  24700. }) => void;
  24701. /**
  24702. * Apply a force
  24703. * @param force The force to apply
  24704. * @param contactPoint The contact point for the force
  24705. * @returns The physics imposter
  24706. */
  24707. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24708. /**
  24709. * Apply an impulse
  24710. * @param force The impulse force
  24711. * @param contactPoint The contact point for the impulse force
  24712. * @returns The physics imposter
  24713. */
  24714. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24715. /**
  24716. * A help function to create a joint
  24717. * @param otherImpostor A physics imposter used to create a joint
  24718. * @param jointType The type of joint
  24719. * @param jointData The data for the joint
  24720. * @returns The physics imposter
  24721. */
  24722. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24723. /**
  24724. * Add a joint to this impostor with a different impostor
  24725. * @param otherImpostor A physics imposter used to add a joint
  24726. * @param joint The joint to add
  24727. * @returns The physics imposter
  24728. */
  24729. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24730. /**
  24731. * Add an anchor to a cloth impostor
  24732. * @param otherImpostor rigid impostor to anchor to
  24733. * @param width ratio across width from 0 to 1
  24734. * @param height ratio up height from 0 to 1
  24735. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24736. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24737. * @returns impostor the soft imposter
  24738. */
  24739. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24740. /**
  24741. * Add a hook to a rope impostor
  24742. * @param otherImpostor rigid impostor to anchor to
  24743. * @param length ratio across rope from 0 to 1
  24744. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24745. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24746. * @returns impostor the rope imposter
  24747. */
  24748. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24749. /**
  24750. * Will keep this body still, in a sleep mode.
  24751. * @returns the physics imposter
  24752. */
  24753. sleep(): PhysicsImpostor;
  24754. /**
  24755. * Wake the body up.
  24756. * @returns The physics imposter
  24757. */
  24758. wakeUp(): PhysicsImpostor;
  24759. /**
  24760. * Clones the physics imposter
  24761. * @param newObject The physics imposter clones to this physics-enabled object
  24762. * @returns A nullable physics imposter
  24763. */
  24764. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24765. /**
  24766. * Disposes the physics imposter
  24767. */
  24768. dispose(): void;
  24769. /**
  24770. * Sets the delta position
  24771. * @param position The delta position amount
  24772. */
  24773. setDeltaPosition(position: Vector3): void;
  24774. /**
  24775. * Sets the delta rotation
  24776. * @param rotation The delta rotation amount
  24777. */
  24778. setDeltaRotation(rotation: Quaternion): void;
  24779. /**
  24780. * Gets the box size of the physics imposter and stores the result in the input parameter
  24781. * @param result Stores the box size
  24782. * @returns The physics imposter
  24783. */
  24784. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24785. /**
  24786. * Gets the radius of the physics imposter
  24787. * @returns Radius of the physics imposter
  24788. */
  24789. getRadius(): number;
  24790. /**
  24791. * Sync a bone with this impostor
  24792. * @param bone The bone to sync to the impostor.
  24793. * @param boneMesh The mesh that the bone is influencing.
  24794. * @param jointPivot The pivot of the joint / bone in local space.
  24795. * @param distToJoint Optional distance from the impostor to the joint.
  24796. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24797. */
  24798. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24799. /**
  24800. * Sync impostor to a bone
  24801. * @param bone The bone that the impostor will be synced to.
  24802. * @param boneMesh The mesh that the bone is influencing.
  24803. * @param jointPivot The pivot of the joint / bone in local space.
  24804. * @param distToJoint Optional distance from the impostor to the joint.
  24805. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24806. * @param boneAxis Optional vector3 axis the bone is aligned with
  24807. */
  24808. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24809. /**
  24810. * No-Imposter type
  24811. */
  24812. static NoImpostor: number;
  24813. /**
  24814. * Sphere-Imposter type
  24815. */
  24816. static SphereImpostor: number;
  24817. /**
  24818. * Box-Imposter type
  24819. */
  24820. static BoxImpostor: number;
  24821. /**
  24822. * Plane-Imposter type
  24823. */
  24824. static PlaneImpostor: number;
  24825. /**
  24826. * Mesh-imposter type
  24827. */
  24828. static MeshImpostor: number;
  24829. /**
  24830. * Capsule-Impostor type (Ammo.js plugin only)
  24831. */
  24832. static CapsuleImpostor: number;
  24833. /**
  24834. * Cylinder-Imposter type
  24835. */
  24836. static CylinderImpostor: number;
  24837. /**
  24838. * Particle-Imposter type
  24839. */
  24840. static ParticleImpostor: number;
  24841. /**
  24842. * Heightmap-Imposter type
  24843. */
  24844. static HeightmapImpostor: number;
  24845. /**
  24846. * ConvexHull-Impostor type (Ammo.js plugin only)
  24847. */
  24848. static ConvexHullImpostor: number;
  24849. /**
  24850. * Custom-Imposter type (Ammo.js plugin only)
  24851. */
  24852. static CustomImpostor: number;
  24853. /**
  24854. * Rope-Imposter type
  24855. */
  24856. static RopeImpostor: number;
  24857. /**
  24858. * Cloth-Imposter type
  24859. */
  24860. static ClothImpostor: number;
  24861. /**
  24862. * Softbody-Imposter type
  24863. */
  24864. static SoftbodyImpostor: number;
  24865. }
  24866. }
  24867. declare module "babylonjs/Meshes/mesh" {
  24868. import { Observable } from "babylonjs/Misc/observable";
  24869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24870. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24871. import { Camera } from "babylonjs/Cameras/camera";
  24872. import { Scene } from "babylonjs/scene";
  24873. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24874. import { Color4 } from "babylonjs/Maths/math.color";
  24875. import { Engine } from "babylonjs/Engines/engine";
  24876. import { Node } from "babylonjs/node";
  24877. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24878. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24879. import { Buffer } from "babylonjs/Meshes/buffer";
  24880. import { Geometry } from "babylonjs/Meshes/geometry";
  24881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24883. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24884. import { Effect } from "babylonjs/Materials/effect";
  24885. import { Material } from "babylonjs/Materials/material";
  24886. import { Skeleton } from "babylonjs/Bones/skeleton";
  24887. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24888. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24889. import { Path3D } from "babylonjs/Maths/math.path";
  24890. import { Plane } from "babylonjs/Maths/math.plane";
  24891. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24892. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24893. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24894. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24895. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24896. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24897. /**
  24898. * @hidden
  24899. **/
  24900. export class _CreationDataStorage {
  24901. closePath?: boolean;
  24902. closeArray?: boolean;
  24903. idx: number[];
  24904. dashSize: number;
  24905. gapSize: number;
  24906. path3D: Path3D;
  24907. pathArray: Vector3[][];
  24908. arc: number;
  24909. radius: number;
  24910. cap: number;
  24911. tessellation: number;
  24912. }
  24913. /**
  24914. * @hidden
  24915. **/
  24916. class _InstanceDataStorage {
  24917. visibleInstances: any;
  24918. batchCache: _InstancesBatch;
  24919. instancesBufferSize: number;
  24920. instancesBuffer: Nullable<Buffer>;
  24921. instancesData: Float32Array;
  24922. overridenInstanceCount: number;
  24923. isFrozen: boolean;
  24924. previousBatch: Nullable<_InstancesBatch>;
  24925. hardwareInstancedRendering: boolean;
  24926. sideOrientation: number;
  24927. manualUpdate: boolean;
  24928. }
  24929. /**
  24930. * @hidden
  24931. **/
  24932. export class _InstancesBatch {
  24933. mustReturn: boolean;
  24934. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24935. renderSelf: boolean[];
  24936. hardwareInstancedRendering: boolean[];
  24937. }
  24938. /**
  24939. * Class used to represent renderable models
  24940. */
  24941. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24942. /**
  24943. * Mesh side orientation : usually the external or front surface
  24944. */
  24945. static readonly FRONTSIDE: number;
  24946. /**
  24947. * Mesh side orientation : usually the internal or back surface
  24948. */
  24949. static readonly BACKSIDE: number;
  24950. /**
  24951. * Mesh side orientation : both internal and external or front and back surfaces
  24952. */
  24953. static readonly DOUBLESIDE: number;
  24954. /**
  24955. * Mesh side orientation : by default, `FRONTSIDE`
  24956. */
  24957. static readonly DEFAULTSIDE: number;
  24958. /**
  24959. * Mesh cap setting : no cap
  24960. */
  24961. static readonly NO_CAP: number;
  24962. /**
  24963. * Mesh cap setting : one cap at the beginning of the mesh
  24964. */
  24965. static readonly CAP_START: number;
  24966. /**
  24967. * Mesh cap setting : one cap at the end of the mesh
  24968. */
  24969. static readonly CAP_END: number;
  24970. /**
  24971. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24972. */
  24973. static readonly CAP_ALL: number;
  24974. /**
  24975. * Mesh pattern setting : no flip or rotate
  24976. */
  24977. static readonly NO_FLIP: number;
  24978. /**
  24979. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24980. */
  24981. static readonly FLIP_TILE: number;
  24982. /**
  24983. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24984. */
  24985. static readonly ROTATE_TILE: number;
  24986. /**
  24987. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24988. */
  24989. static readonly FLIP_ROW: number;
  24990. /**
  24991. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24992. */
  24993. static readonly ROTATE_ROW: number;
  24994. /**
  24995. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24996. */
  24997. static readonly FLIP_N_ROTATE_TILE: number;
  24998. /**
  24999. * Mesh pattern setting : rotate pattern and rotate
  25000. */
  25001. static readonly FLIP_N_ROTATE_ROW: number;
  25002. /**
  25003. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25004. */
  25005. static readonly CENTER: number;
  25006. /**
  25007. * Mesh tile positioning : part tiles on left
  25008. */
  25009. static readonly LEFT: number;
  25010. /**
  25011. * Mesh tile positioning : part tiles on right
  25012. */
  25013. static readonly RIGHT: number;
  25014. /**
  25015. * Mesh tile positioning : part tiles on top
  25016. */
  25017. static readonly TOP: number;
  25018. /**
  25019. * Mesh tile positioning : part tiles on bottom
  25020. */
  25021. static readonly BOTTOM: number;
  25022. /**
  25023. * Gets the default side orientation.
  25024. * @param orientation the orientation to value to attempt to get
  25025. * @returns the default orientation
  25026. * @hidden
  25027. */
  25028. static _GetDefaultSideOrientation(orientation?: number): number;
  25029. private _internalMeshDataInfo;
  25030. /**
  25031. * An event triggered before rendering the mesh
  25032. */
  25033. get onBeforeRenderObservable(): Observable<Mesh>;
  25034. /**
  25035. * An event triggered before binding the mesh
  25036. */
  25037. get onBeforeBindObservable(): Observable<Mesh>;
  25038. /**
  25039. * An event triggered after rendering the mesh
  25040. */
  25041. get onAfterRenderObservable(): Observable<Mesh>;
  25042. /**
  25043. * An event triggered before drawing the mesh
  25044. */
  25045. get onBeforeDrawObservable(): Observable<Mesh>;
  25046. private _onBeforeDrawObserver;
  25047. /**
  25048. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25049. */
  25050. set onBeforeDraw(callback: () => void);
  25051. get hasInstances(): boolean;
  25052. /**
  25053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25054. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25055. */
  25056. delayLoadState: number;
  25057. /**
  25058. * Gets the list of instances created from this mesh
  25059. * it is not supposed to be modified manually.
  25060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25061. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25062. */
  25063. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25064. /**
  25065. * Gets the file containing delay loading data for this mesh
  25066. */
  25067. delayLoadingFile: string;
  25068. /** @hidden */
  25069. _binaryInfo: any;
  25070. /**
  25071. * User defined function used to change how LOD level selection is done
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25073. */
  25074. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25075. /**
  25076. * Gets or sets the morph target manager
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25078. */
  25079. get morphTargetManager(): Nullable<MorphTargetManager>;
  25080. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25081. /** @hidden */
  25082. _creationDataStorage: Nullable<_CreationDataStorage>;
  25083. /** @hidden */
  25084. _geometry: Nullable<Geometry>;
  25085. /** @hidden */
  25086. _delayInfo: Array<string>;
  25087. /** @hidden */
  25088. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25089. /** @hidden */
  25090. _instanceDataStorage: _InstanceDataStorage;
  25091. private _effectiveMaterial;
  25092. /** @hidden */
  25093. _shouldGenerateFlatShading: boolean;
  25094. /** @hidden */
  25095. _originalBuilderSideOrientation: number;
  25096. /**
  25097. * Use this property to change the original side orientation defined at construction time
  25098. */
  25099. overrideMaterialSideOrientation: Nullable<number>;
  25100. /**
  25101. * Gets the source mesh (the one used to clone this one from)
  25102. */
  25103. get source(): Nullable<Mesh>;
  25104. /**
  25105. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25106. */
  25107. get isUnIndexed(): boolean;
  25108. set isUnIndexed(value: boolean);
  25109. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25110. get worldMatrixInstancedBuffer(): Float32Array;
  25111. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25112. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25113. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25114. /**
  25115. * @constructor
  25116. * @param name The value used by scene.getMeshByName() to do a lookup.
  25117. * @param scene The scene to add this mesh to.
  25118. * @param parent The parent of this mesh, if it has one
  25119. * @param source An optional Mesh from which geometry is shared, cloned.
  25120. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25121. * When false, achieved by calling a clone(), also passing False.
  25122. * This will make creation of children, recursive.
  25123. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25124. */
  25125. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25126. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25127. doNotInstantiate: boolean;
  25128. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25129. /**
  25130. * Gets the class name
  25131. * @returns the string "Mesh".
  25132. */
  25133. getClassName(): string;
  25134. /** @hidden */
  25135. get _isMesh(): boolean;
  25136. /**
  25137. * Returns a description of this mesh
  25138. * @param fullDetails define if full details about this mesh must be used
  25139. * @returns a descriptive string representing this mesh
  25140. */
  25141. toString(fullDetails?: boolean): string;
  25142. /** @hidden */
  25143. _unBindEffect(): void;
  25144. /**
  25145. * Gets a boolean indicating if this mesh has LOD
  25146. */
  25147. get hasLODLevels(): boolean;
  25148. /**
  25149. * Gets the list of MeshLODLevel associated with the current mesh
  25150. * @returns an array of MeshLODLevel
  25151. */
  25152. getLODLevels(): MeshLODLevel[];
  25153. private _sortLODLevels;
  25154. /**
  25155. * Add a mesh as LOD level triggered at the given distance.
  25156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25157. * @param distance The distance from the center of the object to show this level
  25158. * @param mesh The mesh to be added as LOD level (can be null)
  25159. * @return This mesh (for chaining)
  25160. */
  25161. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25162. /**
  25163. * Returns the LOD level mesh at the passed distance or null if not found.
  25164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25165. * @param distance The distance from the center of the object to show this level
  25166. * @returns a Mesh or `null`
  25167. */
  25168. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25169. /**
  25170. * Remove a mesh from the LOD array
  25171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25172. * @param mesh defines the mesh to be removed
  25173. * @return This mesh (for chaining)
  25174. */
  25175. removeLODLevel(mesh: Mesh): Mesh;
  25176. /**
  25177. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25178. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25179. * @param camera defines the camera to use to compute distance
  25180. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25181. * @return This mesh (for chaining)
  25182. */
  25183. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25184. /**
  25185. * Gets the mesh internal Geometry object
  25186. */
  25187. get geometry(): Nullable<Geometry>;
  25188. /**
  25189. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25190. * @returns the total number of vertices
  25191. */
  25192. getTotalVertices(): number;
  25193. /**
  25194. * Returns the content of an associated vertex buffer
  25195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25196. * - VertexBuffer.PositionKind
  25197. * - VertexBuffer.UVKind
  25198. * - VertexBuffer.UV2Kind
  25199. * - VertexBuffer.UV3Kind
  25200. * - VertexBuffer.UV4Kind
  25201. * - VertexBuffer.UV5Kind
  25202. * - VertexBuffer.UV6Kind
  25203. * - VertexBuffer.ColorKind
  25204. * - VertexBuffer.MatricesIndicesKind
  25205. * - VertexBuffer.MatricesIndicesExtraKind
  25206. * - VertexBuffer.MatricesWeightsKind
  25207. * - VertexBuffer.MatricesWeightsExtraKind
  25208. * @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
  25209. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25210. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25211. */
  25212. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25213. /**
  25214. * Returns the mesh VertexBuffer object from the requested `kind`
  25215. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25216. * - VertexBuffer.PositionKind
  25217. * - VertexBuffer.NormalKind
  25218. * - VertexBuffer.UVKind
  25219. * - VertexBuffer.UV2Kind
  25220. * - VertexBuffer.UV3Kind
  25221. * - VertexBuffer.UV4Kind
  25222. * - VertexBuffer.UV5Kind
  25223. * - VertexBuffer.UV6Kind
  25224. * - VertexBuffer.ColorKind
  25225. * - VertexBuffer.MatricesIndicesKind
  25226. * - VertexBuffer.MatricesIndicesExtraKind
  25227. * - VertexBuffer.MatricesWeightsKind
  25228. * - VertexBuffer.MatricesWeightsExtraKind
  25229. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25230. */
  25231. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25232. /**
  25233. * Tests if a specific vertex buffer is associated with this mesh
  25234. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25235. * - VertexBuffer.PositionKind
  25236. * - VertexBuffer.NormalKind
  25237. * - VertexBuffer.UVKind
  25238. * - VertexBuffer.UV2Kind
  25239. * - VertexBuffer.UV3Kind
  25240. * - VertexBuffer.UV4Kind
  25241. * - VertexBuffer.UV5Kind
  25242. * - VertexBuffer.UV6Kind
  25243. * - VertexBuffer.ColorKind
  25244. * - VertexBuffer.MatricesIndicesKind
  25245. * - VertexBuffer.MatricesIndicesExtraKind
  25246. * - VertexBuffer.MatricesWeightsKind
  25247. * - VertexBuffer.MatricesWeightsExtraKind
  25248. * @returns a boolean
  25249. */
  25250. isVerticesDataPresent(kind: string): boolean;
  25251. /**
  25252. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25253. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25254. * - VertexBuffer.PositionKind
  25255. * - VertexBuffer.UVKind
  25256. * - VertexBuffer.UV2Kind
  25257. * - VertexBuffer.UV3Kind
  25258. * - VertexBuffer.UV4Kind
  25259. * - VertexBuffer.UV5Kind
  25260. * - VertexBuffer.UV6Kind
  25261. * - VertexBuffer.ColorKind
  25262. * - VertexBuffer.MatricesIndicesKind
  25263. * - VertexBuffer.MatricesIndicesExtraKind
  25264. * - VertexBuffer.MatricesWeightsKind
  25265. * - VertexBuffer.MatricesWeightsExtraKind
  25266. * @returns a boolean
  25267. */
  25268. isVertexBufferUpdatable(kind: string): boolean;
  25269. /**
  25270. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25271. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25272. * - VertexBuffer.PositionKind
  25273. * - VertexBuffer.NormalKind
  25274. * - VertexBuffer.UVKind
  25275. * - VertexBuffer.UV2Kind
  25276. * - VertexBuffer.UV3Kind
  25277. * - VertexBuffer.UV4Kind
  25278. * - VertexBuffer.UV5Kind
  25279. * - VertexBuffer.UV6Kind
  25280. * - VertexBuffer.ColorKind
  25281. * - VertexBuffer.MatricesIndicesKind
  25282. * - VertexBuffer.MatricesIndicesExtraKind
  25283. * - VertexBuffer.MatricesWeightsKind
  25284. * - VertexBuffer.MatricesWeightsExtraKind
  25285. * @returns an array of strings
  25286. */
  25287. getVerticesDataKinds(): string[];
  25288. /**
  25289. * Returns a positive integer : the total number of indices in this mesh geometry.
  25290. * @returns the numner of indices or zero if the mesh has no geometry.
  25291. */
  25292. getTotalIndices(): number;
  25293. /**
  25294. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25295. * @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.
  25296. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25297. * @returns the indices array or an empty array if the mesh has no geometry
  25298. */
  25299. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25300. get isBlocked(): boolean;
  25301. /**
  25302. * Determine if the current mesh is ready to be rendered
  25303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25304. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25305. * @returns true if all associated assets are ready (material, textures, shaders)
  25306. */
  25307. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25308. /**
  25309. * 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.
  25310. */
  25311. get areNormalsFrozen(): boolean;
  25312. /**
  25313. * 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.
  25314. * @returns the current mesh
  25315. */
  25316. freezeNormals(): Mesh;
  25317. /**
  25318. * 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
  25319. * @returns the current mesh
  25320. */
  25321. unfreezeNormals(): Mesh;
  25322. /**
  25323. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25324. */
  25325. set overridenInstanceCount(count: number);
  25326. /** @hidden */
  25327. _preActivate(): Mesh;
  25328. /** @hidden */
  25329. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25330. /** @hidden */
  25331. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25332. /**
  25333. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25334. * This means the mesh underlying bounding box and sphere are recomputed.
  25335. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25336. * @returns the current mesh
  25337. */
  25338. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25339. /** @hidden */
  25340. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25341. /**
  25342. * This function will subdivide the mesh into multiple submeshes
  25343. * @param count defines the expected number of submeshes
  25344. */
  25345. subdivide(count: number): void;
  25346. /**
  25347. * Copy a FloatArray into a specific associated vertex buffer
  25348. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25349. * - VertexBuffer.PositionKind
  25350. * - VertexBuffer.UVKind
  25351. * - VertexBuffer.UV2Kind
  25352. * - VertexBuffer.UV3Kind
  25353. * - VertexBuffer.UV4Kind
  25354. * - VertexBuffer.UV5Kind
  25355. * - VertexBuffer.UV6Kind
  25356. * - VertexBuffer.ColorKind
  25357. * - VertexBuffer.MatricesIndicesKind
  25358. * - VertexBuffer.MatricesIndicesExtraKind
  25359. * - VertexBuffer.MatricesWeightsKind
  25360. * - VertexBuffer.MatricesWeightsExtraKind
  25361. * @param data defines the data source
  25362. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25363. * @param stride defines the data stride size (can be null)
  25364. * @returns the current mesh
  25365. */
  25366. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25367. /**
  25368. * Delete a vertex buffer associated with this mesh
  25369. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25370. * - VertexBuffer.PositionKind
  25371. * - VertexBuffer.UVKind
  25372. * - VertexBuffer.UV2Kind
  25373. * - VertexBuffer.UV3Kind
  25374. * - VertexBuffer.UV4Kind
  25375. * - VertexBuffer.UV5Kind
  25376. * - VertexBuffer.UV6Kind
  25377. * - VertexBuffer.ColorKind
  25378. * - VertexBuffer.MatricesIndicesKind
  25379. * - VertexBuffer.MatricesIndicesExtraKind
  25380. * - VertexBuffer.MatricesWeightsKind
  25381. * - VertexBuffer.MatricesWeightsExtraKind
  25382. */
  25383. removeVerticesData(kind: string): void;
  25384. /**
  25385. * Flags an associated vertex buffer as updatable
  25386. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25387. * - VertexBuffer.PositionKind
  25388. * - VertexBuffer.UVKind
  25389. * - VertexBuffer.UV2Kind
  25390. * - VertexBuffer.UV3Kind
  25391. * - VertexBuffer.UV4Kind
  25392. * - VertexBuffer.UV5Kind
  25393. * - VertexBuffer.UV6Kind
  25394. * - VertexBuffer.ColorKind
  25395. * - VertexBuffer.MatricesIndicesKind
  25396. * - VertexBuffer.MatricesIndicesExtraKind
  25397. * - VertexBuffer.MatricesWeightsKind
  25398. * - VertexBuffer.MatricesWeightsExtraKind
  25399. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25400. */
  25401. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25402. /**
  25403. * Sets the mesh global Vertex Buffer
  25404. * @param buffer defines the buffer to use
  25405. * @returns the current mesh
  25406. */
  25407. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25408. /**
  25409. * Update a specific associated vertex buffer
  25410. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25411. * - VertexBuffer.PositionKind
  25412. * - VertexBuffer.UVKind
  25413. * - VertexBuffer.UV2Kind
  25414. * - VertexBuffer.UV3Kind
  25415. * - VertexBuffer.UV4Kind
  25416. * - VertexBuffer.UV5Kind
  25417. * - VertexBuffer.UV6Kind
  25418. * - VertexBuffer.ColorKind
  25419. * - VertexBuffer.MatricesIndicesKind
  25420. * - VertexBuffer.MatricesIndicesExtraKind
  25421. * - VertexBuffer.MatricesWeightsKind
  25422. * - VertexBuffer.MatricesWeightsExtraKind
  25423. * @param data defines the data source
  25424. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25425. * @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)
  25426. * @returns the current mesh
  25427. */
  25428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25429. /**
  25430. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25431. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25432. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25433. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25434. * @returns the current mesh
  25435. */
  25436. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25437. /**
  25438. * Creates a un-shared specific occurence of the geometry for the mesh.
  25439. * @returns the current mesh
  25440. */
  25441. makeGeometryUnique(): Mesh;
  25442. /**
  25443. * Set the index buffer of this mesh
  25444. * @param indices defines the source data
  25445. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25446. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25447. * @returns the current mesh
  25448. */
  25449. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25450. /**
  25451. * Update the current index buffer
  25452. * @param indices defines the source data
  25453. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25454. * @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)
  25455. * @returns the current mesh
  25456. */
  25457. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25458. /**
  25459. * Invert the geometry to move from a right handed system to a left handed one.
  25460. * @returns the current mesh
  25461. */
  25462. toLeftHanded(): Mesh;
  25463. /** @hidden */
  25464. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25465. /** @hidden */
  25466. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25467. /**
  25468. * Registers for this mesh a javascript function called just before the rendering process
  25469. * @param func defines the function to call before rendering this mesh
  25470. * @returns the current mesh
  25471. */
  25472. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25473. /**
  25474. * Disposes a previously registered javascript function called before the rendering
  25475. * @param func defines the function to remove
  25476. * @returns the current mesh
  25477. */
  25478. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25479. /**
  25480. * Registers for this mesh a javascript function called just after the rendering is complete
  25481. * @param func defines the function to call after rendering this mesh
  25482. * @returns the current mesh
  25483. */
  25484. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25485. /**
  25486. * Disposes a previously registered javascript function called after the rendering.
  25487. * @param func defines the function to remove
  25488. * @returns the current mesh
  25489. */
  25490. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25491. /** @hidden */
  25492. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25493. /** @hidden */
  25494. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25495. /** @hidden */
  25496. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25497. /** @hidden */
  25498. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25499. /** @hidden */
  25500. _rebuild(): void;
  25501. /** @hidden */
  25502. _freeze(): void;
  25503. /** @hidden */
  25504. _unFreeze(): void;
  25505. /**
  25506. * 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
  25507. * @param subMesh defines the subMesh to render
  25508. * @param enableAlphaMode defines if alpha mode can be changed
  25509. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25510. * @returns the current mesh
  25511. */
  25512. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25513. private _onBeforeDraw;
  25514. /**
  25515. * Renormalize the mesh and patch it up if there are no weights
  25516. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25517. * However in the case of zero weights then we set just a single influence to 1.
  25518. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25519. */
  25520. cleanMatrixWeights(): void;
  25521. private normalizeSkinFourWeights;
  25522. private normalizeSkinWeightsAndExtra;
  25523. /**
  25524. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25525. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25526. * the user know there was an issue with importing the mesh
  25527. * @returns a validation object with skinned, valid and report string
  25528. */
  25529. validateSkinning(): {
  25530. skinned: boolean;
  25531. valid: boolean;
  25532. report: string;
  25533. };
  25534. /** @hidden */
  25535. _checkDelayState(): Mesh;
  25536. private _queueLoad;
  25537. /**
  25538. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25539. * A mesh is in the frustum if its bounding box intersects the frustum
  25540. * @param frustumPlanes defines the frustum to test
  25541. * @returns true if the mesh is in the frustum planes
  25542. */
  25543. isInFrustum(frustumPlanes: Plane[]): boolean;
  25544. /**
  25545. * Sets the mesh material by the material or multiMaterial `id` property
  25546. * @param id is a string identifying the material or the multiMaterial
  25547. * @returns the current mesh
  25548. */
  25549. setMaterialByID(id: string): Mesh;
  25550. /**
  25551. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25552. * @returns an array of IAnimatable
  25553. */
  25554. getAnimatables(): IAnimatable[];
  25555. /**
  25556. * Modifies the mesh geometry according to the passed transformation matrix.
  25557. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25558. * The mesh normals are modified using the same transformation.
  25559. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25560. * @param transform defines the transform matrix to use
  25561. * @see http://doc.babylonjs.com/resources/baking_transformations
  25562. * @returns the current mesh
  25563. */
  25564. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25565. /**
  25566. * Modifies the mesh geometry according to its own current World Matrix.
  25567. * The mesh World Matrix is then reset.
  25568. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25569. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25570. * @see http://doc.babylonjs.com/resources/baking_transformations
  25571. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25572. * @returns the current mesh
  25573. */
  25574. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25575. /** @hidden */
  25576. get _positions(): Nullable<Vector3[]>;
  25577. /** @hidden */
  25578. _resetPointsArrayCache(): Mesh;
  25579. /** @hidden */
  25580. _generatePointsArray(): boolean;
  25581. /**
  25582. * Returns a new Mesh object generated from the current mesh properties.
  25583. * This method must not get confused with createInstance()
  25584. * @param name is a string, the name given to the new mesh
  25585. * @param newParent can be any Node object (default `null`)
  25586. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25587. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25588. * @returns a new mesh
  25589. */
  25590. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25591. /**
  25592. * Releases resources associated with this mesh.
  25593. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25594. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25595. */
  25596. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25597. /** @hidden */
  25598. _disposeInstanceSpecificData(): void;
  25599. /**
  25600. * Modifies the mesh geometry according to a displacement map.
  25601. * 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.
  25602. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25603. * @param url is a string, the URL from the image file is to be downloaded.
  25604. * @param minHeight is the lower limit of the displacement.
  25605. * @param maxHeight is the upper limit of the displacement.
  25606. * @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.
  25607. * @param uvOffset is an optional vector2 used to offset UV.
  25608. * @param uvScale is an optional vector2 used to scale UV.
  25609. * @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.
  25610. * @returns the Mesh.
  25611. */
  25612. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25613. /**
  25614. * Modifies the mesh geometry according to a displacementMap buffer.
  25615. * 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.
  25616. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25617. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25618. * @param heightMapWidth is the width of the buffer image.
  25619. * @param heightMapHeight is the height of the buffer image.
  25620. * @param minHeight is the lower limit of the displacement.
  25621. * @param maxHeight is the upper limit of the displacement.
  25622. * @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.
  25623. * @param uvOffset is an optional vector2 used to offset UV.
  25624. * @param uvScale is an optional vector2 used to scale UV.
  25625. * @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.
  25626. * @returns the Mesh.
  25627. */
  25628. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25629. /**
  25630. * Modify the mesh to get a flat shading rendering.
  25631. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25632. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25633. * @returns current mesh
  25634. */
  25635. convertToFlatShadedMesh(): Mesh;
  25636. /**
  25637. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25638. * In other words, more vertices, no more indices and a single bigger VBO.
  25639. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25640. * @returns current mesh
  25641. */
  25642. convertToUnIndexedMesh(): Mesh;
  25643. /**
  25644. * Inverses facet orientations.
  25645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25646. * @param flipNormals will also inverts the normals
  25647. * @returns current mesh
  25648. */
  25649. flipFaces(flipNormals?: boolean): Mesh;
  25650. /**
  25651. * Increase the number of facets and hence vertices in a mesh
  25652. * Vertex normals are interpolated from existing vertex normals
  25653. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25654. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25655. */
  25656. increaseVertices(numberPerEdge: number): void;
  25657. /**
  25658. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25659. * This will undo any application of covertToFlatShadedMesh
  25660. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25661. */
  25662. forceSharedVertices(): void;
  25663. /** @hidden */
  25664. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25665. /** @hidden */
  25666. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25667. /**
  25668. * Creates a new InstancedMesh object from the mesh model.
  25669. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25670. * @param name defines the name of the new instance
  25671. * @returns a new InstancedMesh
  25672. */
  25673. createInstance(name: string): InstancedMesh;
  25674. /**
  25675. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25676. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25677. * @returns the current mesh
  25678. */
  25679. synchronizeInstances(): Mesh;
  25680. /**
  25681. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25682. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25683. * This should be used together with the simplification to avoid disappearing triangles.
  25684. * @param successCallback an optional success callback to be called after the optimization finished.
  25685. * @returns the current mesh
  25686. */
  25687. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25688. /**
  25689. * Serialize current mesh
  25690. * @param serializationObject defines the object which will receive the serialization data
  25691. */
  25692. serialize(serializationObject: any): void;
  25693. /** @hidden */
  25694. _syncGeometryWithMorphTargetManager(): void;
  25695. /** @hidden */
  25696. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25697. /**
  25698. * Returns a new Mesh object parsed from the source provided.
  25699. * @param parsedMesh is the source
  25700. * @param scene defines the hosting scene
  25701. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25702. * @returns a new Mesh
  25703. */
  25704. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25705. /**
  25706. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25707. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25708. * @param name defines the name of the mesh to create
  25709. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25710. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25711. * @param closePath creates a seam between the first and the last points of each path of the path array
  25712. * @param offset is taken in account only if the `pathArray` is containing a single path
  25713. * @param scene defines the hosting scene
  25714. * @param updatable defines if the mesh must be flagged as updatable
  25715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25716. * @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)
  25717. * @returns a new Mesh
  25718. */
  25719. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25720. /**
  25721. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25722. * @param name defines the name of the mesh to create
  25723. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25724. * @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
  25725. * @param scene defines the hosting scene
  25726. * @param updatable defines if the mesh must be flagged as updatable
  25727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25728. * @returns a new Mesh
  25729. */
  25730. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25731. /**
  25732. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25733. * @param name defines the name of the mesh to create
  25734. * @param size sets the size (float) of each box side (default 1)
  25735. * @param scene defines the hosting scene
  25736. * @param updatable defines if the mesh must be flagged as updatable
  25737. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25738. * @returns a new Mesh
  25739. */
  25740. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25741. /**
  25742. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25743. * @param name defines the name of the mesh to create
  25744. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25745. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25746. * @param scene defines the hosting scene
  25747. * @param updatable defines if the mesh must be flagged as updatable
  25748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25749. * @returns a new Mesh
  25750. */
  25751. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25752. /**
  25753. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25754. * @param name defines the name of the mesh to create
  25755. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25756. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25757. * @param scene defines the hosting scene
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25761. /**
  25762. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25763. * @param name defines the name of the mesh to create
  25764. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25765. * @param diameterTop set the top cap diameter (floats, default 1)
  25766. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25767. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25768. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25769. * @param scene defines the hosting scene
  25770. * @param updatable defines if the mesh must be flagged as updatable
  25771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25772. * @returns a new Mesh
  25773. */
  25774. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25775. /**
  25776. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25777. * @param name defines the name of the mesh to create
  25778. * @param diameter sets the diameter size (float) of the torus (default 1)
  25779. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25780. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25781. * @param scene defines the hosting scene
  25782. * @param updatable defines if the mesh must be flagged as updatable
  25783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25784. * @returns a new Mesh
  25785. */
  25786. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25787. /**
  25788. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25789. * @param name defines the name of the mesh to create
  25790. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25791. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25792. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25793. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25794. * @param p the number of windings on X axis (positive integers, default 2)
  25795. * @param q the number of windings on Y axis (positive integers, default 3)
  25796. * @param scene defines the hosting scene
  25797. * @param updatable defines if the mesh must be flagged as updatable
  25798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25799. * @returns a new Mesh
  25800. */
  25801. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25802. /**
  25803. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25804. * @param name defines the name of the mesh to create
  25805. * @param points is an array successive Vector3
  25806. * @param scene defines the hosting scene
  25807. * @param updatable defines if the mesh must be flagged as updatable
  25808. * @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).
  25809. * @returns a new Mesh
  25810. */
  25811. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25812. /**
  25813. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25814. * @param name defines the name of the mesh to create
  25815. * @param points is an array successive Vector3
  25816. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25817. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25818. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25819. * @param scene defines the hosting scene
  25820. * @param updatable defines if the mesh must be flagged as updatable
  25821. * @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)
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25825. /**
  25826. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25827. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25828. * 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.
  25829. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25830. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25831. * Remember you can only change the shape positions, not their number when updating a polygon.
  25832. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25833. * @param name defines the name of the mesh to create
  25834. * @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
  25835. * @param scene defines the hosting scene
  25836. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25837. * @param updatable defines if the mesh must be flagged as updatable
  25838. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25839. * @param earcutInjection can be used to inject your own earcut reference
  25840. * @returns a new Mesh
  25841. */
  25842. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25843. /**
  25844. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25845. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25846. * @param name defines the name of the mesh to create
  25847. * @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
  25848. * @param depth defines the height of extrusion
  25849. * @param scene defines the hosting scene
  25850. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25851. * @param updatable defines if the mesh must be flagged as updatable
  25852. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25853. * @param earcutInjection can be used to inject your own earcut reference
  25854. * @returns a new Mesh
  25855. */
  25856. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25857. /**
  25858. * Creates an extruded shape mesh.
  25859. * 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
  25860. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25861. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25862. * @param name defines the name of the mesh to create
  25863. * @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
  25864. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25865. * @param scale is the value to scale the shape
  25866. * @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
  25867. * @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
  25868. * @param scene defines the hosting scene
  25869. * @param updatable defines if the mesh must be flagged as updatable
  25870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25871. * @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)
  25872. * @returns a new Mesh
  25873. */
  25874. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25875. /**
  25876. * Creates an custom extruded shape mesh.
  25877. * The custom extrusion is a parametric shape.
  25878. * It has no predefined shape. Its final shape will depend on the input parameters.
  25879. * Please consider using the same method from the MeshBuilder class instead
  25880. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25881. * @param name defines the name of the mesh to create
  25882. * @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
  25883. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25884. * @param scaleFunction is a custom Javascript function called on each path point
  25885. * @param rotationFunction is a custom Javascript function called on each path point
  25886. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25887. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25888. * @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
  25889. * @param scene defines the hosting scene
  25890. * @param updatable defines if the mesh must be flagged as updatable
  25891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25892. * @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)
  25893. * @returns a new Mesh
  25894. */
  25895. 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;
  25896. /**
  25897. * Creates lathe mesh.
  25898. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25899. * Please consider using the same method from the MeshBuilder class instead
  25900. * @param name defines the name of the mesh to create
  25901. * @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
  25902. * @param radius is the radius value of the lathe
  25903. * @param tessellation is the side number of the lathe.
  25904. * @param scene defines the hosting scene
  25905. * @param updatable defines if the mesh must be flagged as updatable
  25906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25907. * @returns a new Mesh
  25908. */
  25909. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25910. /**
  25911. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25912. * @param name defines the name of the mesh to create
  25913. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25914. * @param scene defines the hosting scene
  25915. * @param updatable defines if the mesh must be flagged as updatable
  25916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25917. * @returns a new Mesh
  25918. */
  25919. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25920. /**
  25921. * Creates a ground mesh.
  25922. * Please consider using the same method from the MeshBuilder class instead
  25923. * @param name defines the name of the mesh to create
  25924. * @param width set the width of the ground
  25925. * @param height set the height of the ground
  25926. * @param subdivisions sets the number of subdivisions per side
  25927. * @param scene defines the hosting scene
  25928. * @param updatable defines if the mesh must be flagged as updatable
  25929. * @returns a new Mesh
  25930. */
  25931. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25932. /**
  25933. * Creates a tiled ground mesh.
  25934. * Please consider using the same method from the MeshBuilder class instead
  25935. * @param name defines the name of the mesh to create
  25936. * @param xmin set the ground minimum X coordinate
  25937. * @param zmin set the ground minimum Y coordinate
  25938. * @param xmax set the ground maximum X coordinate
  25939. * @param zmax set the ground maximum Z coordinate
  25940. * @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
  25941. * @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
  25942. * @param scene defines the hosting scene
  25943. * @param updatable defines if the mesh must be flagged as updatable
  25944. * @returns a new Mesh
  25945. */
  25946. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25947. w: number;
  25948. h: number;
  25949. }, precision: {
  25950. w: number;
  25951. h: number;
  25952. }, scene: Scene, updatable?: boolean): Mesh;
  25953. /**
  25954. * Creates a ground mesh from a height map.
  25955. * Please consider using the same method from the MeshBuilder class instead
  25956. * @see http://doc.babylonjs.com/babylon101/height_map
  25957. * @param name defines the name of the mesh to create
  25958. * @param url sets the URL of the height map image resource
  25959. * @param width set the ground width size
  25960. * @param height set the ground height size
  25961. * @param subdivisions sets the number of subdivision per side
  25962. * @param minHeight is the minimum altitude on the ground
  25963. * @param maxHeight is the maximum altitude on the ground
  25964. * @param scene defines the hosting scene
  25965. * @param updatable defines if the mesh must be flagged as updatable
  25966. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25967. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25968. * @returns a new Mesh
  25969. */
  25970. 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;
  25971. /**
  25972. * Creates a tube mesh.
  25973. * The tube is a parametric shape.
  25974. * It has no predefined shape. Its final shape will depend on the input parameters.
  25975. * Please consider using the same method from the MeshBuilder class instead
  25976. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25977. * @param name defines the name of the mesh to create
  25978. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25979. * @param radius sets the tube radius size
  25980. * @param tessellation is the number of sides on the tubular surface
  25981. * @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
  25982. * @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
  25983. * @param scene defines the hosting scene
  25984. * @param updatable defines if the mesh must be flagged as updatable
  25985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25986. * @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)
  25987. * @returns a new Mesh
  25988. */
  25989. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25990. (i: number, distance: number): number;
  25991. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25992. /**
  25993. * Creates a polyhedron mesh.
  25994. * Please consider using the same method from the MeshBuilder class instead.
  25995. * * 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
  25996. * * The parameter `size` (positive float, default 1) sets the polygon size
  25997. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25998. * * 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`
  25999. * * 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
  26000. * * 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)`)
  26001. * * 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
  26002. * * 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
  26003. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26004. * * If you create a double-sided mesh, you can choose what parts of 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
  26005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26006. * @param name defines the name of the mesh to create
  26007. * @param options defines the options used to create the mesh
  26008. * @param scene defines the hosting scene
  26009. * @returns a new Mesh
  26010. */
  26011. static CreatePolyhedron(name: string, options: {
  26012. type?: number;
  26013. size?: number;
  26014. sizeX?: number;
  26015. sizeY?: number;
  26016. sizeZ?: number;
  26017. custom?: any;
  26018. faceUV?: Vector4[];
  26019. faceColors?: Color4[];
  26020. updatable?: boolean;
  26021. sideOrientation?: number;
  26022. }, scene: Scene): Mesh;
  26023. /**
  26024. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26025. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26026. * * 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`)
  26027. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26028. * * 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
  26029. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26030. * * If you create a double-sided mesh, you can choose what parts of 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
  26031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26032. * @param name defines the name of the mesh
  26033. * @param options defines the options used to create the mesh
  26034. * @param scene defines the hosting scene
  26035. * @returns a new Mesh
  26036. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26037. */
  26038. static CreateIcoSphere(name: string, options: {
  26039. radius?: number;
  26040. flat?: boolean;
  26041. subdivisions?: number;
  26042. sideOrientation?: number;
  26043. updatable?: boolean;
  26044. }, scene: Scene): Mesh;
  26045. /**
  26046. * Creates a decal mesh.
  26047. * Please consider using the same method from the MeshBuilder class instead.
  26048. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26049. * @param name defines the name of the mesh
  26050. * @param sourceMesh defines the mesh receiving the decal
  26051. * @param position sets the position of the decal in world coordinates
  26052. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26053. * @param size sets the decal scaling
  26054. * @param angle sets the angle to rotate the decal
  26055. * @returns a new Mesh
  26056. */
  26057. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26058. /**
  26059. * Prepare internal position array for software CPU skinning
  26060. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26061. */
  26062. setPositionsForCPUSkinning(): Float32Array;
  26063. /**
  26064. * Prepare internal normal array for software CPU skinning
  26065. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26066. */
  26067. setNormalsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Updates the vertex buffer by applying transformation from the bones
  26070. * @param skeleton defines the skeleton to apply to current mesh
  26071. * @returns the current mesh
  26072. */
  26073. applySkeleton(skeleton: Skeleton): Mesh;
  26074. /**
  26075. * 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
  26076. * @param meshes defines the list of meshes to scan
  26077. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26078. */
  26079. static MinMax(meshes: AbstractMesh[]): {
  26080. min: Vector3;
  26081. max: Vector3;
  26082. };
  26083. /**
  26084. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26085. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26086. * @returns a vector3
  26087. */
  26088. static Center(meshesOrMinMaxVector: {
  26089. min: Vector3;
  26090. max: Vector3;
  26091. } | AbstractMesh[]): Vector3;
  26092. /**
  26093. * Merge the array of meshes into a single mesh for performance reasons.
  26094. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26095. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26096. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26097. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26098. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26099. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26100. * @returns a new mesh
  26101. */
  26102. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26103. /** @hidden */
  26104. addInstance(instance: InstancedMesh): void;
  26105. /** @hidden */
  26106. removeInstance(instance: InstancedMesh): void;
  26107. }
  26108. }
  26109. declare module "babylonjs/Cameras/camera" {
  26110. import { SmartArray } from "babylonjs/Misc/smartArray";
  26111. import { Observable } from "babylonjs/Misc/observable";
  26112. import { Nullable } from "babylonjs/types";
  26113. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26114. import { Scene } from "babylonjs/scene";
  26115. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26116. import { Node } from "babylonjs/node";
  26117. import { Mesh } from "babylonjs/Meshes/mesh";
  26118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26119. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26120. import { Viewport } from "babylonjs/Maths/math.viewport";
  26121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26124. import { Ray } from "babylonjs/Culling/ray";
  26125. /**
  26126. * This is the base class of all the camera used in the application.
  26127. * @see http://doc.babylonjs.com/features/cameras
  26128. */
  26129. export class Camera extends Node {
  26130. /** @hidden */
  26131. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26132. /**
  26133. * This is the default projection mode used by the cameras.
  26134. * It helps recreating a feeling of perspective and better appreciate depth.
  26135. * This is the best way to simulate real life cameras.
  26136. */
  26137. static readonly PERSPECTIVE_CAMERA: number;
  26138. /**
  26139. * This helps creating camera with an orthographic mode.
  26140. * 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.
  26141. */
  26142. static readonly ORTHOGRAPHIC_CAMERA: number;
  26143. /**
  26144. * This is the default FOV mode for perspective cameras.
  26145. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26146. */
  26147. static readonly FOVMODE_VERTICAL_FIXED: number;
  26148. /**
  26149. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26150. */
  26151. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26152. /**
  26153. * This specifies ther is no need for a camera rig.
  26154. * Basically only one eye is rendered corresponding to the camera.
  26155. */
  26156. static readonly RIG_MODE_NONE: number;
  26157. /**
  26158. * Simulates a camera Rig with one blue eye and one red eye.
  26159. * This can be use with 3d blue and red glasses.
  26160. */
  26161. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26162. /**
  26163. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26164. */
  26165. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26166. /**
  26167. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26168. */
  26169. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26170. /**
  26171. * Defines that both eyes of the camera will be rendered over under each other.
  26172. */
  26173. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26174. /**
  26175. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26176. */
  26177. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26178. /**
  26179. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26180. */
  26181. static readonly RIG_MODE_VR: number;
  26182. /**
  26183. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26184. */
  26185. static readonly RIG_MODE_WEBVR: number;
  26186. /**
  26187. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26188. */
  26189. static readonly RIG_MODE_CUSTOM: number;
  26190. /**
  26191. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26192. */
  26193. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26194. /**
  26195. * Define the input manager associated with the camera.
  26196. */
  26197. inputs: CameraInputsManager<Camera>;
  26198. /** @hidden */
  26199. _position: Vector3;
  26200. /**
  26201. * Define the current local position of the camera in the scene
  26202. */
  26203. get position(): Vector3;
  26204. set position(newPosition: Vector3);
  26205. /**
  26206. * The vector the camera should consider as up.
  26207. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26208. */
  26209. upVector: Vector3;
  26210. /**
  26211. * Define the current limit on the left side for an orthographic camera
  26212. * In scene unit
  26213. */
  26214. orthoLeft: Nullable<number>;
  26215. /**
  26216. * Define the current limit on the right side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoRight: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the bottom side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoBottom: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the top side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoTop: Nullable<number>;
  26230. /**
  26231. * Field Of View is set in Radians. (default is 0.8)
  26232. */
  26233. fov: number;
  26234. /**
  26235. * Define the minimum distance the camera can see from.
  26236. * This is important to note that the depth buffer are not infinite and the closer it starts
  26237. * the more your scene might encounter depth fighting issue.
  26238. */
  26239. minZ: number;
  26240. /**
  26241. * Define the maximum distance the camera can see to.
  26242. * This is important to note that the depth buffer are not infinite and the further it end
  26243. * the more your scene might encounter depth fighting issue.
  26244. */
  26245. maxZ: number;
  26246. /**
  26247. * Define the default inertia of the camera.
  26248. * This helps giving a smooth feeling to the camera movement.
  26249. */
  26250. inertia: number;
  26251. /**
  26252. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26253. */
  26254. mode: number;
  26255. /**
  26256. * Define whether the camera is intermediate.
  26257. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26258. */
  26259. isIntermediate: boolean;
  26260. /**
  26261. * Define the viewport of the camera.
  26262. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26263. */
  26264. viewport: Viewport;
  26265. /**
  26266. * Restricts the camera to viewing objects with the same layerMask.
  26267. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26268. */
  26269. layerMask: number;
  26270. /**
  26271. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26272. */
  26273. fovMode: number;
  26274. /**
  26275. * Rig mode of the camera.
  26276. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26277. * This is normally controlled byt the camera themselves as internal use.
  26278. */
  26279. cameraRigMode: number;
  26280. /**
  26281. * Defines the distance between both "eyes" in case of a RIG
  26282. */
  26283. interaxialDistance: number;
  26284. /**
  26285. * Defines if stereoscopic rendering is done side by side or over under.
  26286. */
  26287. isStereoscopicSideBySide: boolean;
  26288. /**
  26289. * 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
  26290. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26291. * else in the scene. (Eg. security camera)
  26292. *
  26293. * 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)
  26294. */
  26295. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26296. /**
  26297. * When set, the camera will render to this render target instead of the default canvas
  26298. *
  26299. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26300. */
  26301. outputRenderTarget: Nullable<RenderTargetTexture>;
  26302. /**
  26303. * Observable triggered when the camera view matrix has changed.
  26304. */
  26305. onViewMatrixChangedObservable: Observable<Camera>;
  26306. /**
  26307. * Observable triggered when the camera Projection matrix has changed.
  26308. */
  26309. onProjectionMatrixChangedObservable: Observable<Camera>;
  26310. /**
  26311. * Observable triggered when the inputs have been processed.
  26312. */
  26313. onAfterCheckInputsObservable: Observable<Camera>;
  26314. /**
  26315. * Observable triggered when reset has been called and applied to the camera.
  26316. */
  26317. onRestoreStateObservable: Observable<Camera>;
  26318. /**
  26319. * Is this camera a part of a rig system?
  26320. */
  26321. isRigCamera: boolean;
  26322. /**
  26323. * If isRigCamera set to true this will be set with the parent camera.
  26324. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26325. */
  26326. rigParent?: Camera;
  26327. /** @hidden */
  26328. _cameraRigParams: any;
  26329. /** @hidden */
  26330. _rigCameras: Camera[];
  26331. /** @hidden */
  26332. _rigPostProcess: Nullable<PostProcess>;
  26333. protected _webvrViewMatrix: Matrix;
  26334. /** @hidden */
  26335. _skipRendering: boolean;
  26336. /** @hidden */
  26337. _projectionMatrix: Matrix;
  26338. /** @hidden */
  26339. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26340. /** @hidden */
  26341. _activeMeshes: SmartArray<AbstractMesh>;
  26342. protected _globalPosition: Vector3;
  26343. /** @hidden */
  26344. _computedViewMatrix: Matrix;
  26345. private _doNotComputeProjectionMatrix;
  26346. private _transformMatrix;
  26347. private _frustumPlanes;
  26348. private _refreshFrustumPlanes;
  26349. private _storedFov;
  26350. private _stateStored;
  26351. /**
  26352. * Instantiates a new camera object.
  26353. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26354. * @see http://doc.babylonjs.com/features/cameras
  26355. * @param name Defines the name of the camera in the scene
  26356. * @param position Defines the position of the camera
  26357. * @param scene Defines the scene the camera belongs too
  26358. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26359. */
  26360. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26361. /**
  26362. * Store current camera state (fov, position, etc..)
  26363. * @returns the camera
  26364. */
  26365. storeState(): Camera;
  26366. /**
  26367. * Restores the camera state values if it has been stored. You must call storeState() first
  26368. */
  26369. protected _restoreStateValues(): boolean;
  26370. /**
  26371. * Restored camera state. You must call storeState() first.
  26372. * @returns true if restored and false otherwise
  26373. */
  26374. restoreState(): boolean;
  26375. /**
  26376. * Gets the class name of the camera.
  26377. * @returns the class name
  26378. */
  26379. getClassName(): string;
  26380. /** @hidden */
  26381. readonly _isCamera: boolean;
  26382. /**
  26383. * Gets a string representation of the camera useful for debug purpose.
  26384. * @param fullDetails Defines that a more verboe level of logging is required
  26385. * @returns the string representation
  26386. */
  26387. toString(fullDetails?: boolean): string;
  26388. /**
  26389. * Gets the current world space position of the camera.
  26390. */
  26391. get globalPosition(): Vector3;
  26392. /**
  26393. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26394. * @returns the active meshe list
  26395. */
  26396. getActiveMeshes(): SmartArray<AbstractMesh>;
  26397. /**
  26398. * Check whether a mesh is part of the current active mesh list of the camera
  26399. * @param mesh Defines the mesh to check
  26400. * @returns true if active, false otherwise
  26401. */
  26402. isActiveMesh(mesh: Mesh): boolean;
  26403. /**
  26404. * Is this camera ready to be used/rendered
  26405. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26406. * @return true if the camera is ready
  26407. */
  26408. isReady(completeCheck?: boolean): boolean;
  26409. /** @hidden */
  26410. _initCache(): void;
  26411. /** @hidden */
  26412. _updateCache(ignoreParentClass?: boolean): void;
  26413. /** @hidden */
  26414. _isSynchronized(): boolean;
  26415. /** @hidden */
  26416. _isSynchronizedViewMatrix(): boolean;
  26417. /** @hidden */
  26418. _isSynchronizedProjectionMatrix(): boolean;
  26419. /**
  26420. * Attach the input controls to a specific dom element to get the input from.
  26421. * @param element Defines the element the controls should be listened from
  26422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26423. */
  26424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26425. /**
  26426. * Detach the current controls from the specified dom element.
  26427. * @param element Defines the element to stop listening the inputs from
  26428. */
  26429. detachControl(element: HTMLElement): void;
  26430. /**
  26431. * Update the camera state according to the different inputs gathered during the frame.
  26432. */
  26433. update(): void;
  26434. /** @hidden */
  26435. _checkInputs(): void;
  26436. /** @hidden */
  26437. get rigCameras(): Camera[];
  26438. /**
  26439. * Gets the post process used by the rig cameras
  26440. */
  26441. get rigPostProcess(): Nullable<PostProcess>;
  26442. /**
  26443. * Internal, gets the first post proces.
  26444. * @returns the first post process to be run on this camera.
  26445. */
  26446. _getFirstPostProcess(): Nullable<PostProcess>;
  26447. private _cascadePostProcessesToRigCams;
  26448. /**
  26449. * Attach a post process to the camera.
  26450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26451. * @param postProcess The post process to attach to the camera
  26452. * @param insertAt The position of the post process in case several of them are in use in the scene
  26453. * @returns the position the post process has been inserted at
  26454. */
  26455. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26456. /**
  26457. * Detach a post process to the camera.
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26459. * @param postProcess The post process to detach from the camera
  26460. */
  26461. detachPostProcess(postProcess: PostProcess): void;
  26462. /**
  26463. * Gets the current world matrix of the camera
  26464. */
  26465. getWorldMatrix(): Matrix;
  26466. /** @hidden */
  26467. _getViewMatrix(): Matrix;
  26468. /**
  26469. * Gets the current view matrix of the camera.
  26470. * @param force forces the camera to recompute the matrix without looking at the cached state
  26471. * @returns the view matrix
  26472. */
  26473. getViewMatrix(force?: boolean): Matrix;
  26474. /**
  26475. * Freeze the projection matrix.
  26476. * It will prevent the cache check of the camera projection compute and can speed up perf
  26477. * if no parameter of the camera are meant to change
  26478. * @param projection Defines manually a projection if necessary
  26479. */
  26480. freezeProjectionMatrix(projection?: Matrix): void;
  26481. /**
  26482. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26483. */
  26484. unfreezeProjectionMatrix(): void;
  26485. /**
  26486. * Gets the current projection matrix of the camera.
  26487. * @param force forces the camera to recompute the matrix without looking at the cached state
  26488. * @returns the projection matrix
  26489. */
  26490. getProjectionMatrix(force?: boolean): Matrix;
  26491. /**
  26492. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26493. * @returns a Matrix
  26494. */
  26495. getTransformationMatrix(): Matrix;
  26496. private _updateFrustumPlanes;
  26497. /**
  26498. * Checks if a cullable object (mesh...) is in the camera frustum
  26499. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26500. * @param target The object to check
  26501. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26502. * @returns true if the object is in frustum otherwise false
  26503. */
  26504. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26505. /**
  26506. * Checks if a cullable object (mesh...) is in the camera frustum
  26507. * Unlike isInFrustum this cheks the full bounding box
  26508. * @param target The object to check
  26509. * @returns true if the object is in frustum otherwise false
  26510. */
  26511. isCompletelyInFrustum(target: ICullable): boolean;
  26512. /**
  26513. * Gets a ray in the forward direction from the camera.
  26514. * @param length Defines the length of the ray to create
  26515. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26516. * @param origin Defines the start point of the ray which defaults to the camera position
  26517. * @returns the forward ray
  26518. */
  26519. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26520. /**
  26521. * Releases resources associated with this node.
  26522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26524. */
  26525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26526. /** @hidden */
  26527. _isLeftCamera: boolean;
  26528. /**
  26529. * Gets the left camera of a rig setup in case of Rigged Camera
  26530. */
  26531. get isLeftCamera(): boolean;
  26532. /** @hidden */
  26533. _isRightCamera: boolean;
  26534. /**
  26535. * Gets the right camera of a rig setup in case of Rigged Camera
  26536. */
  26537. get isRightCamera(): boolean;
  26538. /**
  26539. * Gets the left camera of a rig setup in case of Rigged Camera
  26540. */
  26541. get leftCamera(): Nullable<FreeCamera>;
  26542. /**
  26543. * Gets the right camera of a rig setup in case of Rigged Camera
  26544. */
  26545. get rightCamera(): Nullable<FreeCamera>;
  26546. /**
  26547. * Gets the left camera target of a rig setup in case of Rigged Camera
  26548. * @returns the target position
  26549. */
  26550. getLeftTarget(): Nullable<Vector3>;
  26551. /**
  26552. * Gets the right camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getRightTarget(): Nullable<Vector3>;
  26556. /**
  26557. * @hidden
  26558. */
  26559. setCameraRigMode(mode: number, rigParams: any): void;
  26560. /** @hidden */
  26561. static _setStereoscopicRigMode(camera: Camera): void;
  26562. /** @hidden */
  26563. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26564. /** @hidden */
  26565. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26566. /** @hidden */
  26567. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26568. /** @hidden */
  26569. _getVRProjectionMatrix(): Matrix;
  26570. protected _updateCameraRotationMatrix(): void;
  26571. protected _updateWebVRCameraRotationMatrix(): void;
  26572. /**
  26573. * This function MUST be overwritten by the different WebVR cameras available.
  26574. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26575. * @hidden
  26576. */
  26577. _getWebVRProjectionMatrix(): Matrix;
  26578. /**
  26579. * This function MUST be overwritten by the different WebVR cameras available.
  26580. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26581. * @hidden
  26582. */
  26583. _getWebVRViewMatrix(): Matrix;
  26584. /** @hidden */
  26585. setCameraRigParameter(name: string, value: any): void;
  26586. /**
  26587. * needs to be overridden by children so sub has required properties to be copied
  26588. * @hidden
  26589. */
  26590. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26591. /**
  26592. * May need to be overridden by children
  26593. * @hidden
  26594. */
  26595. _updateRigCameras(): void;
  26596. /** @hidden */
  26597. _setupInputs(): void;
  26598. /**
  26599. * Serialiaze the camera setup to a json represention
  26600. * @returns the JSON representation
  26601. */
  26602. serialize(): any;
  26603. /**
  26604. * Clones the current camera.
  26605. * @param name The cloned camera name
  26606. * @returns the cloned camera
  26607. */
  26608. clone(name: string): Camera;
  26609. /**
  26610. * Gets the direction of the camera relative to a given local axis.
  26611. * @param localAxis Defines the reference axis to provide a relative direction.
  26612. * @return the direction
  26613. */
  26614. getDirection(localAxis: Vector3): Vector3;
  26615. /**
  26616. * Returns the current camera absolute rotation
  26617. */
  26618. get absoluteRotation(): Quaternion;
  26619. /**
  26620. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26621. * @param localAxis Defines the reference axis to provide a relative direction.
  26622. * @param result Defines the vector to store the result in
  26623. */
  26624. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26625. /**
  26626. * Gets a camera constructor for a given camera type
  26627. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26628. * @param name The name of the camera the result will be able to instantiate
  26629. * @param scene The scene the result will construct the camera in
  26630. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26631. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26632. * @returns a factory method to construc the camera
  26633. */
  26634. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26635. /**
  26636. * Compute the world matrix of the camera.
  26637. * @returns the camera world matrix
  26638. */
  26639. computeWorldMatrix(): Matrix;
  26640. /**
  26641. * Parse a JSON and creates the camera from the parsed information
  26642. * @param parsedCamera The JSON to parse
  26643. * @param scene The scene to instantiate the camera in
  26644. * @returns the newly constructed camera
  26645. */
  26646. static Parse(parsedCamera: any, scene: Scene): Camera;
  26647. }
  26648. }
  26649. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26650. import { Nullable } from "babylonjs/types";
  26651. import { Scene } from "babylonjs/scene";
  26652. import { Vector4 } from "babylonjs/Maths/math.vector";
  26653. import { Mesh } from "babylonjs/Meshes/mesh";
  26654. /**
  26655. * Class containing static functions to help procedurally build meshes
  26656. */
  26657. export class DiscBuilder {
  26658. /**
  26659. * Creates a plane polygonal mesh. By default, this is a disc
  26660. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26661. * * 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
  26662. * * 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
  26663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26666. * @param name defines the name of the mesh
  26667. * @param options defines the options used to create the mesh
  26668. * @param scene defines the hosting scene
  26669. * @returns the plane polygonal mesh
  26670. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26671. */
  26672. static CreateDisc(name: string, options: {
  26673. radius?: number;
  26674. tessellation?: number;
  26675. arc?: number;
  26676. updatable?: boolean;
  26677. sideOrientation?: number;
  26678. frontUVs?: Vector4;
  26679. backUVs?: Vector4;
  26680. }, scene?: Nullable<Scene>): Mesh;
  26681. }
  26682. }
  26683. declare module "babylonjs/Materials/fresnelParameters" {
  26684. import { Color3 } from "babylonjs/Maths/math.color";
  26685. /**
  26686. * This represents all the required information to add a fresnel effect on a material:
  26687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26688. */
  26689. export class FresnelParameters {
  26690. private _isEnabled;
  26691. /**
  26692. * Define if the fresnel effect is enable or not.
  26693. */
  26694. get isEnabled(): boolean;
  26695. set isEnabled(value: boolean);
  26696. /**
  26697. * Define the color used on edges (grazing angle)
  26698. */
  26699. leftColor: Color3;
  26700. /**
  26701. * Define the color used on center
  26702. */
  26703. rightColor: Color3;
  26704. /**
  26705. * Define bias applied to computed fresnel term
  26706. */
  26707. bias: number;
  26708. /**
  26709. * Defined the power exponent applied to fresnel term
  26710. */
  26711. power: number;
  26712. /**
  26713. * Clones the current fresnel and its valuues
  26714. * @returns a clone fresnel configuration
  26715. */
  26716. clone(): FresnelParameters;
  26717. /**
  26718. * Serializes the current fresnel parameters to a JSON representation.
  26719. * @return the JSON serialization
  26720. */
  26721. serialize(): any;
  26722. /**
  26723. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26724. * @param parsedFresnelParameters Define the JSON representation
  26725. * @returns the parsed parameters
  26726. */
  26727. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26728. }
  26729. }
  26730. declare module "babylonjs/Materials/pushMaterial" {
  26731. import { Nullable } from "babylonjs/types";
  26732. import { Scene } from "babylonjs/scene";
  26733. import { Matrix } from "babylonjs/Maths/math.vector";
  26734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26735. import { Mesh } from "babylonjs/Meshes/mesh";
  26736. import { Material } from "babylonjs/Materials/material";
  26737. import { Effect } from "babylonjs/Materials/effect";
  26738. /**
  26739. * Base class of materials working in push mode in babylon JS
  26740. * @hidden
  26741. */
  26742. export class PushMaterial extends Material {
  26743. protected _activeEffect: Effect;
  26744. protected _normalMatrix: Matrix;
  26745. /**
  26746. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26747. * This means that the material can keep using a previous shader while a new one is being compiled.
  26748. * This is mostly used when shader parallel compilation is supported (true by default)
  26749. */
  26750. allowShaderHotSwapping: boolean;
  26751. constructor(name: string, scene: Scene);
  26752. getEffect(): Effect;
  26753. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26754. /**
  26755. * Binds the given world matrix to the active effect
  26756. *
  26757. * @param world the matrix to bind
  26758. */
  26759. bindOnlyWorldMatrix(world: Matrix): void;
  26760. /**
  26761. * Binds the given normal matrix to the active effect
  26762. *
  26763. * @param normalMatrix the matrix to bind
  26764. */
  26765. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26766. bind(world: Matrix, mesh?: Mesh): void;
  26767. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26768. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26769. }
  26770. }
  26771. declare module "babylonjs/Materials/materialFlags" {
  26772. /**
  26773. * This groups all the flags used to control the materials channel.
  26774. */
  26775. export class MaterialFlags {
  26776. private static _DiffuseTextureEnabled;
  26777. /**
  26778. * Are diffuse textures enabled in the application.
  26779. */
  26780. static get DiffuseTextureEnabled(): boolean;
  26781. static set DiffuseTextureEnabled(value: boolean);
  26782. private static _AmbientTextureEnabled;
  26783. /**
  26784. * Are ambient textures enabled in the application.
  26785. */
  26786. static get AmbientTextureEnabled(): boolean;
  26787. static set AmbientTextureEnabled(value: boolean);
  26788. private static _OpacityTextureEnabled;
  26789. /**
  26790. * Are opacity textures enabled in the application.
  26791. */
  26792. static get OpacityTextureEnabled(): boolean;
  26793. static set OpacityTextureEnabled(value: boolean);
  26794. private static _ReflectionTextureEnabled;
  26795. /**
  26796. * Are reflection textures enabled in the application.
  26797. */
  26798. static get ReflectionTextureEnabled(): boolean;
  26799. static set ReflectionTextureEnabled(value: boolean);
  26800. private static _EmissiveTextureEnabled;
  26801. /**
  26802. * Are emissive textures enabled in the application.
  26803. */
  26804. static get EmissiveTextureEnabled(): boolean;
  26805. static set EmissiveTextureEnabled(value: boolean);
  26806. private static _SpecularTextureEnabled;
  26807. /**
  26808. * Are specular textures enabled in the application.
  26809. */
  26810. static get SpecularTextureEnabled(): boolean;
  26811. static set SpecularTextureEnabled(value: boolean);
  26812. private static _BumpTextureEnabled;
  26813. /**
  26814. * Are bump textures enabled in the application.
  26815. */
  26816. static get BumpTextureEnabled(): boolean;
  26817. static set BumpTextureEnabled(value: boolean);
  26818. private static _LightmapTextureEnabled;
  26819. /**
  26820. * Are lightmap textures enabled in the application.
  26821. */
  26822. static get LightmapTextureEnabled(): boolean;
  26823. static set LightmapTextureEnabled(value: boolean);
  26824. private static _RefractionTextureEnabled;
  26825. /**
  26826. * Are refraction textures enabled in the application.
  26827. */
  26828. static get RefractionTextureEnabled(): boolean;
  26829. static set RefractionTextureEnabled(value: boolean);
  26830. private static _ColorGradingTextureEnabled;
  26831. /**
  26832. * Are color grading textures enabled in the application.
  26833. */
  26834. static get ColorGradingTextureEnabled(): boolean;
  26835. static set ColorGradingTextureEnabled(value: boolean);
  26836. private static _FresnelEnabled;
  26837. /**
  26838. * Are fresnels enabled in the application.
  26839. */
  26840. static get FresnelEnabled(): boolean;
  26841. static set FresnelEnabled(value: boolean);
  26842. private static _ClearCoatTextureEnabled;
  26843. /**
  26844. * Are clear coat textures enabled in the application.
  26845. */
  26846. static get ClearCoatTextureEnabled(): boolean;
  26847. static set ClearCoatTextureEnabled(value: boolean);
  26848. private static _ClearCoatBumpTextureEnabled;
  26849. /**
  26850. * Are clear coat bump textures enabled in the application.
  26851. */
  26852. static get ClearCoatBumpTextureEnabled(): boolean;
  26853. static set ClearCoatBumpTextureEnabled(value: boolean);
  26854. private static _ClearCoatTintTextureEnabled;
  26855. /**
  26856. * Are clear coat tint textures enabled in the application.
  26857. */
  26858. static get ClearCoatTintTextureEnabled(): boolean;
  26859. static set ClearCoatTintTextureEnabled(value: boolean);
  26860. private static _SheenTextureEnabled;
  26861. /**
  26862. * Are sheen textures enabled in the application.
  26863. */
  26864. static get SheenTextureEnabled(): boolean;
  26865. static set SheenTextureEnabled(value: boolean);
  26866. private static _AnisotropicTextureEnabled;
  26867. /**
  26868. * Are anisotropic textures enabled in the application.
  26869. */
  26870. static get AnisotropicTextureEnabled(): boolean;
  26871. static set AnisotropicTextureEnabled(value: boolean);
  26872. private static _ThicknessTextureEnabled;
  26873. /**
  26874. * Are thickness textures enabled in the application.
  26875. */
  26876. static get ThicknessTextureEnabled(): boolean;
  26877. static set ThicknessTextureEnabled(value: boolean);
  26878. }
  26879. }
  26880. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26881. /** @hidden */
  26882. export var defaultFragmentDeclaration: {
  26883. name: string;
  26884. shader: string;
  26885. };
  26886. }
  26887. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26888. /** @hidden */
  26889. export var defaultUboDeclaration: {
  26890. name: string;
  26891. shader: string;
  26892. };
  26893. }
  26894. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26895. /** @hidden */
  26896. export var lightFragmentDeclaration: {
  26897. name: string;
  26898. shader: string;
  26899. };
  26900. }
  26901. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26902. /** @hidden */
  26903. export var lightUboDeclaration: {
  26904. name: string;
  26905. shader: string;
  26906. };
  26907. }
  26908. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26909. /** @hidden */
  26910. export var lightsFragmentFunctions: {
  26911. name: string;
  26912. shader: string;
  26913. };
  26914. }
  26915. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26916. /** @hidden */
  26917. export var shadowsFragmentFunctions: {
  26918. name: string;
  26919. shader: string;
  26920. };
  26921. }
  26922. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26923. /** @hidden */
  26924. export var fresnelFunction: {
  26925. name: string;
  26926. shader: string;
  26927. };
  26928. }
  26929. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26930. /** @hidden */
  26931. export var reflectionFunction: {
  26932. name: string;
  26933. shader: string;
  26934. };
  26935. }
  26936. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26937. /** @hidden */
  26938. export var bumpFragmentFunctions: {
  26939. name: string;
  26940. shader: string;
  26941. };
  26942. }
  26943. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26944. /** @hidden */
  26945. export var logDepthDeclaration: {
  26946. name: string;
  26947. shader: string;
  26948. };
  26949. }
  26950. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26951. /** @hidden */
  26952. export var bumpFragment: {
  26953. name: string;
  26954. shader: string;
  26955. };
  26956. }
  26957. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26958. /** @hidden */
  26959. export var depthPrePass: {
  26960. name: string;
  26961. shader: string;
  26962. };
  26963. }
  26964. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26965. /** @hidden */
  26966. export var lightFragment: {
  26967. name: string;
  26968. shader: string;
  26969. };
  26970. }
  26971. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26972. /** @hidden */
  26973. export var logDepthFragment: {
  26974. name: string;
  26975. shader: string;
  26976. };
  26977. }
  26978. declare module "babylonjs/Shaders/default.fragment" {
  26979. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26980. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26981. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26982. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26984. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26985. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26986. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26987. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26992. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26993. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26996. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26997. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26998. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26999. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27000. /** @hidden */
  27001. export var defaultPixelShader: {
  27002. name: string;
  27003. shader: string;
  27004. };
  27005. }
  27006. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27007. /** @hidden */
  27008. export var defaultVertexDeclaration: {
  27009. name: string;
  27010. shader: string;
  27011. };
  27012. }
  27013. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27014. /** @hidden */
  27015. export var bumpVertexDeclaration: {
  27016. name: string;
  27017. shader: string;
  27018. };
  27019. }
  27020. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27021. /** @hidden */
  27022. export var bumpVertex: {
  27023. name: string;
  27024. shader: string;
  27025. };
  27026. }
  27027. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27028. /** @hidden */
  27029. export var fogVertex: {
  27030. name: string;
  27031. shader: string;
  27032. };
  27033. }
  27034. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27035. /** @hidden */
  27036. export var shadowsVertex: {
  27037. name: string;
  27038. shader: string;
  27039. };
  27040. }
  27041. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27042. /** @hidden */
  27043. export var pointCloudVertex: {
  27044. name: string;
  27045. shader: string;
  27046. };
  27047. }
  27048. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27049. /** @hidden */
  27050. export var logDepthVertex: {
  27051. name: string;
  27052. shader: string;
  27053. };
  27054. }
  27055. declare module "babylonjs/Shaders/default.vertex" {
  27056. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27057. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27059. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27060. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27061. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27064. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27070. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27071. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27072. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27073. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27074. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27078. /** @hidden */
  27079. export var defaultVertexShader: {
  27080. name: string;
  27081. shader: string;
  27082. };
  27083. }
  27084. declare module "babylonjs/Materials/standardMaterial" {
  27085. import { SmartArray } from "babylonjs/Misc/smartArray";
  27086. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27087. import { Nullable } from "babylonjs/types";
  27088. import { Scene } from "babylonjs/scene";
  27089. import { Matrix } from "babylonjs/Maths/math.vector";
  27090. import { Color3 } from "babylonjs/Maths/math.color";
  27091. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27093. import { Mesh } from "babylonjs/Meshes/mesh";
  27094. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27095. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27096. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27097. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27098. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27101. import "babylonjs/Shaders/default.fragment";
  27102. import "babylonjs/Shaders/default.vertex";
  27103. /** @hidden */
  27104. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27105. MAINUV1: boolean;
  27106. MAINUV2: boolean;
  27107. DIFFUSE: boolean;
  27108. DIFFUSEDIRECTUV: number;
  27109. AMBIENT: boolean;
  27110. AMBIENTDIRECTUV: number;
  27111. OPACITY: boolean;
  27112. OPACITYDIRECTUV: number;
  27113. OPACITYRGB: boolean;
  27114. REFLECTION: boolean;
  27115. EMISSIVE: boolean;
  27116. EMISSIVEDIRECTUV: number;
  27117. SPECULAR: boolean;
  27118. SPECULARDIRECTUV: number;
  27119. BUMP: boolean;
  27120. BUMPDIRECTUV: number;
  27121. PARALLAX: boolean;
  27122. PARALLAXOCCLUSION: boolean;
  27123. SPECULAROVERALPHA: boolean;
  27124. CLIPPLANE: boolean;
  27125. CLIPPLANE2: boolean;
  27126. CLIPPLANE3: boolean;
  27127. CLIPPLANE4: boolean;
  27128. CLIPPLANE5: boolean;
  27129. CLIPPLANE6: boolean;
  27130. ALPHATEST: boolean;
  27131. DEPTHPREPASS: boolean;
  27132. ALPHAFROMDIFFUSE: boolean;
  27133. POINTSIZE: boolean;
  27134. FOG: boolean;
  27135. SPECULARTERM: boolean;
  27136. DIFFUSEFRESNEL: boolean;
  27137. OPACITYFRESNEL: boolean;
  27138. REFLECTIONFRESNEL: boolean;
  27139. REFRACTIONFRESNEL: boolean;
  27140. EMISSIVEFRESNEL: boolean;
  27141. FRESNEL: boolean;
  27142. NORMAL: boolean;
  27143. UV1: boolean;
  27144. UV2: boolean;
  27145. VERTEXCOLOR: boolean;
  27146. VERTEXALPHA: boolean;
  27147. NUM_BONE_INFLUENCERS: number;
  27148. BonesPerMesh: number;
  27149. BONETEXTURE: boolean;
  27150. INSTANCES: boolean;
  27151. GLOSSINESS: boolean;
  27152. ROUGHNESS: boolean;
  27153. EMISSIVEASILLUMINATION: boolean;
  27154. LINKEMISSIVEWITHDIFFUSE: boolean;
  27155. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27156. LIGHTMAP: boolean;
  27157. LIGHTMAPDIRECTUV: number;
  27158. OBJECTSPACE_NORMALMAP: boolean;
  27159. USELIGHTMAPASSHADOWMAP: boolean;
  27160. REFLECTIONMAP_3D: boolean;
  27161. REFLECTIONMAP_SPHERICAL: boolean;
  27162. REFLECTIONMAP_PLANAR: boolean;
  27163. REFLECTIONMAP_CUBIC: boolean;
  27164. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27165. REFLECTIONMAP_PROJECTION: boolean;
  27166. REFLECTIONMAP_SKYBOX: boolean;
  27167. REFLECTIONMAP_EXPLICIT: boolean;
  27168. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27169. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27170. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27171. INVERTCUBICMAP: boolean;
  27172. LOGARITHMICDEPTH: boolean;
  27173. REFRACTION: boolean;
  27174. REFRACTIONMAP_3D: boolean;
  27175. REFLECTIONOVERALPHA: boolean;
  27176. TWOSIDEDLIGHTING: boolean;
  27177. SHADOWFLOAT: boolean;
  27178. MORPHTARGETS: boolean;
  27179. MORPHTARGETS_NORMAL: boolean;
  27180. MORPHTARGETS_TANGENT: boolean;
  27181. MORPHTARGETS_UV: boolean;
  27182. NUM_MORPH_INFLUENCERS: number;
  27183. NONUNIFORMSCALING: boolean;
  27184. PREMULTIPLYALPHA: boolean;
  27185. IMAGEPROCESSING: boolean;
  27186. VIGNETTE: boolean;
  27187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27188. VIGNETTEBLENDMODEOPAQUE: boolean;
  27189. TONEMAPPING: boolean;
  27190. TONEMAPPING_ACES: boolean;
  27191. CONTRAST: boolean;
  27192. COLORCURVES: boolean;
  27193. COLORGRADING: boolean;
  27194. COLORGRADING3D: boolean;
  27195. SAMPLER3DGREENDEPTH: boolean;
  27196. SAMPLER3DBGRMAP: boolean;
  27197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27198. MULTIVIEW: boolean;
  27199. /**
  27200. * If the reflection texture on this material is in linear color space
  27201. * @hidden
  27202. */
  27203. IS_REFLECTION_LINEAR: boolean;
  27204. /**
  27205. * If the refraction texture on this material is in linear color space
  27206. * @hidden
  27207. */
  27208. IS_REFRACTION_LINEAR: boolean;
  27209. EXPOSURE: boolean;
  27210. constructor();
  27211. setReflectionMode(modeToEnable: string): void;
  27212. }
  27213. /**
  27214. * This is the default material used in Babylon. It is the best trade off between quality
  27215. * and performances.
  27216. * @see http://doc.babylonjs.com/babylon101/materials
  27217. */
  27218. export class StandardMaterial extends PushMaterial {
  27219. private _diffuseTexture;
  27220. /**
  27221. * The basic texture of the material as viewed under a light.
  27222. */
  27223. diffuseTexture: Nullable<BaseTexture>;
  27224. private _ambientTexture;
  27225. /**
  27226. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27227. */
  27228. ambientTexture: Nullable<BaseTexture>;
  27229. private _opacityTexture;
  27230. /**
  27231. * Define the transparency of the material from a texture.
  27232. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27233. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27234. */
  27235. opacityTexture: Nullable<BaseTexture>;
  27236. private _reflectionTexture;
  27237. /**
  27238. * Define the texture used to display the reflection.
  27239. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27240. */
  27241. reflectionTexture: Nullable<BaseTexture>;
  27242. private _emissiveTexture;
  27243. /**
  27244. * Define texture of the material as if self lit.
  27245. * This will be mixed in the final result even in the absence of light.
  27246. */
  27247. emissiveTexture: Nullable<BaseTexture>;
  27248. private _specularTexture;
  27249. /**
  27250. * Define how the color and intensity of the highlight given by the light in the material.
  27251. */
  27252. specularTexture: Nullable<BaseTexture>;
  27253. private _bumpTexture;
  27254. /**
  27255. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27256. * 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.
  27257. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27258. */
  27259. bumpTexture: Nullable<BaseTexture>;
  27260. private _lightmapTexture;
  27261. /**
  27262. * Complex lighting can be computationally expensive to compute at runtime.
  27263. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27264. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27265. */
  27266. lightmapTexture: Nullable<BaseTexture>;
  27267. private _refractionTexture;
  27268. /**
  27269. * Define the texture used to display the refraction.
  27270. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27271. */
  27272. refractionTexture: Nullable<BaseTexture>;
  27273. /**
  27274. * The color of the material lit by the environmental background lighting.
  27275. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27276. */
  27277. ambientColor: Color3;
  27278. /**
  27279. * The basic color of the material as viewed under a light.
  27280. */
  27281. diffuseColor: Color3;
  27282. /**
  27283. * Define how the color and intensity of the highlight given by the light in the material.
  27284. */
  27285. specularColor: Color3;
  27286. /**
  27287. * Define the color of the material as if self lit.
  27288. * This will be mixed in the final result even in the absence of light.
  27289. */
  27290. emissiveColor: Color3;
  27291. /**
  27292. * Defines how sharp are the highlights in the material.
  27293. * The bigger the value the sharper giving a more glossy feeling to the result.
  27294. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27295. */
  27296. specularPower: number;
  27297. private _useAlphaFromDiffuseTexture;
  27298. /**
  27299. * Does the transparency come from the diffuse texture alpha channel.
  27300. */
  27301. useAlphaFromDiffuseTexture: boolean;
  27302. private _useEmissiveAsIllumination;
  27303. /**
  27304. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27305. */
  27306. useEmissiveAsIllumination: boolean;
  27307. private _linkEmissiveWithDiffuse;
  27308. /**
  27309. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27310. * the emissive level when the final color is close to one.
  27311. */
  27312. linkEmissiveWithDiffuse: boolean;
  27313. private _useSpecularOverAlpha;
  27314. /**
  27315. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27316. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27317. */
  27318. useSpecularOverAlpha: boolean;
  27319. private _useReflectionOverAlpha;
  27320. /**
  27321. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27322. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27323. */
  27324. useReflectionOverAlpha: boolean;
  27325. private _disableLighting;
  27326. /**
  27327. * Does lights from the scene impacts this material.
  27328. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27329. */
  27330. disableLighting: boolean;
  27331. private _useObjectSpaceNormalMap;
  27332. /**
  27333. * Allows using an object space normal map (instead of tangent space).
  27334. */
  27335. useObjectSpaceNormalMap: boolean;
  27336. private _useParallax;
  27337. /**
  27338. * Is parallax enabled or not.
  27339. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27340. */
  27341. useParallax: boolean;
  27342. private _useParallaxOcclusion;
  27343. /**
  27344. * Is parallax occlusion enabled or not.
  27345. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27346. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27347. */
  27348. useParallaxOcclusion: boolean;
  27349. /**
  27350. * 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.
  27351. */
  27352. parallaxScaleBias: number;
  27353. private _roughness;
  27354. /**
  27355. * Helps to define how blurry the reflections should appears in the material.
  27356. */
  27357. roughness: number;
  27358. /**
  27359. * In case of refraction, define the value of the index of refraction.
  27360. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27361. */
  27362. indexOfRefraction: number;
  27363. /**
  27364. * Invert the refraction texture alongside the y axis.
  27365. * It can be useful with procedural textures or probe for instance.
  27366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27367. */
  27368. invertRefractionY: boolean;
  27369. /**
  27370. * Defines the alpha limits in alpha test mode.
  27371. */
  27372. alphaCutOff: number;
  27373. private _useLightmapAsShadowmap;
  27374. /**
  27375. * In case of light mapping, define whether the map contains light or shadow informations.
  27376. */
  27377. useLightmapAsShadowmap: boolean;
  27378. private _diffuseFresnelParameters;
  27379. /**
  27380. * Define the diffuse fresnel parameters of the material.
  27381. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27382. */
  27383. diffuseFresnelParameters: FresnelParameters;
  27384. private _opacityFresnelParameters;
  27385. /**
  27386. * Define the opacity fresnel parameters of the material.
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27388. */
  27389. opacityFresnelParameters: FresnelParameters;
  27390. private _reflectionFresnelParameters;
  27391. /**
  27392. * Define the reflection fresnel parameters of the material.
  27393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27394. */
  27395. reflectionFresnelParameters: FresnelParameters;
  27396. private _refractionFresnelParameters;
  27397. /**
  27398. * Define the refraction fresnel parameters of the material.
  27399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27400. */
  27401. refractionFresnelParameters: FresnelParameters;
  27402. private _emissiveFresnelParameters;
  27403. /**
  27404. * Define the emissive fresnel parameters of the material.
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27406. */
  27407. emissiveFresnelParameters: FresnelParameters;
  27408. private _useReflectionFresnelFromSpecular;
  27409. /**
  27410. * If true automatically deducts the fresnels values from the material specularity.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. useReflectionFresnelFromSpecular: boolean;
  27414. private _useGlossinessFromSpecularMapAlpha;
  27415. /**
  27416. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27417. */
  27418. useGlossinessFromSpecularMapAlpha: boolean;
  27419. private _maxSimultaneousLights;
  27420. /**
  27421. * Defines the maximum number of lights that can be used in the material
  27422. */
  27423. maxSimultaneousLights: number;
  27424. private _invertNormalMapX;
  27425. /**
  27426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27427. */
  27428. invertNormalMapX: boolean;
  27429. private _invertNormalMapY;
  27430. /**
  27431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27432. */
  27433. invertNormalMapY: boolean;
  27434. private _twoSidedLighting;
  27435. /**
  27436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27437. */
  27438. twoSidedLighting: boolean;
  27439. /**
  27440. * Default configuration related to image processing available in the standard Material.
  27441. */
  27442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27443. /**
  27444. * Gets the image processing configuration used either in this material.
  27445. */
  27446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27447. /**
  27448. * Sets the Default image processing configuration used either in the this material.
  27449. *
  27450. * If sets to null, the scene one is in use.
  27451. */
  27452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27453. /**
  27454. * Keep track of the image processing observer to allow dispose and replace.
  27455. */
  27456. private _imageProcessingObserver;
  27457. /**
  27458. * Attaches a new image processing configuration to the Standard Material.
  27459. * @param configuration
  27460. */
  27461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27462. /**
  27463. * Gets wether the color curves effect is enabled.
  27464. */
  27465. get cameraColorCurvesEnabled(): boolean;
  27466. /**
  27467. * Sets wether the color curves effect is enabled.
  27468. */
  27469. set cameraColorCurvesEnabled(value: boolean);
  27470. /**
  27471. * Gets wether the color grading effect is enabled.
  27472. */
  27473. get cameraColorGradingEnabled(): boolean;
  27474. /**
  27475. * Gets wether the color grading effect is enabled.
  27476. */
  27477. set cameraColorGradingEnabled(value: boolean);
  27478. /**
  27479. * Gets wether tonemapping is enabled or not.
  27480. */
  27481. get cameraToneMappingEnabled(): boolean;
  27482. /**
  27483. * Sets wether tonemapping is enabled or not
  27484. */
  27485. set cameraToneMappingEnabled(value: boolean);
  27486. /**
  27487. * The camera exposure used on this material.
  27488. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27489. * This corresponds to a photographic exposure.
  27490. */
  27491. get cameraExposure(): number;
  27492. /**
  27493. * The camera exposure used on this material.
  27494. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27495. * This corresponds to a photographic exposure.
  27496. */
  27497. set cameraExposure(value: number);
  27498. /**
  27499. * Gets The camera contrast used on this material.
  27500. */
  27501. get cameraContrast(): number;
  27502. /**
  27503. * Sets The camera contrast used on this material.
  27504. */
  27505. set cameraContrast(value: number);
  27506. /**
  27507. * Gets the Color Grading 2D Lookup Texture.
  27508. */
  27509. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27510. /**
  27511. * Sets the Color Grading 2D Lookup Texture.
  27512. */
  27513. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27514. /**
  27515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27517. * 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;
  27518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27519. */
  27520. get cameraColorCurves(): Nullable<ColorCurves>;
  27521. /**
  27522. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27523. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27524. * 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;
  27525. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27526. */
  27527. set cameraColorCurves(value: Nullable<ColorCurves>);
  27528. /**
  27529. * Custom callback helping to override the default shader used in the material.
  27530. */
  27531. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27532. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27533. protected _worldViewProjectionMatrix: Matrix;
  27534. protected _globalAmbientColor: Color3;
  27535. protected _useLogarithmicDepth: boolean;
  27536. protected _rebuildInParallel: boolean;
  27537. /**
  27538. * Instantiates a new standard material.
  27539. * This is the default material used in Babylon. It is the best trade off between quality
  27540. * and performances.
  27541. * @see http://doc.babylonjs.com/babylon101/materials
  27542. * @param name Define the name of the material in the scene
  27543. * @param scene Define the scene the material belong to
  27544. */
  27545. constructor(name: string, scene: Scene);
  27546. /**
  27547. * Gets a boolean indicating that current material needs to register RTT
  27548. */
  27549. get hasRenderTargetTextures(): boolean;
  27550. /**
  27551. * Gets the current class name of the material e.g. "StandardMaterial"
  27552. * Mainly use in serialization.
  27553. * @returns the class name
  27554. */
  27555. getClassName(): string;
  27556. /**
  27557. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27558. * You can try switching to logarithmic depth.
  27559. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27560. */
  27561. get useLogarithmicDepth(): boolean;
  27562. set useLogarithmicDepth(value: boolean);
  27563. /**
  27564. * Specifies if the material will require alpha blending
  27565. * @returns a boolean specifying if alpha blending is needed
  27566. */
  27567. needAlphaBlending(): boolean;
  27568. /**
  27569. * Specifies if this material should be rendered in alpha test mode
  27570. * @returns a boolean specifying if an alpha test is needed.
  27571. */
  27572. needAlphaTesting(): boolean;
  27573. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27574. /**
  27575. * Get the texture used for alpha test purpose.
  27576. * @returns the diffuse texture in case of the standard material.
  27577. */
  27578. getAlphaTestTexture(): Nullable<BaseTexture>;
  27579. /**
  27580. * Get if the submesh is ready to be used and all its information available.
  27581. * Child classes can use it to update shaders
  27582. * @param mesh defines the mesh to check
  27583. * @param subMesh defines which submesh to check
  27584. * @param useInstances specifies that instances should be used
  27585. * @returns a boolean indicating that the submesh is ready or not
  27586. */
  27587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27588. /**
  27589. * Builds the material UBO layouts.
  27590. * Used internally during the effect preparation.
  27591. */
  27592. buildUniformLayout(): void;
  27593. /**
  27594. * Unbinds the material from the mesh
  27595. */
  27596. unbind(): void;
  27597. /**
  27598. * Binds the submesh to this material by preparing the effect and shader to draw
  27599. * @param world defines the world transformation matrix
  27600. * @param mesh defines the mesh containing the submesh
  27601. * @param subMesh defines the submesh to bind the material to
  27602. */
  27603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27604. /**
  27605. * Get the list of animatables in the material.
  27606. * @returns the list of animatables object used in the material
  27607. */
  27608. getAnimatables(): IAnimatable[];
  27609. /**
  27610. * Gets the active textures from the material
  27611. * @returns an array of textures
  27612. */
  27613. getActiveTextures(): BaseTexture[];
  27614. /**
  27615. * Specifies if the material uses a texture
  27616. * @param texture defines the texture to check against the material
  27617. * @returns a boolean specifying if the material uses the texture
  27618. */
  27619. hasTexture(texture: BaseTexture): boolean;
  27620. /**
  27621. * Disposes the material
  27622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27624. */
  27625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27626. /**
  27627. * Makes a duplicate of the material, and gives it a new name
  27628. * @param name defines the new name for the duplicated material
  27629. * @returns the cloned material
  27630. */
  27631. clone(name: string): StandardMaterial;
  27632. /**
  27633. * Serializes this material in a JSON representation
  27634. * @returns the serialized material object
  27635. */
  27636. serialize(): any;
  27637. /**
  27638. * Creates a standard material from parsed material data
  27639. * @param source defines the JSON representation of the material
  27640. * @param scene defines the hosting scene
  27641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27642. * @returns a new standard material
  27643. */
  27644. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27645. /**
  27646. * Are diffuse textures enabled in the application.
  27647. */
  27648. static get DiffuseTextureEnabled(): boolean;
  27649. static set DiffuseTextureEnabled(value: boolean);
  27650. /**
  27651. * Are ambient textures enabled in the application.
  27652. */
  27653. static get AmbientTextureEnabled(): boolean;
  27654. static set AmbientTextureEnabled(value: boolean);
  27655. /**
  27656. * Are opacity textures enabled in the application.
  27657. */
  27658. static get OpacityTextureEnabled(): boolean;
  27659. static set OpacityTextureEnabled(value: boolean);
  27660. /**
  27661. * Are reflection textures enabled in the application.
  27662. */
  27663. static get ReflectionTextureEnabled(): boolean;
  27664. static set ReflectionTextureEnabled(value: boolean);
  27665. /**
  27666. * Are emissive textures enabled in the application.
  27667. */
  27668. static get EmissiveTextureEnabled(): boolean;
  27669. static set EmissiveTextureEnabled(value: boolean);
  27670. /**
  27671. * Are specular textures enabled in the application.
  27672. */
  27673. static get SpecularTextureEnabled(): boolean;
  27674. static set SpecularTextureEnabled(value: boolean);
  27675. /**
  27676. * Are bump textures enabled in the application.
  27677. */
  27678. static get BumpTextureEnabled(): boolean;
  27679. static set BumpTextureEnabled(value: boolean);
  27680. /**
  27681. * Are lightmap textures enabled in the application.
  27682. */
  27683. static get LightmapTextureEnabled(): boolean;
  27684. static set LightmapTextureEnabled(value: boolean);
  27685. /**
  27686. * Are refraction textures enabled in the application.
  27687. */
  27688. static get RefractionTextureEnabled(): boolean;
  27689. static set RefractionTextureEnabled(value: boolean);
  27690. /**
  27691. * Are color grading textures enabled in the application.
  27692. */
  27693. static get ColorGradingTextureEnabled(): boolean;
  27694. static set ColorGradingTextureEnabled(value: boolean);
  27695. /**
  27696. * Are fresnels enabled in the application.
  27697. */
  27698. static get FresnelEnabled(): boolean;
  27699. static set FresnelEnabled(value: boolean);
  27700. }
  27701. }
  27702. declare module "babylonjs/Particles/solidParticleSystem" {
  27703. import { Nullable } from "babylonjs/types";
  27704. import { Vector3 } from "babylonjs/Maths/math.vector";
  27705. import { Mesh } from "babylonjs/Meshes/mesh";
  27706. import { Scene, IDisposable } from "babylonjs/scene";
  27707. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27708. import { Material } from "babylonjs/Materials/material";
  27709. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27710. /**
  27711. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27712. *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.
  27713. * The SPS is also a particle system. It provides some methods to manage the particles.
  27714. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27715. *
  27716. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27717. */
  27718. export class SolidParticleSystem implements IDisposable {
  27719. /**
  27720. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27721. * Example : var p = SPS.particles[i];
  27722. */
  27723. particles: SolidParticle[];
  27724. /**
  27725. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27726. */
  27727. nbParticles: number;
  27728. /**
  27729. * If the particles must ever face the camera (default false). Useful for planar particles.
  27730. */
  27731. billboard: boolean;
  27732. /**
  27733. * Recompute normals when adding a shape
  27734. */
  27735. recomputeNormals: boolean;
  27736. /**
  27737. * This a counter ofr your own usage. It's not set by any SPS functions.
  27738. */
  27739. counter: number;
  27740. /**
  27741. * The SPS name. This name is also given to the underlying mesh.
  27742. */
  27743. name: string;
  27744. /**
  27745. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27746. */
  27747. mesh: Mesh;
  27748. /**
  27749. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27750. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27751. */
  27752. vars: any;
  27753. /**
  27754. * This array is populated when the SPS is set as 'pickable'.
  27755. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27756. * Each element of this array is an object `{idx: int, faceId: int}`.
  27757. * `idx` is the picked particle index in the `SPS.particles` array
  27758. * `faceId` is the picked face index counted within this particle.
  27759. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27760. */
  27761. pickedParticles: {
  27762. idx: number;
  27763. faceId: number;
  27764. }[];
  27765. /**
  27766. * This array is populated when `enableDepthSort` is set to true.
  27767. * Each element of this array is an instance of the class DepthSortedParticle.
  27768. */
  27769. depthSortedParticles: DepthSortedParticle[];
  27770. /**
  27771. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27772. * @hidden
  27773. */
  27774. _bSphereOnly: boolean;
  27775. /**
  27776. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27777. * @hidden
  27778. */
  27779. _bSphereRadiusFactor: number;
  27780. private _scene;
  27781. private _positions;
  27782. private _indices;
  27783. private _normals;
  27784. private _colors;
  27785. private _uvs;
  27786. private _indices32;
  27787. private _positions32;
  27788. private _normals32;
  27789. private _fixedNormal32;
  27790. private _colors32;
  27791. private _uvs32;
  27792. private _index;
  27793. private _updatable;
  27794. private _pickable;
  27795. private _isVisibilityBoxLocked;
  27796. private _alwaysVisible;
  27797. private _depthSort;
  27798. private _expandable;
  27799. private _shapeCounter;
  27800. private _copy;
  27801. private _color;
  27802. private _computeParticleColor;
  27803. private _computeParticleTexture;
  27804. private _computeParticleRotation;
  27805. private _computeParticleVertex;
  27806. private _computeBoundingBox;
  27807. private _depthSortParticles;
  27808. private _camera;
  27809. private _mustUnrotateFixedNormals;
  27810. private _particlesIntersect;
  27811. private _needs32Bits;
  27812. private _isNotBuilt;
  27813. private _lastParticleId;
  27814. private _idxOfId;
  27815. private _multimaterialEnabled;
  27816. private _useModelMaterial;
  27817. private _indicesByMaterial;
  27818. private _materialIndexes;
  27819. private _depthSortFunction;
  27820. private _materialSortFunction;
  27821. private _materials;
  27822. private _multimaterial;
  27823. private _materialIndexesById;
  27824. private _defaultMaterial;
  27825. private _autoUpdateSubMeshes;
  27826. /**
  27827. * Creates a SPS (Solid Particle System) object.
  27828. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27829. * @param scene (Scene) is the scene in which the SPS is added.
  27830. * @param options defines the options of the sps e.g.
  27831. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27832. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27833. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27834. * * 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.
  27835. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27836. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27837. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27838. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27839. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27840. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27841. */
  27842. constructor(name: string, scene: Scene, options?: {
  27843. updatable?: boolean;
  27844. isPickable?: boolean;
  27845. enableDepthSort?: boolean;
  27846. particleIntersection?: boolean;
  27847. boundingSphereOnly?: boolean;
  27848. bSphereRadiusFactor?: number;
  27849. expandable?: boolean;
  27850. useModelMaterial?: boolean;
  27851. enableMultiMaterial?: boolean;
  27852. });
  27853. /**
  27854. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27855. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27856. * @returns the created mesh
  27857. */
  27858. buildMesh(): Mesh;
  27859. /**
  27860. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27861. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27862. * Thus the particles generated from `digest()` have their property `position` set yet.
  27863. * @param mesh ( Mesh ) is the mesh to be digested
  27864. * @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
  27865. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27866. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27867. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27868. * @returns the current SPS
  27869. */
  27870. digest(mesh: Mesh, options?: {
  27871. facetNb?: number;
  27872. number?: number;
  27873. delta?: number;
  27874. storage?: [];
  27875. }): SolidParticleSystem;
  27876. /**
  27877. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27878. * @hidden
  27879. */
  27880. private _unrotateFixedNormals;
  27881. /**
  27882. * Resets the temporary working copy particle
  27883. * @hidden
  27884. */
  27885. private _resetCopy;
  27886. /**
  27887. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27888. * @param p the current index in the positions array to be updated
  27889. * @param ind the current index in the indices array
  27890. * @param shape a Vector3 array, the shape geometry
  27891. * @param positions the positions array to be updated
  27892. * @param meshInd the shape indices array
  27893. * @param indices the indices array to be updated
  27894. * @param meshUV the shape uv array
  27895. * @param uvs the uv array to be updated
  27896. * @param meshCol the shape color array
  27897. * @param colors the color array to be updated
  27898. * @param meshNor the shape normals array
  27899. * @param normals the normals array to be updated
  27900. * @param idx the particle index
  27901. * @param idxInShape the particle index in its shape
  27902. * @param options the addShape() method passed options
  27903. * @model the particle model
  27904. * @hidden
  27905. */
  27906. private _meshBuilder;
  27907. /**
  27908. * Returns a shape Vector3 array from positions float array
  27909. * @param positions float array
  27910. * @returns a vector3 array
  27911. * @hidden
  27912. */
  27913. private _posToShape;
  27914. /**
  27915. * Returns a shapeUV array from a float uvs (array deep copy)
  27916. * @param uvs as a float array
  27917. * @returns a shapeUV array
  27918. * @hidden
  27919. */
  27920. private _uvsToShapeUV;
  27921. /**
  27922. * Adds a new particle object in the particles array
  27923. * @param idx particle index in particles array
  27924. * @param id particle id
  27925. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27926. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27927. * @param model particle ModelShape object
  27928. * @param shapeId model shape identifier
  27929. * @param idxInShape index of the particle in the current model
  27930. * @param bInfo model bounding info object
  27931. * @param storage target storage array, if any
  27932. * @hidden
  27933. */
  27934. private _addParticle;
  27935. /**
  27936. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27937. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27938. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27939. * @param nb (positive integer) the number of particles to be created from this model
  27940. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27941. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27942. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27943. * @returns the number of shapes in the system
  27944. */
  27945. addShape(mesh: Mesh, nb: number, options?: {
  27946. positionFunction?: any;
  27947. vertexFunction?: any;
  27948. storage?: [];
  27949. }): number;
  27950. /**
  27951. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27952. * @hidden
  27953. */
  27954. private _rebuildParticle;
  27955. /**
  27956. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27957. * @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.
  27958. * @returns the SPS.
  27959. */
  27960. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27961. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27962. * Returns an array with the removed particles.
  27963. * 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.
  27964. * The SPS can't be empty so at least one particle needs to remain in place.
  27965. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27966. * @param start index of the first particle to remove
  27967. * @param end index of the last particle to remove (included)
  27968. * @returns an array populated with the removed particles
  27969. */
  27970. removeParticles(start: number, end: number): SolidParticle[];
  27971. /**
  27972. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27973. * @param solidParticleArray an array populated with Solid Particles objects
  27974. * @returns the SPS
  27975. */
  27976. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27977. /**
  27978. * Creates a new particle and modifies the SPS mesh geometry :
  27979. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27980. * - calls _addParticle() to populate the particle array
  27981. * factorized code from addShape() and insertParticlesFromArray()
  27982. * @param idx particle index in the particles array
  27983. * @param i particle index in its shape
  27984. * @param modelShape particle ModelShape object
  27985. * @param shape shape vertex array
  27986. * @param meshInd shape indices array
  27987. * @param meshUV shape uv array
  27988. * @param meshCol shape color array
  27989. * @param meshNor shape normals array
  27990. * @param bbInfo shape bounding info
  27991. * @param storage target particle storage
  27992. * @options addShape() passed options
  27993. * @hidden
  27994. */
  27995. private _insertNewParticle;
  27996. /**
  27997. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27998. * This method calls `updateParticle()` for each particle of the SPS.
  27999. * For an animated SPS, it is usually called within the render loop.
  28000. * 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.
  28001. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28002. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28003. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28004. * @returns the SPS.
  28005. */
  28006. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28007. /**
  28008. * Disposes the SPS.
  28009. */
  28010. dispose(): void;
  28011. /**
  28012. * Returns a SolidParticle object from its identifier : particle.id
  28013. * @param id (integer) the particle Id
  28014. * @returns the searched particle or null if not found in the SPS.
  28015. */
  28016. getParticleById(id: number): Nullable<SolidParticle>;
  28017. /**
  28018. * Returns a new array populated with the particles having the passed shapeId.
  28019. * @param shapeId (integer) the shape identifier
  28020. * @returns a new solid particle array
  28021. */
  28022. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28023. /**
  28024. * Populates the passed array "ref" with the particles having the passed shapeId.
  28025. * @param shapeId the shape identifier
  28026. * @returns the SPS
  28027. * @param ref
  28028. */
  28029. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28030. /**
  28031. * Computes the required SubMeshes according the materials assigned to the particles.
  28032. * @returns the solid particle system.
  28033. * Does nothing if called before the SPS mesh is built.
  28034. */
  28035. computeSubMeshes(): SolidParticleSystem;
  28036. /**
  28037. * Sorts the solid particles by material when MultiMaterial is enabled.
  28038. * Updates the indices32 array.
  28039. * Updates the indicesByMaterial array.
  28040. * Updates the mesh indices array.
  28041. * @returns the SPS
  28042. * @hidden
  28043. */
  28044. private _sortParticlesByMaterial;
  28045. /**
  28046. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28047. * @hidden
  28048. */
  28049. private _setMaterialIndexesById;
  28050. /**
  28051. * Returns an array with unique values of Materials from the passed array
  28052. * @param array the material array to be checked and filtered
  28053. * @hidden
  28054. */
  28055. private _filterUniqueMaterialId;
  28056. /**
  28057. * Sets a new Standard Material as _defaultMaterial if not already set.
  28058. * @hidden
  28059. */
  28060. private _setDefaultMaterial;
  28061. /**
  28062. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28064. * @returns the SPS.
  28065. */
  28066. refreshVisibleSize(): SolidParticleSystem;
  28067. /**
  28068. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28069. * @param size the size (float) of the visibility box
  28070. * note : this doesn't lock the SPS mesh bounding box.
  28071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28072. */
  28073. setVisibilityBox(size: number): void;
  28074. /**
  28075. * Gets whether the SPS as always visible or not
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28077. */
  28078. get isAlwaysVisible(): boolean;
  28079. /**
  28080. * Sets the SPS as always visible or not
  28081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28082. */
  28083. set isAlwaysVisible(val: boolean);
  28084. /**
  28085. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28087. */
  28088. set isVisibilityBoxLocked(val: boolean);
  28089. /**
  28090. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28091. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28092. */
  28093. get isVisibilityBoxLocked(): boolean;
  28094. /**
  28095. * Tells to `setParticles()` to compute the particle rotations or not.
  28096. * Default value : true. The SPS is faster when it's set to false.
  28097. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28098. */
  28099. set computeParticleRotation(val: boolean);
  28100. /**
  28101. * Tells to `setParticles()` to compute the particle colors or not.
  28102. * Default value : true. The SPS is faster when it's set to false.
  28103. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28104. */
  28105. set computeParticleColor(val: boolean);
  28106. set computeParticleTexture(val: boolean);
  28107. /**
  28108. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28109. * Default value : false. The SPS is faster when it's set to false.
  28110. * Note : the particle custom vertex positions aren't stored values.
  28111. */
  28112. set computeParticleVertex(val: boolean);
  28113. /**
  28114. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28115. */
  28116. set computeBoundingBox(val: boolean);
  28117. /**
  28118. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28119. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28120. * Default : `true`
  28121. */
  28122. set depthSortParticles(val: boolean);
  28123. /**
  28124. * Gets if `setParticles()` computes the particle rotations or not.
  28125. * Default value : true. The SPS is faster when it's set to false.
  28126. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28127. */
  28128. get computeParticleRotation(): boolean;
  28129. /**
  28130. * Gets if `setParticles()` computes the particle colors or not.
  28131. * Default value : true. The SPS is faster when it's set to false.
  28132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28133. */
  28134. get computeParticleColor(): boolean;
  28135. /**
  28136. * Gets if `setParticles()` computes the particle textures or not.
  28137. * Default value : true. The SPS is faster when it's set to false.
  28138. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28139. */
  28140. get computeParticleTexture(): boolean;
  28141. /**
  28142. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28143. * Default value : false. The SPS is faster when it's set to false.
  28144. * Note : the particle custom vertex positions aren't stored values.
  28145. */
  28146. get computeParticleVertex(): boolean;
  28147. /**
  28148. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28149. */
  28150. get computeBoundingBox(): boolean;
  28151. /**
  28152. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28153. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28154. * Default : `true`
  28155. */
  28156. get depthSortParticles(): boolean;
  28157. /**
  28158. * Gets if the SPS is created as expandable at construction time.
  28159. * Default : `false`
  28160. */
  28161. get expandable(): boolean;
  28162. /**
  28163. * Gets if the SPS supports the Multi Materials
  28164. */
  28165. get multimaterialEnabled(): boolean;
  28166. /**
  28167. * Gets if the SPS uses the model materials for its own multimaterial.
  28168. */
  28169. get useModelMaterial(): boolean;
  28170. /**
  28171. * The SPS used material array.
  28172. */
  28173. get materials(): Material[];
  28174. /**
  28175. * Sets the SPS MultiMaterial from the passed materials.
  28176. * Note : the passed array is internally copied and not used then by reference.
  28177. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28178. */
  28179. setMultiMaterial(materials: Material[]): void;
  28180. /**
  28181. * The SPS computed multimaterial object
  28182. */
  28183. get multimaterial(): MultiMaterial;
  28184. set multimaterial(mm: MultiMaterial);
  28185. /**
  28186. * If the subMeshes must be updated on the next call to setParticles()
  28187. */
  28188. get autoUpdateSubMeshes(): boolean;
  28189. set autoUpdateSubMeshes(val: boolean);
  28190. /**
  28191. * This function does nothing. It may be overwritten to set all the particle first values.
  28192. * The SPS doesn't call this function, you may have to call it by your own.
  28193. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28194. */
  28195. initParticles(): void;
  28196. /**
  28197. * This function does nothing. It may be overwritten to recycle a particle.
  28198. * The SPS doesn't call this function, you may have to call it by your own.
  28199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28200. * @param particle The particle to recycle
  28201. * @returns the recycled particle
  28202. */
  28203. recycleParticle(particle: SolidParticle): SolidParticle;
  28204. /**
  28205. * Updates a particle : this function should be overwritten by the user.
  28206. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28208. * @example : just set a particle position or velocity and recycle conditions
  28209. * @param particle The particle to update
  28210. * @returns the updated particle
  28211. */
  28212. updateParticle(particle: SolidParticle): SolidParticle;
  28213. /**
  28214. * Updates a vertex of a particle : it can be overwritten by the user.
  28215. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28216. * @param particle the current particle
  28217. * @param vertex the current index of the current particle
  28218. * @param pt the index of the current vertex in the particle shape
  28219. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28220. * @example : just set a vertex particle position
  28221. * @returns the updated vertex
  28222. */
  28223. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28224. /**
  28225. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28226. * This does nothing and may be overwritten by the user.
  28227. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28228. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28229. * @param update the boolean update value actually passed to setParticles()
  28230. */
  28231. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28232. /**
  28233. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28234. * This will be passed three parameters.
  28235. * This does nothing and may be overwritten by the user.
  28236. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28237. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28238. * @param update the boolean update value actually passed to setParticles()
  28239. */
  28240. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28241. }
  28242. }
  28243. declare module "babylonjs/Particles/solidParticle" {
  28244. import { Nullable } from "babylonjs/types";
  28245. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28246. import { Color4 } from "babylonjs/Maths/math.color";
  28247. import { Mesh } from "babylonjs/Meshes/mesh";
  28248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28249. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28250. import { Plane } from "babylonjs/Maths/math.plane";
  28251. import { Material } from "babylonjs/Materials/material";
  28252. /**
  28253. * Represents one particle of a solid particle system.
  28254. */
  28255. export class SolidParticle {
  28256. /**
  28257. * particle global index
  28258. */
  28259. idx: number;
  28260. /**
  28261. * particle identifier
  28262. */
  28263. id: number;
  28264. /**
  28265. * The color of the particle
  28266. */
  28267. color: Nullable<Color4>;
  28268. /**
  28269. * The world space position of the particle.
  28270. */
  28271. position: Vector3;
  28272. /**
  28273. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28274. */
  28275. rotation: Vector3;
  28276. /**
  28277. * The world space rotation quaternion of the particle.
  28278. */
  28279. rotationQuaternion: Nullable<Quaternion>;
  28280. /**
  28281. * The scaling of the particle.
  28282. */
  28283. scaling: Vector3;
  28284. /**
  28285. * The uvs of the particle.
  28286. */
  28287. uvs: Vector4;
  28288. /**
  28289. * The current speed of the particle.
  28290. */
  28291. velocity: Vector3;
  28292. /**
  28293. * The pivot point in the particle local space.
  28294. */
  28295. pivot: Vector3;
  28296. /**
  28297. * Must the particle be translated from its pivot point in its local space ?
  28298. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28299. * Default : false
  28300. */
  28301. translateFromPivot: boolean;
  28302. /**
  28303. * Is the particle active or not ?
  28304. */
  28305. alive: boolean;
  28306. /**
  28307. * Is the particle visible or not ?
  28308. */
  28309. isVisible: boolean;
  28310. /**
  28311. * Index of this particle in the global "positions" array (Internal use)
  28312. * @hidden
  28313. */
  28314. _pos: number;
  28315. /**
  28316. * @hidden Index of this particle in the global "indices" array (Internal use)
  28317. */
  28318. _ind: number;
  28319. /**
  28320. * @hidden ModelShape of this particle (Internal use)
  28321. */
  28322. _model: ModelShape;
  28323. /**
  28324. * ModelShape id of this particle
  28325. */
  28326. shapeId: number;
  28327. /**
  28328. * Index of the particle in its shape id
  28329. */
  28330. idxInShape: number;
  28331. /**
  28332. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28333. */
  28334. _modelBoundingInfo: BoundingInfo;
  28335. /**
  28336. * @hidden Particle BoundingInfo object (Internal use)
  28337. */
  28338. _boundingInfo: BoundingInfo;
  28339. /**
  28340. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28341. */
  28342. _sps: SolidParticleSystem;
  28343. /**
  28344. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28345. */
  28346. _stillInvisible: boolean;
  28347. /**
  28348. * @hidden Last computed particle rotation matrix
  28349. */
  28350. _rotationMatrix: number[];
  28351. /**
  28352. * Parent particle Id, if any.
  28353. * Default null.
  28354. */
  28355. parentId: Nullable<number>;
  28356. /**
  28357. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28358. */
  28359. materialIndex: Nullable<number>;
  28360. /**
  28361. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28362. * The possible values are :
  28363. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28364. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28365. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28366. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28367. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28368. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28369. * */
  28370. cullingStrategy: number;
  28371. /**
  28372. * @hidden Internal global position in the SPS.
  28373. */
  28374. _globalPosition: Vector3;
  28375. /**
  28376. * Creates a Solid Particle object.
  28377. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28378. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28379. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28380. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28381. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28382. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28383. * @param shapeId (integer) is the model shape identifier in the SPS.
  28384. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28385. * @param sps defines the sps it is associated to
  28386. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28387. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28388. */
  28389. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28390. /**
  28391. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28392. * @param target the particle target
  28393. * @returns the current particle
  28394. */
  28395. copyToRef(target: SolidParticle): SolidParticle;
  28396. /**
  28397. * Legacy support, changed scale to scaling
  28398. */
  28399. get scale(): Vector3;
  28400. /**
  28401. * Legacy support, changed scale to scaling
  28402. */
  28403. set scale(scale: Vector3);
  28404. /**
  28405. * Legacy support, changed quaternion to rotationQuaternion
  28406. */
  28407. get quaternion(): Nullable<Quaternion>;
  28408. /**
  28409. * Legacy support, changed quaternion to rotationQuaternion
  28410. */
  28411. set quaternion(q: Nullable<Quaternion>);
  28412. /**
  28413. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28414. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28415. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28416. * @returns true if it intersects
  28417. */
  28418. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28419. /**
  28420. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28421. * A particle is in the frustum if its bounding box intersects the frustum
  28422. * @param frustumPlanes defines the frustum to test
  28423. * @returns true if the particle is in the frustum planes
  28424. */
  28425. isInFrustum(frustumPlanes: Plane[]): boolean;
  28426. /**
  28427. * get the rotation matrix of the particle
  28428. * @hidden
  28429. */
  28430. getRotationMatrix(m: Matrix): void;
  28431. }
  28432. /**
  28433. * Represents the shape of the model used by one particle of a solid particle system.
  28434. * SPS internal tool, don't use it manually.
  28435. */
  28436. export class ModelShape {
  28437. /**
  28438. * The shape id
  28439. * @hidden
  28440. */
  28441. shapeID: number;
  28442. /**
  28443. * flat array of model positions (internal use)
  28444. * @hidden
  28445. */
  28446. _shape: Vector3[];
  28447. /**
  28448. * flat array of model UVs (internal use)
  28449. * @hidden
  28450. */
  28451. _shapeUV: number[];
  28452. /**
  28453. * color array of the model
  28454. * @hidden
  28455. */
  28456. _shapeColors: number[];
  28457. /**
  28458. * indices array of the model
  28459. * @hidden
  28460. */
  28461. _indices: number[];
  28462. /**
  28463. * normals array of the model
  28464. * @hidden
  28465. */
  28466. _normals: number[];
  28467. /**
  28468. * length of the shape in the model indices array (internal use)
  28469. * @hidden
  28470. */
  28471. _indicesLength: number;
  28472. /**
  28473. * Custom position function (internal use)
  28474. * @hidden
  28475. */
  28476. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28477. /**
  28478. * Custom vertex function (internal use)
  28479. * @hidden
  28480. */
  28481. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28482. /**
  28483. * Model material (internal use)
  28484. * @hidden
  28485. */
  28486. _material: Nullable<Material>;
  28487. /**
  28488. * 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.
  28489. * SPS internal tool, don't use it manually.
  28490. * @hidden
  28491. */
  28492. 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>);
  28493. }
  28494. /**
  28495. * Represents a Depth Sorted Particle in the solid particle system.
  28496. * @hidden
  28497. */
  28498. export class DepthSortedParticle {
  28499. /**
  28500. * Index of the particle in the "indices" array
  28501. */
  28502. ind: number;
  28503. /**
  28504. * Length of the particle shape in the "indices" array
  28505. */
  28506. indicesLength: number;
  28507. /**
  28508. * Squared distance from the particle to the camera
  28509. */
  28510. sqDistance: number;
  28511. /**
  28512. * Material index when used with MultiMaterials
  28513. */
  28514. materialIndex: number;
  28515. /**
  28516. * Creates a new sorted particle
  28517. * @param materialIndex
  28518. */
  28519. constructor(ind: number, indLength: number, materialIndex: number);
  28520. }
  28521. }
  28522. declare module "babylonjs/Collisions/meshCollisionData" {
  28523. import { Collider } from "babylonjs/Collisions/collider";
  28524. import { Vector3 } from "babylonjs/Maths/math.vector";
  28525. import { Nullable } from "babylonjs/types";
  28526. import { Observer } from "babylonjs/Misc/observable";
  28527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28528. /**
  28529. * @hidden
  28530. */
  28531. export class _MeshCollisionData {
  28532. _checkCollisions: boolean;
  28533. _collisionMask: number;
  28534. _collisionGroup: number;
  28535. _collider: Nullable<Collider>;
  28536. _oldPositionForCollisions: Vector3;
  28537. _diffPositionForCollisions: Vector3;
  28538. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28539. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28540. }
  28541. }
  28542. declare module "babylonjs/Meshes/abstractMesh" {
  28543. import { Observable } from "babylonjs/Misc/observable";
  28544. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28545. import { Camera } from "babylonjs/Cameras/camera";
  28546. import { Scene, IDisposable } from "babylonjs/scene";
  28547. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28548. import { Node } from "babylonjs/node";
  28549. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28551. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28553. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28554. import { Material } from "babylonjs/Materials/material";
  28555. import { Light } from "babylonjs/Lights/light";
  28556. import { Skeleton } from "babylonjs/Bones/skeleton";
  28557. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28558. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28559. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28560. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28561. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28562. import { Plane } from "babylonjs/Maths/math.plane";
  28563. import { Ray } from "babylonjs/Culling/ray";
  28564. import { Collider } from "babylonjs/Collisions/collider";
  28565. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28566. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28567. /** @hidden */
  28568. class _FacetDataStorage {
  28569. facetPositions: Vector3[];
  28570. facetNormals: Vector3[];
  28571. facetPartitioning: number[][];
  28572. facetNb: number;
  28573. partitioningSubdivisions: number;
  28574. partitioningBBoxRatio: number;
  28575. facetDataEnabled: boolean;
  28576. facetParameters: any;
  28577. bbSize: Vector3;
  28578. subDiv: {
  28579. max: number;
  28580. X: number;
  28581. Y: number;
  28582. Z: number;
  28583. };
  28584. facetDepthSort: boolean;
  28585. facetDepthSortEnabled: boolean;
  28586. depthSortedIndices: IndicesArray;
  28587. depthSortedFacets: {
  28588. ind: number;
  28589. sqDistance: number;
  28590. }[];
  28591. facetDepthSortFunction: (f1: {
  28592. ind: number;
  28593. sqDistance: number;
  28594. }, f2: {
  28595. ind: number;
  28596. sqDistance: number;
  28597. }) => number;
  28598. facetDepthSortFrom: Vector3;
  28599. facetDepthSortOrigin: Vector3;
  28600. invertedMatrix: Matrix;
  28601. }
  28602. /**
  28603. * @hidden
  28604. **/
  28605. class _InternalAbstractMeshDataInfo {
  28606. _hasVertexAlpha: boolean;
  28607. _useVertexColors: boolean;
  28608. _numBoneInfluencers: number;
  28609. _applyFog: boolean;
  28610. _receiveShadows: boolean;
  28611. _facetData: _FacetDataStorage;
  28612. _visibility: number;
  28613. _skeleton: Nullable<Skeleton>;
  28614. _layerMask: number;
  28615. _computeBonesUsingShaders: boolean;
  28616. _isActive: boolean;
  28617. _onlyForInstances: boolean;
  28618. _isActiveIntermediate: boolean;
  28619. _onlyForInstancesIntermediate: boolean;
  28620. _actAsRegularMesh: boolean;
  28621. }
  28622. /**
  28623. * Class used to store all common mesh properties
  28624. */
  28625. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28626. /** No occlusion */
  28627. static OCCLUSION_TYPE_NONE: number;
  28628. /** Occlusion set to optimisitic */
  28629. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28630. /** Occlusion set to strict */
  28631. static OCCLUSION_TYPE_STRICT: number;
  28632. /** Use an accurante occlusion algorithm */
  28633. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28634. /** Use a conservative occlusion algorithm */
  28635. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28636. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28637. * Test order :
  28638. * Is the bounding sphere outside the frustum ?
  28639. * If not, are the bounding box vertices outside the frustum ?
  28640. * It not, then the cullable object is in the frustum.
  28641. */
  28642. static readonly CULLINGSTRATEGY_STANDARD: number;
  28643. /** Culling strategy : Bounding Sphere Only.
  28644. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28645. * It's also less accurate than the standard because some not visible objects can still be selected.
  28646. * Test : is the bounding sphere outside the frustum ?
  28647. * If not, then the cullable object is in the frustum.
  28648. */
  28649. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28650. /** Culling strategy : Optimistic Inclusion.
  28651. * This in an inclusion test first, then the standard exclusion test.
  28652. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28653. * 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.
  28654. * Anyway, it's as accurate as the standard strategy.
  28655. * Test :
  28656. * Is the cullable object bounding sphere center in the frustum ?
  28657. * If not, apply the default culling strategy.
  28658. */
  28659. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28660. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28661. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28662. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28663. * 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.
  28664. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28665. * Test :
  28666. * Is the cullable object bounding sphere center in the frustum ?
  28667. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28668. */
  28669. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28670. /**
  28671. * No billboard
  28672. */
  28673. static get BILLBOARDMODE_NONE(): number;
  28674. /** Billboard on X axis */
  28675. static get BILLBOARDMODE_X(): number;
  28676. /** Billboard on Y axis */
  28677. static get BILLBOARDMODE_Y(): number;
  28678. /** Billboard on Z axis */
  28679. static get BILLBOARDMODE_Z(): number;
  28680. /** Billboard on all axes */
  28681. static get BILLBOARDMODE_ALL(): number;
  28682. /** Billboard on using position instead of orientation */
  28683. static get BILLBOARDMODE_USE_POSITION(): number;
  28684. /** @hidden */
  28685. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28686. /**
  28687. * The culling strategy to use to check whether the mesh must be rendered or not.
  28688. * This value can be changed at any time and will be used on the next render mesh selection.
  28689. * The possible values are :
  28690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28694. * Please read each static variable documentation to get details about the culling process.
  28695. * */
  28696. cullingStrategy: number;
  28697. /**
  28698. * Gets the number of facets in the mesh
  28699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28700. */
  28701. get facetNb(): number;
  28702. /**
  28703. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28705. */
  28706. get partitioningSubdivisions(): number;
  28707. set partitioningSubdivisions(nb: number);
  28708. /**
  28709. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28710. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28712. */
  28713. get partitioningBBoxRatio(): number;
  28714. set partitioningBBoxRatio(ratio: number);
  28715. /**
  28716. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28717. * Works only for updatable meshes.
  28718. * Doesn't work with multi-materials
  28719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28720. */
  28721. get mustDepthSortFacets(): boolean;
  28722. set mustDepthSortFacets(sort: boolean);
  28723. /**
  28724. * The location (Vector3) where the facet depth sort must be computed from.
  28725. * By default, the active camera position.
  28726. * Used only when facet depth sort is enabled
  28727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28728. */
  28729. get facetDepthSortFrom(): Vector3;
  28730. set facetDepthSortFrom(location: Vector3);
  28731. /**
  28732. * gets a boolean indicating if facetData is enabled
  28733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28734. */
  28735. get isFacetDataEnabled(): boolean;
  28736. /** @hidden */
  28737. _updateNonUniformScalingState(value: boolean): boolean;
  28738. /**
  28739. * An event triggered when this mesh collides with another one
  28740. */
  28741. onCollideObservable: Observable<AbstractMesh>;
  28742. /** Set a function to call when this mesh collides with another one */
  28743. set onCollide(callback: () => void);
  28744. /**
  28745. * An event triggered when the collision's position changes
  28746. */
  28747. onCollisionPositionChangeObservable: Observable<Vector3>;
  28748. /** Set a function to call when the collision's position changes */
  28749. set onCollisionPositionChange(callback: () => void);
  28750. /**
  28751. * An event triggered when material is changed
  28752. */
  28753. onMaterialChangedObservable: Observable<AbstractMesh>;
  28754. /**
  28755. * Gets or sets the orientation for POV movement & rotation
  28756. */
  28757. definedFacingForward: boolean;
  28758. /** @hidden */
  28759. _occlusionQuery: Nullable<WebGLQuery>;
  28760. /** @hidden */
  28761. _renderingGroup: Nullable<RenderingGroup>;
  28762. /**
  28763. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28764. */
  28765. get visibility(): number;
  28766. /**
  28767. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28768. */
  28769. set visibility(value: number);
  28770. /** Gets or sets the alpha index used to sort transparent meshes
  28771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28772. */
  28773. alphaIndex: number;
  28774. /**
  28775. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28776. */
  28777. isVisible: boolean;
  28778. /**
  28779. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28780. */
  28781. isPickable: boolean;
  28782. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28783. showSubMeshesBoundingBox: boolean;
  28784. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28786. */
  28787. isBlocker: boolean;
  28788. /**
  28789. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28790. */
  28791. enablePointerMoveEvents: boolean;
  28792. /**
  28793. * Specifies the rendering group id for this mesh (0 by default)
  28794. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28795. */
  28796. renderingGroupId: number;
  28797. private _material;
  28798. /** Gets or sets current material */
  28799. get material(): Nullable<Material>;
  28800. set material(value: Nullable<Material>);
  28801. /**
  28802. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28803. * @see http://doc.babylonjs.com/babylon101/shadows
  28804. */
  28805. get receiveShadows(): boolean;
  28806. set receiveShadows(value: boolean);
  28807. /** Defines color to use when rendering outline */
  28808. outlineColor: Color3;
  28809. /** Define width to use when rendering outline */
  28810. outlineWidth: number;
  28811. /** Defines color to use when rendering overlay */
  28812. overlayColor: Color3;
  28813. /** Defines alpha to use when rendering overlay */
  28814. overlayAlpha: number;
  28815. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28816. get hasVertexAlpha(): boolean;
  28817. set hasVertexAlpha(value: boolean);
  28818. /** 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) */
  28819. get useVertexColors(): boolean;
  28820. set useVertexColors(value: boolean);
  28821. /**
  28822. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28823. */
  28824. get computeBonesUsingShaders(): boolean;
  28825. set computeBonesUsingShaders(value: boolean);
  28826. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28827. get numBoneInfluencers(): number;
  28828. set numBoneInfluencers(value: number);
  28829. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28830. get applyFog(): boolean;
  28831. set applyFog(value: boolean);
  28832. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28833. useOctreeForRenderingSelection: boolean;
  28834. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28835. useOctreeForPicking: boolean;
  28836. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28837. useOctreeForCollisions: boolean;
  28838. /**
  28839. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28840. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28841. */
  28842. get layerMask(): number;
  28843. set layerMask(value: number);
  28844. /**
  28845. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28846. */
  28847. alwaysSelectAsActiveMesh: boolean;
  28848. /**
  28849. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28850. */
  28851. doNotSyncBoundingInfo: boolean;
  28852. /**
  28853. * Gets or sets the current action manager
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28855. */
  28856. actionManager: Nullable<AbstractActionManager>;
  28857. private _meshCollisionData;
  28858. /**
  28859. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28860. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28861. */
  28862. ellipsoid: Vector3;
  28863. /**
  28864. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28866. */
  28867. ellipsoidOffset: Vector3;
  28868. /**
  28869. * Gets or sets a collision mask used to mask collisions (default is -1).
  28870. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28871. */
  28872. get collisionMask(): number;
  28873. set collisionMask(mask: number);
  28874. /**
  28875. * Gets or sets the current collision group mask (-1 by default).
  28876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28877. */
  28878. get collisionGroup(): number;
  28879. set collisionGroup(mask: number);
  28880. /**
  28881. * Defines edge width used when edgesRenderer is enabled
  28882. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28883. */
  28884. edgesWidth: number;
  28885. /**
  28886. * Defines edge color used when edgesRenderer is enabled
  28887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28888. */
  28889. edgesColor: Color4;
  28890. /** @hidden */
  28891. _edgesRenderer: Nullable<IEdgesRenderer>;
  28892. /** @hidden */
  28893. _masterMesh: Nullable<AbstractMesh>;
  28894. /** @hidden */
  28895. _boundingInfo: Nullable<BoundingInfo>;
  28896. /** @hidden */
  28897. _renderId: number;
  28898. /**
  28899. * Gets or sets the list of subMeshes
  28900. * @see http://doc.babylonjs.com/how_to/multi_materials
  28901. */
  28902. subMeshes: SubMesh[];
  28903. /** @hidden */
  28904. _intersectionsInProgress: AbstractMesh[];
  28905. /** @hidden */
  28906. _unIndexed: boolean;
  28907. /** @hidden */
  28908. _lightSources: Light[];
  28909. /** Gets the list of lights affecting that mesh */
  28910. get lightSources(): Light[];
  28911. /** @hidden */
  28912. get _positions(): Nullable<Vector3[]>;
  28913. /** @hidden */
  28914. _waitingData: {
  28915. lods: Nullable<any>;
  28916. actions: Nullable<any>;
  28917. freezeWorldMatrix: Nullable<boolean>;
  28918. };
  28919. /** @hidden */
  28920. _bonesTransformMatrices: Nullable<Float32Array>;
  28921. /** @hidden */
  28922. _transformMatrixTexture: Nullable<RawTexture>;
  28923. /**
  28924. * Gets or sets a skeleton to apply skining transformations
  28925. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28926. */
  28927. set skeleton(value: Nullable<Skeleton>);
  28928. get skeleton(): Nullable<Skeleton>;
  28929. /**
  28930. * An event triggered when the mesh is rebuilt.
  28931. */
  28932. onRebuildObservable: Observable<AbstractMesh>;
  28933. /**
  28934. * Creates a new AbstractMesh
  28935. * @param name defines the name of the mesh
  28936. * @param scene defines the hosting scene
  28937. */
  28938. constructor(name: string, scene?: Nullable<Scene>);
  28939. /**
  28940. * Returns the string "AbstractMesh"
  28941. * @returns "AbstractMesh"
  28942. */
  28943. getClassName(): string;
  28944. /**
  28945. * Gets a string representation of the current mesh
  28946. * @param fullDetails defines a boolean indicating if full details must be included
  28947. * @returns a string representation of the current mesh
  28948. */
  28949. toString(fullDetails?: boolean): string;
  28950. /**
  28951. * @hidden
  28952. */
  28953. protected _getEffectiveParent(): Nullable<Node>;
  28954. /** @hidden */
  28955. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28956. /** @hidden */
  28957. _rebuild(): void;
  28958. /** @hidden */
  28959. _resyncLightSources(): void;
  28960. /** @hidden */
  28961. _resyncLightSource(light: Light): void;
  28962. /** @hidden */
  28963. _unBindEffect(): void;
  28964. /** @hidden */
  28965. _removeLightSource(light: Light, dispose: boolean): void;
  28966. private _markSubMeshesAsDirty;
  28967. /** @hidden */
  28968. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28969. /** @hidden */
  28970. _markSubMeshesAsAttributesDirty(): void;
  28971. /** @hidden */
  28972. _markSubMeshesAsMiscDirty(): void;
  28973. /**
  28974. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28975. */
  28976. get scaling(): Vector3;
  28977. set scaling(newScaling: Vector3);
  28978. /**
  28979. * Returns true if the mesh is blocked. Implemented by child classes
  28980. */
  28981. get isBlocked(): boolean;
  28982. /**
  28983. * Returns the mesh itself by default. Implemented by child classes
  28984. * @param camera defines the camera to use to pick the right LOD level
  28985. * @returns the currentAbstractMesh
  28986. */
  28987. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28988. /**
  28989. * Returns 0 by default. Implemented by child classes
  28990. * @returns an integer
  28991. */
  28992. getTotalVertices(): number;
  28993. /**
  28994. * Returns a positive integer : the total number of indices in this mesh geometry.
  28995. * @returns the numner of indices or zero if the mesh has no geometry.
  28996. */
  28997. getTotalIndices(): number;
  28998. /**
  28999. * Returns null by default. Implemented by child classes
  29000. * @returns null
  29001. */
  29002. getIndices(): Nullable<IndicesArray>;
  29003. /**
  29004. * Returns the array of the requested vertex data kind. Implemented by child classes
  29005. * @param kind defines the vertex data kind to use
  29006. * @returns null
  29007. */
  29008. getVerticesData(kind: string): Nullable<FloatArray>;
  29009. /**
  29010. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29011. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29012. * Note that a new underlying VertexBuffer object is created each call.
  29013. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29014. * @param kind defines vertex data kind:
  29015. * * VertexBuffer.PositionKind
  29016. * * VertexBuffer.UVKind
  29017. * * VertexBuffer.UV2Kind
  29018. * * VertexBuffer.UV3Kind
  29019. * * VertexBuffer.UV4Kind
  29020. * * VertexBuffer.UV5Kind
  29021. * * VertexBuffer.UV6Kind
  29022. * * VertexBuffer.ColorKind
  29023. * * VertexBuffer.MatricesIndicesKind
  29024. * * VertexBuffer.MatricesIndicesExtraKind
  29025. * * VertexBuffer.MatricesWeightsKind
  29026. * * VertexBuffer.MatricesWeightsExtraKind
  29027. * @param data defines the data source
  29028. * @param updatable defines if the data must be flagged as updatable (or static)
  29029. * @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
  29030. * @returns the current mesh
  29031. */
  29032. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29033. /**
  29034. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29035. * If the mesh has no geometry, it is simply returned as it is.
  29036. * @param kind defines vertex data kind:
  29037. * * VertexBuffer.PositionKind
  29038. * * VertexBuffer.UVKind
  29039. * * VertexBuffer.UV2Kind
  29040. * * VertexBuffer.UV3Kind
  29041. * * VertexBuffer.UV4Kind
  29042. * * VertexBuffer.UV5Kind
  29043. * * VertexBuffer.UV6Kind
  29044. * * VertexBuffer.ColorKind
  29045. * * VertexBuffer.MatricesIndicesKind
  29046. * * VertexBuffer.MatricesIndicesExtraKind
  29047. * * VertexBuffer.MatricesWeightsKind
  29048. * * VertexBuffer.MatricesWeightsExtraKind
  29049. * @param data defines the data source
  29050. * @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
  29051. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29052. * @returns the current mesh
  29053. */
  29054. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29055. /**
  29056. * Sets the mesh indices,
  29057. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29058. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29059. * @param totalVertices Defines the total number of vertices
  29060. * @returns the current mesh
  29061. */
  29062. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29063. /**
  29064. * Gets a boolean indicating if specific vertex data is present
  29065. * @param kind defines the vertex data kind to use
  29066. * @returns true is data kind is present
  29067. */
  29068. isVerticesDataPresent(kind: string): boolean;
  29069. /**
  29070. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29071. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29072. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29073. * @returns a BoundingInfo
  29074. */
  29075. getBoundingInfo(): BoundingInfo;
  29076. /**
  29077. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29078. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29079. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29080. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29081. * @returns the current mesh
  29082. */
  29083. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29084. /**
  29085. * Overwrite the current bounding info
  29086. * @param boundingInfo defines the new bounding info
  29087. * @returns the current mesh
  29088. */
  29089. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29090. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29091. get useBones(): boolean;
  29092. /** @hidden */
  29093. _preActivate(): void;
  29094. /** @hidden */
  29095. _preActivateForIntermediateRendering(renderId: number): void;
  29096. /** @hidden */
  29097. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29098. /** @hidden */
  29099. _postActivate(): void;
  29100. /** @hidden */
  29101. _freeze(): void;
  29102. /** @hidden */
  29103. _unFreeze(): void;
  29104. /**
  29105. * Gets the current world matrix
  29106. * @returns a Matrix
  29107. */
  29108. getWorldMatrix(): Matrix;
  29109. /** @hidden */
  29110. _getWorldMatrixDeterminant(): number;
  29111. /**
  29112. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29113. */
  29114. get isAnInstance(): boolean;
  29115. /**
  29116. * Gets a boolean indicating if this mesh has instances
  29117. */
  29118. get hasInstances(): boolean;
  29119. /**
  29120. * Perform relative position change from the point of view of behind the front of the mesh.
  29121. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29122. * Supports definition of mesh facing forward or backward
  29123. * @param amountRight defines the distance on the right axis
  29124. * @param amountUp defines the distance on the up axis
  29125. * @param amountForward defines the distance on the forward axis
  29126. * @returns the current mesh
  29127. */
  29128. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29129. /**
  29130. * Calculate relative position change from the point of view of behind the front of the mesh.
  29131. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29132. * Supports definition of mesh facing forward or backward
  29133. * @param amountRight defines the distance on the right axis
  29134. * @param amountUp defines the distance on the up axis
  29135. * @param amountForward defines the distance on the forward axis
  29136. * @returns the new displacement vector
  29137. */
  29138. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29139. /**
  29140. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29141. * Supports definition of mesh facing forward or backward
  29142. * @param flipBack defines the flip
  29143. * @param twirlClockwise defines the twirl
  29144. * @param tiltRight defines the tilt
  29145. * @returns the current mesh
  29146. */
  29147. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29148. /**
  29149. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29150. * Supports definition of mesh facing forward or backward.
  29151. * @param flipBack defines the flip
  29152. * @param twirlClockwise defines the twirl
  29153. * @param tiltRight defines the tilt
  29154. * @returns the new rotation vector
  29155. */
  29156. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29157. /**
  29158. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29159. * This means the mesh underlying bounding box and sphere are recomputed.
  29160. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29161. * @returns the current mesh
  29162. */
  29163. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29164. /** @hidden */
  29165. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29166. /** @hidden */
  29167. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29168. /** @hidden */
  29169. _updateBoundingInfo(): AbstractMesh;
  29170. /** @hidden */
  29171. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29172. /** @hidden */
  29173. protected _afterComputeWorldMatrix(): void;
  29174. /** @hidden */
  29175. get _effectiveMesh(): AbstractMesh;
  29176. /**
  29177. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29178. * A mesh is in the frustum if its bounding box intersects the frustum
  29179. * @param frustumPlanes defines the frustum to test
  29180. * @returns true if the mesh is in the frustum planes
  29181. */
  29182. isInFrustum(frustumPlanes: Plane[]): boolean;
  29183. /**
  29184. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29185. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29186. * @param frustumPlanes defines the frustum to test
  29187. * @returns true if the mesh is completely in the frustum planes
  29188. */
  29189. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29190. /**
  29191. * True if the mesh intersects another mesh or a SolidParticle object
  29192. * @param mesh defines a target mesh or SolidParticle to test
  29193. * @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)
  29194. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29195. * @returns true if there is an intersection
  29196. */
  29197. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29198. /**
  29199. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29200. * @param point defines the point to test
  29201. * @returns true if there is an intersection
  29202. */
  29203. intersectsPoint(point: Vector3): boolean;
  29204. /**
  29205. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29207. */
  29208. get checkCollisions(): boolean;
  29209. set checkCollisions(collisionEnabled: boolean);
  29210. /**
  29211. * Gets Collider object used to compute collisions (not physics)
  29212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29213. */
  29214. get collider(): Nullable<Collider>;
  29215. /**
  29216. * Move the mesh using collision engine
  29217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29218. * @param displacement defines the requested displacement vector
  29219. * @returns the current mesh
  29220. */
  29221. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29222. private _onCollisionPositionChange;
  29223. /** @hidden */
  29224. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29225. /** @hidden */
  29226. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29227. /** @hidden */
  29228. _checkCollision(collider: Collider): AbstractMesh;
  29229. /** @hidden */
  29230. _generatePointsArray(): boolean;
  29231. /**
  29232. * Checks if the passed Ray intersects with the mesh
  29233. * @param ray defines the ray to use
  29234. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29236. * @returns the picking info
  29237. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29238. */
  29239. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29240. /**
  29241. * Clones the current mesh
  29242. * @param name defines the mesh name
  29243. * @param newParent defines the new mesh parent
  29244. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29245. * @returns the new mesh
  29246. */
  29247. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29248. /**
  29249. * Disposes all the submeshes of the current meshnp
  29250. * @returns the current mesh
  29251. */
  29252. releaseSubMeshes(): AbstractMesh;
  29253. /**
  29254. * Releases resources associated with this abstract mesh.
  29255. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29256. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29257. */
  29258. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29259. /**
  29260. * Adds the passed mesh as a child to the current mesh
  29261. * @param mesh defines the child mesh
  29262. * @returns the current mesh
  29263. */
  29264. addChild(mesh: AbstractMesh): AbstractMesh;
  29265. /**
  29266. * Removes the passed mesh from the current mesh children list
  29267. * @param mesh defines the child mesh
  29268. * @returns the current mesh
  29269. */
  29270. removeChild(mesh: AbstractMesh): AbstractMesh;
  29271. /** @hidden */
  29272. private _initFacetData;
  29273. /**
  29274. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29275. * This method can be called within the render loop.
  29276. * 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
  29277. * @returns the current mesh
  29278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29279. */
  29280. updateFacetData(): AbstractMesh;
  29281. /**
  29282. * Returns the facetLocalNormals array.
  29283. * The normals are expressed in the mesh local spac
  29284. * @returns an array of Vector3
  29285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29286. */
  29287. getFacetLocalNormals(): Vector3[];
  29288. /**
  29289. * Returns the facetLocalPositions array.
  29290. * The facet positions are expressed in the mesh local space
  29291. * @returns an array of Vector3
  29292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29293. */
  29294. getFacetLocalPositions(): Vector3[];
  29295. /**
  29296. * Returns the facetLocalPartioning array
  29297. * @returns an array of array of numbers
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29299. */
  29300. getFacetLocalPartitioning(): number[][];
  29301. /**
  29302. * Returns the i-th facet position in the world system.
  29303. * This method allocates a new Vector3 per call
  29304. * @param i defines the facet index
  29305. * @returns a new Vector3
  29306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29307. */
  29308. getFacetPosition(i: number): Vector3;
  29309. /**
  29310. * Sets the reference Vector3 with the i-th facet position in the world system
  29311. * @param i defines the facet index
  29312. * @param ref defines the target vector
  29313. * @returns the current mesh
  29314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29315. */
  29316. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29317. /**
  29318. * Returns the i-th facet normal in the world system.
  29319. * This method allocates a new Vector3 per call
  29320. * @param i defines the facet index
  29321. * @returns a new Vector3
  29322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29323. */
  29324. getFacetNormal(i: number): Vector3;
  29325. /**
  29326. * Sets the reference Vector3 with the i-th facet normal in the world system
  29327. * @param i defines the facet index
  29328. * @param ref defines the target vector
  29329. * @returns the current mesh
  29330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29331. */
  29332. getFacetNormalToRef(i: number, ref: Vector3): this;
  29333. /**
  29334. * 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)
  29335. * @param x defines x coordinate
  29336. * @param y defines y coordinate
  29337. * @param z defines z coordinate
  29338. * @returns the array of facet indexes
  29339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29340. */
  29341. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29342. /**
  29343. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29344. * @param projected sets as the (x,y,z) world projection on the facet
  29345. * @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
  29346. * @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
  29347. * @param x defines x coordinate
  29348. * @param y defines y coordinate
  29349. * @param z defines z coordinate
  29350. * @returns the face index if found (or null instead)
  29351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29352. */
  29353. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29354. /**
  29355. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29356. * @param projected sets as the (x,y,z) local projection on the facet
  29357. * @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
  29358. * @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
  29359. * @param x defines x coordinate
  29360. * @param y defines y coordinate
  29361. * @param z defines z coordinate
  29362. * @returns the face index if found (or null instead)
  29363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29364. */
  29365. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29366. /**
  29367. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29368. * @returns the parameters
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getFacetDataParameters(): any;
  29372. /**
  29373. * Disables the feature FacetData and frees the related memory
  29374. * @returns the current mesh
  29375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29376. */
  29377. disableFacetData(): AbstractMesh;
  29378. /**
  29379. * Updates the AbstractMesh indices array
  29380. * @param indices defines the data source
  29381. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29382. * @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)
  29383. * @returns the current mesh
  29384. */
  29385. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29386. /**
  29387. * Creates new normals data for the mesh
  29388. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29389. * @returns the current mesh
  29390. */
  29391. createNormals(updatable: boolean): AbstractMesh;
  29392. /**
  29393. * Align the mesh with a normal
  29394. * @param normal defines the normal to use
  29395. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29396. * @returns the current mesh
  29397. */
  29398. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29399. /** @hidden */
  29400. _checkOcclusionQuery(): boolean;
  29401. /**
  29402. * Disables the mesh edge rendering mode
  29403. * @returns the currentAbstractMesh
  29404. */
  29405. disableEdgesRendering(): AbstractMesh;
  29406. /**
  29407. * Enables the edge rendering mode on the mesh.
  29408. * This mode makes the mesh edges visible
  29409. * @param epsilon defines the maximal distance between two angles to detect a face
  29410. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29411. * @returns the currentAbstractMesh
  29412. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29413. */
  29414. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29415. }
  29416. }
  29417. declare module "babylonjs/Actions/actionEvent" {
  29418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29419. import { Nullable } from "babylonjs/types";
  29420. import { Sprite } from "babylonjs/Sprites/sprite";
  29421. import { Scene } from "babylonjs/scene";
  29422. import { Vector2 } from "babylonjs/Maths/math.vector";
  29423. /**
  29424. * Interface used to define ActionEvent
  29425. */
  29426. export interface IActionEvent {
  29427. /** The mesh or sprite that triggered the action */
  29428. source: any;
  29429. /** The X mouse cursor position at the time of the event */
  29430. pointerX: number;
  29431. /** The Y mouse cursor position at the time of the event */
  29432. pointerY: number;
  29433. /** The mesh that is currently pointed at (can be null) */
  29434. meshUnderPointer: Nullable<AbstractMesh>;
  29435. /** the original (browser) event that triggered the ActionEvent */
  29436. sourceEvent?: any;
  29437. /** additional data for the event */
  29438. additionalData?: any;
  29439. }
  29440. /**
  29441. * ActionEvent is the event being sent when an action is triggered.
  29442. */
  29443. export class ActionEvent implements IActionEvent {
  29444. /** The mesh or sprite that triggered the action */
  29445. source: any;
  29446. /** The X mouse cursor position at the time of the event */
  29447. pointerX: number;
  29448. /** The Y mouse cursor position at the time of the event */
  29449. pointerY: number;
  29450. /** The mesh that is currently pointed at (can be null) */
  29451. meshUnderPointer: Nullable<AbstractMesh>;
  29452. /** the original (browser) event that triggered the ActionEvent */
  29453. sourceEvent?: any;
  29454. /** additional data for the event */
  29455. additionalData?: any;
  29456. /**
  29457. * Creates a new ActionEvent
  29458. * @param source The mesh or sprite that triggered the action
  29459. * @param pointerX The X mouse cursor position at the time of the event
  29460. * @param pointerY The Y mouse cursor position at the time of the event
  29461. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29462. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29463. * @param additionalData additional data for the event
  29464. */
  29465. constructor(
  29466. /** The mesh or sprite that triggered the action */
  29467. source: any,
  29468. /** The X mouse cursor position at the time of the event */
  29469. pointerX: number,
  29470. /** The Y mouse cursor position at the time of the event */
  29471. pointerY: number,
  29472. /** The mesh that is currently pointed at (can be null) */
  29473. meshUnderPointer: Nullable<AbstractMesh>,
  29474. /** the original (browser) event that triggered the ActionEvent */
  29475. sourceEvent?: any,
  29476. /** additional data for the event */
  29477. additionalData?: any);
  29478. /**
  29479. * Helper function to auto-create an ActionEvent from a source mesh.
  29480. * @param source The source mesh that triggered the event
  29481. * @param evt The original (browser) event
  29482. * @param additionalData additional data for the event
  29483. * @returns the new ActionEvent
  29484. */
  29485. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29486. /**
  29487. * Helper function to auto-create an ActionEvent from a source sprite
  29488. * @param source The source sprite that triggered the event
  29489. * @param scene Scene associated with the sprite
  29490. * @param evt The original (browser) event
  29491. * @param additionalData additional data for the event
  29492. * @returns the new ActionEvent
  29493. */
  29494. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29495. /**
  29496. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29497. * @param scene the scene where the event occurred
  29498. * @param evt The original (browser) event
  29499. * @returns the new ActionEvent
  29500. */
  29501. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29502. /**
  29503. * Helper function to auto-create an ActionEvent from a primitive
  29504. * @param prim defines the target primitive
  29505. * @param pointerPos defines the pointer position
  29506. * @param evt The original (browser) event
  29507. * @param additionalData additional data for the event
  29508. * @returns the new ActionEvent
  29509. */
  29510. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29511. }
  29512. }
  29513. declare module "babylonjs/Actions/abstractActionManager" {
  29514. import { IDisposable } from "babylonjs/scene";
  29515. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29516. import { IAction } from "babylonjs/Actions/action";
  29517. import { Nullable } from "babylonjs/types";
  29518. /**
  29519. * Abstract class used to decouple action Manager from scene and meshes.
  29520. * Do not instantiate.
  29521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29522. */
  29523. export abstract class AbstractActionManager implements IDisposable {
  29524. /** Gets the list of active triggers */
  29525. static Triggers: {
  29526. [key: string]: number;
  29527. };
  29528. /** Gets the cursor to use when hovering items */
  29529. hoverCursor: string;
  29530. /** Gets the list of actions */
  29531. actions: IAction[];
  29532. /**
  29533. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29534. */
  29535. isRecursive: boolean;
  29536. /**
  29537. * Releases all associated resources
  29538. */
  29539. abstract dispose(): void;
  29540. /**
  29541. * Does this action manager has pointer triggers
  29542. */
  29543. abstract get hasPointerTriggers(): boolean;
  29544. /**
  29545. * Does this action manager has pick triggers
  29546. */
  29547. abstract get hasPickTriggers(): boolean;
  29548. /**
  29549. * Process a specific trigger
  29550. * @param trigger defines the trigger to process
  29551. * @param evt defines the event details to be processed
  29552. */
  29553. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29554. /**
  29555. * Does this action manager handles actions of any of the given triggers
  29556. * @param triggers defines the triggers to be tested
  29557. * @return a boolean indicating whether one (or more) of the triggers is handled
  29558. */
  29559. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29560. /**
  29561. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29562. * speed.
  29563. * @param triggerA defines the trigger to be tested
  29564. * @param triggerB defines the trigger to be tested
  29565. * @return a boolean indicating whether one (or more) of the triggers is handled
  29566. */
  29567. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29568. /**
  29569. * Does this action manager handles actions of a given trigger
  29570. * @param trigger defines the trigger to be tested
  29571. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29572. * @return whether the trigger is handled
  29573. */
  29574. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29575. /**
  29576. * Serialize this manager to a JSON object
  29577. * @param name defines the property name to store this manager
  29578. * @returns a JSON representation of this manager
  29579. */
  29580. abstract serialize(name: string): any;
  29581. /**
  29582. * Registers an action to this action manager
  29583. * @param action defines the action to be registered
  29584. * @return the action amended (prepared) after registration
  29585. */
  29586. abstract registerAction(action: IAction): Nullable<IAction>;
  29587. /**
  29588. * Unregisters an action to this action manager
  29589. * @param action defines the action to be unregistered
  29590. * @return a boolean indicating whether the action has been unregistered
  29591. */
  29592. abstract unregisterAction(action: IAction): Boolean;
  29593. /**
  29594. * Does exist one action manager with at least one trigger
  29595. **/
  29596. static get HasTriggers(): boolean;
  29597. /**
  29598. * Does exist one action manager with at least one pick trigger
  29599. **/
  29600. static get HasPickTriggers(): boolean;
  29601. /**
  29602. * Does exist one action manager that handles actions of a given trigger
  29603. * @param trigger defines the trigger to be tested
  29604. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29605. **/
  29606. static HasSpecificTrigger(trigger: number): boolean;
  29607. }
  29608. }
  29609. declare module "babylonjs/node" {
  29610. import { Scene } from "babylonjs/scene";
  29611. import { Nullable } from "babylonjs/types";
  29612. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29613. import { Engine } from "babylonjs/Engines/engine";
  29614. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29615. import { Observable } from "babylonjs/Misc/observable";
  29616. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29617. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29618. import { Animatable } from "babylonjs/Animations/animatable";
  29619. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29620. import { Animation } from "babylonjs/Animations/animation";
  29621. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29623. /**
  29624. * Defines how a node can be built from a string name.
  29625. */
  29626. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29627. /**
  29628. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29629. */
  29630. export class Node implements IBehaviorAware<Node> {
  29631. /** @hidden */
  29632. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29633. private static _NodeConstructors;
  29634. /**
  29635. * Add a new node constructor
  29636. * @param type defines the type name of the node to construct
  29637. * @param constructorFunc defines the constructor function
  29638. */
  29639. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29640. /**
  29641. * Returns a node constructor based on type name
  29642. * @param type defines the type name
  29643. * @param name defines the new node name
  29644. * @param scene defines the hosting scene
  29645. * @param options defines optional options to transmit to constructors
  29646. * @returns the new constructor or null
  29647. */
  29648. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29649. /**
  29650. * Gets or sets the name of the node
  29651. */
  29652. name: string;
  29653. /**
  29654. * Gets or sets the id of the node
  29655. */
  29656. id: string;
  29657. /**
  29658. * Gets or sets the unique id of the node
  29659. */
  29660. uniqueId: number;
  29661. /**
  29662. * Gets or sets a string used to store user defined state for the node
  29663. */
  29664. state: string;
  29665. /**
  29666. * Gets or sets an object used to store user defined information for the node
  29667. */
  29668. metadata: any;
  29669. /**
  29670. * For internal use only. Please do not use.
  29671. */
  29672. reservedDataStore: any;
  29673. /**
  29674. * List of inspectable custom properties (used by the Inspector)
  29675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29676. */
  29677. inspectableCustomProperties: IInspectable[];
  29678. private _doNotSerialize;
  29679. /**
  29680. * Gets or sets a boolean used to define if the node must be serialized
  29681. */
  29682. get doNotSerialize(): boolean;
  29683. set doNotSerialize(value: boolean);
  29684. /** @hidden */
  29685. _isDisposed: boolean;
  29686. /**
  29687. * Gets a list of Animations associated with the node
  29688. */
  29689. animations: import("babylonjs/Animations/animation").Animation[];
  29690. protected _ranges: {
  29691. [name: string]: Nullable<AnimationRange>;
  29692. };
  29693. /**
  29694. * Callback raised when the node is ready to be used
  29695. */
  29696. onReady: Nullable<(node: Node) => void>;
  29697. private _isEnabled;
  29698. private _isParentEnabled;
  29699. private _isReady;
  29700. /** @hidden */
  29701. _currentRenderId: number;
  29702. private _parentUpdateId;
  29703. /** @hidden */
  29704. _childUpdateId: number;
  29705. /** @hidden */
  29706. _waitingParentId: Nullable<string>;
  29707. /** @hidden */
  29708. _scene: Scene;
  29709. /** @hidden */
  29710. _cache: any;
  29711. private _parentNode;
  29712. private _children;
  29713. /** @hidden */
  29714. _worldMatrix: Matrix;
  29715. /** @hidden */
  29716. _worldMatrixDeterminant: number;
  29717. /** @hidden */
  29718. _worldMatrixDeterminantIsDirty: boolean;
  29719. /** @hidden */
  29720. private _sceneRootNodesIndex;
  29721. /**
  29722. * Gets a boolean indicating if the node has been disposed
  29723. * @returns true if the node was disposed
  29724. */
  29725. isDisposed(): boolean;
  29726. /**
  29727. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29728. * @see https://doc.babylonjs.com/how_to/parenting
  29729. */
  29730. set parent(parent: Nullable<Node>);
  29731. get parent(): Nullable<Node>;
  29732. /** @hidden */
  29733. _addToSceneRootNodes(): void;
  29734. /** @hidden */
  29735. _removeFromSceneRootNodes(): void;
  29736. private _animationPropertiesOverride;
  29737. /**
  29738. * Gets or sets the animation properties override
  29739. */
  29740. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29741. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29742. /**
  29743. * Gets a string idenfifying the name of the class
  29744. * @returns "Node" string
  29745. */
  29746. getClassName(): string;
  29747. /** @hidden */
  29748. readonly _isNode: boolean;
  29749. /**
  29750. * An event triggered when the mesh is disposed
  29751. */
  29752. onDisposeObservable: Observable<Node>;
  29753. private _onDisposeObserver;
  29754. /**
  29755. * Sets a callback that will be raised when the node will be disposed
  29756. */
  29757. set onDispose(callback: () => void);
  29758. /**
  29759. * Creates a new Node
  29760. * @param name the name and id to be given to this node
  29761. * @param scene the scene this node will be added to
  29762. */
  29763. constructor(name: string, scene?: Nullable<Scene>);
  29764. /**
  29765. * Gets the scene of the node
  29766. * @returns a scene
  29767. */
  29768. getScene(): Scene;
  29769. /**
  29770. * Gets the engine of the node
  29771. * @returns a Engine
  29772. */
  29773. getEngine(): Engine;
  29774. private _behaviors;
  29775. /**
  29776. * Attach a behavior to the node
  29777. * @see http://doc.babylonjs.com/features/behaviour
  29778. * @param behavior defines the behavior to attach
  29779. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29780. * @returns the current Node
  29781. */
  29782. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29783. /**
  29784. * Remove an attached behavior
  29785. * @see http://doc.babylonjs.com/features/behaviour
  29786. * @param behavior defines the behavior to attach
  29787. * @returns the current Node
  29788. */
  29789. removeBehavior(behavior: Behavior<Node>): Node;
  29790. /**
  29791. * Gets the list of attached behaviors
  29792. * @see http://doc.babylonjs.com/features/behaviour
  29793. */
  29794. get behaviors(): Behavior<Node>[];
  29795. /**
  29796. * Gets an attached behavior by name
  29797. * @param name defines the name of the behavior to look for
  29798. * @see http://doc.babylonjs.com/features/behaviour
  29799. * @returns null if behavior was not found else the requested behavior
  29800. */
  29801. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29802. /**
  29803. * Returns the latest update of the World matrix
  29804. * @returns a Matrix
  29805. */
  29806. getWorldMatrix(): Matrix;
  29807. /** @hidden */
  29808. _getWorldMatrixDeterminant(): number;
  29809. /**
  29810. * Returns directly the latest state of the mesh World matrix.
  29811. * A Matrix is returned.
  29812. */
  29813. get worldMatrixFromCache(): Matrix;
  29814. /** @hidden */
  29815. _initCache(): void;
  29816. /** @hidden */
  29817. updateCache(force?: boolean): void;
  29818. /** @hidden */
  29819. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29820. /** @hidden */
  29821. _updateCache(ignoreParentClass?: boolean): void;
  29822. /** @hidden */
  29823. _isSynchronized(): boolean;
  29824. /** @hidden */
  29825. _markSyncedWithParent(): void;
  29826. /** @hidden */
  29827. isSynchronizedWithParent(): boolean;
  29828. /** @hidden */
  29829. isSynchronized(): boolean;
  29830. /**
  29831. * Is this node ready to be used/rendered
  29832. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29833. * @return true if the node is ready
  29834. */
  29835. isReady(completeCheck?: boolean): boolean;
  29836. /**
  29837. * Is this node enabled?
  29838. * 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
  29839. * @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
  29840. * @return whether this node (and its parent) is enabled
  29841. */
  29842. isEnabled(checkAncestors?: boolean): boolean;
  29843. /** @hidden */
  29844. protected _syncParentEnabledState(): void;
  29845. /**
  29846. * Set the enabled state of this node
  29847. * @param value defines the new enabled state
  29848. */
  29849. setEnabled(value: boolean): void;
  29850. /**
  29851. * Is this node a descendant of the given node?
  29852. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29853. * @param ancestor defines the parent node to inspect
  29854. * @returns a boolean indicating if this node is a descendant of the given node
  29855. */
  29856. isDescendantOf(ancestor: Node): boolean;
  29857. /** @hidden */
  29858. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29859. /**
  29860. * Will return all nodes that have this node as ascendant
  29861. * @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
  29862. * @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
  29863. * @return all children nodes of all types
  29864. */
  29865. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29866. /**
  29867. * Get all child-meshes of this node
  29868. * @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)
  29869. * @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
  29870. * @returns an array of AbstractMesh
  29871. */
  29872. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29873. /**
  29874. * Get all direct children of this node
  29875. * @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
  29876. * @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)
  29877. * @returns an array of Node
  29878. */
  29879. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29880. /** @hidden */
  29881. _setReady(state: boolean): void;
  29882. /**
  29883. * Get an animation by name
  29884. * @param name defines the name of the animation to look for
  29885. * @returns null if not found else the requested animation
  29886. */
  29887. getAnimationByName(name: string): Nullable<Animation>;
  29888. /**
  29889. * Creates an animation range for this node
  29890. * @param name defines the name of the range
  29891. * @param from defines the starting key
  29892. * @param to defines the end key
  29893. */
  29894. createAnimationRange(name: string, from: number, to: number): void;
  29895. /**
  29896. * Delete a specific animation range
  29897. * @param name defines the name of the range to delete
  29898. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29899. */
  29900. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29901. /**
  29902. * Get an animation range by name
  29903. * @param name defines the name of the animation range to look for
  29904. * @returns null if not found else the requested animation range
  29905. */
  29906. getAnimationRange(name: string): Nullable<AnimationRange>;
  29907. /**
  29908. * Gets the list of all animation ranges defined on this node
  29909. * @returns an array
  29910. */
  29911. getAnimationRanges(): Nullable<AnimationRange>[];
  29912. /**
  29913. * Will start the animation sequence
  29914. * @param name defines the range frames for animation sequence
  29915. * @param loop defines if the animation should loop (false by default)
  29916. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29917. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29918. * @returns the object created for this animation. If range does not exist, it will return null
  29919. */
  29920. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29921. /**
  29922. * Serialize animation ranges into a JSON compatible object
  29923. * @returns serialization object
  29924. */
  29925. serializeAnimationRanges(): any;
  29926. /**
  29927. * Computes the world matrix of the node
  29928. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29929. * @returns the world matrix
  29930. */
  29931. computeWorldMatrix(force?: boolean): Matrix;
  29932. /**
  29933. * Releases resources associated with this node.
  29934. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29935. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29936. */
  29937. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29938. /**
  29939. * Parse animation range data from a serialization object and store them into a given node
  29940. * @param node defines where to store the animation ranges
  29941. * @param parsedNode defines the serialization object to read data from
  29942. * @param scene defines the hosting scene
  29943. */
  29944. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29945. /**
  29946. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29947. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29948. * @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
  29949. * @returns the new bounding vectors
  29950. */
  29951. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29952. min: Vector3;
  29953. max: Vector3;
  29954. };
  29955. }
  29956. }
  29957. declare module "babylonjs/Animations/animation" {
  29958. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29959. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29960. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29961. import { Nullable } from "babylonjs/types";
  29962. import { Scene } from "babylonjs/scene";
  29963. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29964. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29965. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29966. import { Node } from "babylonjs/node";
  29967. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29968. import { Size } from "babylonjs/Maths/math.size";
  29969. import { Animatable } from "babylonjs/Animations/animatable";
  29970. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29971. /**
  29972. * @hidden
  29973. */
  29974. export class _IAnimationState {
  29975. key: number;
  29976. repeatCount: number;
  29977. workValue?: any;
  29978. loopMode?: number;
  29979. offsetValue?: any;
  29980. highLimitValue?: any;
  29981. }
  29982. /**
  29983. * Class used to store any kind of animation
  29984. */
  29985. export class Animation {
  29986. /**Name of the animation */
  29987. name: string;
  29988. /**Property to animate */
  29989. targetProperty: string;
  29990. /**The frames per second of the animation */
  29991. framePerSecond: number;
  29992. /**The data type of the animation */
  29993. dataType: number;
  29994. /**The loop mode of the animation */
  29995. loopMode?: number | undefined;
  29996. /**Specifies if blending should be enabled */
  29997. enableBlending?: boolean | undefined;
  29998. /**
  29999. * Use matrix interpolation instead of using direct key value when animating matrices
  30000. */
  30001. static AllowMatricesInterpolation: boolean;
  30002. /**
  30003. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30004. */
  30005. static AllowMatrixDecomposeForInterpolation: boolean;
  30006. /**
  30007. * Stores the key frames of the animation
  30008. */
  30009. private _keys;
  30010. /**
  30011. * Stores the easing function of the animation
  30012. */
  30013. private _easingFunction;
  30014. /**
  30015. * @hidden Internal use only
  30016. */
  30017. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30018. /**
  30019. * The set of event that will be linked to this animation
  30020. */
  30021. private _events;
  30022. /**
  30023. * Stores an array of target property paths
  30024. */
  30025. targetPropertyPath: string[];
  30026. /**
  30027. * Stores the blending speed of the animation
  30028. */
  30029. blendingSpeed: number;
  30030. /**
  30031. * Stores the animation ranges for the animation
  30032. */
  30033. private _ranges;
  30034. /**
  30035. * @hidden Internal use
  30036. */
  30037. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30038. /**
  30039. * Sets up an animation
  30040. * @param property The property to animate
  30041. * @param animationType The animation type to apply
  30042. * @param framePerSecond The frames per second of the animation
  30043. * @param easingFunction The easing function used in the animation
  30044. * @returns The created animation
  30045. */
  30046. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30047. /**
  30048. * Create and start an animation on a node
  30049. * @param name defines the name of the global animation that will be run on all nodes
  30050. * @param node defines the root node where the animation will take place
  30051. * @param targetProperty defines property to animate
  30052. * @param framePerSecond defines the number of frame per second yo use
  30053. * @param totalFrame defines the number of frames in total
  30054. * @param from defines the initial value
  30055. * @param to defines the final value
  30056. * @param loopMode defines which loop mode you want to use (off by default)
  30057. * @param easingFunction defines the easing function to use (linear by default)
  30058. * @param onAnimationEnd defines the callback to call when animation end
  30059. * @returns the animatable created for this animation
  30060. */
  30061. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30062. /**
  30063. * Create and start an animation on a node and its descendants
  30064. * @param name defines the name of the global animation that will be run on all nodes
  30065. * @param node defines the root node where the animation will take place
  30066. * @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
  30067. * @param targetProperty defines property to animate
  30068. * @param framePerSecond defines the number of frame per second to use
  30069. * @param totalFrame defines the number of frames in total
  30070. * @param from defines the initial value
  30071. * @param to defines the final value
  30072. * @param loopMode defines which loop mode you want to use (off by default)
  30073. * @param easingFunction defines the easing function to use (linear by default)
  30074. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30075. * @returns the list of animatables created for all nodes
  30076. * @example https://www.babylonjs-playground.com/#MH0VLI
  30077. */
  30078. 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[]>;
  30079. /**
  30080. * Creates a new animation, merges it with the existing animations and starts it
  30081. * @param name Name of the animation
  30082. * @param node Node which contains the scene that begins the animations
  30083. * @param targetProperty Specifies which property to animate
  30084. * @param framePerSecond The frames per second of the animation
  30085. * @param totalFrame The total number of frames
  30086. * @param from The frame at the beginning of the animation
  30087. * @param to The frame at the end of the animation
  30088. * @param loopMode Specifies the loop mode of the animation
  30089. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30090. * @param onAnimationEnd Callback to run once the animation is complete
  30091. * @returns Nullable animation
  30092. */
  30093. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30094. /**
  30095. * Transition property of an host to the target Value
  30096. * @param property The property to transition
  30097. * @param targetValue The target Value of the property
  30098. * @param host The object where the property to animate belongs
  30099. * @param scene Scene used to run the animation
  30100. * @param frameRate Framerate (in frame/s) to use
  30101. * @param transition The transition type we want to use
  30102. * @param duration The duration of the animation, in milliseconds
  30103. * @param onAnimationEnd Callback trigger at the end of the animation
  30104. * @returns Nullable animation
  30105. */
  30106. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30107. /**
  30108. * Return the array of runtime animations currently using this animation
  30109. */
  30110. get runtimeAnimations(): RuntimeAnimation[];
  30111. /**
  30112. * Specifies if any of the runtime animations are currently running
  30113. */
  30114. get hasRunningRuntimeAnimations(): boolean;
  30115. /**
  30116. * Initializes the animation
  30117. * @param name Name of the animation
  30118. * @param targetProperty Property to animate
  30119. * @param framePerSecond The frames per second of the animation
  30120. * @param dataType The data type of the animation
  30121. * @param loopMode The loop mode of the animation
  30122. * @param enableBlending Specifies if blending should be enabled
  30123. */
  30124. constructor(
  30125. /**Name of the animation */
  30126. name: string,
  30127. /**Property to animate */
  30128. targetProperty: string,
  30129. /**The frames per second of the animation */
  30130. framePerSecond: number,
  30131. /**The data type of the animation */
  30132. dataType: number,
  30133. /**The loop mode of the animation */
  30134. loopMode?: number | undefined,
  30135. /**Specifies if blending should be enabled */
  30136. enableBlending?: boolean | undefined);
  30137. /**
  30138. * Converts the animation to a string
  30139. * @param fullDetails support for multiple levels of logging within scene loading
  30140. * @returns String form of the animation
  30141. */
  30142. toString(fullDetails?: boolean): string;
  30143. /**
  30144. * Add an event to this animation
  30145. * @param event Event to add
  30146. */
  30147. addEvent(event: AnimationEvent): void;
  30148. /**
  30149. * Remove all events found at the given frame
  30150. * @param frame The frame to remove events from
  30151. */
  30152. removeEvents(frame: number): void;
  30153. /**
  30154. * Retrieves all the events from the animation
  30155. * @returns Events from the animation
  30156. */
  30157. getEvents(): AnimationEvent[];
  30158. /**
  30159. * Creates an animation range
  30160. * @param name Name of the animation range
  30161. * @param from Starting frame of the animation range
  30162. * @param to Ending frame of the animation
  30163. */
  30164. createRange(name: string, from: number, to: number): void;
  30165. /**
  30166. * Deletes an animation range by name
  30167. * @param name Name of the animation range to delete
  30168. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30169. */
  30170. deleteRange(name: string, deleteFrames?: boolean): void;
  30171. /**
  30172. * Gets the animation range by name, or null if not defined
  30173. * @param name Name of the animation range
  30174. * @returns Nullable animation range
  30175. */
  30176. getRange(name: string): Nullable<AnimationRange>;
  30177. /**
  30178. * Gets the key frames from the animation
  30179. * @returns The key frames of the animation
  30180. */
  30181. getKeys(): Array<IAnimationKey>;
  30182. /**
  30183. * Gets the highest frame rate of the animation
  30184. * @returns Highest frame rate of the animation
  30185. */
  30186. getHighestFrame(): number;
  30187. /**
  30188. * Gets the easing function of the animation
  30189. * @returns Easing function of the animation
  30190. */
  30191. getEasingFunction(): IEasingFunction;
  30192. /**
  30193. * Sets the easing function of the animation
  30194. * @param easingFunction A custom mathematical formula for animation
  30195. */
  30196. setEasingFunction(easingFunction: EasingFunction): void;
  30197. /**
  30198. * Interpolates a scalar linearly
  30199. * @param startValue Start value of the animation curve
  30200. * @param endValue End value of the animation curve
  30201. * @param gradient Scalar amount to interpolate
  30202. * @returns Interpolated scalar value
  30203. */
  30204. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30205. /**
  30206. * Interpolates a scalar cubically
  30207. * @param startValue Start value of the animation curve
  30208. * @param outTangent End tangent of the animation
  30209. * @param endValue End value of the animation curve
  30210. * @param inTangent Start tangent of the animation curve
  30211. * @param gradient Scalar amount to interpolate
  30212. * @returns Interpolated scalar value
  30213. */
  30214. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30215. /**
  30216. * Interpolates a quaternion using a spherical linear interpolation
  30217. * @param startValue Start value of the animation curve
  30218. * @param endValue End value of the animation curve
  30219. * @param gradient Scalar amount to interpolate
  30220. * @returns Interpolated quaternion value
  30221. */
  30222. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30223. /**
  30224. * Interpolates a quaternion cubically
  30225. * @param startValue Start value of the animation curve
  30226. * @param outTangent End tangent of the animation curve
  30227. * @param endValue End value of the animation curve
  30228. * @param inTangent Start tangent of the animation curve
  30229. * @param gradient Scalar amount to interpolate
  30230. * @returns Interpolated quaternion value
  30231. */
  30232. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30233. /**
  30234. * Interpolates a Vector3 linearl
  30235. * @param startValue Start value of the animation curve
  30236. * @param endValue End value of the animation curve
  30237. * @param gradient Scalar amount to interpolate
  30238. * @returns Interpolated scalar value
  30239. */
  30240. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30241. /**
  30242. * Interpolates a Vector3 cubically
  30243. * @param startValue Start value of the animation curve
  30244. * @param outTangent End tangent of the animation
  30245. * @param endValue End value of the animation curve
  30246. * @param inTangent Start tangent of the animation curve
  30247. * @param gradient Scalar amount to interpolate
  30248. * @returns InterpolatedVector3 value
  30249. */
  30250. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30251. /**
  30252. * Interpolates a Vector2 linearly
  30253. * @param startValue Start value of the animation curve
  30254. * @param endValue End value of the animation curve
  30255. * @param gradient Scalar amount to interpolate
  30256. * @returns Interpolated Vector2 value
  30257. */
  30258. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30259. /**
  30260. * Interpolates a Vector2 cubically
  30261. * @param startValue Start value of the animation curve
  30262. * @param outTangent End tangent of the animation
  30263. * @param endValue End value of the animation curve
  30264. * @param inTangent Start tangent of the animation curve
  30265. * @param gradient Scalar amount to interpolate
  30266. * @returns Interpolated Vector2 value
  30267. */
  30268. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30269. /**
  30270. * Interpolates a size linearly
  30271. * @param startValue Start value of the animation curve
  30272. * @param endValue End value of the animation curve
  30273. * @param gradient Scalar amount to interpolate
  30274. * @returns Interpolated Size value
  30275. */
  30276. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30277. /**
  30278. * Interpolates a Color3 linearly
  30279. * @param startValue Start value of the animation curve
  30280. * @param endValue End value of the animation curve
  30281. * @param gradient Scalar amount to interpolate
  30282. * @returns Interpolated Color3 value
  30283. */
  30284. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30285. /**
  30286. * Interpolates a Color4 linearly
  30287. * @param startValue Start value of the animation curve
  30288. * @param endValue End value of the animation curve
  30289. * @param gradient Scalar amount to interpolate
  30290. * @returns Interpolated Color3 value
  30291. */
  30292. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30293. /**
  30294. * @hidden Internal use only
  30295. */
  30296. _getKeyValue(value: any): any;
  30297. /**
  30298. * @hidden Internal use only
  30299. */
  30300. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30301. /**
  30302. * Defines the function to use to interpolate matrices
  30303. * @param startValue defines the start matrix
  30304. * @param endValue defines the end matrix
  30305. * @param gradient defines the gradient between both matrices
  30306. * @param result defines an optional target matrix where to store the interpolation
  30307. * @returns the interpolated matrix
  30308. */
  30309. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30310. /**
  30311. * Makes a copy of the animation
  30312. * @returns Cloned animation
  30313. */
  30314. clone(): Animation;
  30315. /**
  30316. * Sets the key frames of the animation
  30317. * @param values The animation key frames to set
  30318. */
  30319. setKeys(values: Array<IAnimationKey>): void;
  30320. /**
  30321. * Serializes the animation to an object
  30322. * @returns Serialized object
  30323. */
  30324. serialize(): any;
  30325. /**
  30326. * Float animation type
  30327. */
  30328. static readonly ANIMATIONTYPE_FLOAT: number;
  30329. /**
  30330. * Vector3 animation type
  30331. */
  30332. static readonly ANIMATIONTYPE_VECTOR3: number;
  30333. /**
  30334. * Quaternion animation type
  30335. */
  30336. static readonly ANIMATIONTYPE_QUATERNION: number;
  30337. /**
  30338. * Matrix animation type
  30339. */
  30340. static readonly ANIMATIONTYPE_MATRIX: number;
  30341. /**
  30342. * Color3 animation type
  30343. */
  30344. static readonly ANIMATIONTYPE_COLOR3: number;
  30345. /**
  30346. * Color3 animation type
  30347. */
  30348. static readonly ANIMATIONTYPE_COLOR4: number;
  30349. /**
  30350. * Vector2 animation type
  30351. */
  30352. static readonly ANIMATIONTYPE_VECTOR2: number;
  30353. /**
  30354. * Size animation type
  30355. */
  30356. static readonly ANIMATIONTYPE_SIZE: number;
  30357. /**
  30358. * Relative Loop Mode
  30359. */
  30360. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30361. /**
  30362. * Cycle Loop Mode
  30363. */
  30364. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30365. /**
  30366. * Constant Loop Mode
  30367. */
  30368. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30369. /** @hidden */
  30370. static _UniversalLerp(left: any, right: any, amount: number): any;
  30371. /**
  30372. * Parses an animation object and creates an animation
  30373. * @param parsedAnimation Parsed animation object
  30374. * @returns Animation object
  30375. */
  30376. static Parse(parsedAnimation: any): Animation;
  30377. /**
  30378. * Appends the serialized animations from the source animations
  30379. * @param source Source containing the animations
  30380. * @param destination Target to store the animations
  30381. */
  30382. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30383. }
  30384. }
  30385. declare module "babylonjs/Animations/animatable.interface" {
  30386. import { Nullable } from "babylonjs/types";
  30387. import { Animation } from "babylonjs/Animations/animation";
  30388. /**
  30389. * Interface containing an array of animations
  30390. */
  30391. export interface IAnimatable {
  30392. /**
  30393. * Array of animations
  30394. */
  30395. animations: Nullable<Array<Animation>>;
  30396. }
  30397. }
  30398. declare module "babylonjs/Misc/decorators" {
  30399. import { Nullable } from "babylonjs/types";
  30400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30401. import { Scene } from "babylonjs/scene";
  30402. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30403. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30404. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30405. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30406. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30407. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30408. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. /**
  30416. * Decorator used to define property that can be serialized as reference to a camera
  30417. * @param sourceName defines the name of the property to decorate
  30418. */
  30419. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. /**
  30421. * Class used to help serialization objects
  30422. */
  30423. export class SerializationHelper {
  30424. /** @hidden */
  30425. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30426. /** @hidden */
  30427. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30428. /** @hidden */
  30429. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30430. /** @hidden */
  30431. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30432. /**
  30433. * Appends the serialized animations from the source animations
  30434. * @param source Source containing the animations
  30435. * @param destination Target to store the animations
  30436. */
  30437. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30438. /**
  30439. * Static function used to serialized a specific entity
  30440. * @param entity defines the entity to serialize
  30441. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30442. * @returns a JSON compatible object representing the serialization of the entity
  30443. */
  30444. static Serialize<T>(entity: T, serializationObject?: any): any;
  30445. /**
  30446. * Creates a new entity from a serialization data object
  30447. * @param creationFunction defines a function used to instanciated the new entity
  30448. * @param source defines the source serialization data
  30449. * @param scene defines the hosting scene
  30450. * @param rootUrl defines the root url for resources
  30451. * @returns a new entity
  30452. */
  30453. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30454. /**
  30455. * Clones an object
  30456. * @param creationFunction defines the function used to instanciate the new object
  30457. * @param source defines the source object
  30458. * @returns the cloned object
  30459. */
  30460. static Clone<T>(creationFunction: () => T, source: T): T;
  30461. /**
  30462. * Instanciates a new object based on a source one (some data will be shared between both object)
  30463. * @param creationFunction defines the function used to instanciate the new object
  30464. * @param source defines the source object
  30465. * @returns the new object
  30466. */
  30467. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30468. }
  30469. }
  30470. declare module "babylonjs/Misc/guid" {
  30471. /**
  30472. * Class used to manipulate GUIDs
  30473. */
  30474. export class GUID {
  30475. /**
  30476. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30477. * Be aware Math.random() could cause collisions, but:
  30478. * "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"
  30479. * @returns a pseudo random id
  30480. */
  30481. static RandomId(): string;
  30482. }
  30483. }
  30484. declare module "babylonjs/Materials/Textures/baseTexture" {
  30485. import { Observable } from "babylonjs/Misc/observable";
  30486. import { Nullable } from "babylonjs/types";
  30487. import { Scene } from "babylonjs/scene";
  30488. import { Matrix } from "babylonjs/Maths/math.vector";
  30489. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30490. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30491. import { ISize } from "babylonjs/Maths/math.size";
  30492. import "babylonjs/Misc/fileTools";
  30493. /**
  30494. * Base class of all the textures in babylon.
  30495. * It groups all the common properties the materials, post process, lights... might need
  30496. * in order to make a correct use of the texture.
  30497. */
  30498. export class BaseTexture implements IAnimatable {
  30499. /**
  30500. * Default anisotropic filtering level for the application.
  30501. * It is set to 4 as a good tradeoff between perf and quality.
  30502. */
  30503. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30504. /**
  30505. * Gets or sets the unique id of the texture
  30506. */
  30507. uniqueId: number;
  30508. /**
  30509. * Define the name of the texture.
  30510. */
  30511. name: string;
  30512. /**
  30513. * Gets or sets an object used to store user defined information.
  30514. */
  30515. metadata: any;
  30516. /**
  30517. * For internal use only. Please do not use.
  30518. */
  30519. reservedDataStore: any;
  30520. private _hasAlpha;
  30521. /**
  30522. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30523. */
  30524. set hasAlpha(value: boolean);
  30525. get hasAlpha(): boolean;
  30526. /**
  30527. * Defines if the alpha value should be determined via the rgb values.
  30528. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30529. */
  30530. getAlphaFromRGB: boolean;
  30531. /**
  30532. * Intensity or strength of the texture.
  30533. * It is commonly used by materials to fine tune the intensity of the texture
  30534. */
  30535. level: number;
  30536. /**
  30537. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30538. * This is part of the texture as textures usually maps to one uv set.
  30539. */
  30540. coordinatesIndex: number;
  30541. private _coordinatesMode;
  30542. /**
  30543. * How a texture is mapped.
  30544. *
  30545. * | Value | Type | Description |
  30546. * | ----- | ----------------------------------- | ----------- |
  30547. * | 0 | EXPLICIT_MODE | |
  30548. * | 1 | SPHERICAL_MODE | |
  30549. * | 2 | PLANAR_MODE | |
  30550. * | 3 | CUBIC_MODE | |
  30551. * | 4 | PROJECTION_MODE | |
  30552. * | 5 | SKYBOX_MODE | |
  30553. * | 6 | INVCUBIC_MODE | |
  30554. * | 7 | EQUIRECTANGULAR_MODE | |
  30555. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30556. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30557. */
  30558. set coordinatesMode(value: number);
  30559. get coordinatesMode(): number;
  30560. /**
  30561. * | Value | Type | Description |
  30562. * | ----- | ------------------ | ----------- |
  30563. * | 0 | CLAMP_ADDRESSMODE | |
  30564. * | 1 | WRAP_ADDRESSMODE | |
  30565. * | 2 | MIRROR_ADDRESSMODE | |
  30566. */
  30567. wrapU: number;
  30568. /**
  30569. * | Value | Type | Description |
  30570. * | ----- | ------------------ | ----------- |
  30571. * | 0 | CLAMP_ADDRESSMODE | |
  30572. * | 1 | WRAP_ADDRESSMODE | |
  30573. * | 2 | MIRROR_ADDRESSMODE | |
  30574. */
  30575. wrapV: number;
  30576. /**
  30577. * | Value | Type | Description |
  30578. * | ----- | ------------------ | ----------- |
  30579. * | 0 | CLAMP_ADDRESSMODE | |
  30580. * | 1 | WRAP_ADDRESSMODE | |
  30581. * | 2 | MIRROR_ADDRESSMODE | |
  30582. */
  30583. wrapR: number;
  30584. /**
  30585. * With compliant hardware and browser (supporting anisotropic filtering)
  30586. * this defines the level of anisotropic filtering in the texture.
  30587. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30588. */
  30589. anisotropicFilteringLevel: number;
  30590. /**
  30591. * Define if the texture is a cube texture or if false a 2d texture.
  30592. */
  30593. get isCube(): boolean;
  30594. set isCube(value: boolean);
  30595. /**
  30596. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30597. */
  30598. get is3D(): boolean;
  30599. set is3D(value: boolean);
  30600. /**
  30601. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30602. */
  30603. get is2DArray(): boolean;
  30604. set is2DArray(value: boolean);
  30605. /**
  30606. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30607. * HDR texture are usually stored in linear space.
  30608. * This only impacts the PBR and Background materials
  30609. */
  30610. gammaSpace: boolean;
  30611. /**
  30612. * Gets or sets whether or not the texture contains RGBD data.
  30613. */
  30614. get isRGBD(): boolean;
  30615. set isRGBD(value: boolean);
  30616. /**
  30617. * Is Z inverted in the texture (useful in a cube texture).
  30618. */
  30619. invertZ: boolean;
  30620. /**
  30621. * Are mip maps generated for this texture or not.
  30622. */
  30623. get noMipmap(): boolean;
  30624. /**
  30625. * @hidden
  30626. */
  30627. lodLevelInAlpha: boolean;
  30628. /**
  30629. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30630. */
  30631. get lodGenerationOffset(): number;
  30632. set lodGenerationOffset(value: number);
  30633. /**
  30634. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30635. */
  30636. get lodGenerationScale(): number;
  30637. set lodGenerationScale(value: number);
  30638. /**
  30639. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30640. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30641. * average roughness values.
  30642. */
  30643. get linearSpecularLOD(): boolean;
  30644. set linearSpecularLOD(value: boolean);
  30645. /**
  30646. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30647. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30648. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30649. */
  30650. get irradianceTexture(): Nullable<BaseTexture>;
  30651. set irradianceTexture(value: Nullable<BaseTexture>);
  30652. /**
  30653. * Define if the texture is a render target.
  30654. */
  30655. isRenderTarget: boolean;
  30656. /**
  30657. * Define the unique id of the texture in the scene.
  30658. */
  30659. get uid(): string;
  30660. /**
  30661. * Return a string representation of the texture.
  30662. * @returns the texture as a string
  30663. */
  30664. toString(): string;
  30665. /**
  30666. * Get the class name of the texture.
  30667. * @returns "BaseTexture"
  30668. */
  30669. getClassName(): string;
  30670. /**
  30671. * Define the list of animation attached to the texture.
  30672. */
  30673. animations: import("babylonjs/Animations/animation").Animation[];
  30674. /**
  30675. * An event triggered when the texture is disposed.
  30676. */
  30677. onDisposeObservable: Observable<BaseTexture>;
  30678. private _onDisposeObserver;
  30679. /**
  30680. * Callback triggered when the texture has been disposed.
  30681. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30682. */
  30683. set onDispose(callback: () => void);
  30684. /**
  30685. * Define the current state of the loading sequence when in delayed load mode.
  30686. */
  30687. delayLoadState: number;
  30688. private _scene;
  30689. /** @hidden */
  30690. _texture: Nullable<InternalTexture>;
  30691. private _uid;
  30692. /**
  30693. * Define if the texture is preventinga material to render or not.
  30694. * If not and the texture is not ready, the engine will use a default black texture instead.
  30695. */
  30696. get isBlocking(): boolean;
  30697. /**
  30698. * Instantiates a new BaseTexture.
  30699. * Base class of all the textures in babylon.
  30700. * It groups all the common properties the materials, post process, lights... might need
  30701. * in order to make a correct use of the texture.
  30702. * @param scene Define the scene the texture blongs to
  30703. */
  30704. constructor(scene: Nullable<Scene>);
  30705. /**
  30706. * Get the scene the texture belongs to.
  30707. * @returns the scene or null if undefined
  30708. */
  30709. getScene(): Nullable<Scene>;
  30710. /**
  30711. * Get the texture transform matrix used to offset tile the texture for istance.
  30712. * @returns the transformation matrix
  30713. */
  30714. getTextureMatrix(): Matrix;
  30715. /**
  30716. * Get the texture reflection matrix used to rotate/transform the reflection.
  30717. * @returns the reflection matrix
  30718. */
  30719. getReflectionTextureMatrix(): Matrix;
  30720. /**
  30721. * Get the underlying lower level texture from Babylon.
  30722. * @returns the insternal texture
  30723. */
  30724. getInternalTexture(): Nullable<InternalTexture>;
  30725. /**
  30726. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30727. * @returns true if ready or not blocking
  30728. */
  30729. isReadyOrNotBlocking(): boolean;
  30730. /**
  30731. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30732. * @returns true if fully ready
  30733. */
  30734. isReady(): boolean;
  30735. private _cachedSize;
  30736. /**
  30737. * Get the size of the texture.
  30738. * @returns the texture size.
  30739. */
  30740. getSize(): ISize;
  30741. /**
  30742. * Get the base size of the texture.
  30743. * It can be different from the size if the texture has been resized for POT for instance
  30744. * @returns the base size
  30745. */
  30746. getBaseSize(): ISize;
  30747. /**
  30748. * Update the sampling mode of the texture.
  30749. * Default is Trilinear mode.
  30750. *
  30751. * | Value | Type | Description |
  30752. * | ----- | ------------------ | ----------- |
  30753. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30754. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30755. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30756. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30757. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30758. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30759. * | 7 | NEAREST_LINEAR | |
  30760. * | 8 | NEAREST_NEAREST | |
  30761. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30762. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30763. * | 11 | LINEAR_LINEAR | |
  30764. * | 12 | LINEAR_NEAREST | |
  30765. *
  30766. * > _mag_: magnification filter (close to the viewer)
  30767. * > _min_: minification filter (far from the viewer)
  30768. * > _mip_: filter used between mip map levels
  30769. *@param samplingMode Define the new sampling mode of the texture
  30770. */
  30771. updateSamplingMode(samplingMode: number): void;
  30772. /**
  30773. * Scales the texture if is `canRescale()`
  30774. * @param ratio the resize factor we want to use to rescale
  30775. */
  30776. scale(ratio: number): void;
  30777. /**
  30778. * Get if the texture can rescale.
  30779. */
  30780. get canRescale(): boolean;
  30781. /** @hidden */
  30782. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30783. /** @hidden */
  30784. _rebuild(): void;
  30785. /**
  30786. * Triggers the load sequence in delayed load mode.
  30787. */
  30788. delayLoad(): void;
  30789. /**
  30790. * Clones the texture.
  30791. * @returns the cloned texture
  30792. */
  30793. clone(): Nullable<BaseTexture>;
  30794. /**
  30795. * Get the texture underlying type (INT, FLOAT...)
  30796. */
  30797. get textureType(): number;
  30798. /**
  30799. * Get the texture underlying format (RGB, RGBA...)
  30800. */
  30801. get textureFormat(): number;
  30802. /**
  30803. * Indicates that textures need to be re-calculated for all materials
  30804. */
  30805. protected _markAllSubMeshesAsTexturesDirty(): void;
  30806. /**
  30807. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30808. * This will returns an RGBA array buffer containing either in values (0-255) or
  30809. * float values (0-1) depending of the underlying buffer type.
  30810. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30811. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30812. * @param buffer defines a user defined buffer to fill with data (can be null)
  30813. * @returns The Array buffer containing the pixels data.
  30814. */
  30815. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30816. /**
  30817. * Release and destroy the underlying lower level texture aka internalTexture.
  30818. */
  30819. releaseInternalTexture(): void;
  30820. /** @hidden */
  30821. get _lodTextureHigh(): Nullable<BaseTexture>;
  30822. /** @hidden */
  30823. get _lodTextureMid(): Nullable<BaseTexture>;
  30824. /** @hidden */
  30825. get _lodTextureLow(): Nullable<BaseTexture>;
  30826. /**
  30827. * Dispose the texture and release its associated resources.
  30828. */
  30829. dispose(): void;
  30830. /**
  30831. * Serialize the texture into a JSON representation that can be parsed later on.
  30832. * @returns the JSON representation of the texture
  30833. */
  30834. serialize(): any;
  30835. /**
  30836. * Helper function to be called back once a list of texture contains only ready textures.
  30837. * @param textures Define the list of textures to wait for
  30838. * @param callback Define the callback triggered once the entire list will be ready
  30839. */
  30840. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30841. }
  30842. }
  30843. declare module "babylonjs/Materials/effect" {
  30844. import { Observable } from "babylonjs/Misc/observable";
  30845. import { Nullable } from "babylonjs/types";
  30846. import { IDisposable } from "babylonjs/scene";
  30847. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30848. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30849. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30850. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30851. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30852. import { Engine } from "babylonjs/Engines/engine";
  30853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30857. /**
  30858. * Options to be used when creating an effect.
  30859. */
  30860. export interface IEffectCreationOptions {
  30861. /**
  30862. * Atrributes that will be used in the shader.
  30863. */
  30864. attributes: string[];
  30865. /**
  30866. * Uniform varible names that will be set in the shader.
  30867. */
  30868. uniformsNames: string[];
  30869. /**
  30870. * Uniform buffer variable names that will be set in the shader.
  30871. */
  30872. uniformBuffersNames: string[];
  30873. /**
  30874. * Sampler texture variable names that will be set in the shader.
  30875. */
  30876. samplers: string[];
  30877. /**
  30878. * Define statements that will be set in the shader.
  30879. */
  30880. defines: any;
  30881. /**
  30882. * Possible fallbacks for this effect to improve performance when needed.
  30883. */
  30884. fallbacks: Nullable<IEffectFallbacks>;
  30885. /**
  30886. * Callback that will be called when the shader is compiled.
  30887. */
  30888. onCompiled: Nullable<(effect: Effect) => void>;
  30889. /**
  30890. * Callback that will be called if an error occurs during shader compilation.
  30891. */
  30892. onError: Nullable<(effect: Effect, errors: string) => void>;
  30893. /**
  30894. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30895. */
  30896. indexParameters?: any;
  30897. /**
  30898. * Max number of lights that can be used in the shader.
  30899. */
  30900. maxSimultaneousLights?: number;
  30901. /**
  30902. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30903. */
  30904. transformFeedbackVaryings?: Nullable<string[]>;
  30905. }
  30906. /**
  30907. * Effect containing vertex and fragment shader that can be executed on an object.
  30908. */
  30909. export class Effect implements IDisposable {
  30910. /**
  30911. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30912. */
  30913. static ShadersRepository: string;
  30914. /**
  30915. * Name of the effect.
  30916. */
  30917. name: any;
  30918. /**
  30919. * String container all the define statements that should be set on the shader.
  30920. */
  30921. defines: string;
  30922. /**
  30923. * Callback that will be called when the shader is compiled.
  30924. */
  30925. onCompiled: Nullable<(effect: Effect) => void>;
  30926. /**
  30927. * Callback that will be called if an error occurs during shader compilation.
  30928. */
  30929. onError: Nullable<(effect: Effect, errors: string) => void>;
  30930. /**
  30931. * Callback that will be called when effect is bound.
  30932. */
  30933. onBind: Nullable<(effect: Effect) => void>;
  30934. /**
  30935. * Unique ID of the effect.
  30936. */
  30937. uniqueId: number;
  30938. /**
  30939. * Observable that will be called when the shader is compiled.
  30940. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30941. */
  30942. onCompileObservable: Observable<Effect>;
  30943. /**
  30944. * Observable that will be called if an error occurs during shader compilation.
  30945. */
  30946. onErrorObservable: Observable<Effect>;
  30947. /** @hidden */
  30948. _onBindObservable: Nullable<Observable<Effect>>;
  30949. /**
  30950. * @hidden
  30951. * Specifies if the effect was previously ready
  30952. */
  30953. _wasPreviouslyReady: boolean;
  30954. /**
  30955. * Observable that will be called when effect is bound.
  30956. */
  30957. get onBindObservable(): Observable<Effect>;
  30958. /** @hidden */
  30959. _bonesComputationForcedToCPU: boolean;
  30960. private static _uniqueIdSeed;
  30961. private _engine;
  30962. private _uniformBuffersNames;
  30963. private _uniformsNames;
  30964. private _samplerList;
  30965. private _samplers;
  30966. private _isReady;
  30967. private _compilationError;
  30968. private _allFallbacksProcessed;
  30969. private _attributesNames;
  30970. private _attributes;
  30971. private _attributeLocationByName;
  30972. private _uniforms;
  30973. /**
  30974. * Key for the effect.
  30975. * @hidden
  30976. */
  30977. _key: string;
  30978. private _indexParameters;
  30979. private _fallbacks;
  30980. private _vertexSourceCode;
  30981. private _fragmentSourceCode;
  30982. private _vertexSourceCodeOverride;
  30983. private _fragmentSourceCodeOverride;
  30984. private _transformFeedbackVaryings;
  30985. /**
  30986. * Compiled shader to webGL program.
  30987. * @hidden
  30988. */
  30989. _pipelineContext: Nullable<IPipelineContext>;
  30990. private _valueCache;
  30991. private static _baseCache;
  30992. /**
  30993. * Instantiates an effect.
  30994. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30995. * @param baseName Name of the effect.
  30996. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30997. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30998. * @param samplers List of sampler variables that will be passed to the shader.
  30999. * @param engine Engine to be used to render the effect
  31000. * @param defines Define statements to be added to the shader.
  31001. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31002. * @param onCompiled Callback that will be called when the shader is compiled.
  31003. * @param onError Callback that will be called if an error occurs during shader compilation.
  31004. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31005. */
  31006. 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);
  31007. private _useFinalCode;
  31008. /**
  31009. * Unique key for this effect
  31010. */
  31011. get key(): string;
  31012. /**
  31013. * If the effect has been compiled and prepared.
  31014. * @returns if the effect is compiled and prepared.
  31015. */
  31016. isReady(): boolean;
  31017. private _isReadyInternal;
  31018. /**
  31019. * The engine the effect was initialized with.
  31020. * @returns the engine.
  31021. */
  31022. getEngine(): Engine;
  31023. /**
  31024. * The pipeline context for this effect
  31025. * @returns the associated pipeline context
  31026. */
  31027. getPipelineContext(): Nullable<IPipelineContext>;
  31028. /**
  31029. * The set of names of attribute variables for the shader.
  31030. * @returns An array of attribute names.
  31031. */
  31032. getAttributesNames(): string[];
  31033. /**
  31034. * Returns the attribute at the given index.
  31035. * @param index The index of the attribute.
  31036. * @returns The location of the attribute.
  31037. */
  31038. getAttributeLocation(index: number): number;
  31039. /**
  31040. * Returns the attribute based on the name of the variable.
  31041. * @param name of the attribute to look up.
  31042. * @returns the attribute location.
  31043. */
  31044. getAttributeLocationByName(name: string): number;
  31045. /**
  31046. * The number of attributes.
  31047. * @returns the numnber of attributes.
  31048. */
  31049. getAttributesCount(): number;
  31050. /**
  31051. * Gets the index of a uniform variable.
  31052. * @param uniformName of the uniform to look up.
  31053. * @returns the index.
  31054. */
  31055. getUniformIndex(uniformName: string): number;
  31056. /**
  31057. * Returns the attribute based on the name of the variable.
  31058. * @param uniformName of the uniform to look up.
  31059. * @returns the location of the uniform.
  31060. */
  31061. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31062. /**
  31063. * Returns an array of sampler variable names
  31064. * @returns The array of sampler variable neames.
  31065. */
  31066. getSamplers(): string[];
  31067. /**
  31068. * The error from the last compilation.
  31069. * @returns the error string.
  31070. */
  31071. getCompilationError(): string;
  31072. /**
  31073. * Gets a boolean indicating that all fallbacks were used during compilation
  31074. * @returns true if all fallbacks were used
  31075. */
  31076. allFallbacksProcessed(): boolean;
  31077. /**
  31078. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31079. * @param func The callback to be used.
  31080. */
  31081. executeWhenCompiled(func: (effect: Effect) => void): void;
  31082. private _checkIsReady;
  31083. private _loadShader;
  31084. /**
  31085. * Recompiles the webGL program
  31086. * @param vertexSourceCode The source code for the vertex shader.
  31087. * @param fragmentSourceCode The source code for the fragment shader.
  31088. * @param onCompiled Callback called when completed.
  31089. * @param onError Callback called on error.
  31090. * @hidden
  31091. */
  31092. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31093. /**
  31094. * Prepares the effect
  31095. * @hidden
  31096. */
  31097. _prepareEffect(): void;
  31098. private _processCompilationErrors;
  31099. /**
  31100. * Checks if the effect is supported. (Must be called after compilation)
  31101. */
  31102. get isSupported(): boolean;
  31103. /**
  31104. * Binds a texture to the engine to be used as output of the shader.
  31105. * @param channel Name of the output variable.
  31106. * @param texture Texture to bind.
  31107. * @hidden
  31108. */
  31109. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31110. /**
  31111. * Sets a texture on the engine to be used in the shader.
  31112. * @param channel Name of the sampler variable.
  31113. * @param texture Texture to set.
  31114. */
  31115. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31116. /**
  31117. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31118. * @param channel Name of the sampler variable.
  31119. * @param texture Texture to set.
  31120. */
  31121. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31122. /**
  31123. * Sets an array of textures on the engine to be used in the shader.
  31124. * @param channel Name of the variable.
  31125. * @param textures Textures to set.
  31126. */
  31127. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31128. /**
  31129. * 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)
  31130. * @param channel Name of the sampler variable.
  31131. * @param postProcess Post process to get the input texture from.
  31132. */
  31133. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31134. /**
  31135. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31136. * 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)
  31137. * @param channel Name of the sampler variable.
  31138. * @param postProcess Post process to get the output texture from.
  31139. */
  31140. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31141. /** @hidden */
  31142. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31143. /** @hidden */
  31144. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31145. /** @hidden */
  31146. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31147. /** @hidden */
  31148. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31149. /**
  31150. * Binds a buffer to a uniform.
  31151. * @param buffer Buffer to bind.
  31152. * @param name Name of the uniform variable to bind to.
  31153. */
  31154. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31155. /**
  31156. * Binds block to a uniform.
  31157. * @param blockName Name of the block to bind.
  31158. * @param index Index to bind.
  31159. */
  31160. bindUniformBlock(blockName: string, index: number): void;
  31161. /**
  31162. * Sets an interger value on a uniform variable.
  31163. * @param uniformName Name of the variable.
  31164. * @param value Value to be set.
  31165. * @returns this effect.
  31166. */
  31167. setInt(uniformName: string, value: number): Effect;
  31168. /**
  31169. * Sets an int array on a uniform variable.
  31170. * @param uniformName Name of the variable.
  31171. * @param array array to be set.
  31172. * @returns this effect.
  31173. */
  31174. setIntArray(uniformName: string, array: Int32Array): Effect;
  31175. /**
  31176. * 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)
  31177. * @param uniformName Name of the variable.
  31178. * @param array array to be set.
  31179. * @returns this effect.
  31180. */
  31181. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31182. /**
  31183. * 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)
  31184. * @param uniformName Name of the variable.
  31185. * @param array array to be set.
  31186. * @returns this effect.
  31187. */
  31188. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31189. /**
  31190. * 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)
  31191. * @param uniformName Name of the variable.
  31192. * @param array array to be set.
  31193. * @returns this effect.
  31194. */
  31195. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31196. /**
  31197. * Sets an float array on a uniform variable.
  31198. * @param uniformName Name of the variable.
  31199. * @param array array to be set.
  31200. * @returns this effect.
  31201. */
  31202. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31203. /**
  31204. * 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)
  31205. * @param uniformName Name of the variable.
  31206. * @param array array to be set.
  31207. * @returns this effect.
  31208. */
  31209. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31210. /**
  31211. * 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)
  31212. * @param uniformName Name of the variable.
  31213. * @param array array to be set.
  31214. * @returns this effect.
  31215. */
  31216. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31217. /**
  31218. * 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)
  31219. * @param uniformName Name of the variable.
  31220. * @param array array to be set.
  31221. * @returns this effect.
  31222. */
  31223. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31224. /**
  31225. * Sets an array on a uniform variable.
  31226. * @param uniformName Name of the variable.
  31227. * @param array array to be set.
  31228. * @returns this effect.
  31229. */
  31230. setArray(uniformName: string, array: number[]): Effect;
  31231. /**
  31232. * 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)
  31233. * @param uniformName Name of the variable.
  31234. * @param array array to be set.
  31235. * @returns this effect.
  31236. */
  31237. setArray2(uniformName: string, array: number[]): Effect;
  31238. /**
  31239. * 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)
  31240. * @param uniformName Name of the variable.
  31241. * @param array array to be set.
  31242. * @returns this effect.
  31243. */
  31244. setArray3(uniformName: string, array: number[]): Effect;
  31245. /**
  31246. * 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)
  31247. * @param uniformName Name of the variable.
  31248. * @param array array to be set.
  31249. * @returns this effect.
  31250. */
  31251. setArray4(uniformName: string, array: number[]): Effect;
  31252. /**
  31253. * Sets matrices on a uniform variable.
  31254. * @param uniformName Name of the variable.
  31255. * @param matrices matrices to be set.
  31256. * @returns this effect.
  31257. */
  31258. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31259. /**
  31260. * Sets matrix on a uniform variable.
  31261. * @param uniformName Name of the variable.
  31262. * @param matrix matrix to be set.
  31263. * @returns this effect.
  31264. */
  31265. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31266. /**
  31267. * 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)
  31268. * @param uniformName Name of the variable.
  31269. * @param matrix matrix to be set.
  31270. * @returns this effect.
  31271. */
  31272. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31273. /**
  31274. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31275. * @param uniformName Name of the variable.
  31276. * @param matrix matrix to be set.
  31277. * @returns this effect.
  31278. */
  31279. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31280. /**
  31281. * Sets a float on a uniform variable.
  31282. * @param uniformName Name of the variable.
  31283. * @param value value to be set.
  31284. * @returns this effect.
  31285. */
  31286. setFloat(uniformName: string, value: number): Effect;
  31287. /**
  31288. * Sets a boolean on a uniform variable.
  31289. * @param uniformName Name of the variable.
  31290. * @param bool value to be set.
  31291. * @returns this effect.
  31292. */
  31293. setBool(uniformName: string, bool: boolean): Effect;
  31294. /**
  31295. * Sets a Vector2 on a uniform variable.
  31296. * @param uniformName Name of the variable.
  31297. * @param vector2 vector2 to be set.
  31298. * @returns this effect.
  31299. */
  31300. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31301. /**
  31302. * Sets a float2 on a uniform variable.
  31303. * @param uniformName Name of the variable.
  31304. * @param x First float in float2.
  31305. * @param y Second float in float2.
  31306. * @returns this effect.
  31307. */
  31308. setFloat2(uniformName: string, x: number, y: number): Effect;
  31309. /**
  31310. * Sets a Vector3 on a uniform variable.
  31311. * @param uniformName Name of the variable.
  31312. * @param vector3 Value to be set.
  31313. * @returns this effect.
  31314. */
  31315. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31316. /**
  31317. * Sets a float3 on a uniform variable.
  31318. * @param uniformName Name of the variable.
  31319. * @param x First float in float3.
  31320. * @param y Second float in float3.
  31321. * @param z Third float in float3.
  31322. * @returns this effect.
  31323. */
  31324. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31325. /**
  31326. * Sets a Vector4 on a uniform variable.
  31327. * @param uniformName Name of the variable.
  31328. * @param vector4 Value to be set.
  31329. * @returns this effect.
  31330. */
  31331. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31332. /**
  31333. * Sets a float4 on a uniform variable.
  31334. * @param uniformName Name of the variable.
  31335. * @param x First float in float4.
  31336. * @param y Second float in float4.
  31337. * @param z Third float in float4.
  31338. * @param w Fourth float in float4.
  31339. * @returns this effect.
  31340. */
  31341. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31342. /**
  31343. * Sets a Color3 on a uniform variable.
  31344. * @param uniformName Name of the variable.
  31345. * @param color3 Value to be set.
  31346. * @returns this effect.
  31347. */
  31348. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31349. /**
  31350. * Sets a Color4 on a uniform variable.
  31351. * @param uniformName Name of the variable.
  31352. * @param color3 Value to be set.
  31353. * @param alpha Alpha value to be set.
  31354. * @returns this effect.
  31355. */
  31356. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31357. /**
  31358. * Sets a Color4 on a uniform variable
  31359. * @param uniformName defines the name of the variable
  31360. * @param color4 defines the value to be set
  31361. * @returns this effect.
  31362. */
  31363. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31364. /** Release all associated resources */
  31365. dispose(): void;
  31366. /**
  31367. * This function will add a new shader to the shader store
  31368. * @param name the name of the shader
  31369. * @param pixelShader optional pixel shader content
  31370. * @param vertexShader optional vertex shader content
  31371. */
  31372. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31373. /**
  31374. * Store of each shader (The can be looked up using effect.key)
  31375. */
  31376. static ShadersStore: {
  31377. [key: string]: string;
  31378. };
  31379. /**
  31380. * Store of each included file for a shader (The can be looked up using effect.key)
  31381. */
  31382. static IncludesShadersStore: {
  31383. [key: string]: string;
  31384. };
  31385. /**
  31386. * Resets the cache of effects.
  31387. */
  31388. static ResetCache(): void;
  31389. }
  31390. }
  31391. declare module "babylonjs/Engines/engineCapabilities" {
  31392. /**
  31393. * Interface used to describe the capabilities of the engine relatively to the current browser
  31394. */
  31395. export interface EngineCapabilities {
  31396. /** Maximum textures units per fragment shader */
  31397. maxTexturesImageUnits: number;
  31398. /** Maximum texture units per vertex shader */
  31399. maxVertexTextureImageUnits: number;
  31400. /** Maximum textures units in the entire pipeline */
  31401. maxCombinedTexturesImageUnits: number;
  31402. /** Maximum texture size */
  31403. maxTextureSize: number;
  31404. /** Maximum texture samples */
  31405. maxSamples?: number;
  31406. /** Maximum cube texture size */
  31407. maxCubemapTextureSize: number;
  31408. /** Maximum render texture size */
  31409. maxRenderTextureSize: number;
  31410. /** Maximum number of vertex attributes */
  31411. maxVertexAttribs: number;
  31412. /** Maximum number of varyings */
  31413. maxVaryingVectors: number;
  31414. /** Maximum number of uniforms per vertex shader */
  31415. maxVertexUniformVectors: number;
  31416. /** Maximum number of uniforms per fragment shader */
  31417. maxFragmentUniformVectors: number;
  31418. /** Defines if standard derivates (dx/dy) are supported */
  31419. standardDerivatives: boolean;
  31420. /** Defines if s3tc texture compression is supported */
  31421. s3tc?: WEBGL_compressed_texture_s3tc;
  31422. /** Defines if pvrtc texture compression is supported */
  31423. pvrtc: any;
  31424. /** Defines if etc1 texture compression is supported */
  31425. etc1: any;
  31426. /** Defines if etc2 texture compression is supported */
  31427. etc2: any;
  31428. /** Defines if astc texture compression is supported */
  31429. astc: any;
  31430. /** Defines if float textures are supported */
  31431. textureFloat: boolean;
  31432. /** Defines if vertex array objects are supported */
  31433. vertexArrayObject: boolean;
  31434. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31435. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31436. /** Gets the maximum level of anisotropy supported */
  31437. maxAnisotropy: number;
  31438. /** Defines if instancing is supported */
  31439. instancedArrays: boolean;
  31440. /** Defines if 32 bits indices are supported */
  31441. uintIndices: boolean;
  31442. /** Defines if high precision shaders are supported */
  31443. highPrecisionShaderSupported: boolean;
  31444. /** Defines if depth reading in the fragment shader is supported */
  31445. fragmentDepthSupported: boolean;
  31446. /** Defines if float texture linear filtering is supported*/
  31447. textureFloatLinearFiltering: boolean;
  31448. /** Defines if rendering to float textures is supported */
  31449. textureFloatRender: boolean;
  31450. /** Defines if half float textures are supported*/
  31451. textureHalfFloat: boolean;
  31452. /** Defines if half float texture linear filtering is supported*/
  31453. textureHalfFloatLinearFiltering: boolean;
  31454. /** Defines if rendering to half float textures is supported */
  31455. textureHalfFloatRender: boolean;
  31456. /** Defines if textureLOD shader command is supported */
  31457. textureLOD: boolean;
  31458. /** Defines if draw buffers extension is supported */
  31459. drawBuffersExtension: boolean;
  31460. /** Defines if depth textures are supported */
  31461. depthTextureExtension: boolean;
  31462. /** Defines if float color buffer are supported */
  31463. colorBufferFloat: boolean;
  31464. /** Gets disjoint timer query extension (null if not supported) */
  31465. timerQuery?: EXT_disjoint_timer_query;
  31466. /** Defines if timestamp can be used with timer query */
  31467. canUseTimestampForTimerQuery: boolean;
  31468. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31469. multiview?: any;
  31470. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31471. oculusMultiview?: any;
  31472. /** Function used to let the system compiles shaders in background */
  31473. parallelShaderCompile?: {
  31474. COMPLETION_STATUS_KHR: number;
  31475. };
  31476. /** Max number of texture samples for MSAA */
  31477. maxMSAASamples: number;
  31478. /** Defines if the blend min max extension is supported */
  31479. blendMinMax: boolean;
  31480. }
  31481. }
  31482. declare module "babylonjs/States/depthCullingState" {
  31483. import { Nullable } from "babylonjs/types";
  31484. /**
  31485. * @hidden
  31486. **/
  31487. export class DepthCullingState {
  31488. private _isDepthTestDirty;
  31489. private _isDepthMaskDirty;
  31490. private _isDepthFuncDirty;
  31491. private _isCullFaceDirty;
  31492. private _isCullDirty;
  31493. private _isZOffsetDirty;
  31494. private _isFrontFaceDirty;
  31495. private _depthTest;
  31496. private _depthMask;
  31497. private _depthFunc;
  31498. private _cull;
  31499. private _cullFace;
  31500. private _zOffset;
  31501. private _frontFace;
  31502. /**
  31503. * Initializes the state.
  31504. */
  31505. constructor();
  31506. get isDirty(): boolean;
  31507. get zOffset(): number;
  31508. set zOffset(value: number);
  31509. get cullFace(): Nullable<number>;
  31510. set cullFace(value: Nullable<number>);
  31511. get cull(): Nullable<boolean>;
  31512. set cull(value: Nullable<boolean>);
  31513. get depthFunc(): Nullable<number>;
  31514. set depthFunc(value: Nullable<number>);
  31515. get depthMask(): boolean;
  31516. set depthMask(value: boolean);
  31517. get depthTest(): boolean;
  31518. set depthTest(value: boolean);
  31519. get frontFace(): Nullable<number>;
  31520. set frontFace(value: Nullable<number>);
  31521. reset(): void;
  31522. apply(gl: WebGLRenderingContext): void;
  31523. }
  31524. }
  31525. declare module "babylonjs/States/stencilState" {
  31526. /**
  31527. * @hidden
  31528. **/
  31529. export class StencilState {
  31530. /** 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 */
  31531. static readonly ALWAYS: number;
  31532. /** Passed to stencilOperation to specify that stencil value must be kept */
  31533. static readonly KEEP: number;
  31534. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31535. static readonly REPLACE: number;
  31536. private _isStencilTestDirty;
  31537. private _isStencilMaskDirty;
  31538. private _isStencilFuncDirty;
  31539. private _isStencilOpDirty;
  31540. private _stencilTest;
  31541. private _stencilMask;
  31542. private _stencilFunc;
  31543. private _stencilFuncRef;
  31544. private _stencilFuncMask;
  31545. private _stencilOpStencilFail;
  31546. private _stencilOpDepthFail;
  31547. private _stencilOpStencilDepthPass;
  31548. get isDirty(): boolean;
  31549. get stencilFunc(): number;
  31550. set stencilFunc(value: number);
  31551. get stencilFuncRef(): number;
  31552. set stencilFuncRef(value: number);
  31553. get stencilFuncMask(): number;
  31554. set stencilFuncMask(value: number);
  31555. get stencilOpStencilFail(): number;
  31556. set stencilOpStencilFail(value: number);
  31557. get stencilOpDepthFail(): number;
  31558. set stencilOpDepthFail(value: number);
  31559. get stencilOpStencilDepthPass(): number;
  31560. set stencilOpStencilDepthPass(value: number);
  31561. get stencilMask(): number;
  31562. set stencilMask(value: number);
  31563. get stencilTest(): boolean;
  31564. set stencilTest(value: boolean);
  31565. constructor();
  31566. reset(): void;
  31567. apply(gl: WebGLRenderingContext): void;
  31568. }
  31569. }
  31570. declare module "babylonjs/States/alphaCullingState" {
  31571. /**
  31572. * @hidden
  31573. **/
  31574. export class AlphaState {
  31575. private _isAlphaBlendDirty;
  31576. private _isBlendFunctionParametersDirty;
  31577. private _isBlendEquationParametersDirty;
  31578. private _isBlendConstantsDirty;
  31579. private _alphaBlend;
  31580. private _blendFunctionParameters;
  31581. private _blendEquationParameters;
  31582. private _blendConstants;
  31583. /**
  31584. * Initializes the state.
  31585. */
  31586. constructor();
  31587. get isDirty(): boolean;
  31588. get alphaBlend(): boolean;
  31589. set alphaBlend(value: boolean);
  31590. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31591. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31592. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31593. reset(): void;
  31594. apply(gl: WebGLRenderingContext): void;
  31595. }
  31596. }
  31597. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31598. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31599. /** @hidden */
  31600. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31601. attributeProcessor(attribute: string): string;
  31602. varyingProcessor(varying: string, isFragment: boolean): string;
  31603. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31604. }
  31605. }
  31606. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31607. /**
  31608. * Interface for attribute information associated with buffer instanciation
  31609. */
  31610. export interface InstancingAttributeInfo {
  31611. /**
  31612. * Name of the GLSL attribute
  31613. * if attribute index is not specified, this is used to retrieve the index from the effect
  31614. */
  31615. attributeName: string;
  31616. /**
  31617. * Index/offset of the attribute in the vertex shader
  31618. * if not specified, this will be computes from the name.
  31619. */
  31620. index?: number;
  31621. /**
  31622. * size of the attribute, 1, 2, 3 or 4
  31623. */
  31624. attributeSize: number;
  31625. /**
  31626. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31627. */
  31628. offset: number;
  31629. /**
  31630. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31631. * default to 1
  31632. */
  31633. divisor?: number;
  31634. /**
  31635. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31636. * default is FLOAT
  31637. */
  31638. attributeType?: number;
  31639. /**
  31640. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31641. */
  31642. normalized?: boolean;
  31643. }
  31644. }
  31645. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31646. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31647. import { Nullable } from "babylonjs/types";
  31648. module "babylonjs/Engines/thinEngine" {
  31649. interface ThinEngine {
  31650. /**
  31651. * Update a video texture
  31652. * @param texture defines the texture to update
  31653. * @param video defines the video element to use
  31654. * @param invertY defines if data must be stored with Y axis inverted
  31655. */
  31656. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31657. }
  31658. }
  31659. }
  31660. declare module "babylonjs/Materials/Textures/videoTexture" {
  31661. import { Observable } from "babylonjs/Misc/observable";
  31662. import { Nullable } from "babylonjs/types";
  31663. import { Scene } from "babylonjs/scene";
  31664. import { Texture } from "babylonjs/Materials/Textures/texture";
  31665. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31666. /**
  31667. * Settings for finer control over video usage
  31668. */
  31669. export interface VideoTextureSettings {
  31670. /**
  31671. * Applies `autoplay` to video, if specified
  31672. */
  31673. autoPlay?: boolean;
  31674. /**
  31675. * Applies `loop` to video, if specified
  31676. */
  31677. loop?: boolean;
  31678. /**
  31679. * Automatically updates internal texture from video at every frame in the render loop
  31680. */
  31681. autoUpdateTexture: boolean;
  31682. /**
  31683. * Image src displayed during the video loading or until the user interacts with the video.
  31684. */
  31685. poster?: string;
  31686. }
  31687. /**
  31688. * If you want to display a video in your scene, this is the special texture for that.
  31689. * This special texture works similar to other textures, with the exception of a few parameters.
  31690. * @see https://doc.babylonjs.com/how_to/video_texture
  31691. */
  31692. export class VideoTexture extends Texture {
  31693. /**
  31694. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31695. */
  31696. readonly autoUpdateTexture: boolean;
  31697. /**
  31698. * The video instance used by the texture internally
  31699. */
  31700. readonly video: HTMLVideoElement;
  31701. private _onUserActionRequestedObservable;
  31702. /**
  31703. * Event triggerd when a dom action is required by the user to play the video.
  31704. * This happens due to recent changes in browser policies preventing video to auto start.
  31705. */
  31706. get onUserActionRequestedObservable(): Observable<Texture>;
  31707. private _generateMipMaps;
  31708. private _engine;
  31709. private _stillImageCaptured;
  31710. private _displayingPosterTexture;
  31711. private _settings;
  31712. private _createInternalTextureOnEvent;
  31713. private _frameId;
  31714. private _currentSrc;
  31715. /**
  31716. * Creates a video texture.
  31717. * If you want to display a video in your scene, this is the special texture for that.
  31718. * This special texture works similar to other textures, with the exception of a few parameters.
  31719. * @see https://doc.babylonjs.com/how_to/video_texture
  31720. * @param name optional name, will detect from video source, if not defined
  31721. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31722. * @param scene is obviously the current scene.
  31723. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31724. * @param invertY is false by default but can be used to invert video on Y axis
  31725. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31726. * @param settings allows finer control over video usage
  31727. */
  31728. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31729. private _getName;
  31730. private _getVideo;
  31731. private _createInternalTexture;
  31732. private reset;
  31733. /**
  31734. * @hidden Internal method to initiate `update`.
  31735. */
  31736. _rebuild(): void;
  31737. /**
  31738. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31739. */
  31740. update(): void;
  31741. /**
  31742. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31743. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31744. */
  31745. updateTexture(isVisible: boolean): void;
  31746. protected _updateInternalTexture: () => void;
  31747. /**
  31748. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31749. * @param url New url.
  31750. */
  31751. updateURL(url: string): void;
  31752. /**
  31753. * Clones the texture.
  31754. * @returns the cloned texture
  31755. */
  31756. clone(): VideoTexture;
  31757. /**
  31758. * Dispose the texture and release its associated resources.
  31759. */
  31760. dispose(): void;
  31761. /**
  31762. * Creates a video texture straight from a stream.
  31763. * @param scene Define the scene the texture should be created in
  31764. * @param stream Define the stream the texture should be created from
  31765. * @returns The created video texture as a promise
  31766. */
  31767. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31768. /**
  31769. * Creates a video texture straight from your WebCam video feed.
  31770. * @param scene Define the scene the texture should be created in
  31771. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31772. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31773. * @returns The created video texture as a promise
  31774. */
  31775. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31776. minWidth: number;
  31777. maxWidth: number;
  31778. minHeight: number;
  31779. maxHeight: number;
  31780. deviceId: string;
  31781. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31782. /**
  31783. * Creates a video texture straight from your WebCam video feed.
  31784. * @param scene Define the scene the texture should be created in
  31785. * @param onReady Define a callback to triggered once the texture will be ready
  31786. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31787. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31788. */
  31789. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31790. minWidth: number;
  31791. maxWidth: number;
  31792. minHeight: number;
  31793. maxHeight: number;
  31794. deviceId: string;
  31795. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31796. }
  31797. }
  31798. declare module "babylonjs/Engines/thinEngine" {
  31799. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31800. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31801. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31802. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31803. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31804. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31805. import { Observable } from "babylonjs/Misc/observable";
  31806. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31807. import { StencilState } from "babylonjs/States/stencilState";
  31808. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31810. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31811. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31812. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31813. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31814. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31815. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31816. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31818. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31819. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31820. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31821. import { WebRequest } from "babylonjs/Misc/webRequest";
  31822. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31823. /**
  31824. * Defines the interface used by objects working like Scene
  31825. * @hidden
  31826. */
  31827. export interface ISceneLike {
  31828. _addPendingData(data: any): void;
  31829. _removePendingData(data: any): void;
  31830. offlineProvider: IOfflineProvider;
  31831. }
  31832. /** Interface defining initialization parameters for Engine class */
  31833. export interface EngineOptions extends WebGLContextAttributes {
  31834. /**
  31835. * Defines if the engine should no exceed a specified device ratio
  31836. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31837. */
  31838. limitDeviceRatio?: number;
  31839. /**
  31840. * Defines if webvr should be enabled automatically
  31841. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31842. */
  31843. autoEnableWebVR?: boolean;
  31844. /**
  31845. * Defines if webgl2 should be turned off even if supported
  31846. * @see http://doc.babylonjs.com/features/webgl2
  31847. */
  31848. disableWebGL2Support?: boolean;
  31849. /**
  31850. * Defines if webaudio should be initialized as well
  31851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31852. */
  31853. audioEngine?: boolean;
  31854. /**
  31855. * Defines if animations should run using a deterministic lock step
  31856. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31857. */
  31858. deterministicLockstep?: boolean;
  31859. /** Defines the maximum steps to use with deterministic lock step mode */
  31860. lockstepMaxSteps?: number;
  31861. /** Defines the seconds between each deterministic lock step */
  31862. timeStep?: number;
  31863. /**
  31864. * Defines that engine should ignore context lost events
  31865. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31866. */
  31867. doNotHandleContextLost?: boolean;
  31868. /**
  31869. * Defines that engine should ignore modifying touch action attribute and style
  31870. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31871. */
  31872. doNotHandleTouchAction?: boolean;
  31873. /**
  31874. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31875. */
  31876. useHighPrecisionFloats?: boolean;
  31877. }
  31878. /**
  31879. * The base engine class (root of all engines)
  31880. */
  31881. export class ThinEngine {
  31882. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31883. static ExceptionList: ({
  31884. key: string;
  31885. capture: string;
  31886. captureConstraint: number;
  31887. targets: string[];
  31888. } | {
  31889. key: string;
  31890. capture: null;
  31891. captureConstraint: null;
  31892. targets: string[];
  31893. })[];
  31894. /** @hidden */
  31895. static _TextureLoaders: IInternalTextureLoader[];
  31896. /**
  31897. * Returns the current npm package of the sdk
  31898. */
  31899. static get NpmPackage(): string;
  31900. /**
  31901. * Returns the current version of the framework
  31902. */
  31903. static get Version(): string;
  31904. /**
  31905. * Returns a string describing the current engine
  31906. */
  31907. get description(): string;
  31908. /**
  31909. * Gets or sets the epsilon value used by collision engine
  31910. */
  31911. static CollisionsEpsilon: number;
  31912. /**
  31913. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31914. */
  31915. static get ShadersRepository(): string;
  31916. static set ShadersRepository(value: string);
  31917. /** @hidden */
  31918. _shaderProcessor: IShaderProcessor;
  31919. /**
  31920. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31921. */
  31922. forcePOTTextures: boolean;
  31923. /**
  31924. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31925. */
  31926. isFullscreen: boolean;
  31927. /**
  31928. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31929. */
  31930. cullBackFaces: boolean;
  31931. /**
  31932. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31933. */
  31934. renderEvenInBackground: boolean;
  31935. /**
  31936. * Gets or sets a boolean indicating that cache can be kept between frames
  31937. */
  31938. preventCacheWipeBetweenFrames: boolean;
  31939. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31940. validateShaderPrograms: boolean;
  31941. /**
  31942. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31943. * This can provide greater z depth for distant objects.
  31944. */
  31945. useReverseDepthBuffer: boolean;
  31946. /**
  31947. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31948. */
  31949. disableUniformBuffers: boolean;
  31950. /** @hidden */
  31951. _uniformBuffers: UniformBuffer[];
  31952. /**
  31953. * Gets a boolean indicating that the engine supports uniform buffers
  31954. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31955. */
  31956. get supportsUniformBuffers(): boolean;
  31957. /** @hidden */
  31958. _gl: WebGLRenderingContext;
  31959. /** @hidden */
  31960. _webGLVersion: number;
  31961. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31962. protected _windowIsBackground: boolean;
  31963. protected _creationOptions: EngineOptions;
  31964. protected _highPrecisionShadersAllowed: boolean;
  31965. /** @hidden */
  31966. get _shouldUseHighPrecisionShader(): boolean;
  31967. /**
  31968. * Gets a boolean indicating that only power of 2 textures are supported
  31969. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31970. */
  31971. get needPOTTextures(): boolean;
  31972. /** @hidden */
  31973. _badOS: boolean;
  31974. /** @hidden */
  31975. _badDesktopOS: boolean;
  31976. private _hardwareScalingLevel;
  31977. /** @hidden */
  31978. _caps: EngineCapabilities;
  31979. private _isStencilEnable;
  31980. private _glVersion;
  31981. private _glRenderer;
  31982. private _glVendor;
  31983. /** @hidden */
  31984. _videoTextureSupported: boolean;
  31985. protected _renderingQueueLaunched: boolean;
  31986. protected _activeRenderLoops: (() => void)[];
  31987. /**
  31988. * Observable signaled when a context lost event is raised
  31989. */
  31990. onContextLostObservable: Observable<ThinEngine>;
  31991. /**
  31992. * Observable signaled when a context restored event is raised
  31993. */
  31994. onContextRestoredObservable: Observable<ThinEngine>;
  31995. private _onContextLost;
  31996. private _onContextRestored;
  31997. protected _contextWasLost: boolean;
  31998. /** @hidden */
  31999. _doNotHandleContextLost: boolean;
  32000. /**
  32001. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32003. */
  32004. get doNotHandleContextLost(): boolean;
  32005. set doNotHandleContextLost(value: boolean);
  32006. /**
  32007. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32008. */
  32009. disableVertexArrayObjects: boolean;
  32010. /** @hidden */
  32011. protected _colorWrite: boolean;
  32012. /** @hidden */
  32013. protected _colorWriteChanged: boolean;
  32014. /** @hidden */
  32015. protected _depthCullingState: DepthCullingState;
  32016. /** @hidden */
  32017. protected _stencilState: StencilState;
  32018. /** @hidden */
  32019. _alphaState: AlphaState;
  32020. /** @hidden */
  32021. _alphaMode: number;
  32022. /** @hidden */
  32023. _alphaEquation: number;
  32024. /** @hidden */
  32025. _internalTexturesCache: InternalTexture[];
  32026. /** @hidden */
  32027. protected _activeChannel: number;
  32028. private _currentTextureChannel;
  32029. /** @hidden */
  32030. protected _boundTexturesCache: {
  32031. [key: string]: Nullable<InternalTexture>;
  32032. };
  32033. /** @hidden */
  32034. protected _currentEffect: Nullable<Effect>;
  32035. /** @hidden */
  32036. protected _currentProgram: Nullable<WebGLProgram>;
  32037. private _compiledEffects;
  32038. private _vertexAttribArraysEnabled;
  32039. /** @hidden */
  32040. protected _cachedViewport: Nullable<IViewportLike>;
  32041. private _cachedVertexArrayObject;
  32042. /** @hidden */
  32043. protected _cachedVertexBuffers: any;
  32044. /** @hidden */
  32045. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32046. /** @hidden */
  32047. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32048. /** @hidden */
  32049. _currentRenderTarget: Nullable<InternalTexture>;
  32050. private _uintIndicesCurrentlySet;
  32051. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32052. /** @hidden */
  32053. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32054. private _currentBufferPointers;
  32055. private _currentInstanceLocations;
  32056. private _currentInstanceBuffers;
  32057. private _textureUnits;
  32058. /** @hidden */
  32059. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32060. /** @hidden */
  32061. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32062. /** @hidden */
  32063. _boundRenderFunction: any;
  32064. private _vaoRecordInProgress;
  32065. private _mustWipeVertexAttributes;
  32066. private _emptyTexture;
  32067. private _emptyCubeTexture;
  32068. private _emptyTexture3D;
  32069. private _emptyTexture2DArray;
  32070. /** @hidden */
  32071. _frameHandler: number;
  32072. private _nextFreeTextureSlots;
  32073. private _maxSimultaneousTextures;
  32074. private _activeRequests;
  32075. protected _texturesSupported: string[];
  32076. /** @hidden */
  32077. _textureFormatInUse: Nullable<string>;
  32078. protected get _supportsHardwareTextureRescaling(): boolean;
  32079. /**
  32080. * Gets the list of texture formats supported
  32081. */
  32082. get texturesSupported(): Array<string>;
  32083. /**
  32084. * Gets the list of texture formats in use
  32085. */
  32086. get textureFormatInUse(): Nullable<string>;
  32087. /**
  32088. * Gets the current viewport
  32089. */
  32090. get currentViewport(): Nullable<IViewportLike>;
  32091. /**
  32092. * Gets the default empty texture
  32093. */
  32094. get emptyTexture(): InternalTexture;
  32095. /**
  32096. * Gets the default empty 3D texture
  32097. */
  32098. get emptyTexture3D(): InternalTexture;
  32099. /**
  32100. * Gets the default empty 2D array texture
  32101. */
  32102. get emptyTexture2DArray(): InternalTexture;
  32103. /**
  32104. * Gets the default empty cube texture
  32105. */
  32106. get emptyCubeTexture(): InternalTexture;
  32107. /**
  32108. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32109. */
  32110. readonly premultipliedAlpha: boolean;
  32111. /**
  32112. * Observable event triggered before each texture is initialized
  32113. */
  32114. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32115. /**
  32116. * Creates a new engine
  32117. * @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
  32118. * @param antialias defines enable antialiasing (default: false)
  32119. * @param options defines further options to be sent to the getContext() function
  32120. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32121. */
  32122. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32123. private _rebuildInternalTextures;
  32124. private _rebuildEffects;
  32125. /**
  32126. * Gets a boolean indicating if all created effects are ready
  32127. * @returns true if all effects are ready
  32128. */
  32129. areAllEffectsReady(): boolean;
  32130. protected _rebuildBuffers(): void;
  32131. private _initGLContext;
  32132. /**
  32133. * Gets version of the current webGL context
  32134. */
  32135. get webGLVersion(): number;
  32136. /**
  32137. * Gets a string idenfifying the name of the class
  32138. * @returns "Engine" string
  32139. */
  32140. getClassName(): string;
  32141. /**
  32142. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32143. */
  32144. get isStencilEnable(): boolean;
  32145. /** @hidden */
  32146. _prepareWorkingCanvas(): void;
  32147. /**
  32148. * Reset the texture cache to empty state
  32149. */
  32150. resetTextureCache(): void;
  32151. /**
  32152. * Gets an object containing information about the current webGL context
  32153. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32154. */
  32155. getGlInfo(): {
  32156. vendor: string;
  32157. renderer: string;
  32158. version: string;
  32159. };
  32160. /**
  32161. * Defines the hardware scaling level.
  32162. * By default the hardware scaling level is computed from the window device ratio.
  32163. * 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.
  32164. * @param level defines the level to use
  32165. */
  32166. setHardwareScalingLevel(level: number): void;
  32167. /**
  32168. * Gets the current hardware scaling level.
  32169. * By default the hardware scaling level is computed from the window device ratio.
  32170. * 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.
  32171. * @returns a number indicating the current hardware scaling level
  32172. */
  32173. getHardwareScalingLevel(): number;
  32174. /**
  32175. * Gets the list of loaded textures
  32176. * @returns an array containing all loaded textures
  32177. */
  32178. getLoadedTexturesCache(): InternalTexture[];
  32179. /**
  32180. * Gets the object containing all engine capabilities
  32181. * @returns the EngineCapabilities object
  32182. */
  32183. getCaps(): EngineCapabilities;
  32184. /**
  32185. * stop executing a render loop function and remove it from the execution array
  32186. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32187. */
  32188. stopRenderLoop(renderFunction?: () => void): void;
  32189. /** @hidden */
  32190. _renderLoop(): void;
  32191. /**
  32192. * Gets the HTML canvas attached with the current webGL context
  32193. * @returns a HTML canvas
  32194. */
  32195. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32196. /**
  32197. * Gets host window
  32198. * @returns the host window object
  32199. */
  32200. getHostWindow(): Nullable<Window>;
  32201. /**
  32202. * Gets the current render width
  32203. * @param useScreen defines if screen size must be used (or the current render target if any)
  32204. * @returns a number defining the current render width
  32205. */
  32206. getRenderWidth(useScreen?: boolean): number;
  32207. /**
  32208. * Gets the current render height
  32209. * @param useScreen defines if screen size must be used (or the current render target if any)
  32210. * @returns a number defining the current render height
  32211. */
  32212. getRenderHeight(useScreen?: boolean): number;
  32213. /**
  32214. * Can be used to override the current requestAnimationFrame requester.
  32215. * @hidden
  32216. */
  32217. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32218. /**
  32219. * Register and execute a render loop. The engine can have more than one render function
  32220. * @param renderFunction defines the function to continuously execute
  32221. */
  32222. runRenderLoop(renderFunction: () => void): void;
  32223. /**
  32224. * Clear the current render buffer or the current render target (if any is set up)
  32225. * @param color defines the color to use
  32226. * @param backBuffer defines if the back buffer must be cleared
  32227. * @param depth defines if the depth buffer must be cleared
  32228. * @param stencil defines if the stencil buffer must be cleared
  32229. */
  32230. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32231. private _viewportCached;
  32232. /** @hidden */
  32233. _viewport(x: number, y: number, width: number, height: number): void;
  32234. /**
  32235. * Set the WebGL's viewport
  32236. * @param viewport defines the viewport element to be used
  32237. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32238. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32239. */
  32240. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32241. /**
  32242. * Begin a new frame
  32243. */
  32244. beginFrame(): void;
  32245. /**
  32246. * Enf the current frame
  32247. */
  32248. endFrame(): void;
  32249. /**
  32250. * Resize the view according to the canvas' size
  32251. */
  32252. resize(): void;
  32253. /**
  32254. * Force a specific size of the canvas
  32255. * @param width defines the new canvas' width
  32256. * @param height defines the new canvas' height
  32257. */
  32258. setSize(width: number, height: number): void;
  32259. /**
  32260. * Binds the frame buffer to the specified texture.
  32261. * @param texture The texture to render to or null for the default canvas
  32262. * @param faceIndex The face of the texture to render to in case of cube texture
  32263. * @param requiredWidth The width of the target to render to
  32264. * @param requiredHeight The height of the target to render to
  32265. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32266. * @param lodLevel defines the lod level to bind to the frame buffer
  32267. * @param layer defines the 2d array index to bind to frame buffer to
  32268. */
  32269. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32270. /** @hidden */
  32271. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32272. /**
  32273. * Unbind the current render target texture from the webGL context
  32274. * @param texture defines the render target texture to unbind
  32275. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32276. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32277. */
  32278. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32279. /**
  32280. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32281. */
  32282. flushFramebuffer(): void;
  32283. /**
  32284. * Unbind the current render target and bind the default framebuffer
  32285. */
  32286. restoreDefaultFramebuffer(): void;
  32287. /** @hidden */
  32288. protected _resetVertexBufferBinding(): void;
  32289. /**
  32290. * Creates a vertex buffer
  32291. * @param data the data for the vertex buffer
  32292. * @returns the new WebGL static buffer
  32293. */
  32294. createVertexBuffer(data: DataArray): DataBuffer;
  32295. private _createVertexBuffer;
  32296. /**
  32297. * Creates a dynamic vertex buffer
  32298. * @param data the data for the dynamic vertex buffer
  32299. * @returns the new WebGL dynamic buffer
  32300. */
  32301. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32302. protected _resetIndexBufferBinding(): void;
  32303. /**
  32304. * Creates a new index buffer
  32305. * @param indices defines the content of the index buffer
  32306. * @param updatable defines if the index buffer must be updatable
  32307. * @returns a new webGL buffer
  32308. */
  32309. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32310. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32311. /**
  32312. * Bind a webGL buffer to the webGL context
  32313. * @param buffer defines the buffer to bind
  32314. */
  32315. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32316. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32317. private bindBuffer;
  32318. /**
  32319. * update the bound buffer with the given data
  32320. * @param data defines the data to update
  32321. */
  32322. updateArrayBuffer(data: Float32Array): void;
  32323. private _vertexAttribPointer;
  32324. /** @hidden */
  32325. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32326. private _bindVertexBuffersAttributes;
  32327. /**
  32328. * Records a vertex array object
  32329. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32330. * @param vertexBuffers defines the list of vertex buffers to store
  32331. * @param indexBuffer defines the index buffer to store
  32332. * @param effect defines the effect to store
  32333. * @returns the new vertex array object
  32334. */
  32335. recordVertexArrayObject(vertexBuffers: {
  32336. [key: string]: VertexBuffer;
  32337. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32338. /**
  32339. * Bind a specific vertex array object
  32340. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32341. * @param vertexArrayObject defines the vertex array object to bind
  32342. * @param indexBuffer defines the index buffer to bind
  32343. */
  32344. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32345. /**
  32346. * Bind webGl buffers directly to the webGL context
  32347. * @param vertexBuffer defines the vertex buffer to bind
  32348. * @param indexBuffer defines the index buffer to bind
  32349. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32350. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32351. * @param effect defines the effect associated with the vertex buffer
  32352. */
  32353. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32354. private _unbindVertexArrayObject;
  32355. /**
  32356. * Bind a list of vertex buffers to the webGL context
  32357. * @param vertexBuffers defines the list of vertex buffers to bind
  32358. * @param indexBuffer defines the index buffer to bind
  32359. * @param effect defines the effect associated with the vertex buffers
  32360. */
  32361. bindBuffers(vertexBuffers: {
  32362. [key: string]: Nullable<VertexBuffer>;
  32363. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32364. /**
  32365. * Unbind all instance attributes
  32366. */
  32367. unbindInstanceAttributes(): void;
  32368. /**
  32369. * Release and free the memory of a vertex array object
  32370. * @param vao defines the vertex array object to delete
  32371. */
  32372. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32373. /** @hidden */
  32374. _releaseBuffer(buffer: DataBuffer): boolean;
  32375. protected _deleteBuffer(buffer: DataBuffer): void;
  32376. /**
  32377. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32378. * @param instancesBuffer defines the webGL buffer to update and bind
  32379. * @param data defines the data to store in the buffer
  32380. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32381. */
  32382. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32383. /**
  32384. * Bind the content of a webGL buffer used with instantiation
  32385. * @param instancesBuffer defines the webGL buffer to bind
  32386. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32387. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32388. */
  32389. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32390. /**
  32391. * Disable the instance attribute corresponding to the name in parameter
  32392. * @param name defines the name of the attribute to disable
  32393. */
  32394. disableInstanceAttributeByName(name: string): void;
  32395. /**
  32396. * Disable the instance attribute corresponding to the location in parameter
  32397. * @param attributeLocation defines the attribute location of the attribute to disable
  32398. */
  32399. disableInstanceAttribute(attributeLocation: number): void;
  32400. /**
  32401. * Disable the attribute corresponding to the location in parameter
  32402. * @param attributeLocation defines the attribute location of the attribute to disable
  32403. */
  32404. disableAttributeByIndex(attributeLocation: number): void;
  32405. /**
  32406. * Send a draw order
  32407. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32408. * @param indexStart defines the starting index
  32409. * @param indexCount defines the number of index to draw
  32410. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32411. */
  32412. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32413. /**
  32414. * Draw a list of points
  32415. * @param verticesStart defines the index of first vertex to draw
  32416. * @param verticesCount defines the count of vertices to draw
  32417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32418. */
  32419. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32420. /**
  32421. * Draw a list of unindexed primitives
  32422. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32423. * @param verticesStart defines the index of first vertex to draw
  32424. * @param verticesCount defines the count of vertices to draw
  32425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32426. */
  32427. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32428. /**
  32429. * Draw a list of indexed primitives
  32430. * @param fillMode defines the primitive to use
  32431. * @param indexStart defines the starting index
  32432. * @param indexCount defines the number of index to draw
  32433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32434. */
  32435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32436. /**
  32437. * Draw a list of unindexed primitives
  32438. * @param fillMode defines the primitive to use
  32439. * @param verticesStart defines the index of first vertex to draw
  32440. * @param verticesCount defines the count of vertices to draw
  32441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32442. */
  32443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32444. private _drawMode;
  32445. /** @hidden */
  32446. protected _reportDrawCall(): void;
  32447. /** @hidden */
  32448. _releaseEffect(effect: Effect): void;
  32449. /** @hidden */
  32450. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32451. /**
  32452. * Create a new effect (used to store vertex/fragment shaders)
  32453. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32454. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32455. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32456. * @param samplers defines an array of string used to represent textures
  32457. * @param defines defines the string containing the defines to use to compile the shaders
  32458. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32459. * @param onCompiled defines a function to call when the effect creation is successful
  32460. * @param onError defines a function to call when the effect creation has failed
  32461. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32462. * @returns the new Effect
  32463. */
  32464. 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;
  32465. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32466. private _compileShader;
  32467. private _compileRawShader;
  32468. /**
  32469. * Directly creates a webGL program
  32470. * @param pipelineContext defines the pipeline context to attach to
  32471. * @param vertexCode defines the vertex shader code to use
  32472. * @param fragmentCode defines the fragment shader code to use
  32473. * @param context defines the webGL context to use (if not set, the current one will be used)
  32474. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32475. * @returns the new webGL program
  32476. */
  32477. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32478. /**
  32479. * Creates a webGL program
  32480. * @param pipelineContext defines the pipeline context to attach to
  32481. * @param vertexCode defines the vertex shader code to use
  32482. * @param fragmentCode defines the fragment shader code to use
  32483. * @param defines defines the string containing the defines to use to compile the shaders
  32484. * @param context defines the webGL context to use (if not set, the current one will be used)
  32485. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32486. * @returns the new webGL program
  32487. */
  32488. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32489. /**
  32490. * Creates a new pipeline context
  32491. * @returns the new pipeline
  32492. */
  32493. createPipelineContext(): IPipelineContext;
  32494. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32495. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32496. /** @hidden */
  32497. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32498. /** @hidden */
  32499. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32500. /** @hidden */
  32501. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32502. /**
  32503. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32504. * @param pipelineContext defines the pipeline context to use
  32505. * @param uniformsNames defines the list of uniform names
  32506. * @returns an array of webGL uniform locations
  32507. */
  32508. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32509. /**
  32510. * Gets the lsit of active attributes for a given webGL program
  32511. * @param pipelineContext defines the pipeline context to use
  32512. * @param attributesNames defines the list of attribute names to get
  32513. * @returns an array of indices indicating the offset of each attribute
  32514. */
  32515. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32516. /**
  32517. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32518. * @param effect defines the effect to activate
  32519. */
  32520. enableEffect(effect: Nullable<Effect>): void;
  32521. /**
  32522. * Set the value of an uniform to a number (int)
  32523. * @param uniform defines the webGL uniform location where to store the value
  32524. * @param value defines the int number to store
  32525. */
  32526. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32527. /**
  32528. * Set the value of an uniform to an array of int32
  32529. * @param uniform defines the webGL uniform location where to store the value
  32530. * @param array defines the array of int32 to store
  32531. */
  32532. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32533. /**
  32534. * Set the value of an uniform to an array of int32 (stored as vec2)
  32535. * @param uniform defines the webGL uniform location where to store the value
  32536. * @param array defines the array of int32 to store
  32537. */
  32538. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32539. /**
  32540. * Set the value of an uniform to an array of int32 (stored as vec3)
  32541. * @param uniform defines the webGL uniform location where to store the value
  32542. * @param array defines the array of int32 to store
  32543. */
  32544. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32545. /**
  32546. * Set the value of an uniform to an array of int32 (stored as vec4)
  32547. * @param uniform defines the webGL uniform location where to store the value
  32548. * @param array defines the array of int32 to store
  32549. */
  32550. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32551. /**
  32552. * Set the value of an uniform to an array of number
  32553. * @param uniform defines the webGL uniform location where to store the value
  32554. * @param array defines the array of number to store
  32555. */
  32556. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32557. /**
  32558. * Set the value of an uniform to an array of number (stored as vec2)
  32559. * @param uniform defines the webGL uniform location where to store the value
  32560. * @param array defines the array of number to store
  32561. */
  32562. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32563. /**
  32564. * Set the value of an uniform to an array of number (stored as vec3)
  32565. * @param uniform defines the webGL uniform location where to store the value
  32566. * @param array defines the array of number to store
  32567. */
  32568. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32569. /**
  32570. * Set the value of an uniform to an array of number (stored as vec4)
  32571. * @param uniform defines the webGL uniform location where to store the value
  32572. * @param array defines the array of number to store
  32573. */
  32574. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32575. /**
  32576. * Set the value of an uniform to an array of float32 (stored as matrices)
  32577. * @param uniform defines the webGL uniform location where to store the value
  32578. * @param matrices defines the array of float32 to store
  32579. */
  32580. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32581. /**
  32582. * Set the value of an uniform to a matrix (3x3)
  32583. * @param uniform defines the webGL uniform location where to store the value
  32584. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32585. */
  32586. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32587. /**
  32588. * Set the value of an uniform to a matrix (2x2)
  32589. * @param uniform defines the webGL uniform location where to store the value
  32590. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32591. */
  32592. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32593. /**
  32594. * Set the value of an uniform to a number (float)
  32595. * @param uniform defines the webGL uniform location where to store the value
  32596. * @param value defines the float number to store
  32597. */
  32598. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32599. /**
  32600. * Set the value of an uniform to a vec2
  32601. * @param uniform defines the webGL uniform location where to store the value
  32602. * @param x defines the 1st component of the value
  32603. * @param y defines the 2nd component of the value
  32604. */
  32605. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32606. /**
  32607. * Set the value of an uniform to a vec3
  32608. * @param uniform defines the webGL uniform location where to store the value
  32609. * @param x defines the 1st component of the value
  32610. * @param y defines the 2nd component of the value
  32611. * @param z defines the 3rd component of the value
  32612. */
  32613. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32614. /**
  32615. * Set the value of an uniform to a vec4
  32616. * @param uniform defines the webGL uniform location where to store the value
  32617. * @param x defines the 1st component of the value
  32618. * @param y defines the 2nd component of the value
  32619. * @param z defines the 3rd component of the value
  32620. * @param w defines the 4th component of the value
  32621. */
  32622. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32623. /**
  32624. * Apply all cached states (depth, culling, stencil and alpha)
  32625. */
  32626. applyStates(): void;
  32627. /**
  32628. * Enable or disable color writing
  32629. * @param enable defines the state to set
  32630. */
  32631. setColorWrite(enable: boolean): void;
  32632. /**
  32633. * Gets a boolean indicating if color writing is enabled
  32634. * @returns the current color writing state
  32635. */
  32636. getColorWrite(): boolean;
  32637. /**
  32638. * Gets the depth culling state manager
  32639. */
  32640. get depthCullingState(): DepthCullingState;
  32641. /**
  32642. * Gets the alpha state manager
  32643. */
  32644. get alphaState(): AlphaState;
  32645. /**
  32646. * Gets the stencil state manager
  32647. */
  32648. get stencilState(): StencilState;
  32649. /**
  32650. * Clears the list of texture accessible through engine.
  32651. * This can help preventing texture load conflict due to name collision.
  32652. */
  32653. clearInternalTexturesCache(): void;
  32654. /**
  32655. * Force the entire cache to be cleared
  32656. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32657. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32658. */
  32659. wipeCaches(bruteForce?: boolean): void;
  32660. /** @hidden */
  32661. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32662. min: number;
  32663. mag: number;
  32664. };
  32665. /** @hidden */
  32666. _createTexture(): WebGLTexture;
  32667. /**
  32668. * Usually called from Texture.ts.
  32669. * Passed information to create a WebGLTexture
  32670. * @param urlArg defines a value which contains one of the following:
  32671. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32672. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32673. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32675. * @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)
  32676. * @param scene needed for loading to the correct scene
  32677. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32678. * @param onLoad optional callback to be called upon successful completion
  32679. * @param onError optional callback to be called upon failure
  32680. * @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
  32681. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32682. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32683. * @param forcedExtension defines the extension to use to pick the right loader
  32684. * @param mimeType defines an optional mime type
  32685. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32686. */
  32687. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32688. /**
  32689. * Loads an image as an HTMLImageElement.
  32690. * @param input url string, ArrayBuffer, or Blob to load
  32691. * @param onLoad callback called when the image successfully loads
  32692. * @param onError callback called when the image fails to load
  32693. * @param offlineProvider offline provider for caching
  32694. * @param mimeType optional mime type
  32695. * @returns the HTMLImageElement of the loaded image
  32696. * @hidden
  32697. */
  32698. 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>;
  32699. /**
  32700. * @hidden
  32701. */
  32702. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32703. /**
  32704. * Creates a raw texture
  32705. * @param data defines the data to store in the texture
  32706. * @param width defines the width of the texture
  32707. * @param height defines the height of the texture
  32708. * @param format defines the format of the data
  32709. * @param generateMipMaps defines if the engine should generate the mip levels
  32710. * @param invertY defines if data must be stored with Y axis inverted
  32711. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32712. * @param compression defines the compression used (null by default)
  32713. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32714. * @returns the raw texture inside an InternalTexture
  32715. */
  32716. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32717. /**
  32718. * Creates a new raw cube texture
  32719. * @param data defines the array of data to use to create each face
  32720. * @param size defines the size of the textures
  32721. * @param format defines the format of the data
  32722. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32723. * @param generateMipMaps defines if the engine should generate the mip levels
  32724. * @param invertY defines if data must be stored with Y axis inverted
  32725. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32726. * @param compression defines the compression used (null by default)
  32727. * @returns the cube texture as an InternalTexture
  32728. */
  32729. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32730. /**
  32731. * Creates a new raw 3D texture
  32732. * @param data defines the data used to create the texture
  32733. * @param width defines the width of the texture
  32734. * @param height defines the height of the texture
  32735. * @param depth defines the depth of the texture
  32736. * @param format defines the format of the texture
  32737. * @param generateMipMaps defines if the engine must generate mip levels
  32738. * @param invertY defines if data must be stored with Y axis inverted
  32739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32740. * @param compression defines the compressed used (can be null)
  32741. * @param textureType defines the compressed used (can be null)
  32742. * @returns a new raw 3D texture (stored in an InternalTexture)
  32743. */
  32744. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32745. /**
  32746. * Creates a new raw 2D array texture
  32747. * @param data defines the data used to create the texture
  32748. * @param width defines the width of the texture
  32749. * @param height defines the height of the texture
  32750. * @param depth defines the number of layers of the texture
  32751. * @param format defines the format of the texture
  32752. * @param generateMipMaps defines if the engine must generate mip levels
  32753. * @param invertY defines if data must be stored with Y axis inverted
  32754. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32755. * @param compression defines the compressed used (can be null)
  32756. * @param textureType defines the compressed used (can be null)
  32757. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32758. */
  32759. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32760. private _unpackFlipYCached;
  32761. /**
  32762. * In case you are sharing the context with other applications, it might
  32763. * be interested to not cache the unpack flip y state to ensure a consistent
  32764. * value would be set.
  32765. */
  32766. enableUnpackFlipYCached: boolean;
  32767. /** @hidden */
  32768. _unpackFlipY(value: boolean): void;
  32769. /** @hidden */
  32770. _getUnpackAlignement(): number;
  32771. private _getTextureTarget;
  32772. /**
  32773. * Update the sampling mode of a given texture
  32774. * @param samplingMode defines the required sampling mode
  32775. * @param texture defines the texture to update
  32776. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32777. */
  32778. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32779. /**
  32780. * Update the sampling mode of a given texture
  32781. * @param texture defines the texture to update
  32782. * @param wrapU defines the texture wrap mode of the u coordinates
  32783. * @param wrapV defines the texture wrap mode of the v coordinates
  32784. * @param wrapR defines the texture wrap mode of the r coordinates
  32785. */
  32786. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32787. /** @hidden */
  32788. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32789. width: number;
  32790. height: number;
  32791. layers?: number;
  32792. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32793. /** @hidden */
  32794. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32795. /** @hidden */
  32796. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32797. /**
  32798. * Update a portion of an internal texture
  32799. * @param texture defines the texture to update
  32800. * @param imageData defines the data to store into the texture
  32801. * @param xOffset defines the x coordinates of the update rectangle
  32802. * @param yOffset defines the y coordinates of the update rectangle
  32803. * @param width defines the width of the update rectangle
  32804. * @param height defines the height of the update rectangle
  32805. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32806. * @param lod defines the lod level to update (0 by default)
  32807. */
  32808. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32809. /** @hidden */
  32810. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32811. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32812. private _prepareWebGLTexture;
  32813. /** @hidden */
  32814. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32815. private _getDepthStencilBuffer;
  32816. /** @hidden */
  32817. _releaseFramebufferObjects(texture: InternalTexture): void;
  32818. /** @hidden */
  32819. _releaseTexture(texture: InternalTexture): void;
  32820. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32821. protected _setProgram(program: WebGLProgram): void;
  32822. protected _boundUniforms: {
  32823. [key: number]: WebGLUniformLocation;
  32824. };
  32825. /**
  32826. * Binds an effect to the webGL context
  32827. * @param effect defines the effect to bind
  32828. */
  32829. bindSamplers(effect: Effect): void;
  32830. private _activateCurrentTexture;
  32831. /** @hidden */
  32832. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32833. /** @hidden */
  32834. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32835. /**
  32836. * Unbind all textures from the webGL context
  32837. */
  32838. unbindAllTextures(): void;
  32839. /**
  32840. * Sets a texture to the according uniform.
  32841. * @param channel The texture channel
  32842. * @param uniform The uniform to set
  32843. * @param texture The texture to apply
  32844. */
  32845. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32846. private _bindSamplerUniformToChannel;
  32847. private _getTextureWrapMode;
  32848. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32849. /**
  32850. * Sets an array of texture to the webGL context
  32851. * @param channel defines the channel where the texture array must be set
  32852. * @param uniform defines the associated uniform location
  32853. * @param textures defines the array of textures to bind
  32854. */
  32855. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32856. /** @hidden */
  32857. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32858. private _setTextureParameterFloat;
  32859. private _setTextureParameterInteger;
  32860. /**
  32861. * Unbind all vertex attributes from the webGL context
  32862. */
  32863. unbindAllAttributes(): void;
  32864. /**
  32865. * 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
  32866. */
  32867. releaseEffects(): void;
  32868. /**
  32869. * Dispose and release all associated resources
  32870. */
  32871. dispose(): void;
  32872. /**
  32873. * Attach a new callback raised when context lost event is fired
  32874. * @param callback defines the callback to call
  32875. */
  32876. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32877. /**
  32878. * Attach a new callback raised when context restored event is fired
  32879. * @param callback defines the callback to call
  32880. */
  32881. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32882. /**
  32883. * Get the current error code of the webGL context
  32884. * @returns the error code
  32885. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32886. */
  32887. getError(): number;
  32888. private _canRenderToFloatFramebuffer;
  32889. private _canRenderToHalfFloatFramebuffer;
  32890. private _canRenderToFramebuffer;
  32891. /** @hidden */
  32892. _getWebGLTextureType(type: number): number;
  32893. /** @hidden */
  32894. _getInternalFormat(format: number): number;
  32895. /** @hidden */
  32896. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32897. /** @hidden */
  32898. _getRGBAMultiSampleBufferFormat(type: number): number;
  32899. /** @hidden */
  32900. _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;
  32901. /**
  32902. * Loads a file from a url
  32903. * @param url url to load
  32904. * @param onSuccess callback called when the file successfully loads
  32905. * @param onProgress callback called while file is loading (if the server supports this mode)
  32906. * @param offlineProvider defines the offline provider for caching
  32907. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32908. * @param onError callback called when the file fails to load
  32909. * @returns a file request object
  32910. * @hidden
  32911. */
  32912. 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;
  32913. /**
  32914. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32915. * @param x defines the x coordinate of the rectangle where pixels must be read
  32916. * @param y defines the y coordinate of the rectangle where pixels must be read
  32917. * @param width defines the width of the rectangle where pixels must be read
  32918. * @param height defines the height of the rectangle where pixels must be read
  32919. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32920. * @returns a Uint8Array containing RGBA colors
  32921. */
  32922. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32923. private static _isSupported;
  32924. /**
  32925. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32926. * @returns true if the engine can be created
  32927. * @ignorenaming
  32928. */
  32929. static isSupported(): boolean;
  32930. /**
  32931. * Find the next highest power of two.
  32932. * @param x Number to start search from.
  32933. * @return Next highest power of two.
  32934. */
  32935. static CeilingPOT(x: number): number;
  32936. /**
  32937. * Find the next lowest power of two.
  32938. * @param x Number to start search from.
  32939. * @return Next lowest power of two.
  32940. */
  32941. static FloorPOT(x: number): number;
  32942. /**
  32943. * Find the nearest power of two.
  32944. * @param x Number to start search from.
  32945. * @return Next nearest power of two.
  32946. */
  32947. static NearestPOT(x: number): number;
  32948. /**
  32949. * Get the closest exponent of two
  32950. * @param value defines the value to approximate
  32951. * @param max defines the maximum value to return
  32952. * @param mode defines how to define the closest value
  32953. * @returns closest exponent of two of the given value
  32954. */
  32955. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32956. /**
  32957. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32958. * @param func - the function to be called
  32959. * @param requester - the object that will request the next frame. Falls back to window.
  32960. * @returns frame number
  32961. */
  32962. static QueueNewFrame(func: () => void, requester?: any): number;
  32963. /**
  32964. * Gets host document
  32965. * @returns the host document object
  32966. */
  32967. getHostDocument(): Nullable<Document>;
  32968. }
  32969. }
  32970. declare module "babylonjs/Maths/sphericalPolynomial" {
  32971. import { Vector3 } from "babylonjs/Maths/math.vector";
  32972. import { Color3 } from "babylonjs/Maths/math.color";
  32973. /**
  32974. * Class representing spherical harmonics coefficients to the 3rd degree
  32975. */
  32976. export class SphericalHarmonics {
  32977. /**
  32978. * Defines whether or not the harmonics have been prescaled for rendering.
  32979. */
  32980. preScaled: boolean;
  32981. /**
  32982. * The l0,0 coefficients of the spherical harmonics
  32983. */
  32984. l00: Vector3;
  32985. /**
  32986. * The l1,-1 coefficients of the spherical harmonics
  32987. */
  32988. l1_1: Vector3;
  32989. /**
  32990. * The l1,0 coefficients of the spherical harmonics
  32991. */
  32992. l10: Vector3;
  32993. /**
  32994. * The l1,1 coefficients of the spherical harmonics
  32995. */
  32996. l11: Vector3;
  32997. /**
  32998. * The l2,-2 coefficients of the spherical harmonics
  32999. */
  33000. l2_2: Vector3;
  33001. /**
  33002. * The l2,-1 coefficients of the spherical harmonics
  33003. */
  33004. l2_1: Vector3;
  33005. /**
  33006. * The l2,0 coefficients of the spherical harmonics
  33007. */
  33008. l20: Vector3;
  33009. /**
  33010. * The l2,1 coefficients of the spherical harmonics
  33011. */
  33012. l21: Vector3;
  33013. /**
  33014. * The l2,2 coefficients of the spherical harmonics
  33015. */
  33016. l22: Vector3;
  33017. /**
  33018. * Adds a light to the spherical harmonics
  33019. * @param direction the direction of the light
  33020. * @param color the color of the light
  33021. * @param deltaSolidAngle the delta solid angle of the light
  33022. */
  33023. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33024. /**
  33025. * Scales the spherical harmonics by the given amount
  33026. * @param scale the amount to scale
  33027. */
  33028. scaleInPlace(scale: number): void;
  33029. /**
  33030. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33031. *
  33032. * ```
  33033. * E_lm = A_l * L_lm
  33034. * ```
  33035. *
  33036. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33037. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33038. * the scaling factors are given in equation 9.
  33039. */
  33040. convertIncidentRadianceToIrradiance(): void;
  33041. /**
  33042. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33043. *
  33044. * ```
  33045. * L = (1/pi) * E * rho
  33046. * ```
  33047. *
  33048. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33049. */
  33050. convertIrradianceToLambertianRadiance(): void;
  33051. /**
  33052. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33053. * required operations at run time.
  33054. *
  33055. * This is simply done by scaling back the SH with Ylm constants parameter.
  33056. * The trigonometric part being applied by the shader at run time.
  33057. */
  33058. preScaleForRendering(): void;
  33059. /**
  33060. * Constructs a spherical harmonics from an array.
  33061. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33062. * @returns the spherical harmonics
  33063. */
  33064. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33065. /**
  33066. * Gets the spherical harmonics from polynomial
  33067. * @param polynomial the spherical polynomial
  33068. * @returns the spherical harmonics
  33069. */
  33070. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33071. }
  33072. /**
  33073. * Class representing spherical polynomial coefficients to the 3rd degree
  33074. */
  33075. export class SphericalPolynomial {
  33076. private _harmonics;
  33077. /**
  33078. * The spherical harmonics used to create the polynomials.
  33079. */
  33080. get preScaledHarmonics(): SphericalHarmonics;
  33081. /**
  33082. * The x coefficients of the spherical polynomial
  33083. */
  33084. x: Vector3;
  33085. /**
  33086. * The y coefficients of the spherical polynomial
  33087. */
  33088. y: Vector3;
  33089. /**
  33090. * The z coefficients of the spherical polynomial
  33091. */
  33092. z: Vector3;
  33093. /**
  33094. * The xx coefficients of the spherical polynomial
  33095. */
  33096. xx: Vector3;
  33097. /**
  33098. * The yy coefficients of the spherical polynomial
  33099. */
  33100. yy: Vector3;
  33101. /**
  33102. * The zz coefficients of the spherical polynomial
  33103. */
  33104. zz: Vector3;
  33105. /**
  33106. * The xy coefficients of the spherical polynomial
  33107. */
  33108. xy: Vector3;
  33109. /**
  33110. * The yz coefficients of the spherical polynomial
  33111. */
  33112. yz: Vector3;
  33113. /**
  33114. * The zx coefficients of the spherical polynomial
  33115. */
  33116. zx: Vector3;
  33117. /**
  33118. * Adds an ambient color to the spherical polynomial
  33119. * @param color the color to add
  33120. */
  33121. addAmbient(color: Color3): void;
  33122. /**
  33123. * Scales the spherical polynomial by the given amount
  33124. * @param scale the amount to scale
  33125. */
  33126. scaleInPlace(scale: number): void;
  33127. /**
  33128. * Gets the spherical polynomial from harmonics
  33129. * @param harmonics the spherical harmonics
  33130. * @returns the spherical polynomial
  33131. */
  33132. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33133. /**
  33134. * Constructs a spherical polynomial from an array.
  33135. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33136. * @returns the spherical polynomial
  33137. */
  33138. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33139. }
  33140. }
  33141. declare module "babylonjs/Materials/Textures/internalTexture" {
  33142. import { Observable } from "babylonjs/Misc/observable";
  33143. import { Nullable, int } from "babylonjs/types";
  33144. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33146. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33147. /**
  33148. * Defines the source of the internal texture
  33149. */
  33150. export enum InternalTextureSource {
  33151. /**
  33152. * The source of the texture data is unknown
  33153. */
  33154. Unknown = 0,
  33155. /**
  33156. * Texture data comes from an URL
  33157. */
  33158. Url = 1,
  33159. /**
  33160. * Texture data is only used for temporary storage
  33161. */
  33162. Temp = 2,
  33163. /**
  33164. * Texture data comes from raw data (ArrayBuffer)
  33165. */
  33166. Raw = 3,
  33167. /**
  33168. * Texture content is dynamic (video or dynamic texture)
  33169. */
  33170. Dynamic = 4,
  33171. /**
  33172. * Texture content is generated by rendering to it
  33173. */
  33174. RenderTarget = 5,
  33175. /**
  33176. * Texture content is part of a multi render target process
  33177. */
  33178. MultiRenderTarget = 6,
  33179. /**
  33180. * Texture data comes from a cube data file
  33181. */
  33182. Cube = 7,
  33183. /**
  33184. * Texture data comes from a raw cube data
  33185. */
  33186. CubeRaw = 8,
  33187. /**
  33188. * Texture data come from a prefiltered cube data file
  33189. */
  33190. CubePrefiltered = 9,
  33191. /**
  33192. * Texture content is raw 3D data
  33193. */
  33194. Raw3D = 10,
  33195. /**
  33196. * Texture content is raw 2D array data
  33197. */
  33198. Raw2DArray = 11,
  33199. /**
  33200. * Texture content is a depth texture
  33201. */
  33202. Depth = 12,
  33203. /**
  33204. * Texture data comes from a raw cube data encoded with RGBD
  33205. */
  33206. CubeRawRGBD = 13
  33207. }
  33208. /**
  33209. * Class used to store data associated with WebGL texture data for the engine
  33210. * This class should not be used directly
  33211. */
  33212. export class InternalTexture {
  33213. /** @hidden */
  33214. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33215. /**
  33216. * Defines if the texture is ready
  33217. */
  33218. isReady: boolean;
  33219. /**
  33220. * Defines if the texture is a cube texture
  33221. */
  33222. isCube: boolean;
  33223. /**
  33224. * Defines if the texture contains 3D data
  33225. */
  33226. is3D: boolean;
  33227. /**
  33228. * Defines if the texture contains 2D array data
  33229. */
  33230. is2DArray: boolean;
  33231. /**
  33232. * Defines if the texture contains multiview data
  33233. */
  33234. isMultiview: boolean;
  33235. /**
  33236. * Gets the URL used to load this texture
  33237. */
  33238. url: string;
  33239. /**
  33240. * Gets the sampling mode of the texture
  33241. */
  33242. samplingMode: number;
  33243. /**
  33244. * Gets a boolean indicating if the texture needs mipmaps generation
  33245. */
  33246. generateMipMaps: boolean;
  33247. /**
  33248. * Gets the number of samples used by the texture (WebGL2+ only)
  33249. */
  33250. samples: number;
  33251. /**
  33252. * Gets the type of the texture (int, float...)
  33253. */
  33254. type: number;
  33255. /**
  33256. * Gets the format of the texture (RGB, RGBA...)
  33257. */
  33258. format: number;
  33259. /**
  33260. * Observable called when the texture is loaded
  33261. */
  33262. onLoadedObservable: Observable<InternalTexture>;
  33263. /**
  33264. * Gets the width of the texture
  33265. */
  33266. width: number;
  33267. /**
  33268. * Gets the height of the texture
  33269. */
  33270. height: number;
  33271. /**
  33272. * Gets the depth of the texture
  33273. */
  33274. depth: number;
  33275. /**
  33276. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33277. */
  33278. baseWidth: number;
  33279. /**
  33280. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33281. */
  33282. baseHeight: number;
  33283. /**
  33284. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33285. */
  33286. baseDepth: number;
  33287. /**
  33288. * Gets a boolean indicating if the texture is inverted on Y axis
  33289. */
  33290. invertY: boolean;
  33291. /** @hidden */
  33292. _invertVScale: boolean;
  33293. /** @hidden */
  33294. _associatedChannel: number;
  33295. /** @hidden */
  33296. _source: InternalTextureSource;
  33297. /** @hidden */
  33298. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33299. /** @hidden */
  33300. _bufferView: Nullable<ArrayBufferView>;
  33301. /** @hidden */
  33302. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33303. /** @hidden */
  33304. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33305. /** @hidden */
  33306. _size: number;
  33307. /** @hidden */
  33308. _extension: string;
  33309. /** @hidden */
  33310. _files: Nullable<string[]>;
  33311. /** @hidden */
  33312. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33313. /** @hidden */
  33314. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33315. /** @hidden */
  33316. _framebuffer: Nullable<WebGLFramebuffer>;
  33317. /** @hidden */
  33318. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33319. /** @hidden */
  33320. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33321. /** @hidden */
  33322. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33323. /** @hidden */
  33324. _attachments: Nullable<number[]>;
  33325. /** @hidden */
  33326. _cachedCoordinatesMode: Nullable<number>;
  33327. /** @hidden */
  33328. _cachedWrapU: Nullable<number>;
  33329. /** @hidden */
  33330. _cachedWrapV: Nullable<number>;
  33331. /** @hidden */
  33332. _cachedWrapR: Nullable<number>;
  33333. /** @hidden */
  33334. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33335. /** @hidden */
  33336. _isDisabled: boolean;
  33337. /** @hidden */
  33338. _compression: Nullable<string>;
  33339. /** @hidden */
  33340. _generateStencilBuffer: boolean;
  33341. /** @hidden */
  33342. _generateDepthBuffer: boolean;
  33343. /** @hidden */
  33344. _comparisonFunction: number;
  33345. /** @hidden */
  33346. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33347. /** @hidden */
  33348. _lodGenerationScale: number;
  33349. /** @hidden */
  33350. _lodGenerationOffset: number;
  33351. /** @hidden */
  33352. _depthStencilTexture: Nullable<InternalTexture>;
  33353. /** @hidden */
  33354. _colorTextureArray: Nullable<WebGLTexture>;
  33355. /** @hidden */
  33356. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33357. /** @hidden */
  33358. _lodTextureHigh: Nullable<BaseTexture>;
  33359. /** @hidden */
  33360. _lodTextureMid: Nullable<BaseTexture>;
  33361. /** @hidden */
  33362. _lodTextureLow: Nullable<BaseTexture>;
  33363. /** @hidden */
  33364. _isRGBD: boolean;
  33365. /** @hidden */
  33366. _linearSpecularLOD: boolean;
  33367. /** @hidden */
  33368. _irradianceTexture: Nullable<BaseTexture>;
  33369. /** @hidden */
  33370. _webGLTexture: Nullable<WebGLTexture>;
  33371. /** @hidden */
  33372. _references: number;
  33373. private _engine;
  33374. /**
  33375. * Gets the Engine the texture belongs to.
  33376. * @returns The babylon engine
  33377. */
  33378. getEngine(): ThinEngine;
  33379. /**
  33380. * Gets the data source type of the texture
  33381. */
  33382. get source(): InternalTextureSource;
  33383. /**
  33384. * Creates a new InternalTexture
  33385. * @param engine defines the engine to use
  33386. * @param source defines the type of data that will be used
  33387. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33388. */
  33389. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33390. /**
  33391. * Increments the number of references (ie. the number of Texture that point to it)
  33392. */
  33393. incrementReferences(): void;
  33394. /**
  33395. * Change the size of the texture (not the size of the content)
  33396. * @param width defines the new width
  33397. * @param height defines the new height
  33398. * @param depth defines the new depth (1 by default)
  33399. */
  33400. updateSize(width: int, height: int, depth?: int): void;
  33401. /** @hidden */
  33402. _rebuild(): void;
  33403. /** @hidden */
  33404. _swapAndDie(target: InternalTexture): void;
  33405. /**
  33406. * Dispose the current allocated resources
  33407. */
  33408. dispose(): void;
  33409. }
  33410. }
  33411. declare module "babylonjs/Audio/analyser" {
  33412. import { Scene } from "babylonjs/scene";
  33413. /**
  33414. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33416. */
  33417. export class Analyser {
  33418. /**
  33419. * Gets or sets the smoothing
  33420. * @ignorenaming
  33421. */
  33422. SMOOTHING: number;
  33423. /**
  33424. * Gets or sets the FFT table size
  33425. * @ignorenaming
  33426. */
  33427. FFT_SIZE: number;
  33428. /**
  33429. * Gets or sets the bar graph amplitude
  33430. * @ignorenaming
  33431. */
  33432. BARGRAPHAMPLITUDE: number;
  33433. /**
  33434. * Gets or sets the position of the debug canvas
  33435. * @ignorenaming
  33436. */
  33437. DEBUGCANVASPOS: {
  33438. x: number;
  33439. y: number;
  33440. };
  33441. /**
  33442. * Gets or sets the debug canvas size
  33443. * @ignorenaming
  33444. */
  33445. DEBUGCANVASSIZE: {
  33446. width: number;
  33447. height: number;
  33448. };
  33449. private _byteFreqs;
  33450. private _byteTime;
  33451. private _floatFreqs;
  33452. private _webAudioAnalyser;
  33453. private _debugCanvas;
  33454. private _debugCanvasContext;
  33455. private _scene;
  33456. private _registerFunc;
  33457. private _audioEngine;
  33458. /**
  33459. * Creates a new analyser
  33460. * @param scene defines hosting scene
  33461. */
  33462. constructor(scene: Scene);
  33463. /**
  33464. * Get the number of data values you will have to play with for the visualization
  33465. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33466. * @returns a number
  33467. */
  33468. getFrequencyBinCount(): number;
  33469. /**
  33470. * Gets the current frequency data as a byte array
  33471. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33472. * @returns a Uint8Array
  33473. */
  33474. getByteFrequencyData(): Uint8Array;
  33475. /**
  33476. * Gets the current waveform as a byte array
  33477. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33478. * @returns a Uint8Array
  33479. */
  33480. getByteTimeDomainData(): Uint8Array;
  33481. /**
  33482. * Gets the current frequency data as a float array
  33483. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33484. * @returns a Float32Array
  33485. */
  33486. getFloatFrequencyData(): Float32Array;
  33487. /**
  33488. * Renders the debug canvas
  33489. */
  33490. drawDebugCanvas(): void;
  33491. /**
  33492. * Stops rendering the debug canvas and removes it
  33493. */
  33494. stopDebugCanvas(): void;
  33495. /**
  33496. * Connects two audio nodes
  33497. * @param inputAudioNode defines first node to connect
  33498. * @param outputAudioNode defines second node to connect
  33499. */
  33500. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33501. /**
  33502. * Releases all associated resources
  33503. */
  33504. dispose(): void;
  33505. }
  33506. }
  33507. declare module "babylonjs/Audio/audioEngine" {
  33508. import { IDisposable } from "babylonjs/scene";
  33509. import { Analyser } from "babylonjs/Audio/analyser";
  33510. import { Nullable } from "babylonjs/types";
  33511. import { Observable } from "babylonjs/Misc/observable";
  33512. /**
  33513. * This represents an audio engine and it is responsible
  33514. * to play, synchronize and analyse sounds throughout the application.
  33515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33516. */
  33517. export interface IAudioEngine extends IDisposable {
  33518. /**
  33519. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33520. */
  33521. readonly canUseWebAudio: boolean;
  33522. /**
  33523. * Gets the current AudioContext if available.
  33524. */
  33525. readonly audioContext: Nullable<AudioContext>;
  33526. /**
  33527. * The master gain node defines the global audio volume of your audio engine.
  33528. */
  33529. readonly masterGain: GainNode;
  33530. /**
  33531. * Gets whether or not mp3 are supported by your browser.
  33532. */
  33533. readonly isMP3supported: boolean;
  33534. /**
  33535. * Gets whether or not ogg are supported by your browser.
  33536. */
  33537. readonly isOGGsupported: boolean;
  33538. /**
  33539. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33540. * @ignoreNaming
  33541. */
  33542. WarnedWebAudioUnsupported: boolean;
  33543. /**
  33544. * Defines if the audio engine relies on a custom unlocked button.
  33545. * In this case, the embedded button will not be displayed.
  33546. */
  33547. useCustomUnlockedButton: boolean;
  33548. /**
  33549. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33550. */
  33551. readonly unlocked: 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. * Flags the audio engine in Locked state.
  33562. * This happens due to new browser policies preventing audio to autoplay.
  33563. */
  33564. lock(): void;
  33565. /**
  33566. * Unlocks the audio engine once a user action has been done on the dom.
  33567. * This is helpful to resume play once browser policies have been satisfied.
  33568. */
  33569. unlock(): void;
  33570. }
  33571. /**
  33572. * This represents the default audio engine used in babylon.
  33573. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33575. */
  33576. export class AudioEngine implements IAudioEngine {
  33577. private _audioContext;
  33578. private _audioContextInitialized;
  33579. private _muteButton;
  33580. private _hostElement;
  33581. /**
  33582. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33583. */
  33584. canUseWebAudio: boolean;
  33585. /**
  33586. * The master gain node defines the global audio volume of your audio engine.
  33587. */
  33588. masterGain: GainNode;
  33589. /**
  33590. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33591. * @ignoreNaming
  33592. */
  33593. WarnedWebAudioUnsupported: boolean;
  33594. /**
  33595. * Gets whether or not mp3 are supported by your browser.
  33596. */
  33597. isMP3supported: boolean;
  33598. /**
  33599. * Gets whether or not ogg are supported by your browser.
  33600. */
  33601. isOGGsupported: boolean;
  33602. /**
  33603. * Gets whether audio has been unlocked on the device.
  33604. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33605. * a user interaction has happened.
  33606. */
  33607. unlocked: boolean;
  33608. /**
  33609. * Defines if the audio engine relies on a custom unlocked button.
  33610. * In this case, the embedded button will not be displayed.
  33611. */
  33612. useCustomUnlockedButton: boolean;
  33613. /**
  33614. * Event raised when audio has been unlocked on the browser.
  33615. */
  33616. onAudioUnlockedObservable: Observable<AudioEngine>;
  33617. /**
  33618. * Event raised when audio has been locked on the browser.
  33619. */
  33620. onAudioLockedObservable: Observable<AudioEngine>;
  33621. /**
  33622. * Gets the current AudioContext if available.
  33623. */
  33624. get audioContext(): Nullable<AudioContext>;
  33625. private _connectedAnalyser;
  33626. /**
  33627. * Instantiates a new audio engine.
  33628. *
  33629. * There should be only one per page as some browsers restrict the number
  33630. * of audio contexts you can create.
  33631. * @param hostElement defines the host element where to display the mute icon if necessary
  33632. */
  33633. constructor(hostElement?: Nullable<HTMLElement>);
  33634. /**
  33635. * Flags the audio engine in Locked state.
  33636. * This happens due to new browser policies preventing audio to autoplay.
  33637. */
  33638. lock(): void;
  33639. /**
  33640. * Unlocks the audio engine once a user action has been done on the dom.
  33641. * This is helpful to resume play once browser policies have been satisfied.
  33642. */
  33643. unlock(): void;
  33644. private _resumeAudioContext;
  33645. private _initializeAudioContext;
  33646. private _tryToRun;
  33647. private _triggerRunningState;
  33648. private _triggerSuspendedState;
  33649. private _displayMuteButton;
  33650. private _moveButtonToTopLeft;
  33651. private _onResize;
  33652. private _hideMuteButton;
  33653. /**
  33654. * Destroy and release the resources associated with the audio ccontext.
  33655. */
  33656. dispose(): void;
  33657. /**
  33658. * Gets the global volume sets on the master gain.
  33659. * @returns the global volume if set or -1 otherwise
  33660. */
  33661. getGlobalVolume(): number;
  33662. /**
  33663. * Sets the global volume of your experience (sets on the master gain).
  33664. * @param newVolume Defines the new global volume of the application
  33665. */
  33666. setGlobalVolume(newVolume: number): void;
  33667. /**
  33668. * Connect the audio engine to an audio analyser allowing some amazing
  33669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33671. * @param analyser The analyser to connect to the engine
  33672. */
  33673. connectToAnalyser(analyser: Analyser): void;
  33674. }
  33675. }
  33676. declare module "babylonjs/Loading/loadingScreen" {
  33677. /**
  33678. * Interface used to present a loading screen while loading a scene
  33679. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33680. */
  33681. export interface ILoadingScreen {
  33682. /**
  33683. * Function called to display the loading screen
  33684. */
  33685. displayLoadingUI: () => void;
  33686. /**
  33687. * Function called to hide the loading screen
  33688. */
  33689. hideLoadingUI: () => void;
  33690. /**
  33691. * Gets or sets the color to use for the background
  33692. */
  33693. loadingUIBackgroundColor: string;
  33694. /**
  33695. * Gets or sets the text to display while loading
  33696. */
  33697. loadingUIText: string;
  33698. }
  33699. /**
  33700. * Class used for the default loading screen
  33701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33702. */
  33703. export class DefaultLoadingScreen implements ILoadingScreen {
  33704. private _renderingCanvas;
  33705. private _loadingText;
  33706. private _loadingDivBackgroundColor;
  33707. private _loadingDiv;
  33708. private _loadingTextDiv;
  33709. /** Gets or sets the logo url to use for the default loading screen */
  33710. static DefaultLogoUrl: string;
  33711. /** Gets or sets the spinner url to use for the default loading screen */
  33712. static DefaultSpinnerUrl: string;
  33713. /**
  33714. * Creates a new default loading screen
  33715. * @param _renderingCanvas defines the canvas used to render the scene
  33716. * @param _loadingText defines the default text to display
  33717. * @param _loadingDivBackgroundColor defines the default background color
  33718. */
  33719. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33720. /**
  33721. * Function called to display the loading screen
  33722. */
  33723. displayLoadingUI(): void;
  33724. /**
  33725. * Function called to hide the loading screen
  33726. */
  33727. hideLoadingUI(): void;
  33728. /**
  33729. * Gets or sets the text to display while loading
  33730. */
  33731. set loadingUIText(text: string);
  33732. get loadingUIText(): string;
  33733. /**
  33734. * Gets or sets the color to use for the background
  33735. */
  33736. get loadingUIBackgroundColor(): string;
  33737. set loadingUIBackgroundColor(color: string);
  33738. private _resizeLoadingUI;
  33739. }
  33740. }
  33741. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33742. /**
  33743. * Interface for any object that can request an animation frame
  33744. */
  33745. export interface ICustomAnimationFrameRequester {
  33746. /**
  33747. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33748. */
  33749. renderFunction?: Function;
  33750. /**
  33751. * Called to request the next frame to render to
  33752. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33753. */
  33754. requestAnimationFrame: Function;
  33755. /**
  33756. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33757. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33758. */
  33759. requestID?: number;
  33760. }
  33761. }
  33762. declare module "babylonjs/Misc/performanceMonitor" {
  33763. /**
  33764. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33765. */
  33766. export class PerformanceMonitor {
  33767. private _enabled;
  33768. private _rollingFrameTime;
  33769. private _lastFrameTimeMs;
  33770. /**
  33771. * constructor
  33772. * @param frameSampleSize The number of samples required to saturate the sliding window
  33773. */
  33774. constructor(frameSampleSize?: number);
  33775. /**
  33776. * Samples current frame
  33777. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33778. */
  33779. sampleFrame(timeMs?: number): void;
  33780. /**
  33781. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33782. */
  33783. get averageFrameTime(): number;
  33784. /**
  33785. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33786. */
  33787. get averageFrameTimeVariance(): number;
  33788. /**
  33789. * Returns the frame time of the most recent frame
  33790. */
  33791. get instantaneousFrameTime(): number;
  33792. /**
  33793. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33794. */
  33795. get averageFPS(): number;
  33796. /**
  33797. * Returns the average framerate in frames per second using the most recent frame time
  33798. */
  33799. get instantaneousFPS(): number;
  33800. /**
  33801. * Returns true if enough samples have been taken to completely fill the sliding window
  33802. */
  33803. get isSaturated(): boolean;
  33804. /**
  33805. * Enables contributions to the sliding window sample set
  33806. */
  33807. enable(): void;
  33808. /**
  33809. * Disables contributions to the sliding window sample set
  33810. * Samples will not be interpolated over the disabled period
  33811. */
  33812. disable(): void;
  33813. /**
  33814. * Returns true if sampling is enabled
  33815. */
  33816. get isEnabled(): boolean;
  33817. /**
  33818. * Resets performance monitor
  33819. */
  33820. reset(): void;
  33821. }
  33822. /**
  33823. * RollingAverage
  33824. *
  33825. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33826. */
  33827. export class RollingAverage {
  33828. /**
  33829. * Current average
  33830. */
  33831. average: number;
  33832. /**
  33833. * Current variance
  33834. */
  33835. variance: number;
  33836. protected _samples: Array<number>;
  33837. protected _sampleCount: number;
  33838. protected _pos: number;
  33839. protected _m2: number;
  33840. /**
  33841. * constructor
  33842. * @param length The number of samples required to saturate the sliding window
  33843. */
  33844. constructor(length: number);
  33845. /**
  33846. * Adds a sample to the sample set
  33847. * @param v The sample value
  33848. */
  33849. add(v: number): void;
  33850. /**
  33851. * Returns previously added values or null if outside of history or outside the sliding window domain
  33852. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33853. * @return Value previously recorded with add() or null if outside of range
  33854. */
  33855. history(i: number): number;
  33856. /**
  33857. * Returns true if enough samples have been taken to completely fill the sliding window
  33858. * @return true if sample-set saturated
  33859. */
  33860. isSaturated(): boolean;
  33861. /**
  33862. * Resets the rolling average (equivalent to 0 samples taken so far)
  33863. */
  33864. reset(): void;
  33865. /**
  33866. * Wraps a value around the sample range boundaries
  33867. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33868. * @return Wrapped position in sample range
  33869. */
  33870. protected _wrapPosition(i: number): number;
  33871. }
  33872. }
  33873. declare module "babylonjs/Misc/perfCounter" {
  33874. /**
  33875. * This class is used to track a performance counter which is number based.
  33876. * The user has access to many properties which give statistics of different nature.
  33877. *
  33878. * The implementer can track two kinds of Performance Counter: time and count.
  33879. * 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.
  33880. * 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.
  33881. */
  33882. export class PerfCounter {
  33883. /**
  33884. * Gets or sets a global boolean to turn on and off all the counters
  33885. */
  33886. static Enabled: boolean;
  33887. /**
  33888. * Returns the smallest value ever
  33889. */
  33890. get min(): number;
  33891. /**
  33892. * Returns the biggest value ever
  33893. */
  33894. get max(): number;
  33895. /**
  33896. * Returns the average value since the performance counter is running
  33897. */
  33898. get average(): number;
  33899. /**
  33900. * Returns the average value of the last second the counter was monitored
  33901. */
  33902. get lastSecAverage(): number;
  33903. /**
  33904. * Returns the current value
  33905. */
  33906. get current(): number;
  33907. /**
  33908. * Gets the accumulated total
  33909. */
  33910. get total(): number;
  33911. /**
  33912. * Gets the total value count
  33913. */
  33914. get count(): number;
  33915. /**
  33916. * Creates a new counter
  33917. */
  33918. constructor();
  33919. /**
  33920. * Call this method to start monitoring a new frame.
  33921. * 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.
  33922. */
  33923. fetchNewFrame(): void;
  33924. /**
  33925. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33926. * @param newCount the count value to add to the monitored count
  33927. * @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.
  33928. */
  33929. addCount(newCount: number, fetchResult: boolean): void;
  33930. /**
  33931. * Start monitoring this performance counter
  33932. */
  33933. beginMonitoring(): void;
  33934. /**
  33935. * Compute the time lapsed since the previous beginMonitoring() call.
  33936. * @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
  33937. */
  33938. endMonitoring(newFrame?: boolean): void;
  33939. private _fetchResult;
  33940. private _startMonitoringTime;
  33941. private _min;
  33942. private _max;
  33943. private _average;
  33944. private _current;
  33945. private _totalValueCount;
  33946. private _totalAccumulated;
  33947. private _lastSecAverage;
  33948. private _lastSecAccumulated;
  33949. private _lastSecTime;
  33950. private _lastSecValueCount;
  33951. }
  33952. }
  33953. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33954. module "babylonjs/Engines/thinEngine" {
  33955. interface ThinEngine {
  33956. /**
  33957. * Sets alpha constants used by some alpha blending modes
  33958. * @param r defines the red component
  33959. * @param g defines the green component
  33960. * @param b defines the blue component
  33961. * @param a defines the alpha component
  33962. */
  33963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33964. /**
  33965. * Sets the current alpha mode
  33966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33969. */
  33970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33971. /**
  33972. * Gets the current alpha mode
  33973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33974. * @returns the current alpha mode
  33975. */
  33976. getAlphaMode(): number;
  33977. /**
  33978. * Sets the current alpha equation
  33979. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33980. */
  33981. setAlphaEquation(equation: number): void;
  33982. /**
  33983. * Gets the current alpha equation.
  33984. * @returns the current alpha equation
  33985. */
  33986. getAlphaEquation(): number;
  33987. }
  33988. }
  33989. }
  33990. declare module "babylonjs/Engines/engine" {
  33991. import { Observable } from "babylonjs/Misc/observable";
  33992. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33993. import { Scene } from "babylonjs/scene";
  33994. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33995. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33996. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33997. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33998. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33999. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34000. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34001. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34002. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34004. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34005. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34006. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34007. import "babylonjs/Engines/Extensions/engine.alpha";
  34008. import { Material } from "babylonjs/Materials/material";
  34009. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34010. /**
  34011. * Defines the interface used by display changed events
  34012. */
  34013. export interface IDisplayChangedEventArgs {
  34014. /** Gets the vrDisplay object (if any) */
  34015. vrDisplay: Nullable<any>;
  34016. /** Gets a boolean indicating if webVR is supported */
  34017. vrSupported: boolean;
  34018. }
  34019. /**
  34020. * Defines the interface used by objects containing a viewport (like a camera)
  34021. */
  34022. interface IViewportOwnerLike {
  34023. /**
  34024. * Gets or sets the viewport
  34025. */
  34026. viewport: IViewportLike;
  34027. }
  34028. /**
  34029. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34030. */
  34031. export class Engine extends ThinEngine {
  34032. /** Defines that alpha blending is disabled */
  34033. static readonly ALPHA_DISABLE: number;
  34034. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34035. static readonly ALPHA_ADD: number;
  34036. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34037. static readonly ALPHA_COMBINE: number;
  34038. /** Defines that alpha blending to DEST - SRC * DEST */
  34039. static readonly ALPHA_SUBTRACT: number;
  34040. /** Defines that alpha blending to SRC * DEST */
  34041. static readonly ALPHA_MULTIPLY: number;
  34042. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34043. static readonly ALPHA_MAXIMIZED: number;
  34044. /** Defines that alpha blending to SRC + DEST */
  34045. static readonly ALPHA_ONEONE: number;
  34046. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34047. static readonly ALPHA_PREMULTIPLIED: number;
  34048. /**
  34049. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34050. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34051. */
  34052. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34053. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34054. static readonly ALPHA_INTERPOLATE: number;
  34055. /**
  34056. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34057. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34058. */
  34059. static readonly ALPHA_SCREENMODE: number;
  34060. /** Defines that the ressource is not delayed*/
  34061. static readonly DELAYLOADSTATE_NONE: number;
  34062. /** Defines that the ressource was successfully delay loaded */
  34063. static readonly DELAYLOADSTATE_LOADED: number;
  34064. /** Defines that the ressource is currently delay loading */
  34065. static readonly DELAYLOADSTATE_LOADING: number;
  34066. /** Defines that the ressource is delayed and has not started loading */
  34067. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34069. static readonly NEVER: number;
  34070. /** 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 */
  34071. static readonly ALWAYS: number;
  34072. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34073. static readonly LESS: number;
  34074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34075. static readonly EQUAL: number;
  34076. /** 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 */
  34077. static readonly LEQUAL: number;
  34078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34079. static readonly GREATER: number;
  34080. /** 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 */
  34081. static readonly GEQUAL: number;
  34082. /** 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 */
  34083. static readonly NOTEQUAL: number;
  34084. /** Passed to stencilOperation to specify that stencil value must be kept */
  34085. static readonly KEEP: number;
  34086. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34087. static readonly REPLACE: number;
  34088. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34089. static readonly INCR: number;
  34090. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34091. static readonly DECR: number;
  34092. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34093. static readonly INVERT: number;
  34094. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34095. static readonly INCR_WRAP: number;
  34096. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34097. static readonly DECR_WRAP: number;
  34098. /** Texture is not repeating outside of 0..1 UVs */
  34099. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34100. /** Texture is repeating outside of 0..1 UVs */
  34101. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34102. /** Texture is repeating and mirrored */
  34103. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34104. /** ALPHA */
  34105. static readonly TEXTUREFORMAT_ALPHA: number;
  34106. /** LUMINANCE */
  34107. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34108. /** LUMINANCE_ALPHA */
  34109. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34110. /** RGB */
  34111. static readonly TEXTUREFORMAT_RGB: number;
  34112. /** RGBA */
  34113. static readonly TEXTUREFORMAT_RGBA: number;
  34114. /** RED */
  34115. static readonly TEXTUREFORMAT_RED: number;
  34116. /** RED (2nd reference) */
  34117. static readonly TEXTUREFORMAT_R: number;
  34118. /** RG */
  34119. static readonly TEXTUREFORMAT_RG: number;
  34120. /** RED_INTEGER */
  34121. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34122. /** RED_INTEGER (2nd reference) */
  34123. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34124. /** RG_INTEGER */
  34125. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34126. /** RGB_INTEGER */
  34127. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34128. /** RGBA_INTEGER */
  34129. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34130. /** UNSIGNED_BYTE */
  34131. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34132. /** UNSIGNED_BYTE (2nd reference) */
  34133. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34134. /** FLOAT */
  34135. static readonly TEXTURETYPE_FLOAT: number;
  34136. /** HALF_FLOAT */
  34137. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34138. /** BYTE */
  34139. static readonly TEXTURETYPE_BYTE: number;
  34140. /** SHORT */
  34141. static readonly TEXTURETYPE_SHORT: number;
  34142. /** UNSIGNED_SHORT */
  34143. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34144. /** INT */
  34145. static readonly TEXTURETYPE_INT: number;
  34146. /** UNSIGNED_INT */
  34147. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34148. /** UNSIGNED_SHORT_4_4_4_4 */
  34149. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34150. /** UNSIGNED_SHORT_5_5_5_1 */
  34151. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34152. /** UNSIGNED_SHORT_5_6_5 */
  34153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34154. /** UNSIGNED_INT_2_10_10_10_REV */
  34155. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34156. /** UNSIGNED_INT_24_8 */
  34157. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34158. /** UNSIGNED_INT_10F_11F_11F_REV */
  34159. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34160. /** UNSIGNED_INT_5_9_9_9_REV */
  34161. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34162. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34163. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34164. /** nearest is mag = nearest and min = nearest and mip = linear */
  34165. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34166. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34167. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34168. /** Trilinear is mag = linear and min = linear and mip = linear */
  34169. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34170. /** nearest is mag = nearest and min = nearest and mip = linear */
  34171. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34172. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34173. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34174. /** Trilinear is mag = linear and min = linear and mip = linear */
  34175. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34176. /** mag = nearest and min = nearest and mip = nearest */
  34177. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34178. /** mag = nearest and min = linear and mip = nearest */
  34179. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34180. /** mag = nearest and min = linear and mip = linear */
  34181. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34182. /** mag = nearest and min = linear and mip = none */
  34183. static readonly TEXTURE_NEAREST_LINEAR: number;
  34184. /** mag = nearest and min = nearest and mip = none */
  34185. static readonly TEXTURE_NEAREST_NEAREST: number;
  34186. /** mag = linear and min = nearest and mip = nearest */
  34187. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34188. /** mag = linear and min = nearest and mip = linear */
  34189. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34190. /** mag = linear and min = linear and mip = none */
  34191. static readonly TEXTURE_LINEAR_LINEAR: number;
  34192. /** mag = linear and min = nearest and mip = none */
  34193. static readonly TEXTURE_LINEAR_NEAREST: number;
  34194. /** Explicit coordinates mode */
  34195. static readonly TEXTURE_EXPLICIT_MODE: number;
  34196. /** Spherical coordinates mode */
  34197. static readonly TEXTURE_SPHERICAL_MODE: number;
  34198. /** Planar coordinates mode */
  34199. static readonly TEXTURE_PLANAR_MODE: number;
  34200. /** Cubic coordinates mode */
  34201. static readonly TEXTURE_CUBIC_MODE: number;
  34202. /** Projection coordinates mode */
  34203. static readonly TEXTURE_PROJECTION_MODE: number;
  34204. /** Skybox coordinates mode */
  34205. static readonly TEXTURE_SKYBOX_MODE: number;
  34206. /** Inverse Cubic coordinates mode */
  34207. static readonly TEXTURE_INVCUBIC_MODE: number;
  34208. /** Equirectangular coordinates mode */
  34209. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34210. /** Equirectangular Fixed coordinates mode */
  34211. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34212. /** Equirectangular Fixed Mirrored coordinates mode */
  34213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34214. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34215. static readonly SCALEMODE_FLOOR: number;
  34216. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34217. static readonly SCALEMODE_NEAREST: number;
  34218. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34219. static readonly SCALEMODE_CEILING: number;
  34220. /**
  34221. * Returns the current npm package of the sdk
  34222. */
  34223. static get NpmPackage(): string;
  34224. /**
  34225. * Returns the current version of the framework
  34226. */
  34227. static get Version(): string;
  34228. /** Gets the list of created engines */
  34229. static get Instances(): Engine[];
  34230. /**
  34231. * Gets the latest created engine
  34232. */
  34233. static get LastCreatedEngine(): Nullable<Engine>;
  34234. /**
  34235. * Gets the latest created scene
  34236. */
  34237. static get LastCreatedScene(): Nullable<Scene>;
  34238. /**
  34239. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34240. * @param flag defines which part of the materials must be marked as dirty
  34241. * @param predicate defines a predicate used to filter which materials should be affected
  34242. */
  34243. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34244. /**
  34245. * Method called to create the default loading screen.
  34246. * This can be overriden in your own app.
  34247. * @param canvas The rendering canvas element
  34248. * @returns The loading screen
  34249. */
  34250. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34251. /**
  34252. * Method called to create the default rescale post process on each engine.
  34253. */
  34254. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34255. /**
  34256. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34257. **/
  34258. enableOfflineSupport: boolean;
  34259. /**
  34260. * 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)
  34261. **/
  34262. disableManifestCheck: boolean;
  34263. /**
  34264. * Gets the list of created scenes
  34265. */
  34266. scenes: Scene[];
  34267. /**
  34268. * Event raised when a new scene is created
  34269. */
  34270. onNewSceneAddedObservable: Observable<Scene>;
  34271. /**
  34272. * Gets the list of created postprocesses
  34273. */
  34274. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34275. /**
  34276. * Gets a boolean indicating if the pointer is currently locked
  34277. */
  34278. isPointerLock: boolean;
  34279. /**
  34280. * Observable event triggered each time the rendering canvas is resized
  34281. */
  34282. onResizeObservable: Observable<Engine>;
  34283. /**
  34284. * Observable event triggered each time the canvas loses focus
  34285. */
  34286. onCanvasBlurObservable: Observable<Engine>;
  34287. /**
  34288. * Observable event triggered each time the canvas gains focus
  34289. */
  34290. onCanvasFocusObservable: Observable<Engine>;
  34291. /**
  34292. * Observable event triggered each time the canvas receives pointerout event
  34293. */
  34294. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34295. /**
  34296. * Observable raised when the engine begins a new frame
  34297. */
  34298. onBeginFrameObservable: Observable<Engine>;
  34299. /**
  34300. * If set, will be used to request the next animation frame for the render loop
  34301. */
  34302. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34303. /**
  34304. * Observable raised when the engine ends the current frame
  34305. */
  34306. onEndFrameObservable: Observable<Engine>;
  34307. /**
  34308. * Observable raised when the engine is about to compile a shader
  34309. */
  34310. onBeforeShaderCompilationObservable: Observable<Engine>;
  34311. /**
  34312. * Observable raised when the engine has jsut compiled a shader
  34313. */
  34314. onAfterShaderCompilationObservable: Observable<Engine>;
  34315. /**
  34316. * Gets the audio engine
  34317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34318. * @ignorenaming
  34319. */
  34320. static audioEngine: IAudioEngine;
  34321. /**
  34322. * Default AudioEngine factory responsible of creating the Audio Engine.
  34323. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34324. */
  34325. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34326. /**
  34327. * Default offline support factory responsible of creating a tool used to store data locally.
  34328. * By default, this will create a Database object if the workload has been embedded.
  34329. */
  34330. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34331. private _loadingScreen;
  34332. private _pointerLockRequested;
  34333. private _dummyFramebuffer;
  34334. private _rescalePostProcess;
  34335. private _deterministicLockstep;
  34336. private _lockstepMaxSteps;
  34337. private _timeStep;
  34338. protected get _supportsHardwareTextureRescaling(): boolean;
  34339. private _fps;
  34340. private _deltaTime;
  34341. /** @hidden */
  34342. _drawCalls: PerfCounter;
  34343. /** 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 */
  34344. canvasTabIndex: number;
  34345. /**
  34346. * Turn this value on if you want to pause FPS computation when in background
  34347. */
  34348. disablePerformanceMonitorInBackground: boolean;
  34349. private _performanceMonitor;
  34350. /**
  34351. * Gets the performance monitor attached to this engine
  34352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34353. */
  34354. get performanceMonitor(): PerformanceMonitor;
  34355. private _onFocus;
  34356. private _onBlur;
  34357. private _onCanvasPointerOut;
  34358. private _onCanvasBlur;
  34359. private _onCanvasFocus;
  34360. private _onFullscreenChange;
  34361. private _onPointerLockChange;
  34362. /**
  34363. * Gets the HTML element used to attach event listeners
  34364. * @returns a HTML element
  34365. */
  34366. getInputElement(): Nullable<HTMLElement>;
  34367. /**
  34368. * Creates a new engine
  34369. * @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
  34370. * @param antialias defines enable antialiasing (default: false)
  34371. * @param options defines further options to be sent to the getContext() function
  34372. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34373. */
  34374. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34375. /**
  34376. * Gets current aspect ratio
  34377. * @param viewportOwner defines the camera to use to get the aspect ratio
  34378. * @param useScreen defines if screen size must be used (or the current render target if any)
  34379. * @returns a number defining the aspect ratio
  34380. */
  34381. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34382. /**
  34383. * Gets current screen aspect ratio
  34384. * @returns a number defining the aspect ratio
  34385. */
  34386. getScreenAspectRatio(): number;
  34387. /**
  34388. * Gets the client rect of the HTML canvas attached with the current webGL context
  34389. * @returns a client rectanglee
  34390. */
  34391. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34392. /**
  34393. * Gets the client rect of the HTML element used for events
  34394. * @returns a client rectanglee
  34395. */
  34396. getInputElementClientRect(): Nullable<ClientRect>;
  34397. /**
  34398. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34399. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34400. * @returns true if engine is in deterministic lock step mode
  34401. */
  34402. isDeterministicLockStep(): boolean;
  34403. /**
  34404. * Gets the max steps when engine is running in deterministic lock step
  34405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34406. * @returns the max steps
  34407. */
  34408. getLockstepMaxSteps(): number;
  34409. /**
  34410. * Returns the time in ms between steps when using deterministic lock step.
  34411. * @returns time step in (ms)
  34412. */
  34413. getTimeStep(): number;
  34414. /**
  34415. * Force the mipmap generation for the given render target texture
  34416. * @param texture defines the render target texture to use
  34417. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34418. */
  34419. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34420. /** States */
  34421. /**
  34422. * Set various states to the webGL context
  34423. * @param culling defines backface culling state
  34424. * @param zOffset defines the value to apply to zOffset (0 by default)
  34425. * @param force defines if states must be applied even if cache is up to date
  34426. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34427. */
  34428. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34429. /**
  34430. * Set the z offset to apply to current rendering
  34431. * @param value defines the offset to apply
  34432. */
  34433. setZOffset(value: number): void;
  34434. /**
  34435. * Gets the current value of the zOffset
  34436. * @returns the current zOffset state
  34437. */
  34438. getZOffset(): number;
  34439. /**
  34440. * Enable or disable depth buffering
  34441. * @param enable defines the state to set
  34442. */
  34443. setDepthBuffer(enable: boolean): void;
  34444. /**
  34445. * Gets a boolean indicating if depth writing is enabled
  34446. * @returns the current depth writing state
  34447. */
  34448. getDepthWrite(): boolean;
  34449. /**
  34450. * Enable or disable depth writing
  34451. * @param enable defines the state to set
  34452. */
  34453. setDepthWrite(enable: boolean): void;
  34454. /**
  34455. * Gets a boolean indicating if stencil buffer is enabled
  34456. * @returns the current stencil buffer state
  34457. */
  34458. getStencilBuffer(): boolean;
  34459. /**
  34460. * Enable or disable the stencil buffer
  34461. * @param enable defines if the stencil buffer must be enabled or disabled
  34462. */
  34463. setStencilBuffer(enable: boolean): void;
  34464. /**
  34465. * Gets the current stencil mask
  34466. * @returns a number defining the new stencil mask to use
  34467. */
  34468. getStencilMask(): number;
  34469. /**
  34470. * Sets the current stencil mask
  34471. * @param mask defines the new stencil mask to use
  34472. */
  34473. setStencilMask(mask: number): void;
  34474. /**
  34475. * Gets the current stencil function
  34476. * @returns a number defining the stencil function to use
  34477. */
  34478. getStencilFunction(): number;
  34479. /**
  34480. * Gets the current stencil reference value
  34481. * @returns a number defining the stencil reference value to use
  34482. */
  34483. getStencilFunctionReference(): number;
  34484. /**
  34485. * Gets the current stencil mask
  34486. * @returns a number defining the stencil mask to use
  34487. */
  34488. getStencilFunctionMask(): number;
  34489. /**
  34490. * Sets the current stencil function
  34491. * @param stencilFunc defines the new stencil function to use
  34492. */
  34493. setStencilFunction(stencilFunc: number): void;
  34494. /**
  34495. * Sets the current stencil reference
  34496. * @param reference defines the new stencil reference to use
  34497. */
  34498. setStencilFunctionReference(reference: number): void;
  34499. /**
  34500. * Sets the current stencil mask
  34501. * @param mask defines the new stencil mask to use
  34502. */
  34503. setStencilFunctionMask(mask: number): void;
  34504. /**
  34505. * Gets the current stencil operation when stencil fails
  34506. * @returns a number defining stencil operation to use when stencil fails
  34507. */
  34508. getStencilOperationFail(): number;
  34509. /**
  34510. * Gets the current stencil operation when depth fails
  34511. * @returns a number defining stencil operation to use when depth fails
  34512. */
  34513. getStencilOperationDepthFail(): number;
  34514. /**
  34515. * Gets the current stencil operation when stencil passes
  34516. * @returns a number defining stencil operation to use when stencil passes
  34517. */
  34518. getStencilOperationPass(): number;
  34519. /**
  34520. * Sets the stencil operation to use when stencil fails
  34521. * @param operation defines the stencil operation to use when stencil fails
  34522. */
  34523. setStencilOperationFail(operation: number): void;
  34524. /**
  34525. * Sets the stencil operation to use when depth fails
  34526. * @param operation defines the stencil operation to use when depth fails
  34527. */
  34528. setStencilOperationDepthFail(operation: number): void;
  34529. /**
  34530. * Sets the stencil operation to use when stencil passes
  34531. * @param operation defines the stencil operation to use when stencil passes
  34532. */
  34533. setStencilOperationPass(operation: number): void;
  34534. /**
  34535. * Sets a boolean indicating if the dithering state is enabled or disabled
  34536. * @param value defines the dithering state
  34537. */
  34538. setDitheringState(value: boolean): void;
  34539. /**
  34540. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34541. * @param value defines the rasterizer state
  34542. */
  34543. setRasterizerState(value: boolean): void;
  34544. /**
  34545. * Gets the current depth function
  34546. * @returns a number defining the depth function
  34547. */
  34548. getDepthFunction(): Nullable<number>;
  34549. /**
  34550. * Sets the current depth function
  34551. * @param depthFunc defines the function to use
  34552. */
  34553. setDepthFunction(depthFunc: number): void;
  34554. /**
  34555. * Sets the current depth function to GREATER
  34556. */
  34557. setDepthFunctionToGreater(): void;
  34558. /**
  34559. * Sets the current depth function to GEQUAL
  34560. */
  34561. setDepthFunctionToGreaterOrEqual(): void;
  34562. /**
  34563. * Sets the current depth function to LESS
  34564. */
  34565. setDepthFunctionToLess(): void;
  34566. /**
  34567. * Sets the current depth function to LEQUAL
  34568. */
  34569. setDepthFunctionToLessOrEqual(): void;
  34570. private _cachedStencilBuffer;
  34571. private _cachedStencilFunction;
  34572. private _cachedStencilMask;
  34573. private _cachedStencilOperationPass;
  34574. private _cachedStencilOperationFail;
  34575. private _cachedStencilOperationDepthFail;
  34576. private _cachedStencilReference;
  34577. /**
  34578. * Caches the the state of the stencil buffer
  34579. */
  34580. cacheStencilState(): void;
  34581. /**
  34582. * Restores the state of the stencil buffer
  34583. */
  34584. restoreStencilState(): void;
  34585. /**
  34586. * Directly set the WebGL Viewport
  34587. * @param x defines the x coordinate of the viewport (in screen space)
  34588. * @param y defines the y coordinate of the viewport (in screen space)
  34589. * @param width defines the width of the viewport (in screen space)
  34590. * @param height defines the height of the viewport (in screen space)
  34591. * @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
  34592. */
  34593. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34594. /**
  34595. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34596. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34597. * @param y defines the y-coordinate of the corner of the clear rectangle
  34598. * @param width defines the width of the clear rectangle
  34599. * @param height defines the height of the clear rectangle
  34600. * @param clearColor defines the clear color
  34601. */
  34602. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34603. /**
  34604. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34605. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34606. * @param y defines the y-coordinate of the corner of the clear rectangle
  34607. * @param width defines the width of the clear rectangle
  34608. * @param height defines the height of the clear rectangle
  34609. */
  34610. enableScissor(x: number, y: number, width: number, height: number): void;
  34611. /**
  34612. * Disable previously set scissor test rectangle
  34613. */
  34614. disableScissor(): void;
  34615. protected _reportDrawCall(): void;
  34616. /**
  34617. * Initializes a webVR display and starts listening to display change events
  34618. * The onVRDisplayChangedObservable will be notified upon these changes
  34619. * @returns The onVRDisplayChangedObservable
  34620. */
  34621. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34622. /** @hidden */
  34623. _prepareVRComponent(): void;
  34624. /** @hidden */
  34625. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34626. /** @hidden */
  34627. _submitVRFrame(): void;
  34628. /**
  34629. * Call this function to leave webVR mode
  34630. * Will do nothing if webVR is not supported or if there is no webVR device
  34631. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34632. */
  34633. disableVR(): void;
  34634. /**
  34635. * Gets a boolean indicating that the system is in VR mode and is presenting
  34636. * @returns true if VR mode is engaged
  34637. */
  34638. isVRPresenting(): boolean;
  34639. /** @hidden */
  34640. _requestVRFrame(): void;
  34641. /** @hidden */
  34642. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34643. /**
  34644. * Gets the source code of the vertex shader associated with a specific webGL program
  34645. * @param program defines the program to use
  34646. * @returns a string containing the source code of the vertex shader associated with the program
  34647. */
  34648. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34649. /**
  34650. * Gets the source code of the fragment shader associated with a specific webGL program
  34651. * @param program defines the program to use
  34652. * @returns a string containing the source code of the fragment shader associated with the program
  34653. */
  34654. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34655. /**
  34656. * Sets a depth stencil texture from a render target to the according uniform.
  34657. * @param channel The texture channel
  34658. * @param uniform The uniform to set
  34659. * @param texture The render target texture containing the depth stencil texture to apply
  34660. */
  34661. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34662. /**
  34663. * Sets a texture to the webGL context from a postprocess
  34664. * @param channel defines the channel to use
  34665. * @param postProcess defines the source postprocess
  34666. */
  34667. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34668. /**
  34669. * Binds the output of the passed in post process to the texture channel specified
  34670. * @param channel The channel the texture should be bound to
  34671. * @param postProcess The post process which's output should be bound
  34672. */
  34673. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34674. /** @hidden */
  34675. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34676. protected _rebuildBuffers(): void;
  34677. /** @hidden */
  34678. _renderFrame(): void;
  34679. _renderLoop(): void;
  34680. /** @hidden */
  34681. _renderViews(): boolean;
  34682. /**
  34683. * Toggle full screen mode
  34684. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34685. */
  34686. switchFullscreen(requestPointerLock: boolean): void;
  34687. /**
  34688. * Enters full screen mode
  34689. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34690. */
  34691. enterFullscreen(requestPointerLock: boolean): void;
  34692. /**
  34693. * Exits full screen mode
  34694. */
  34695. exitFullscreen(): void;
  34696. /**
  34697. * Enters Pointerlock mode
  34698. */
  34699. enterPointerlock(): void;
  34700. /**
  34701. * Exits Pointerlock mode
  34702. */
  34703. exitPointerlock(): void;
  34704. /**
  34705. * Begin a new frame
  34706. */
  34707. beginFrame(): void;
  34708. /**
  34709. * Enf the current frame
  34710. */
  34711. endFrame(): void;
  34712. resize(): void;
  34713. /**
  34714. * Force a specific size of the canvas
  34715. * @param width defines the new canvas' width
  34716. * @param height defines the new canvas' height
  34717. */
  34718. setSize(width: number, height: number): void;
  34719. /**
  34720. * Updates a dynamic vertex buffer.
  34721. * @param vertexBuffer the vertex buffer to update
  34722. * @param data the data used to update the vertex buffer
  34723. * @param byteOffset the byte offset of the data
  34724. * @param byteLength the byte length of the data
  34725. */
  34726. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34727. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34728. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34729. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34730. _releaseTexture(texture: InternalTexture): void;
  34731. /**
  34732. * @hidden
  34733. * Rescales a texture
  34734. * @param source input texutre
  34735. * @param destination destination texture
  34736. * @param scene scene to use to render the resize
  34737. * @param internalFormat format to use when resizing
  34738. * @param onComplete callback to be called when resize has completed
  34739. */
  34740. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34741. /**
  34742. * Gets the current framerate
  34743. * @returns a number representing the framerate
  34744. */
  34745. getFps(): number;
  34746. /**
  34747. * Gets the time spent between current and previous frame
  34748. * @returns a number representing the delta time in ms
  34749. */
  34750. getDeltaTime(): number;
  34751. private _measureFps;
  34752. /** @hidden */
  34753. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34754. /**
  34755. * Update a dynamic index buffer
  34756. * @param indexBuffer defines the target index buffer
  34757. * @param indices defines the data to update
  34758. * @param offset defines the offset in the target index buffer where update should start
  34759. */
  34760. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34761. /**
  34762. * Updates the sample count of a render target texture
  34763. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34764. * @param texture defines the texture to update
  34765. * @param samples defines the sample count to set
  34766. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34767. */
  34768. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34769. /**
  34770. * Updates a depth texture Comparison Mode and Function.
  34771. * If the comparison Function is equal to 0, the mode will be set to none.
  34772. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34773. * @param texture The texture to set the comparison function for
  34774. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34775. */
  34776. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34777. /**
  34778. * Creates a webGL buffer to use with instanciation
  34779. * @param capacity defines the size of the buffer
  34780. * @returns the webGL buffer
  34781. */
  34782. createInstancesBuffer(capacity: number): DataBuffer;
  34783. /**
  34784. * Delete a webGL buffer used with instanciation
  34785. * @param buffer defines the webGL buffer to delete
  34786. */
  34787. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34788. private _clientWaitAsync;
  34789. /** @hidden */
  34790. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34791. /** @hidden */
  34792. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34793. dispose(): void;
  34794. private _disableTouchAction;
  34795. /**
  34796. * Display the loading screen
  34797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34798. */
  34799. displayLoadingUI(): void;
  34800. /**
  34801. * Hide the loading screen
  34802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34803. */
  34804. hideLoadingUI(): void;
  34805. /**
  34806. * Gets the current loading screen object
  34807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34808. */
  34809. get loadingScreen(): ILoadingScreen;
  34810. /**
  34811. * Sets the current loading screen object
  34812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34813. */
  34814. set loadingScreen(loadingScreen: ILoadingScreen);
  34815. /**
  34816. * Sets the current loading screen text
  34817. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34818. */
  34819. set loadingUIText(text: string);
  34820. /**
  34821. * Sets the current loading screen background color
  34822. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34823. */
  34824. set loadingUIBackgroundColor(color: string);
  34825. /** Pointerlock and fullscreen */
  34826. /**
  34827. * Ask the browser to promote the current element to pointerlock mode
  34828. * @param element defines the DOM element to promote
  34829. */
  34830. static _RequestPointerlock(element: HTMLElement): void;
  34831. /**
  34832. * Asks the browser to exit pointerlock mode
  34833. */
  34834. static _ExitPointerlock(): void;
  34835. /**
  34836. * Ask the browser to promote the current element to fullscreen rendering mode
  34837. * @param element defines the DOM element to promote
  34838. */
  34839. static _RequestFullscreen(element: HTMLElement): void;
  34840. /**
  34841. * Asks the browser to exit fullscreen mode
  34842. */
  34843. static _ExitFullscreen(): void;
  34844. }
  34845. }
  34846. declare module "babylonjs/Engines/engineStore" {
  34847. import { Nullable } from "babylonjs/types";
  34848. import { Engine } from "babylonjs/Engines/engine";
  34849. import { Scene } from "babylonjs/scene";
  34850. /**
  34851. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34852. * during the life time of the application.
  34853. */
  34854. export class EngineStore {
  34855. /** Gets the list of created engines */
  34856. static Instances: import("babylonjs/Engines/engine").Engine[];
  34857. /** @hidden */
  34858. static _LastCreatedScene: Nullable<Scene>;
  34859. /**
  34860. * Gets the latest created engine
  34861. */
  34862. static get LastCreatedEngine(): Nullable<Engine>;
  34863. /**
  34864. * Gets the latest created scene
  34865. */
  34866. static get LastCreatedScene(): Nullable<Scene>;
  34867. /**
  34868. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34869. * @ignorenaming
  34870. */
  34871. static UseFallbackTexture: boolean;
  34872. /**
  34873. * Texture content used if a texture cannot loaded
  34874. * @ignorenaming
  34875. */
  34876. static FallbackTexture: string;
  34877. }
  34878. }
  34879. declare module "babylonjs/Misc/promise" {
  34880. /**
  34881. * Helper class that provides a small promise polyfill
  34882. */
  34883. export class PromisePolyfill {
  34884. /**
  34885. * Static function used to check if the polyfill is required
  34886. * If this is the case then the function will inject the polyfill to window.Promise
  34887. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34888. */
  34889. static Apply(force?: boolean): void;
  34890. }
  34891. }
  34892. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34893. /**
  34894. * Interface for screenshot methods with describe argument called `size` as object with options
  34895. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34896. */
  34897. export interface IScreenshotSize {
  34898. /**
  34899. * number in pixels for canvas height
  34900. */
  34901. height?: number;
  34902. /**
  34903. * multiplier allowing render at a higher or lower resolution
  34904. * If value is defined then height and width will be ignored and taken from camera
  34905. */
  34906. precision?: number;
  34907. /**
  34908. * number in pixels for canvas width
  34909. */
  34910. width?: number;
  34911. }
  34912. }
  34913. declare module "babylonjs/Misc/tools" {
  34914. import { Nullable, float } from "babylonjs/types";
  34915. import { DomManagement } from "babylonjs/Misc/domManagement";
  34916. import { WebRequest } from "babylonjs/Misc/webRequest";
  34917. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34918. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34919. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34920. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34921. import { Camera } from "babylonjs/Cameras/camera";
  34922. import { Engine } from "babylonjs/Engines/engine";
  34923. interface IColor4Like {
  34924. r: float;
  34925. g: float;
  34926. b: float;
  34927. a: float;
  34928. }
  34929. /**
  34930. * Class containing a set of static utilities functions
  34931. */
  34932. export class Tools {
  34933. /**
  34934. * Gets or sets the base URL to use to load assets
  34935. */
  34936. static get BaseUrl(): string;
  34937. static set BaseUrl(value: string);
  34938. /**
  34939. * Enable/Disable Custom HTTP Request Headers globally.
  34940. * default = false
  34941. * @see CustomRequestHeaders
  34942. */
  34943. static UseCustomRequestHeaders: boolean;
  34944. /**
  34945. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34946. * i.e. when loading files, where the server/service expects an Authorization header
  34947. */
  34948. static CustomRequestHeaders: {
  34949. [key: string]: string;
  34950. };
  34951. /**
  34952. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34953. */
  34954. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34955. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34956. /**
  34957. * Default behaviour for cors in the application.
  34958. * It can be a string if the expected behavior is identical in the entire app.
  34959. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34960. */
  34961. static CorsBehavior: string | ((url: string | string[]) => string);
  34962. /**
  34963. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34964. * @ignorenaming
  34965. */
  34966. static get UseFallbackTexture(): boolean;
  34967. static set UseFallbackTexture(value: boolean);
  34968. /**
  34969. * Use this object to register external classes like custom textures or material
  34970. * to allow the laoders to instantiate them
  34971. */
  34972. static get RegisteredExternalClasses(): {
  34973. [key: string]: Object;
  34974. };
  34975. static set RegisteredExternalClasses(classes: {
  34976. [key: string]: Object;
  34977. });
  34978. /**
  34979. * Texture content used if a texture cannot loaded
  34980. * @ignorenaming
  34981. */
  34982. static get fallbackTexture(): string;
  34983. static set fallbackTexture(value: string);
  34984. /**
  34985. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34986. * @param u defines the coordinate on X axis
  34987. * @param v defines the coordinate on Y axis
  34988. * @param width defines the width of the source data
  34989. * @param height defines the height of the source data
  34990. * @param pixels defines the source byte array
  34991. * @param color defines the output color
  34992. */
  34993. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34994. /**
  34995. * Interpolates between a and b via alpha
  34996. * @param a The lower value (returned when alpha = 0)
  34997. * @param b The upper value (returned when alpha = 1)
  34998. * @param alpha The interpolation-factor
  34999. * @return The mixed value
  35000. */
  35001. static Mix(a: number, b: number, alpha: number): number;
  35002. /**
  35003. * Tries to instantiate a new object from a given class name
  35004. * @param className defines the class name to instantiate
  35005. * @returns the new object or null if the system was not able to do the instantiation
  35006. */
  35007. static Instantiate(className: string): any;
  35008. /**
  35009. * Provides a slice function that will work even on IE
  35010. * @param data defines the array to slice
  35011. * @param start defines the start of the data (optional)
  35012. * @param end defines the end of the data (optional)
  35013. * @returns the new sliced array
  35014. */
  35015. static Slice<T>(data: T, start?: number, end?: number): T;
  35016. /**
  35017. * Polyfill for setImmediate
  35018. * @param action defines the action to execute after the current execution block
  35019. */
  35020. static SetImmediate(action: () => void): void;
  35021. /**
  35022. * Function indicating if a number is an exponent of 2
  35023. * @param value defines the value to test
  35024. * @returns true if the value is an exponent of 2
  35025. */
  35026. static IsExponentOfTwo(value: number): boolean;
  35027. private static _tmpFloatArray;
  35028. /**
  35029. * Returns the nearest 32-bit single precision float representation of a Number
  35030. * @param value A Number. If the parameter is of a different type, it will get converted
  35031. * to a number or to NaN if it cannot be converted
  35032. * @returns number
  35033. */
  35034. static FloatRound(value: number): number;
  35035. /**
  35036. * Extracts the filename from a path
  35037. * @param path defines the path to use
  35038. * @returns the filename
  35039. */
  35040. static GetFilename(path: string): string;
  35041. /**
  35042. * Extracts the "folder" part of a path (everything before the filename).
  35043. * @param uri The URI to extract the info from
  35044. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35045. * @returns The "folder" part of the path
  35046. */
  35047. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35048. /**
  35049. * Extracts text content from a DOM element hierarchy
  35050. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35051. */
  35052. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35053. /**
  35054. * Convert an angle in radians to degrees
  35055. * @param angle defines the angle to convert
  35056. * @returns the angle in degrees
  35057. */
  35058. static ToDegrees(angle: number): number;
  35059. /**
  35060. * Convert an angle in degrees to radians
  35061. * @param angle defines the angle to convert
  35062. * @returns the angle in radians
  35063. */
  35064. static ToRadians(angle: number): number;
  35065. /**
  35066. * Returns an array if obj is not an array
  35067. * @param obj defines the object to evaluate as an array
  35068. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35069. * @returns either obj directly if obj is an array or a new array containing obj
  35070. */
  35071. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35072. /**
  35073. * Gets the pointer prefix to use
  35074. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35075. */
  35076. static GetPointerPrefix(): string;
  35077. /**
  35078. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35079. * @param url define the url we are trying
  35080. * @param element define the dom element where to configure the cors policy
  35081. */
  35082. static SetCorsBehavior(url: string | string[], element: {
  35083. crossOrigin: string | null;
  35084. }): void;
  35085. /**
  35086. * Removes unwanted characters from an url
  35087. * @param url defines the url to clean
  35088. * @returns the cleaned url
  35089. */
  35090. static CleanUrl(url: string): string;
  35091. /**
  35092. * Gets or sets a function used to pre-process url before using them to load assets
  35093. */
  35094. static get PreprocessUrl(): (url: string) => string;
  35095. static set PreprocessUrl(processor: (url: string) => string);
  35096. /**
  35097. * Loads an image as an HTMLImageElement.
  35098. * @param input url string, ArrayBuffer, or Blob to load
  35099. * @param onLoad callback called when the image successfully loads
  35100. * @param onError callback called when the image fails to load
  35101. * @param offlineProvider offline provider for caching
  35102. * @param mimeType optional mime type
  35103. * @returns the HTMLImageElement of the loaded image
  35104. */
  35105. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35106. /**
  35107. * Loads a file from a url
  35108. * @param url url string, ArrayBuffer, or Blob to load
  35109. * @param onSuccess callback called when the file successfully loads
  35110. * @param onProgress callback called while file is loading (if the server supports this mode)
  35111. * @param offlineProvider defines the offline provider for caching
  35112. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35113. * @param onError callback called when the file fails to load
  35114. * @returns a file request object
  35115. */
  35116. 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;
  35117. /**
  35118. * Loads a file from a url
  35119. * @param url the file url to load
  35120. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35121. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35122. */
  35123. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35124. /**
  35125. * Load a script (identified by an url). When the url returns, the
  35126. * content of this file is added into a new script element, attached to the DOM (body element)
  35127. * @param scriptUrl defines the url of the script to laod
  35128. * @param onSuccess defines the callback called when the script is loaded
  35129. * @param onError defines the callback to call if an error occurs
  35130. * @param scriptId defines the id of the script element
  35131. */
  35132. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35133. /**
  35134. * Load an asynchronous script (identified by an url). When the url returns, the
  35135. * content of this file is added into a new script element, attached to the DOM (body element)
  35136. * @param scriptUrl defines the url of the script to laod
  35137. * @param scriptId defines the id of the script element
  35138. * @returns a promise request object
  35139. */
  35140. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35141. /**
  35142. * Loads a file from a blob
  35143. * @param fileToLoad defines the blob to use
  35144. * @param callback defines the callback to call when data is loaded
  35145. * @param progressCallback defines the callback to call during loading process
  35146. * @returns a file request object
  35147. */
  35148. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35149. /**
  35150. * Reads a file from a File object
  35151. * @param file defines the file to load
  35152. * @param onSuccess defines the callback to call when data is loaded
  35153. * @param onProgress defines the callback to call during loading process
  35154. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35155. * @param onError defines the callback to call when an error occurs
  35156. * @returns a file request object
  35157. */
  35158. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35159. /**
  35160. * Creates a data url from a given string content
  35161. * @param content defines the content to convert
  35162. * @returns the new data url link
  35163. */
  35164. static FileAsURL(content: string): string;
  35165. /**
  35166. * Format the given number to a specific decimal format
  35167. * @param value defines the number to format
  35168. * @param decimals defines the number of decimals to use
  35169. * @returns the formatted string
  35170. */
  35171. static Format(value: number, decimals?: number): string;
  35172. /**
  35173. * Tries to copy an object by duplicating every property
  35174. * @param source defines the source object
  35175. * @param destination defines the target object
  35176. * @param doNotCopyList defines a list of properties to avoid
  35177. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35178. */
  35179. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35180. /**
  35181. * Gets a boolean indicating if the given object has no own property
  35182. * @param obj defines the object to test
  35183. * @returns true if object has no own property
  35184. */
  35185. static IsEmpty(obj: any): boolean;
  35186. /**
  35187. * Function used to register events at window level
  35188. * @param windowElement defines the Window object to use
  35189. * @param events defines the events to register
  35190. */
  35191. static RegisterTopRootEvents(windowElement: Window, events: {
  35192. name: string;
  35193. handler: Nullable<(e: FocusEvent) => any>;
  35194. }[]): void;
  35195. /**
  35196. * Function used to unregister events from window level
  35197. * @param windowElement defines the Window object to use
  35198. * @param events defines the events to unregister
  35199. */
  35200. static UnregisterTopRootEvents(windowElement: Window, events: {
  35201. name: string;
  35202. handler: Nullable<(e: FocusEvent) => any>;
  35203. }[]): void;
  35204. /**
  35205. * @ignore
  35206. */
  35207. static _ScreenshotCanvas: HTMLCanvasElement;
  35208. /**
  35209. * Dumps the current bound framebuffer
  35210. * @param width defines the rendering width
  35211. * @param height defines the rendering height
  35212. * @param engine defines the hosting engine
  35213. * @param successCallback defines the callback triggered once the data are available
  35214. * @param mimeType defines the mime type of the result
  35215. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35216. */
  35217. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35218. /**
  35219. * Converts the canvas data to blob.
  35220. * This acts as a polyfill for browsers not supporting the to blob function.
  35221. * @param canvas Defines the canvas to extract the data from
  35222. * @param successCallback Defines the callback triggered once the data are available
  35223. * @param mimeType Defines the mime type of the result
  35224. */
  35225. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35226. /**
  35227. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35228. * @param successCallback defines the callback triggered once the data are available
  35229. * @param mimeType defines the mime type of the result
  35230. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35231. */
  35232. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35233. /**
  35234. * Downloads a blob in the browser
  35235. * @param blob defines the blob to download
  35236. * @param fileName defines the name of the downloaded file
  35237. */
  35238. static Download(blob: Blob, fileName: string): void;
  35239. /**
  35240. * Captures a screenshot of the current rendering
  35241. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35242. * @param engine defines the rendering engine
  35243. * @param camera defines the source camera
  35244. * @param size This parameter can be set to a single number or to an object with the
  35245. * following (optional) properties: precision, width, height. If a single number is passed,
  35246. * it will be used for both width and height. If an object is passed, the screenshot size
  35247. * will be derived from the parameters. The precision property is a multiplier allowing
  35248. * rendering at a higher or lower resolution
  35249. * @param successCallback defines the callback receives a single parameter which contains the
  35250. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35251. * src parameter of an <img> to display it
  35252. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35253. * Check your browser for supported MIME types
  35254. */
  35255. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35256. /**
  35257. * Captures a screenshot of the current rendering
  35258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35259. * @param engine defines the rendering engine
  35260. * @param camera defines the source camera
  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 defines the MIME type of the screenshot image (default: image/png).
  35267. * Check your browser for supported MIME types
  35268. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35269. * to the src parameter of an <img> to display it
  35270. */
  35271. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35272. /**
  35273. * Generates an image screenshot from the specified camera.
  35274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35275. * @param engine The engine to use for rendering
  35276. * @param camera The camera to use for rendering
  35277. * @param size This parameter can be set to a single number or to an object with the
  35278. * following (optional) properties: precision, width, height. If a single number is passed,
  35279. * it will be used for both width and height. If an object is passed, the screenshot size
  35280. * will be derived from the parameters. The precision property is a multiplier allowing
  35281. * rendering at a higher or lower resolution
  35282. * @param successCallback The callback receives a single parameter which contains the
  35283. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35284. * src parameter of an <img> to display it
  35285. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35286. * Check your browser for supported MIME types
  35287. * @param samples Texture samples (default: 1)
  35288. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35289. * @param fileName A name for for the downloaded file.
  35290. */
  35291. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35292. /**
  35293. * Generates an image screenshot from the specified camera.
  35294. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35295. * @param engine The engine to use for rendering
  35296. * @param camera The camera to use for rendering
  35297. * @param size This parameter can be set to a single number or to an object with the
  35298. * following (optional) properties: precision, width, height. If a single number is passed,
  35299. * it will be used for both width and height. If an object is passed, the screenshot size
  35300. * will be derived from the parameters. The precision property is a multiplier allowing
  35301. * rendering at a higher or lower resolution
  35302. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35303. * Check your browser for supported MIME types
  35304. * @param samples Texture samples (default: 1)
  35305. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35306. * @param fileName A name for for the downloaded file.
  35307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35308. * to the src parameter of an <img> to display it
  35309. */
  35310. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35311. /**
  35312. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35313. * Be aware Math.random() could cause collisions, but:
  35314. * "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"
  35315. * @returns a pseudo random id
  35316. */
  35317. static RandomId(): string;
  35318. /**
  35319. * Test if the given uri is a base64 string
  35320. * @param uri The uri to test
  35321. * @return True if the uri is a base64 string or false otherwise
  35322. */
  35323. static IsBase64(uri: string): boolean;
  35324. /**
  35325. * Decode the given base64 uri.
  35326. * @param uri The uri to decode
  35327. * @return The decoded base64 data.
  35328. */
  35329. static DecodeBase64(uri: string): ArrayBuffer;
  35330. /**
  35331. * Gets the absolute url.
  35332. * @param url the input url
  35333. * @return the absolute url
  35334. */
  35335. static GetAbsoluteUrl(url: string): string;
  35336. /**
  35337. * No log
  35338. */
  35339. static readonly NoneLogLevel: number;
  35340. /**
  35341. * Only message logs
  35342. */
  35343. static readonly MessageLogLevel: number;
  35344. /**
  35345. * Only warning logs
  35346. */
  35347. static readonly WarningLogLevel: number;
  35348. /**
  35349. * Only error logs
  35350. */
  35351. static readonly ErrorLogLevel: number;
  35352. /**
  35353. * All logs
  35354. */
  35355. static readonly AllLogLevel: number;
  35356. /**
  35357. * Gets a value indicating the number of loading errors
  35358. * @ignorenaming
  35359. */
  35360. static get errorsCount(): number;
  35361. /**
  35362. * Callback called when a new log is added
  35363. */
  35364. static OnNewCacheEntry: (entry: string) => void;
  35365. /**
  35366. * Log a message to the console
  35367. * @param message defines the message to log
  35368. */
  35369. static Log(message: string): void;
  35370. /**
  35371. * Write a warning message to the console
  35372. * @param message defines the message to log
  35373. */
  35374. static Warn(message: string): void;
  35375. /**
  35376. * Write an error message to the console
  35377. * @param message defines the message to log
  35378. */
  35379. static Error(message: string): void;
  35380. /**
  35381. * Gets current log cache (list of logs)
  35382. */
  35383. static get LogCache(): string;
  35384. /**
  35385. * Clears the log cache
  35386. */
  35387. static ClearLogCache(): void;
  35388. /**
  35389. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35390. */
  35391. static set LogLevels(level: number);
  35392. /**
  35393. * Checks if the window object exists
  35394. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35395. */
  35396. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35397. /**
  35398. * No performance log
  35399. */
  35400. static readonly PerformanceNoneLogLevel: number;
  35401. /**
  35402. * Use user marks to log performance
  35403. */
  35404. static readonly PerformanceUserMarkLogLevel: number;
  35405. /**
  35406. * Log performance to the console
  35407. */
  35408. static readonly PerformanceConsoleLogLevel: number;
  35409. private static _performance;
  35410. /**
  35411. * Sets the current performance log level
  35412. */
  35413. static set PerformanceLogLevel(level: number);
  35414. private static _StartPerformanceCounterDisabled;
  35415. private static _EndPerformanceCounterDisabled;
  35416. private static _StartUserMark;
  35417. private static _EndUserMark;
  35418. private static _StartPerformanceConsole;
  35419. private static _EndPerformanceConsole;
  35420. /**
  35421. * Starts a performance counter
  35422. */
  35423. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35424. /**
  35425. * Ends a specific performance coutner
  35426. */
  35427. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35428. /**
  35429. * Gets either window.performance.now() if supported or Date.now() else
  35430. */
  35431. static get Now(): number;
  35432. /**
  35433. * This method will return the name of the class used to create the instance of the given object.
  35434. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35435. * @param object the object to get the class name from
  35436. * @param isType defines if the object is actually a type
  35437. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35438. */
  35439. static GetClassName(object: any, isType?: boolean): string;
  35440. /**
  35441. * Gets the first element of an array satisfying a given predicate
  35442. * @param array defines the array to browse
  35443. * @param predicate defines the predicate to use
  35444. * @returns null if not found or the element
  35445. */
  35446. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35447. /**
  35448. * This method will return the name of the full name of the class, including its owning module (if any).
  35449. * 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).
  35450. * @param object the object to get the class name from
  35451. * @param isType defines if the object is actually a type
  35452. * @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.
  35453. * @ignorenaming
  35454. */
  35455. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35456. /**
  35457. * Returns a promise that resolves after the given amount of time.
  35458. * @param delay Number of milliseconds to delay
  35459. * @returns Promise that resolves after the given amount of time
  35460. */
  35461. static DelayAsync(delay: number): Promise<void>;
  35462. /**
  35463. * Utility function to detect if the current user agent is Safari
  35464. * @returns whether or not the current user agent is safari
  35465. */
  35466. static IsSafari(): boolean;
  35467. }
  35468. /**
  35469. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35470. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35471. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35472. * @param name The name of the class, case should be preserved
  35473. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35474. */
  35475. export function className(name: string, module?: string): (target: Object) => void;
  35476. /**
  35477. * An implementation of a loop for asynchronous functions.
  35478. */
  35479. export class AsyncLoop {
  35480. /**
  35481. * Defines the number of iterations for the loop
  35482. */
  35483. iterations: number;
  35484. /**
  35485. * Defines the current index of the loop.
  35486. */
  35487. index: number;
  35488. private _done;
  35489. private _fn;
  35490. private _successCallback;
  35491. /**
  35492. * Constructor.
  35493. * @param iterations the number of iterations.
  35494. * @param func the function to run each iteration
  35495. * @param successCallback the callback that will be called upon succesful execution
  35496. * @param offset starting offset.
  35497. */
  35498. constructor(
  35499. /**
  35500. * Defines the number of iterations for the loop
  35501. */
  35502. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35503. /**
  35504. * Execute the next iteration. Must be called after the last iteration was finished.
  35505. */
  35506. executeNext(): void;
  35507. /**
  35508. * Break the loop and run the success callback.
  35509. */
  35510. breakLoop(): void;
  35511. /**
  35512. * Create and run an async loop.
  35513. * @param iterations the number of iterations.
  35514. * @param fn the function to run each iteration
  35515. * @param successCallback the callback that will be called upon succesful execution
  35516. * @param offset starting offset.
  35517. * @returns the created async loop object
  35518. */
  35519. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35520. /**
  35521. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35522. * @param iterations total number of iterations
  35523. * @param syncedIterations number of synchronous iterations in each async iteration.
  35524. * @param fn the function to call each iteration.
  35525. * @param callback a success call back that will be called when iterating stops.
  35526. * @param breakFunction a break condition (optional)
  35527. * @param timeout timeout settings for the setTimeout function. default - 0.
  35528. * @returns the created async loop object
  35529. */
  35530. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35531. }
  35532. }
  35533. declare module "babylonjs/Misc/stringDictionary" {
  35534. import { Nullable } from "babylonjs/types";
  35535. /**
  35536. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35537. * The underlying implementation relies on an associative array to ensure the best performances.
  35538. * The value can be anything including 'null' but except 'undefined'
  35539. */
  35540. export class StringDictionary<T> {
  35541. /**
  35542. * This will clear this dictionary and copy the content from the 'source' one.
  35543. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35544. * @param source the dictionary to take the content from and copy to this dictionary
  35545. */
  35546. copyFrom(source: StringDictionary<T>): void;
  35547. /**
  35548. * Get a value based from its key
  35549. * @param key the given key to get the matching value from
  35550. * @return the value if found, otherwise undefined is returned
  35551. */
  35552. get(key: string): T | undefined;
  35553. /**
  35554. * Get a value from its key or add it if it doesn't exist.
  35555. * This method will ensure you that a given key/data will be present in the dictionary.
  35556. * @param key the given key to get the matching value from
  35557. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35558. * The factory will only be invoked if there's no data for the given key.
  35559. * @return the value corresponding to the key.
  35560. */
  35561. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35562. /**
  35563. * Get a value from its key if present in the dictionary otherwise add it
  35564. * @param key the key to get the value from
  35565. * @param val if there's no such key/value pair in the dictionary add it with this value
  35566. * @return the value corresponding to the key
  35567. */
  35568. getOrAdd(key: string, val: T): T;
  35569. /**
  35570. * Check if there's a given key in the dictionary
  35571. * @param key the key to check for
  35572. * @return true if the key is present, false otherwise
  35573. */
  35574. contains(key: string): boolean;
  35575. /**
  35576. * Add a new key and its corresponding value
  35577. * @param key the key to add
  35578. * @param value the value corresponding to the key
  35579. * @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
  35580. */
  35581. add(key: string, value: T): boolean;
  35582. /**
  35583. * Update a specific value associated to a key
  35584. * @param key defines the key to use
  35585. * @param value defines the value to store
  35586. * @returns true if the value was updated (or false if the key was not found)
  35587. */
  35588. set(key: string, value: T): boolean;
  35589. /**
  35590. * Get the element of the given key and remove it from the dictionary
  35591. * @param key defines the key to search
  35592. * @returns the value associated with the key or null if not found
  35593. */
  35594. getAndRemove(key: string): Nullable<T>;
  35595. /**
  35596. * Remove a key/value from the dictionary.
  35597. * @param key the key to remove
  35598. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35599. */
  35600. remove(key: string): boolean;
  35601. /**
  35602. * Clear the whole content of the dictionary
  35603. */
  35604. clear(): void;
  35605. /**
  35606. * Gets the current count
  35607. */
  35608. get count(): number;
  35609. /**
  35610. * Execute a callback on each key/val of the dictionary.
  35611. * Note that you can remove any element in this dictionary in the callback implementation
  35612. * @param callback the callback to execute on a given key/value pair
  35613. */
  35614. forEach(callback: (key: string, val: T) => void): void;
  35615. /**
  35616. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35617. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35618. * Note that you can remove any element in this dictionary in the callback implementation
  35619. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35620. * @returns the first item
  35621. */
  35622. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35623. private _count;
  35624. private _data;
  35625. }
  35626. }
  35627. declare module "babylonjs/Collisions/collisionCoordinator" {
  35628. import { Nullable } from "babylonjs/types";
  35629. import { Scene } from "babylonjs/scene";
  35630. import { Vector3 } from "babylonjs/Maths/math.vector";
  35631. import { Collider } from "babylonjs/Collisions/collider";
  35632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35633. /** @hidden */
  35634. export interface ICollisionCoordinator {
  35635. createCollider(): Collider;
  35636. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35637. init(scene: Scene): void;
  35638. }
  35639. /** @hidden */
  35640. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35641. private _scene;
  35642. private _scaledPosition;
  35643. private _scaledVelocity;
  35644. private _finalPosition;
  35645. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35646. createCollider(): Collider;
  35647. init(scene: Scene): void;
  35648. private _collideWithWorld;
  35649. }
  35650. }
  35651. declare module "babylonjs/Inputs/scene.inputManager" {
  35652. import { Nullable } from "babylonjs/types";
  35653. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35654. import { Vector2 } from "babylonjs/Maths/math.vector";
  35655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35656. import { Scene } from "babylonjs/scene";
  35657. /**
  35658. * Class used to manage all inputs for the scene.
  35659. */
  35660. export class InputManager {
  35661. /** The distance in pixel that you have to move to prevent some events */
  35662. static DragMovementThreshold: number;
  35663. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35664. static LongPressDelay: number;
  35665. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35666. static DoubleClickDelay: number;
  35667. /** If you need to check double click without raising a single click at first click, enable this flag */
  35668. static ExclusiveDoubleClickMode: boolean;
  35669. private _wheelEventName;
  35670. private _onPointerMove;
  35671. private _onPointerDown;
  35672. private _onPointerUp;
  35673. private _initClickEvent;
  35674. private _initActionManager;
  35675. private _delayedSimpleClick;
  35676. private _delayedSimpleClickTimeout;
  35677. private _previousDelayedSimpleClickTimeout;
  35678. private _meshPickProceed;
  35679. private _previousButtonPressed;
  35680. private _currentPickResult;
  35681. private _previousPickResult;
  35682. private _totalPointersPressed;
  35683. private _doubleClickOccured;
  35684. private _pointerOverMesh;
  35685. private _pickedDownMesh;
  35686. private _pickedUpMesh;
  35687. private _pointerX;
  35688. private _pointerY;
  35689. private _unTranslatedPointerX;
  35690. private _unTranslatedPointerY;
  35691. private _startingPointerPosition;
  35692. private _previousStartingPointerPosition;
  35693. private _startingPointerTime;
  35694. private _previousStartingPointerTime;
  35695. private _pointerCaptures;
  35696. private _onKeyDown;
  35697. private _onKeyUp;
  35698. private _onCanvasFocusObserver;
  35699. private _onCanvasBlurObserver;
  35700. private _scene;
  35701. /**
  35702. * Creates a new InputManager
  35703. * @param scene defines the hosting scene
  35704. */
  35705. constructor(scene: Scene);
  35706. /**
  35707. * Gets the mesh that is currently under the pointer
  35708. */
  35709. get meshUnderPointer(): Nullable<AbstractMesh>;
  35710. /**
  35711. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35712. */
  35713. get unTranslatedPointer(): Vector2;
  35714. /**
  35715. * Gets or sets the current on-screen X position of the pointer
  35716. */
  35717. get pointerX(): number;
  35718. set pointerX(value: number);
  35719. /**
  35720. * Gets or sets the current on-screen Y position of the pointer
  35721. */
  35722. get pointerY(): number;
  35723. set pointerY(value: number);
  35724. private _updatePointerPosition;
  35725. private _processPointerMove;
  35726. private _setRayOnPointerInfo;
  35727. private _checkPrePointerObservable;
  35728. /**
  35729. * Use this method to simulate a pointer move on a mesh
  35730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35733. */
  35734. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35735. /**
  35736. * Use this method to simulate a pointer down on a mesh
  35737. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35738. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35739. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35740. */
  35741. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35742. private _processPointerDown;
  35743. /** @hidden */
  35744. _isPointerSwiping(): boolean;
  35745. /**
  35746. * Use this method to simulate a pointer up on a mesh
  35747. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35748. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35749. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35750. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35751. */
  35752. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35753. private _processPointerUp;
  35754. /**
  35755. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35756. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35757. * @returns true if the pointer was captured
  35758. */
  35759. isPointerCaptured(pointerId?: number): boolean;
  35760. /**
  35761. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35762. * @param attachUp defines if you want to attach events to pointerup
  35763. * @param attachDown defines if you want to attach events to pointerdown
  35764. * @param attachMove defines if you want to attach events to pointermove
  35765. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35766. */
  35767. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35768. /**
  35769. * Detaches all event handlers
  35770. */
  35771. detachControl(): void;
  35772. /**
  35773. * Force the value of meshUnderPointer
  35774. * @param mesh defines the mesh to use
  35775. */
  35776. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35777. /**
  35778. * Gets the mesh under the pointer
  35779. * @returns a Mesh or null if no mesh is under the pointer
  35780. */
  35781. getPointerOverMesh(): Nullable<AbstractMesh>;
  35782. }
  35783. }
  35784. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35785. /**
  35786. * Helper class used to generate session unique ID
  35787. */
  35788. export class UniqueIdGenerator {
  35789. private static _UniqueIdCounter;
  35790. /**
  35791. * Gets an unique (relatively to the current scene) Id
  35792. */
  35793. static get UniqueId(): number;
  35794. }
  35795. }
  35796. declare module "babylonjs/Animations/animationGroup" {
  35797. import { Animatable } from "babylonjs/Animations/animatable";
  35798. import { Animation } from "babylonjs/Animations/animation";
  35799. import { Scene, IDisposable } from "babylonjs/scene";
  35800. import { Observable } from "babylonjs/Misc/observable";
  35801. import { Nullable } from "babylonjs/types";
  35802. import "babylonjs/Animations/animatable";
  35803. /**
  35804. * This class defines the direct association between an animation and a target
  35805. */
  35806. export class TargetedAnimation {
  35807. /**
  35808. * Animation to perform
  35809. */
  35810. animation: Animation;
  35811. /**
  35812. * Target to animate
  35813. */
  35814. target: any;
  35815. /**
  35816. * Serialize the object
  35817. * @returns the JSON object representing the current entity
  35818. */
  35819. serialize(): any;
  35820. }
  35821. /**
  35822. * Use this class to create coordinated animations on multiple targets
  35823. */
  35824. export class AnimationGroup implements IDisposable {
  35825. /** The name of the animation group */
  35826. name: string;
  35827. private _scene;
  35828. private _targetedAnimations;
  35829. private _animatables;
  35830. private _from;
  35831. private _to;
  35832. private _isStarted;
  35833. private _isPaused;
  35834. private _speedRatio;
  35835. private _loopAnimation;
  35836. /**
  35837. * Gets or sets the unique id of the node
  35838. */
  35839. uniqueId: number;
  35840. /**
  35841. * This observable will notify when one animation have ended
  35842. */
  35843. onAnimationEndObservable: Observable<TargetedAnimation>;
  35844. /**
  35845. * Observer raised when one animation loops
  35846. */
  35847. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35848. /**
  35849. * Observer raised when all animations have looped
  35850. */
  35851. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35852. /**
  35853. * This observable will notify when all animations have ended.
  35854. */
  35855. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35856. /**
  35857. * This observable will notify when all animations have paused.
  35858. */
  35859. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35860. /**
  35861. * This observable will notify when all animations are playing.
  35862. */
  35863. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35864. /**
  35865. * Gets the first frame
  35866. */
  35867. get from(): number;
  35868. /**
  35869. * Gets the last frame
  35870. */
  35871. get to(): number;
  35872. /**
  35873. * Define if the animations are started
  35874. */
  35875. get isStarted(): boolean;
  35876. /**
  35877. * Gets a value indicating that the current group is playing
  35878. */
  35879. get isPlaying(): boolean;
  35880. /**
  35881. * Gets or sets the speed ratio to use for all animations
  35882. */
  35883. get speedRatio(): number;
  35884. /**
  35885. * Gets or sets the speed ratio to use for all animations
  35886. */
  35887. set speedRatio(value: number);
  35888. /**
  35889. * Gets or sets if all animations should loop or not
  35890. */
  35891. get loopAnimation(): boolean;
  35892. set loopAnimation(value: boolean);
  35893. /**
  35894. * Gets the targeted animations for this animation group
  35895. */
  35896. get targetedAnimations(): Array<TargetedAnimation>;
  35897. /**
  35898. * returning the list of animatables controlled by this animation group.
  35899. */
  35900. get animatables(): Array<Animatable>;
  35901. /**
  35902. * Instantiates a new Animation Group.
  35903. * This helps managing several animations at once.
  35904. * @see http://doc.babylonjs.com/how_to/group
  35905. * @param name Defines the name of the group
  35906. * @param scene Defines the scene the group belongs to
  35907. */
  35908. constructor(
  35909. /** The name of the animation group */
  35910. name: string, scene?: Nullable<Scene>);
  35911. /**
  35912. * Add an animation (with its target) in the group
  35913. * @param animation defines the animation we want to add
  35914. * @param target defines the target of the animation
  35915. * @returns the TargetedAnimation object
  35916. */
  35917. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35918. /**
  35919. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35920. * It can add constant keys at begin or end
  35921. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35922. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35923. * @returns the animation group
  35924. */
  35925. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35926. private _animationLoopCount;
  35927. private _animationLoopFlags;
  35928. private _processLoop;
  35929. /**
  35930. * Start all animations on given targets
  35931. * @param loop defines if animations must loop
  35932. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35933. * @param from defines the from key (optional)
  35934. * @param to defines the to key (optional)
  35935. * @returns the current animation group
  35936. */
  35937. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35938. /**
  35939. * Pause all animations
  35940. * @returns the animation group
  35941. */
  35942. pause(): AnimationGroup;
  35943. /**
  35944. * Play all animations to initial state
  35945. * This function will start() the animations if they were not started or will restart() them if they were paused
  35946. * @param loop defines if animations must loop
  35947. * @returns the animation group
  35948. */
  35949. play(loop?: boolean): AnimationGroup;
  35950. /**
  35951. * Reset all animations to initial state
  35952. * @returns the animation group
  35953. */
  35954. reset(): AnimationGroup;
  35955. /**
  35956. * Restart animations from key 0
  35957. * @returns the animation group
  35958. */
  35959. restart(): AnimationGroup;
  35960. /**
  35961. * Stop all animations
  35962. * @returns the animation group
  35963. */
  35964. stop(): AnimationGroup;
  35965. /**
  35966. * Set animation weight for all animatables
  35967. * @param weight defines the weight to use
  35968. * @return the animationGroup
  35969. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35970. */
  35971. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35972. /**
  35973. * Synchronize and normalize all animatables with a source animatable
  35974. * @param root defines the root animatable to synchronize with
  35975. * @return the animationGroup
  35976. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35977. */
  35978. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35979. /**
  35980. * Goes to a specific frame in this animation group
  35981. * @param frame the frame number to go to
  35982. * @return the animationGroup
  35983. */
  35984. goToFrame(frame: number): AnimationGroup;
  35985. /**
  35986. * Dispose all associated resources
  35987. */
  35988. dispose(): void;
  35989. private _checkAnimationGroupEnded;
  35990. /**
  35991. * Clone the current animation group and returns a copy
  35992. * @param newName defines the name of the new group
  35993. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35994. * @returns the new aniamtion group
  35995. */
  35996. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35997. /**
  35998. * Serializes the animationGroup to an object
  35999. * @returns Serialized object
  36000. */
  36001. serialize(): any;
  36002. /**
  36003. * Returns a new AnimationGroup object parsed from the source provided.
  36004. * @param parsedAnimationGroup defines the source
  36005. * @param scene defines the scene that will receive the animationGroup
  36006. * @returns a new AnimationGroup
  36007. */
  36008. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36009. /**
  36010. * Returns the string "AnimationGroup"
  36011. * @returns "AnimationGroup"
  36012. */
  36013. getClassName(): string;
  36014. /**
  36015. * Creates a detailled string about the object
  36016. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36017. * @returns a string representing the object
  36018. */
  36019. toString(fullDetails?: boolean): string;
  36020. }
  36021. }
  36022. declare module "babylonjs/scene" {
  36023. import { Nullable } from "babylonjs/types";
  36024. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36025. import { Observable } from "babylonjs/Misc/observable";
  36026. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36027. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36028. import { Geometry } from "babylonjs/Meshes/geometry";
  36029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36030. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36032. import { Mesh } from "babylonjs/Meshes/mesh";
  36033. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36034. import { Bone } from "babylonjs/Bones/bone";
  36035. import { Skeleton } from "babylonjs/Bones/skeleton";
  36036. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36037. import { Camera } from "babylonjs/Cameras/camera";
  36038. import { AbstractScene } from "babylonjs/abstractScene";
  36039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36040. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36041. import { Material } from "babylonjs/Materials/material";
  36042. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36043. import { Effect } from "babylonjs/Materials/effect";
  36044. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36045. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36046. import { Light } from "babylonjs/Lights/light";
  36047. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36048. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36049. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36050. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36052. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36053. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36054. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36055. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36056. import { Engine } from "babylonjs/Engines/engine";
  36057. import { Node } from "babylonjs/node";
  36058. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36059. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36060. import { WebRequest } from "babylonjs/Misc/webRequest";
  36061. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36062. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36063. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36064. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36065. import { Plane } from "babylonjs/Maths/math.plane";
  36066. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36067. import { Ray } from "babylonjs/Culling/ray";
  36068. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36069. import { Animation } from "babylonjs/Animations/animation";
  36070. import { Animatable } from "babylonjs/Animations/animatable";
  36071. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36072. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36073. import { Collider } from "babylonjs/Collisions/collider";
  36074. /**
  36075. * Define an interface for all classes that will hold resources
  36076. */
  36077. export interface IDisposable {
  36078. /**
  36079. * Releases all held resources
  36080. */
  36081. dispose(): void;
  36082. }
  36083. /** Interface defining initialization parameters for Scene class */
  36084. export interface SceneOptions {
  36085. /**
  36086. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36087. * It will improve performance when the number of geometries becomes important.
  36088. */
  36089. useGeometryUniqueIdsMap?: boolean;
  36090. /**
  36091. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36092. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36093. */
  36094. useMaterialMeshMap?: boolean;
  36095. /**
  36096. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36097. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36098. */
  36099. useClonedMeshMap?: boolean;
  36100. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36101. virtual?: boolean;
  36102. }
  36103. /**
  36104. * Represents a scene to be rendered by the engine.
  36105. * @see http://doc.babylonjs.com/features/scene
  36106. */
  36107. export class Scene extends AbstractScene implements IAnimatable {
  36108. /** The fog is deactivated */
  36109. static readonly FOGMODE_NONE: number;
  36110. /** The fog density is following an exponential function */
  36111. static readonly FOGMODE_EXP: number;
  36112. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36113. static readonly FOGMODE_EXP2: number;
  36114. /** The fog density is following a linear function. */
  36115. static readonly FOGMODE_LINEAR: number;
  36116. /**
  36117. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36119. */
  36120. static MinDeltaTime: number;
  36121. /**
  36122. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36123. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36124. */
  36125. static MaxDeltaTime: number;
  36126. /**
  36127. * Factory used to create the default material.
  36128. * @param name The name of the material to create
  36129. * @param scene The scene to create the material for
  36130. * @returns The default material
  36131. */
  36132. static DefaultMaterialFactory(scene: Scene): Material;
  36133. /**
  36134. * Factory used to create the a collision coordinator.
  36135. * @returns The collision coordinator
  36136. */
  36137. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36138. /** @hidden */
  36139. _inputManager: InputManager;
  36140. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36141. cameraToUseForPointers: Nullable<Camera>;
  36142. /** @hidden */
  36143. readonly _isScene: boolean;
  36144. /** @hidden */
  36145. _blockEntityCollection: boolean;
  36146. /**
  36147. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36148. */
  36149. autoClear: boolean;
  36150. /**
  36151. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36152. */
  36153. autoClearDepthAndStencil: boolean;
  36154. /**
  36155. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36156. */
  36157. clearColor: Color4;
  36158. /**
  36159. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36160. */
  36161. ambientColor: Color3;
  36162. /**
  36163. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36164. * It should only be one of the following (if not the default embedded one):
  36165. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36166. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36167. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36168. * The material properties need to be setup according to the type of texture in use.
  36169. */
  36170. environmentBRDFTexture: BaseTexture;
  36171. /** @hidden */
  36172. protected _environmentTexture: Nullable<BaseTexture>;
  36173. /**
  36174. * Texture used in all pbr material as the reflection texture.
  36175. * As in the majority of the scene they are the same (exception for multi room and so on),
  36176. * this is easier to reference from here than from all the materials.
  36177. */
  36178. get environmentTexture(): Nullable<BaseTexture>;
  36179. /**
  36180. * Texture used in all pbr material as the reflection texture.
  36181. * As in the majority of the scene they are the same (exception for multi room and so on),
  36182. * this is easier to set here than in all the materials.
  36183. */
  36184. set environmentTexture(value: Nullable<BaseTexture>);
  36185. /** @hidden */
  36186. protected _environmentIntensity: number;
  36187. /**
  36188. * Intensity of the environment in all pbr material.
  36189. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36190. * As in the majority of the scene they are the same (exception for multi room and so on),
  36191. * this is easier to reference from here than from all the materials.
  36192. */
  36193. get environmentIntensity(): number;
  36194. /**
  36195. * Intensity of the environment in all pbr material.
  36196. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36197. * As in the majority of the scene they are the same (exception for multi room and so on),
  36198. * this is easier to set here than in all the materials.
  36199. */
  36200. set environmentIntensity(value: number);
  36201. /** @hidden */
  36202. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36203. /**
  36204. * Default image processing configuration used either in the rendering
  36205. * Forward main pass or through the imageProcessingPostProcess if present.
  36206. * As in the majority of the scene they are the same (exception for multi camera),
  36207. * this is easier to reference from here than from all the materials and post process.
  36208. *
  36209. * No setter as we it is a shared configuration, you can set the values instead.
  36210. */
  36211. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36212. private _forceWireframe;
  36213. /**
  36214. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36215. */
  36216. set forceWireframe(value: boolean);
  36217. get forceWireframe(): boolean;
  36218. private _skipFrustumClipping;
  36219. /**
  36220. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36221. */
  36222. set skipFrustumClipping(value: boolean);
  36223. get skipFrustumClipping(): boolean;
  36224. private _forcePointsCloud;
  36225. /**
  36226. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36227. */
  36228. set forcePointsCloud(value: boolean);
  36229. get forcePointsCloud(): boolean;
  36230. /**
  36231. * Gets or sets the active clipplane 1
  36232. */
  36233. clipPlane: Nullable<Plane>;
  36234. /**
  36235. * Gets or sets the active clipplane 2
  36236. */
  36237. clipPlane2: Nullable<Plane>;
  36238. /**
  36239. * Gets or sets the active clipplane 3
  36240. */
  36241. clipPlane3: Nullable<Plane>;
  36242. /**
  36243. * Gets or sets the active clipplane 4
  36244. */
  36245. clipPlane4: Nullable<Plane>;
  36246. /**
  36247. * Gets or sets the active clipplane 5
  36248. */
  36249. clipPlane5: Nullable<Plane>;
  36250. /**
  36251. * Gets or sets the active clipplane 6
  36252. */
  36253. clipPlane6: Nullable<Plane>;
  36254. /**
  36255. * Gets or sets a boolean indicating if animations are enabled
  36256. */
  36257. animationsEnabled: boolean;
  36258. private _animationPropertiesOverride;
  36259. /**
  36260. * Gets or sets the animation properties override
  36261. */
  36262. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36263. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36264. /**
  36265. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36266. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36267. */
  36268. useConstantAnimationDeltaTime: boolean;
  36269. /**
  36270. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36271. * Please note that it requires to run a ray cast through the scene on every frame
  36272. */
  36273. constantlyUpdateMeshUnderPointer: boolean;
  36274. /**
  36275. * Defines the HTML cursor to use when hovering over interactive elements
  36276. */
  36277. hoverCursor: string;
  36278. /**
  36279. * Defines the HTML default cursor to use (empty by default)
  36280. */
  36281. defaultCursor: string;
  36282. /**
  36283. * Defines whether cursors are handled by the scene.
  36284. */
  36285. doNotHandleCursors: boolean;
  36286. /**
  36287. * This is used to call preventDefault() on pointer down
  36288. * in order to block unwanted artifacts like system double clicks
  36289. */
  36290. preventDefaultOnPointerDown: boolean;
  36291. /**
  36292. * This is used to call preventDefault() on pointer up
  36293. * in order to block unwanted artifacts like system double clicks
  36294. */
  36295. preventDefaultOnPointerUp: boolean;
  36296. /**
  36297. * Gets or sets user defined metadata
  36298. */
  36299. metadata: any;
  36300. /**
  36301. * For internal use only. Please do not use.
  36302. */
  36303. reservedDataStore: any;
  36304. /**
  36305. * Gets the name of the plugin used to load this scene (null by default)
  36306. */
  36307. loadingPluginName: string;
  36308. /**
  36309. * Use this array to add regular expressions used to disable offline support for specific urls
  36310. */
  36311. disableOfflineSupportExceptionRules: RegExp[];
  36312. /**
  36313. * An event triggered when the scene is disposed.
  36314. */
  36315. onDisposeObservable: Observable<Scene>;
  36316. private _onDisposeObserver;
  36317. /** Sets a function to be executed when this scene is disposed. */
  36318. set onDispose(callback: () => void);
  36319. /**
  36320. * An event triggered before rendering the scene (right after animations and physics)
  36321. */
  36322. onBeforeRenderObservable: Observable<Scene>;
  36323. private _onBeforeRenderObserver;
  36324. /** Sets a function to be executed before rendering this scene */
  36325. set beforeRender(callback: Nullable<() => void>);
  36326. /**
  36327. * An event triggered after rendering the scene
  36328. */
  36329. onAfterRenderObservable: Observable<Scene>;
  36330. /**
  36331. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36332. */
  36333. onAfterRenderCameraObservable: Observable<Camera>;
  36334. private _onAfterRenderObserver;
  36335. /** Sets a function to be executed after rendering this scene */
  36336. set afterRender(callback: Nullable<() => void>);
  36337. /**
  36338. * An event triggered before animating the scene
  36339. */
  36340. onBeforeAnimationsObservable: Observable<Scene>;
  36341. /**
  36342. * An event triggered after animations processing
  36343. */
  36344. onAfterAnimationsObservable: Observable<Scene>;
  36345. /**
  36346. * An event triggered before draw calls are ready to be sent
  36347. */
  36348. onBeforeDrawPhaseObservable: Observable<Scene>;
  36349. /**
  36350. * An event triggered after draw calls have been sent
  36351. */
  36352. onAfterDrawPhaseObservable: Observable<Scene>;
  36353. /**
  36354. * An event triggered when the scene is ready
  36355. */
  36356. onReadyObservable: Observable<Scene>;
  36357. /**
  36358. * An event triggered before rendering a camera
  36359. */
  36360. onBeforeCameraRenderObservable: Observable<Camera>;
  36361. private _onBeforeCameraRenderObserver;
  36362. /** Sets a function to be executed before rendering a camera*/
  36363. set beforeCameraRender(callback: () => void);
  36364. /**
  36365. * An event triggered after rendering a camera
  36366. */
  36367. onAfterCameraRenderObservable: Observable<Camera>;
  36368. private _onAfterCameraRenderObserver;
  36369. /** Sets a function to be executed after rendering a camera*/
  36370. set afterCameraRender(callback: () => void);
  36371. /**
  36372. * An event triggered when active meshes evaluation is about to start
  36373. */
  36374. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36375. /**
  36376. * An event triggered when active meshes evaluation is done
  36377. */
  36378. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36379. /**
  36380. * An event triggered when particles rendering is about to start
  36381. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36382. */
  36383. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36384. /**
  36385. * An event triggered when particles rendering is done
  36386. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36387. */
  36388. onAfterParticlesRenderingObservable: Observable<Scene>;
  36389. /**
  36390. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36391. */
  36392. onDataLoadedObservable: Observable<Scene>;
  36393. /**
  36394. * An event triggered when a camera is created
  36395. */
  36396. onNewCameraAddedObservable: Observable<Camera>;
  36397. /**
  36398. * An event triggered when a camera is removed
  36399. */
  36400. onCameraRemovedObservable: Observable<Camera>;
  36401. /**
  36402. * An event triggered when a light is created
  36403. */
  36404. onNewLightAddedObservable: Observable<Light>;
  36405. /**
  36406. * An event triggered when a light is removed
  36407. */
  36408. onLightRemovedObservable: Observable<Light>;
  36409. /**
  36410. * An event triggered when a geometry is created
  36411. */
  36412. onNewGeometryAddedObservable: Observable<Geometry>;
  36413. /**
  36414. * An event triggered when a geometry is removed
  36415. */
  36416. onGeometryRemovedObservable: Observable<Geometry>;
  36417. /**
  36418. * An event triggered when a transform node is created
  36419. */
  36420. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36421. /**
  36422. * An event triggered when a transform node is removed
  36423. */
  36424. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36425. /**
  36426. * An event triggered when a mesh is created
  36427. */
  36428. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36429. /**
  36430. * An event triggered when a mesh is removed
  36431. */
  36432. onMeshRemovedObservable: Observable<AbstractMesh>;
  36433. /**
  36434. * An event triggered when a skeleton is created
  36435. */
  36436. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36437. /**
  36438. * An event triggered when a skeleton is removed
  36439. */
  36440. onSkeletonRemovedObservable: Observable<Skeleton>;
  36441. /**
  36442. * An event triggered when a material is created
  36443. */
  36444. onNewMaterialAddedObservable: Observable<Material>;
  36445. /**
  36446. * An event triggered when a material is removed
  36447. */
  36448. onMaterialRemovedObservable: Observable<Material>;
  36449. /**
  36450. * An event triggered when a texture is created
  36451. */
  36452. onNewTextureAddedObservable: Observable<BaseTexture>;
  36453. /**
  36454. * An event triggered when a texture is removed
  36455. */
  36456. onTextureRemovedObservable: Observable<BaseTexture>;
  36457. /**
  36458. * An event triggered when render targets are about to be rendered
  36459. * Can happen multiple times per frame.
  36460. */
  36461. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36462. /**
  36463. * An event triggered when render targets were rendered.
  36464. * Can happen multiple times per frame.
  36465. */
  36466. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36467. /**
  36468. * An event triggered before calculating deterministic simulation step
  36469. */
  36470. onBeforeStepObservable: Observable<Scene>;
  36471. /**
  36472. * An event triggered after calculating deterministic simulation step
  36473. */
  36474. onAfterStepObservable: Observable<Scene>;
  36475. /**
  36476. * An event triggered when the activeCamera property is updated
  36477. */
  36478. onActiveCameraChanged: Observable<Scene>;
  36479. /**
  36480. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36481. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36482. * 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)
  36483. */
  36484. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36485. /**
  36486. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36487. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36488. * 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)
  36489. */
  36490. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36491. /**
  36492. * This Observable will when a mesh has been imported into the scene.
  36493. */
  36494. onMeshImportedObservable: Observable<AbstractMesh>;
  36495. /**
  36496. * This Observable will when an animation file has been imported into the scene.
  36497. */
  36498. onAnimationFileImportedObservable: Observable<Scene>;
  36499. /**
  36500. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36501. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36502. */
  36503. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36504. /** @hidden */
  36505. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36506. /**
  36507. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36508. */
  36509. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36510. /**
  36511. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36512. */
  36513. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36514. /**
  36515. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36516. */
  36517. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36518. /** Callback called when a pointer move is detected */
  36519. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36520. /** Callback called when a pointer down is detected */
  36521. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36522. /** Callback called when a pointer up is detected */
  36523. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36524. /** Callback called when a pointer pick is detected */
  36525. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36526. /**
  36527. * 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).
  36528. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36529. */
  36530. onPrePointerObservable: Observable<PointerInfoPre>;
  36531. /**
  36532. * Observable event triggered each time an input event is received from the rendering canvas
  36533. */
  36534. onPointerObservable: Observable<PointerInfo>;
  36535. /**
  36536. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36537. */
  36538. get unTranslatedPointer(): Vector2;
  36539. /**
  36540. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36541. */
  36542. static get DragMovementThreshold(): number;
  36543. static set DragMovementThreshold(value: number);
  36544. /**
  36545. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36546. */
  36547. static get LongPressDelay(): number;
  36548. static set LongPressDelay(value: number);
  36549. /**
  36550. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36551. */
  36552. static get DoubleClickDelay(): number;
  36553. static set DoubleClickDelay(value: number);
  36554. /** If you need to check double click without raising a single click at first click, enable this flag */
  36555. static get ExclusiveDoubleClickMode(): boolean;
  36556. static set ExclusiveDoubleClickMode(value: boolean);
  36557. /** @hidden */
  36558. _mirroredCameraPosition: Nullable<Vector3>;
  36559. /**
  36560. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36561. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36562. */
  36563. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36564. /**
  36565. * Observable event triggered each time an keyboard event is received from the hosting window
  36566. */
  36567. onKeyboardObservable: Observable<KeyboardInfo>;
  36568. private _useRightHandedSystem;
  36569. /**
  36570. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36571. */
  36572. set useRightHandedSystem(value: boolean);
  36573. get useRightHandedSystem(): boolean;
  36574. private _timeAccumulator;
  36575. private _currentStepId;
  36576. private _currentInternalStep;
  36577. /**
  36578. * Sets the step Id used by deterministic lock step
  36579. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36580. * @param newStepId defines the step Id
  36581. */
  36582. setStepId(newStepId: number): void;
  36583. /**
  36584. * Gets the step Id used by deterministic lock step
  36585. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36586. * @returns the step Id
  36587. */
  36588. getStepId(): number;
  36589. /**
  36590. * Gets the internal step used by deterministic lock step
  36591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36592. * @returns the internal step
  36593. */
  36594. getInternalStep(): number;
  36595. private _fogEnabled;
  36596. /**
  36597. * Gets or sets a boolean indicating if fog is enabled on this scene
  36598. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36599. * (Default is true)
  36600. */
  36601. set fogEnabled(value: boolean);
  36602. get fogEnabled(): boolean;
  36603. private _fogMode;
  36604. /**
  36605. * Gets or sets the fog mode to use
  36606. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36607. * | mode | value |
  36608. * | --- | --- |
  36609. * | FOGMODE_NONE | 0 |
  36610. * | FOGMODE_EXP | 1 |
  36611. * | FOGMODE_EXP2 | 2 |
  36612. * | FOGMODE_LINEAR | 3 |
  36613. */
  36614. set fogMode(value: number);
  36615. get fogMode(): number;
  36616. /**
  36617. * Gets or sets the fog color to use
  36618. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36619. * (Default is Color3(0.2, 0.2, 0.3))
  36620. */
  36621. fogColor: Color3;
  36622. /**
  36623. * Gets or sets the fog density to use
  36624. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36625. * (Default is 0.1)
  36626. */
  36627. fogDensity: number;
  36628. /**
  36629. * Gets or sets the fog start distance to use
  36630. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36631. * (Default is 0)
  36632. */
  36633. fogStart: number;
  36634. /**
  36635. * Gets or sets the fog end distance to use
  36636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36637. * (Default is 1000)
  36638. */
  36639. fogEnd: number;
  36640. private _shadowsEnabled;
  36641. /**
  36642. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36643. */
  36644. set shadowsEnabled(value: boolean);
  36645. get shadowsEnabled(): boolean;
  36646. private _lightsEnabled;
  36647. /**
  36648. * Gets or sets a boolean indicating if lights are enabled on this scene
  36649. */
  36650. set lightsEnabled(value: boolean);
  36651. get lightsEnabled(): boolean;
  36652. /** All of the active cameras added to this scene. */
  36653. activeCameras: Camera[];
  36654. /** @hidden */
  36655. _activeCamera: Nullable<Camera>;
  36656. /** Gets or sets the current active camera */
  36657. get activeCamera(): Nullable<Camera>;
  36658. set activeCamera(value: Nullable<Camera>);
  36659. private _defaultMaterial;
  36660. /** The default material used on meshes when no material is affected */
  36661. get defaultMaterial(): Material;
  36662. /** The default material used on meshes when no material is affected */
  36663. set defaultMaterial(value: Material);
  36664. private _texturesEnabled;
  36665. /**
  36666. * Gets or sets a boolean indicating if textures are enabled on this scene
  36667. */
  36668. set texturesEnabled(value: boolean);
  36669. get texturesEnabled(): boolean;
  36670. /**
  36671. * Gets or sets a boolean indicating if particles are enabled on this scene
  36672. */
  36673. particlesEnabled: boolean;
  36674. /**
  36675. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36676. */
  36677. spritesEnabled: boolean;
  36678. private _skeletonsEnabled;
  36679. /**
  36680. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36681. */
  36682. set skeletonsEnabled(value: boolean);
  36683. get skeletonsEnabled(): boolean;
  36684. /**
  36685. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36686. */
  36687. lensFlaresEnabled: boolean;
  36688. /**
  36689. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36691. */
  36692. collisionsEnabled: boolean;
  36693. private _collisionCoordinator;
  36694. /** @hidden */
  36695. get collisionCoordinator(): ICollisionCoordinator;
  36696. /**
  36697. * Defines the gravity applied to this scene (used only for collisions)
  36698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36699. */
  36700. gravity: Vector3;
  36701. /**
  36702. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36703. */
  36704. postProcessesEnabled: boolean;
  36705. /**
  36706. * The list of postprocesses added to the scene
  36707. */
  36708. postProcesses: PostProcess[];
  36709. /**
  36710. * Gets the current postprocess manager
  36711. */
  36712. postProcessManager: PostProcessManager;
  36713. /**
  36714. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36715. */
  36716. renderTargetsEnabled: boolean;
  36717. /**
  36718. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36719. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36720. */
  36721. dumpNextRenderTargets: boolean;
  36722. /**
  36723. * The list of user defined render targets added to the scene
  36724. */
  36725. customRenderTargets: RenderTargetTexture[];
  36726. /**
  36727. * Defines if texture loading must be delayed
  36728. * If true, textures will only be loaded when they need to be rendered
  36729. */
  36730. useDelayedTextureLoading: boolean;
  36731. /**
  36732. * Gets the list of meshes imported to the scene through SceneLoader
  36733. */
  36734. importedMeshesFiles: String[];
  36735. /**
  36736. * Gets or sets a boolean indicating if probes are enabled on this scene
  36737. */
  36738. probesEnabled: boolean;
  36739. /**
  36740. * Gets or sets the current offline provider to use to store scene data
  36741. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36742. */
  36743. offlineProvider: IOfflineProvider;
  36744. /**
  36745. * Gets or sets the action manager associated with the scene
  36746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36747. */
  36748. actionManager: AbstractActionManager;
  36749. private _meshesForIntersections;
  36750. /**
  36751. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36752. */
  36753. proceduralTexturesEnabled: boolean;
  36754. private _engine;
  36755. private _totalVertices;
  36756. /** @hidden */
  36757. _activeIndices: PerfCounter;
  36758. /** @hidden */
  36759. _activeParticles: PerfCounter;
  36760. /** @hidden */
  36761. _activeBones: PerfCounter;
  36762. private _animationRatio;
  36763. /** @hidden */
  36764. _animationTimeLast: number;
  36765. /** @hidden */
  36766. _animationTime: number;
  36767. /**
  36768. * Gets or sets a general scale for animation speed
  36769. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36770. */
  36771. animationTimeScale: number;
  36772. /** @hidden */
  36773. _cachedMaterial: Nullable<Material>;
  36774. /** @hidden */
  36775. _cachedEffect: Nullable<Effect>;
  36776. /** @hidden */
  36777. _cachedVisibility: Nullable<number>;
  36778. private _renderId;
  36779. private _frameId;
  36780. private _executeWhenReadyTimeoutId;
  36781. private _intermediateRendering;
  36782. private _viewUpdateFlag;
  36783. private _projectionUpdateFlag;
  36784. /** @hidden */
  36785. _toBeDisposed: Nullable<IDisposable>[];
  36786. private _activeRequests;
  36787. /** @hidden */
  36788. _pendingData: any[];
  36789. private _isDisposed;
  36790. /**
  36791. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36792. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36793. */
  36794. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36795. private _activeMeshes;
  36796. private _processedMaterials;
  36797. private _renderTargets;
  36798. /** @hidden */
  36799. _activeParticleSystems: SmartArray<IParticleSystem>;
  36800. private _activeSkeletons;
  36801. private _softwareSkinnedMeshes;
  36802. private _renderingManager;
  36803. /** @hidden */
  36804. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36805. private _transformMatrix;
  36806. private _sceneUbo;
  36807. /** @hidden */
  36808. _viewMatrix: Matrix;
  36809. private _projectionMatrix;
  36810. /** @hidden */
  36811. _forcedViewPosition: Nullable<Vector3>;
  36812. /** @hidden */
  36813. _frustumPlanes: Plane[];
  36814. /**
  36815. * Gets the list of frustum planes (built from the active camera)
  36816. */
  36817. get frustumPlanes(): Plane[];
  36818. /**
  36819. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36820. * This is useful if there are more lights that the maximum simulteanous authorized
  36821. */
  36822. requireLightSorting: boolean;
  36823. /** @hidden */
  36824. readonly useMaterialMeshMap: boolean;
  36825. /** @hidden */
  36826. readonly useClonedMeshMap: boolean;
  36827. private _externalData;
  36828. private _uid;
  36829. /**
  36830. * @hidden
  36831. * Backing store of defined scene components.
  36832. */
  36833. _components: ISceneComponent[];
  36834. /**
  36835. * @hidden
  36836. * Backing store of defined scene components.
  36837. */
  36838. _serializableComponents: ISceneSerializableComponent[];
  36839. /**
  36840. * List of components to register on the next registration step.
  36841. */
  36842. private _transientComponents;
  36843. /**
  36844. * Registers the transient components if needed.
  36845. */
  36846. private _registerTransientComponents;
  36847. /**
  36848. * @hidden
  36849. * Add a component to the scene.
  36850. * Note that the ccomponent could be registered on th next frame if this is called after
  36851. * the register component stage.
  36852. * @param component Defines the component to add to the scene
  36853. */
  36854. _addComponent(component: ISceneComponent): void;
  36855. /**
  36856. * @hidden
  36857. * Gets a component from the scene.
  36858. * @param name defines the name of the component to retrieve
  36859. * @returns the component or null if not present
  36860. */
  36861. _getComponent(name: string): Nullable<ISceneComponent>;
  36862. /**
  36863. * @hidden
  36864. * Defines the actions happening before camera updates.
  36865. */
  36866. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36867. /**
  36868. * @hidden
  36869. * Defines the actions happening before clear the canvas.
  36870. */
  36871. _beforeClearStage: Stage<SimpleStageAction>;
  36872. /**
  36873. * @hidden
  36874. * Defines the actions when collecting render targets for the frame.
  36875. */
  36876. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36877. /**
  36878. * @hidden
  36879. * Defines the actions happening for one camera in the frame.
  36880. */
  36881. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36882. /**
  36883. * @hidden
  36884. * Defines the actions happening during the per mesh ready checks.
  36885. */
  36886. _isReadyForMeshStage: Stage<MeshStageAction>;
  36887. /**
  36888. * @hidden
  36889. * Defines the actions happening before evaluate active mesh checks.
  36890. */
  36891. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36892. /**
  36893. * @hidden
  36894. * Defines the actions happening during the evaluate sub mesh checks.
  36895. */
  36896. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36897. /**
  36898. * @hidden
  36899. * Defines the actions happening during the active mesh stage.
  36900. */
  36901. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36902. /**
  36903. * @hidden
  36904. * Defines the actions happening during the per camera render target step.
  36905. */
  36906. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36907. /**
  36908. * @hidden
  36909. * Defines the actions happening just before the active camera is drawing.
  36910. */
  36911. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36912. /**
  36913. * @hidden
  36914. * Defines the actions happening just before a render target is drawing.
  36915. */
  36916. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36917. /**
  36918. * @hidden
  36919. * Defines the actions happening just before a rendering group is drawing.
  36920. */
  36921. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36922. /**
  36923. * @hidden
  36924. * Defines the actions happening just before a mesh is drawing.
  36925. */
  36926. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36927. /**
  36928. * @hidden
  36929. * Defines the actions happening just after a mesh has been drawn.
  36930. */
  36931. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36932. /**
  36933. * @hidden
  36934. * Defines the actions happening just after a rendering group has been drawn.
  36935. */
  36936. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36937. /**
  36938. * @hidden
  36939. * Defines the actions happening just after the active camera has been drawn.
  36940. */
  36941. _afterCameraDrawStage: Stage<CameraStageAction>;
  36942. /**
  36943. * @hidden
  36944. * Defines the actions happening just after a render target has been drawn.
  36945. */
  36946. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36947. /**
  36948. * @hidden
  36949. * Defines the actions happening just after rendering all cameras and computing intersections.
  36950. */
  36951. _afterRenderStage: Stage<SimpleStageAction>;
  36952. /**
  36953. * @hidden
  36954. * Defines the actions happening when a pointer move event happens.
  36955. */
  36956. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36957. /**
  36958. * @hidden
  36959. * Defines the actions happening when a pointer down event happens.
  36960. */
  36961. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36962. /**
  36963. * @hidden
  36964. * Defines the actions happening when a pointer up event happens.
  36965. */
  36966. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36967. /**
  36968. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36969. */
  36970. private geometriesByUniqueId;
  36971. /**
  36972. * Creates a new Scene
  36973. * @param engine defines the engine to use to render this scene
  36974. * @param options defines the scene options
  36975. */
  36976. constructor(engine: Engine, options?: SceneOptions);
  36977. /**
  36978. * Gets a string idenfifying the name of the class
  36979. * @returns "Scene" string
  36980. */
  36981. getClassName(): string;
  36982. private _defaultMeshCandidates;
  36983. /**
  36984. * @hidden
  36985. */
  36986. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36987. private _defaultSubMeshCandidates;
  36988. /**
  36989. * @hidden
  36990. */
  36991. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36992. /**
  36993. * Sets the default candidate providers for the scene.
  36994. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36995. * and getCollidingSubMeshCandidates to their default function
  36996. */
  36997. setDefaultCandidateProviders(): void;
  36998. /**
  36999. * Gets the mesh that is currently under the pointer
  37000. */
  37001. get meshUnderPointer(): Nullable<AbstractMesh>;
  37002. /**
  37003. * Gets or sets the current on-screen X position of the pointer
  37004. */
  37005. get pointerX(): number;
  37006. set pointerX(value: number);
  37007. /**
  37008. * Gets or sets the current on-screen Y position of the pointer
  37009. */
  37010. get pointerY(): number;
  37011. set pointerY(value: number);
  37012. /**
  37013. * Gets the cached material (ie. the latest rendered one)
  37014. * @returns the cached material
  37015. */
  37016. getCachedMaterial(): Nullable<Material>;
  37017. /**
  37018. * Gets the cached effect (ie. the latest rendered one)
  37019. * @returns the cached effect
  37020. */
  37021. getCachedEffect(): Nullable<Effect>;
  37022. /**
  37023. * Gets the cached visibility state (ie. the latest rendered one)
  37024. * @returns the cached visibility state
  37025. */
  37026. getCachedVisibility(): Nullable<number>;
  37027. /**
  37028. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37029. * @param material defines the current material
  37030. * @param effect defines the current effect
  37031. * @param visibility defines the current visibility state
  37032. * @returns true if one parameter is not cached
  37033. */
  37034. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37035. /**
  37036. * Gets the engine associated with the scene
  37037. * @returns an Engine
  37038. */
  37039. getEngine(): Engine;
  37040. /**
  37041. * Gets the total number of vertices rendered per frame
  37042. * @returns the total number of vertices rendered per frame
  37043. */
  37044. getTotalVertices(): number;
  37045. /**
  37046. * Gets the performance counter for total vertices
  37047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37048. */
  37049. get totalVerticesPerfCounter(): PerfCounter;
  37050. /**
  37051. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37052. * @returns the total number of active indices rendered per frame
  37053. */
  37054. getActiveIndices(): number;
  37055. /**
  37056. * Gets the performance counter for active indices
  37057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37058. */
  37059. get totalActiveIndicesPerfCounter(): PerfCounter;
  37060. /**
  37061. * Gets the total number of active particles rendered per frame
  37062. * @returns the total number of active particles rendered per frame
  37063. */
  37064. getActiveParticles(): number;
  37065. /**
  37066. * Gets the performance counter for active particles
  37067. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37068. */
  37069. get activeParticlesPerfCounter(): PerfCounter;
  37070. /**
  37071. * Gets the total number of active bones rendered per frame
  37072. * @returns the total number of active bones rendered per frame
  37073. */
  37074. getActiveBones(): number;
  37075. /**
  37076. * Gets the performance counter for active bones
  37077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37078. */
  37079. get activeBonesPerfCounter(): PerfCounter;
  37080. /**
  37081. * Gets the array of active meshes
  37082. * @returns an array of AbstractMesh
  37083. */
  37084. getActiveMeshes(): SmartArray<AbstractMesh>;
  37085. /**
  37086. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37087. * @returns a number
  37088. */
  37089. getAnimationRatio(): number;
  37090. /**
  37091. * Gets an unique Id for the current render phase
  37092. * @returns a number
  37093. */
  37094. getRenderId(): number;
  37095. /**
  37096. * Gets an unique Id for the current frame
  37097. * @returns a number
  37098. */
  37099. getFrameId(): number;
  37100. /** Call this function if you want to manually increment the render Id*/
  37101. incrementRenderId(): void;
  37102. private _createUbo;
  37103. /**
  37104. * Use this method to simulate a pointer move on a mesh
  37105. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37106. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37107. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37108. * @returns the current scene
  37109. */
  37110. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37111. /**
  37112. * Use this method to simulate a pointer down on a mesh
  37113. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37114. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37115. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37116. * @returns the current scene
  37117. */
  37118. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37119. /**
  37120. * Use this method to simulate a pointer up on a mesh
  37121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37124. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37125. * @returns the current scene
  37126. */
  37127. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37128. /**
  37129. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37130. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37131. * @returns true if the pointer was captured
  37132. */
  37133. isPointerCaptured(pointerId?: number): boolean;
  37134. /**
  37135. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37136. * @param attachUp defines if you want to attach events to pointerup
  37137. * @param attachDown defines if you want to attach events to pointerdown
  37138. * @param attachMove defines if you want to attach events to pointermove
  37139. */
  37140. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37141. /** Detaches all event handlers*/
  37142. detachControl(): void;
  37143. /**
  37144. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37145. * Delay loaded resources are not taking in account
  37146. * @return true if all required resources are ready
  37147. */
  37148. isReady(): boolean;
  37149. /** Resets all cached information relative to material (including effect and visibility) */
  37150. resetCachedMaterial(): void;
  37151. /**
  37152. * Registers a function to be called before every frame render
  37153. * @param func defines the function to register
  37154. */
  37155. registerBeforeRender(func: () => void): void;
  37156. /**
  37157. * Unregisters a function called before every frame render
  37158. * @param func defines the function to unregister
  37159. */
  37160. unregisterBeforeRender(func: () => void): void;
  37161. /**
  37162. * Registers a function to be called after every frame render
  37163. * @param func defines the function to register
  37164. */
  37165. registerAfterRender(func: () => void): void;
  37166. /**
  37167. * Unregisters a function called after every frame render
  37168. * @param func defines the function to unregister
  37169. */
  37170. unregisterAfterRender(func: () => void): void;
  37171. private _executeOnceBeforeRender;
  37172. /**
  37173. * The provided function will run before render once and will be disposed afterwards.
  37174. * A timeout delay can be provided so that the function will be executed in N ms.
  37175. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37176. * @param func The function to be executed.
  37177. * @param timeout optional delay in ms
  37178. */
  37179. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37180. /** @hidden */
  37181. _addPendingData(data: any): void;
  37182. /** @hidden */
  37183. _removePendingData(data: any): void;
  37184. /**
  37185. * Returns the number of items waiting to be loaded
  37186. * @returns the number of items waiting to be loaded
  37187. */
  37188. getWaitingItemsCount(): number;
  37189. /**
  37190. * Returns a boolean indicating if the scene is still loading data
  37191. */
  37192. get isLoading(): boolean;
  37193. /**
  37194. * Registers a function to be executed when the scene is ready
  37195. * @param {Function} func - the function to be executed
  37196. */
  37197. executeWhenReady(func: () => void): void;
  37198. /**
  37199. * Returns a promise that resolves when the scene is ready
  37200. * @returns A promise that resolves when the scene is ready
  37201. */
  37202. whenReadyAsync(): Promise<void>;
  37203. /** @hidden */
  37204. _checkIsReady(): void;
  37205. /**
  37206. * Gets all animatable attached to the scene
  37207. */
  37208. get animatables(): Animatable[];
  37209. /**
  37210. * Resets the last animation time frame.
  37211. * Useful to override when animations start running when loading a scene for the first time.
  37212. */
  37213. resetLastAnimationTimeFrame(): void;
  37214. /**
  37215. * Gets the current view matrix
  37216. * @returns a Matrix
  37217. */
  37218. getViewMatrix(): Matrix;
  37219. /**
  37220. * Gets the current projection matrix
  37221. * @returns a Matrix
  37222. */
  37223. getProjectionMatrix(): Matrix;
  37224. /**
  37225. * Gets the current transform matrix
  37226. * @returns a Matrix made of View * Projection
  37227. */
  37228. getTransformMatrix(): Matrix;
  37229. /**
  37230. * Sets the current transform matrix
  37231. * @param viewL defines the View matrix to use
  37232. * @param projectionL defines the Projection matrix to use
  37233. * @param viewR defines the right View matrix to use (if provided)
  37234. * @param projectionR defines the right Projection matrix to use (if provided)
  37235. */
  37236. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37237. /**
  37238. * Gets the uniform buffer used to store scene data
  37239. * @returns a UniformBuffer
  37240. */
  37241. getSceneUniformBuffer(): UniformBuffer;
  37242. /**
  37243. * Gets an unique (relatively to the current scene) Id
  37244. * @returns an unique number for the scene
  37245. */
  37246. getUniqueId(): number;
  37247. /**
  37248. * Add a mesh to the list of scene's meshes
  37249. * @param newMesh defines the mesh to add
  37250. * @param recursive if all child meshes should also be added to the scene
  37251. */
  37252. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37253. /**
  37254. * Remove a mesh for the list of scene's meshes
  37255. * @param toRemove defines the mesh to remove
  37256. * @param recursive if all child meshes should also be removed from the scene
  37257. * @returns the index where the mesh was in the mesh list
  37258. */
  37259. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37260. /**
  37261. * Add a transform node to the list of scene's transform nodes
  37262. * @param newTransformNode defines the transform node to add
  37263. */
  37264. addTransformNode(newTransformNode: TransformNode): void;
  37265. /**
  37266. * Remove a transform node for the list of scene's transform nodes
  37267. * @param toRemove defines the transform node to remove
  37268. * @returns the index where the transform node was in the transform node list
  37269. */
  37270. removeTransformNode(toRemove: TransformNode): number;
  37271. /**
  37272. * Remove a skeleton for the list of scene's skeletons
  37273. * @param toRemove defines the skeleton to remove
  37274. * @returns the index where the skeleton was in the skeleton list
  37275. */
  37276. removeSkeleton(toRemove: Skeleton): number;
  37277. /**
  37278. * Remove a morph target for the list of scene's morph targets
  37279. * @param toRemove defines the morph target to remove
  37280. * @returns the index where the morph target was in the morph target list
  37281. */
  37282. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37283. /**
  37284. * Remove a light for the list of scene's lights
  37285. * @param toRemove defines the light to remove
  37286. * @returns the index where the light was in the light list
  37287. */
  37288. removeLight(toRemove: Light): number;
  37289. /**
  37290. * Remove a camera for the list of scene's cameras
  37291. * @param toRemove defines the camera to remove
  37292. * @returns the index where the camera was in the camera list
  37293. */
  37294. removeCamera(toRemove: Camera): number;
  37295. /**
  37296. * Remove a particle system for the list of scene's particle systems
  37297. * @param toRemove defines the particle system to remove
  37298. * @returns the index where the particle system was in the particle system list
  37299. */
  37300. removeParticleSystem(toRemove: IParticleSystem): number;
  37301. /**
  37302. * Remove a animation for the list of scene's animations
  37303. * @param toRemove defines the animation to remove
  37304. * @returns the index where the animation was in the animation list
  37305. */
  37306. removeAnimation(toRemove: Animation): number;
  37307. /**
  37308. * Will stop the animation of the given target
  37309. * @param target - the target
  37310. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37311. * @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)
  37312. */
  37313. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37314. /**
  37315. * Removes the given animation group from this scene.
  37316. * @param toRemove The animation group to remove
  37317. * @returns The index of the removed animation group
  37318. */
  37319. removeAnimationGroup(toRemove: AnimationGroup): number;
  37320. /**
  37321. * Removes the given multi-material from this scene.
  37322. * @param toRemove The multi-material to remove
  37323. * @returns The index of the removed multi-material
  37324. */
  37325. removeMultiMaterial(toRemove: MultiMaterial): number;
  37326. /**
  37327. * Removes the given material from this scene.
  37328. * @param toRemove The material to remove
  37329. * @returns The index of the removed material
  37330. */
  37331. removeMaterial(toRemove: Material): number;
  37332. /**
  37333. * Removes the given action manager from this scene.
  37334. * @param toRemove The action manager to remove
  37335. * @returns The index of the removed action manager
  37336. */
  37337. removeActionManager(toRemove: AbstractActionManager): number;
  37338. /**
  37339. * Removes the given texture from this scene.
  37340. * @param toRemove The texture to remove
  37341. * @returns The index of the removed texture
  37342. */
  37343. removeTexture(toRemove: BaseTexture): number;
  37344. /**
  37345. * Adds the given light to this scene
  37346. * @param newLight The light to add
  37347. */
  37348. addLight(newLight: Light): void;
  37349. /**
  37350. * Sorts the list list based on light priorities
  37351. */
  37352. sortLightsByPriority(): void;
  37353. /**
  37354. * Adds the given camera to this scene
  37355. * @param newCamera The camera to add
  37356. */
  37357. addCamera(newCamera: Camera): void;
  37358. /**
  37359. * Adds the given skeleton to this scene
  37360. * @param newSkeleton The skeleton to add
  37361. */
  37362. addSkeleton(newSkeleton: Skeleton): void;
  37363. /**
  37364. * Adds the given particle system to this scene
  37365. * @param newParticleSystem The particle system to add
  37366. */
  37367. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37368. /**
  37369. * Adds the given animation to this scene
  37370. * @param newAnimation The animation to add
  37371. */
  37372. addAnimation(newAnimation: Animation): void;
  37373. /**
  37374. * Adds the given animation group to this scene.
  37375. * @param newAnimationGroup The animation group to add
  37376. */
  37377. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37378. /**
  37379. * Adds the given multi-material to this scene
  37380. * @param newMultiMaterial The multi-material to add
  37381. */
  37382. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37383. /**
  37384. * Adds the given material to this scene
  37385. * @param newMaterial The material to add
  37386. */
  37387. addMaterial(newMaterial: Material): void;
  37388. /**
  37389. * Adds the given morph target to this scene
  37390. * @param newMorphTargetManager The morph target to add
  37391. */
  37392. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37393. /**
  37394. * Adds the given geometry to this scene
  37395. * @param newGeometry The geometry to add
  37396. */
  37397. addGeometry(newGeometry: Geometry): void;
  37398. /**
  37399. * Adds the given action manager to this scene
  37400. * @param newActionManager The action manager to add
  37401. */
  37402. addActionManager(newActionManager: AbstractActionManager): void;
  37403. /**
  37404. * Adds the given texture to this scene.
  37405. * @param newTexture The texture to add
  37406. */
  37407. addTexture(newTexture: BaseTexture): void;
  37408. /**
  37409. * Switch active camera
  37410. * @param newCamera defines the new active camera
  37411. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37412. */
  37413. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37414. /**
  37415. * sets the active camera of the scene using its ID
  37416. * @param id defines the camera's ID
  37417. * @return the new active camera or null if none found.
  37418. */
  37419. setActiveCameraByID(id: string): Nullable<Camera>;
  37420. /**
  37421. * sets the active camera of the scene using its name
  37422. * @param name defines the camera's name
  37423. * @returns the new active camera or null if none found.
  37424. */
  37425. setActiveCameraByName(name: string): Nullable<Camera>;
  37426. /**
  37427. * get an animation group using its name
  37428. * @param name defines the material's name
  37429. * @return the animation group or null if none found.
  37430. */
  37431. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37432. /**
  37433. * Get a material using its unique id
  37434. * @param uniqueId defines the material's unique id
  37435. * @return the material or null if none found.
  37436. */
  37437. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37438. /**
  37439. * get a material using its id
  37440. * @param id defines the material's ID
  37441. * @return the material or null if none found.
  37442. */
  37443. getMaterialByID(id: string): Nullable<Material>;
  37444. /**
  37445. * Gets a the last added material using a given id
  37446. * @param id defines the material's ID
  37447. * @return the last material with the given id or null if none found.
  37448. */
  37449. getLastMaterialByID(id: string): Nullable<Material>;
  37450. /**
  37451. * Gets a material using its name
  37452. * @param name defines the material's name
  37453. * @return the material or null if none found.
  37454. */
  37455. getMaterialByName(name: string): Nullable<Material>;
  37456. /**
  37457. * Get a texture using its unique id
  37458. * @param uniqueId defines the texture's unique id
  37459. * @return the texture or null if none found.
  37460. */
  37461. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37462. /**
  37463. * Gets a camera using its id
  37464. * @param id defines the id to look for
  37465. * @returns the camera or null if not found
  37466. */
  37467. getCameraByID(id: string): Nullable<Camera>;
  37468. /**
  37469. * Gets a camera using its unique id
  37470. * @param uniqueId defines the unique id to look for
  37471. * @returns the camera or null if not found
  37472. */
  37473. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37474. /**
  37475. * Gets a camera using its name
  37476. * @param name defines the camera's name
  37477. * @return the camera or null if none found.
  37478. */
  37479. getCameraByName(name: string): Nullable<Camera>;
  37480. /**
  37481. * Gets a bone using its id
  37482. * @param id defines the bone's id
  37483. * @return the bone or null if not found
  37484. */
  37485. getBoneByID(id: string): Nullable<Bone>;
  37486. /**
  37487. * Gets a bone using its id
  37488. * @param name defines the bone's name
  37489. * @return the bone or null if not found
  37490. */
  37491. getBoneByName(name: string): Nullable<Bone>;
  37492. /**
  37493. * Gets a light node using its name
  37494. * @param name defines the the light's name
  37495. * @return the light or null if none found.
  37496. */
  37497. getLightByName(name: string): Nullable<Light>;
  37498. /**
  37499. * Gets a light node using its id
  37500. * @param id defines the light's id
  37501. * @return the light or null if none found.
  37502. */
  37503. getLightByID(id: string): Nullable<Light>;
  37504. /**
  37505. * Gets a light node using its scene-generated unique ID
  37506. * @param uniqueId defines the light's unique id
  37507. * @return the light or null if none found.
  37508. */
  37509. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37510. /**
  37511. * Gets a particle system by id
  37512. * @param id defines the particle system id
  37513. * @return the corresponding system or null if none found
  37514. */
  37515. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37516. /**
  37517. * Gets a geometry using its ID
  37518. * @param id defines the geometry's id
  37519. * @return the geometry or null if none found.
  37520. */
  37521. getGeometryByID(id: string): Nullable<Geometry>;
  37522. private _getGeometryByUniqueID;
  37523. /**
  37524. * Add a new geometry to this scene
  37525. * @param geometry defines the geometry to be added to the scene.
  37526. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37527. * @return a boolean defining if the geometry was added or not
  37528. */
  37529. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37530. /**
  37531. * Removes an existing geometry
  37532. * @param geometry defines the geometry to be removed from the scene
  37533. * @return a boolean defining if the geometry was removed or not
  37534. */
  37535. removeGeometry(geometry: Geometry): boolean;
  37536. /**
  37537. * Gets the list of geometries attached to the scene
  37538. * @returns an array of Geometry
  37539. */
  37540. getGeometries(): Geometry[];
  37541. /**
  37542. * Gets the first added mesh found of a given ID
  37543. * @param id defines the id to search for
  37544. * @return the mesh found or null if not found at all
  37545. */
  37546. getMeshByID(id: string): Nullable<AbstractMesh>;
  37547. /**
  37548. * Gets a list of meshes using their id
  37549. * @param id defines the id to search for
  37550. * @returns a list of meshes
  37551. */
  37552. getMeshesByID(id: string): Array<AbstractMesh>;
  37553. /**
  37554. * Gets the first added transform node found of a given ID
  37555. * @param id defines the id to search for
  37556. * @return the found transform node or null if not found at all.
  37557. */
  37558. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37559. /**
  37560. * Gets a transform node with its auto-generated unique id
  37561. * @param uniqueId efines the unique id to search for
  37562. * @return the found transform node or null if not found at all.
  37563. */
  37564. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37565. /**
  37566. * Gets a list of transform nodes using their id
  37567. * @param id defines the id to search for
  37568. * @returns a list of transform nodes
  37569. */
  37570. getTransformNodesByID(id: string): Array<TransformNode>;
  37571. /**
  37572. * Gets a mesh with its auto-generated unique id
  37573. * @param uniqueId defines the unique id to search for
  37574. * @return the found mesh or null if not found at all.
  37575. */
  37576. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37577. /**
  37578. * Gets a the last added mesh using a given id
  37579. * @param id defines the id to search for
  37580. * @return the found mesh or null if not found at all.
  37581. */
  37582. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37583. /**
  37584. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37585. * @param id defines the id to search for
  37586. * @return the found node or null if not found at all
  37587. */
  37588. getLastEntryByID(id: string): Nullable<Node>;
  37589. /**
  37590. * Gets a node (Mesh, Camera, Light) using a given id
  37591. * @param id defines the id to search for
  37592. * @return the found node or null if not found at all
  37593. */
  37594. getNodeByID(id: string): Nullable<Node>;
  37595. /**
  37596. * Gets a node (Mesh, Camera, Light) using a given name
  37597. * @param name defines the name to search for
  37598. * @return the found node or null if not found at all.
  37599. */
  37600. getNodeByName(name: string): Nullable<Node>;
  37601. /**
  37602. * Gets a mesh using a given name
  37603. * @param name defines the name to search for
  37604. * @return the found mesh or null if not found at all.
  37605. */
  37606. getMeshByName(name: string): Nullable<AbstractMesh>;
  37607. /**
  37608. * Gets a transform node using a given name
  37609. * @param name defines the name to search for
  37610. * @return the found transform node or null if not found at all.
  37611. */
  37612. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37613. /**
  37614. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37615. * @param id defines the id to search for
  37616. * @return the found skeleton or null if not found at all.
  37617. */
  37618. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37619. /**
  37620. * Gets a skeleton using a given auto generated unique id
  37621. * @param uniqueId defines the unique id to search for
  37622. * @return the found skeleton or null if not found at all.
  37623. */
  37624. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37625. /**
  37626. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37627. * @param id defines the id to search for
  37628. * @return the found skeleton or null if not found at all.
  37629. */
  37630. getSkeletonById(id: string): Nullable<Skeleton>;
  37631. /**
  37632. * Gets a skeleton using a given name
  37633. * @param name defines the name to search for
  37634. * @return the found skeleton or null if not found at all.
  37635. */
  37636. getSkeletonByName(name: string): Nullable<Skeleton>;
  37637. /**
  37638. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37639. * @param id defines the id to search for
  37640. * @return the found morph target manager or null if not found at all.
  37641. */
  37642. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37643. /**
  37644. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37645. * @param id defines the id to search for
  37646. * @return the found morph target or null if not found at all.
  37647. */
  37648. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37649. /**
  37650. * Gets a boolean indicating if the given mesh is active
  37651. * @param mesh defines the mesh to look for
  37652. * @returns true if the mesh is in the active list
  37653. */
  37654. isActiveMesh(mesh: AbstractMesh): boolean;
  37655. /**
  37656. * Return a unique id as a string which can serve as an identifier for the scene
  37657. */
  37658. get uid(): string;
  37659. /**
  37660. * Add an externaly attached data from its key.
  37661. * This method call will fail and return false, if such key already exists.
  37662. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37663. * @param key the unique key that identifies the data
  37664. * @param data the data object to associate to the key for this Engine instance
  37665. * @return true if no such key were already present and the data was added successfully, false otherwise
  37666. */
  37667. addExternalData<T>(key: string, data: T): boolean;
  37668. /**
  37669. * Get an externaly attached data from its key
  37670. * @param key the unique key that identifies the data
  37671. * @return the associated data, if present (can be null), or undefined if not present
  37672. */
  37673. getExternalData<T>(key: string): Nullable<T>;
  37674. /**
  37675. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37676. * @param key the unique key that identifies the data
  37677. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37678. * @return the associated data, can be null if the factory returned null.
  37679. */
  37680. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37681. /**
  37682. * Remove an externaly attached data from the Engine instance
  37683. * @param key the unique key that identifies the data
  37684. * @return true if the data was successfully removed, false if it doesn't exist
  37685. */
  37686. removeExternalData(key: string): boolean;
  37687. private _evaluateSubMesh;
  37688. /**
  37689. * Clear the processed materials smart array preventing retention point in material dispose.
  37690. */
  37691. freeProcessedMaterials(): void;
  37692. private _preventFreeActiveMeshesAndRenderingGroups;
  37693. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37694. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37695. * when disposing several meshes in a row or a hierarchy of meshes.
  37696. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37697. */
  37698. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37699. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37700. /**
  37701. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37702. */
  37703. freeActiveMeshes(): void;
  37704. /**
  37705. * Clear the info related to rendering groups preventing retention points during dispose.
  37706. */
  37707. freeRenderingGroups(): void;
  37708. /** @hidden */
  37709. _isInIntermediateRendering(): boolean;
  37710. /**
  37711. * Lambda returning the list of potentially active meshes.
  37712. */
  37713. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37714. /**
  37715. * Lambda returning the list of potentially active sub meshes.
  37716. */
  37717. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37718. /**
  37719. * Lambda returning the list of potentially intersecting sub meshes.
  37720. */
  37721. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37722. /**
  37723. * Lambda returning the list of potentially colliding sub meshes.
  37724. */
  37725. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37726. private _activeMeshesFrozen;
  37727. private _skipEvaluateActiveMeshesCompletely;
  37728. /**
  37729. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37730. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37731. * @returns the current scene
  37732. */
  37733. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37734. /**
  37735. * Use this function to restart evaluating active meshes on every frame
  37736. * @returns the current scene
  37737. */
  37738. unfreezeActiveMeshes(): Scene;
  37739. private _evaluateActiveMeshes;
  37740. private _activeMesh;
  37741. /**
  37742. * Update the transform matrix to update from the current active camera
  37743. * @param force defines a boolean used to force the update even if cache is up to date
  37744. */
  37745. updateTransformMatrix(force?: boolean): void;
  37746. private _bindFrameBuffer;
  37747. /** @hidden */
  37748. _allowPostProcessClearColor: boolean;
  37749. /** @hidden */
  37750. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37751. private _processSubCameras;
  37752. private _checkIntersections;
  37753. /** @hidden */
  37754. _advancePhysicsEngineStep(step: number): void;
  37755. /**
  37756. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37757. */
  37758. getDeterministicFrameTime: () => number;
  37759. /** @hidden */
  37760. _animate(): void;
  37761. /** Execute all animations (for a frame) */
  37762. animate(): void;
  37763. /**
  37764. * Render the scene
  37765. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37766. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37767. */
  37768. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37769. /**
  37770. * Freeze all materials
  37771. * A frozen material will not be updatable but should be faster to render
  37772. */
  37773. freezeMaterials(): void;
  37774. /**
  37775. * Unfreeze all materials
  37776. * A frozen material will not be updatable but should be faster to render
  37777. */
  37778. unfreezeMaterials(): void;
  37779. /**
  37780. * Releases all held ressources
  37781. */
  37782. dispose(): void;
  37783. /**
  37784. * Gets if the scene is already disposed
  37785. */
  37786. get isDisposed(): boolean;
  37787. /**
  37788. * Call this function to reduce memory footprint of the scene.
  37789. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37790. */
  37791. clearCachedVertexData(): void;
  37792. /**
  37793. * This function will remove the local cached buffer data from texture.
  37794. * It will save memory but will prevent the texture from being rebuilt
  37795. */
  37796. cleanCachedTextureBuffer(): void;
  37797. /**
  37798. * Get the world extend vectors with an optional filter
  37799. *
  37800. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37801. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37802. */
  37803. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37804. min: Vector3;
  37805. max: Vector3;
  37806. };
  37807. /**
  37808. * Creates a ray that can be used to pick in the scene
  37809. * @param x defines the x coordinate of the origin (on-screen)
  37810. * @param y defines the y coordinate of the origin (on-screen)
  37811. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37812. * @param camera defines the camera to use for the picking
  37813. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37814. * @returns a Ray
  37815. */
  37816. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37817. /**
  37818. * Creates a ray that can be used to pick in the scene
  37819. * @param x defines the x coordinate of the origin (on-screen)
  37820. * @param y defines the y coordinate of the origin (on-screen)
  37821. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37822. * @param result defines the ray where to store the picking ray
  37823. * @param camera defines the camera to use for the picking
  37824. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37825. * @returns the current scene
  37826. */
  37827. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37828. /**
  37829. * Creates a ray that can be used to pick in the scene
  37830. * @param x defines the x coordinate of the origin (on-screen)
  37831. * @param y defines the y coordinate of the origin (on-screen)
  37832. * @param camera defines the camera to use for the picking
  37833. * @returns a Ray
  37834. */
  37835. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37836. /**
  37837. * Creates a ray that can be used to pick in the scene
  37838. * @param x defines the x coordinate of the origin (on-screen)
  37839. * @param y defines the y coordinate of the origin (on-screen)
  37840. * @param result defines the ray where to store the picking ray
  37841. * @param camera defines the camera to use for the picking
  37842. * @returns the current scene
  37843. */
  37844. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37845. /** Launch a ray to try to pick a mesh in the scene
  37846. * @param x position on screen
  37847. * @param y position on screen
  37848. * @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
  37849. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37850. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37851. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37852. * @returns a PickingInfo
  37853. */
  37854. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37855. /** Use the given ray to pick a mesh in the scene
  37856. * @param ray The ray to use to pick meshes
  37857. * @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
  37858. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37859. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37860. * @returns a PickingInfo
  37861. */
  37862. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37863. /**
  37864. * Launch a ray to try to pick a mesh in the scene
  37865. * @param x X position on screen
  37866. * @param y Y position on screen
  37867. * @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
  37868. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37870. * @returns an array of PickingInfo
  37871. */
  37872. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37873. /**
  37874. * Launch a ray to try to pick a mesh in the scene
  37875. * @param ray Ray to use
  37876. * @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
  37877. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37878. * @returns an array of PickingInfo
  37879. */
  37880. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37881. /**
  37882. * Force the value of meshUnderPointer
  37883. * @param mesh defines the mesh to use
  37884. */
  37885. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37886. /**
  37887. * Gets the mesh under the pointer
  37888. * @returns a Mesh or null if no mesh is under the pointer
  37889. */
  37890. getPointerOverMesh(): Nullable<AbstractMesh>;
  37891. /** @hidden */
  37892. _rebuildGeometries(): void;
  37893. /** @hidden */
  37894. _rebuildTextures(): void;
  37895. private _getByTags;
  37896. /**
  37897. * Get a list of meshes by tags
  37898. * @param tagsQuery defines the tags query to use
  37899. * @param forEach defines a predicate used to filter results
  37900. * @returns an array of Mesh
  37901. */
  37902. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37903. /**
  37904. * Get a list of cameras by tags
  37905. * @param tagsQuery defines the tags query to use
  37906. * @param forEach defines a predicate used to filter results
  37907. * @returns an array of Camera
  37908. */
  37909. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37910. /**
  37911. * Get a list of lights by tags
  37912. * @param tagsQuery defines the tags query to use
  37913. * @param forEach defines a predicate used to filter results
  37914. * @returns an array of Light
  37915. */
  37916. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37917. /**
  37918. * Get a list of materials by tags
  37919. * @param tagsQuery defines the tags query to use
  37920. * @param forEach defines a predicate used to filter results
  37921. * @returns an array of Material
  37922. */
  37923. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37924. /**
  37925. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37926. * This allowed control for front to back rendering or reversly depending of the special needs.
  37927. *
  37928. * @param renderingGroupId The rendering group id corresponding to its index
  37929. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37930. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37931. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37932. */
  37933. 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;
  37934. /**
  37935. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37936. *
  37937. * @param renderingGroupId The rendering group id corresponding to its index
  37938. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37939. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37940. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37941. */
  37942. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37943. /**
  37944. * Gets the current auto clear configuration for one rendering group of the rendering
  37945. * manager.
  37946. * @param index the rendering group index to get the information for
  37947. * @returns The auto clear setup for the requested rendering group
  37948. */
  37949. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37950. private _blockMaterialDirtyMechanism;
  37951. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37952. get blockMaterialDirtyMechanism(): boolean;
  37953. set blockMaterialDirtyMechanism(value: boolean);
  37954. /**
  37955. * Will flag all materials as dirty to trigger new shader compilation
  37956. * @param flag defines the flag used to specify which material part must be marked as dirty
  37957. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37958. */
  37959. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37960. /** @hidden */
  37961. _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;
  37962. /** @hidden */
  37963. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37964. /** @hidden */
  37965. _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;
  37966. /** @hidden */
  37967. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37968. /** @hidden */
  37969. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37970. /** @hidden */
  37971. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37972. }
  37973. }
  37974. declare module "babylonjs/assetContainer" {
  37975. import { AbstractScene } from "babylonjs/abstractScene";
  37976. import { Scene } from "babylonjs/scene";
  37977. import { Mesh } from "babylonjs/Meshes/mesh";
  37978. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37979. import { Skeleton } from "babylonjs/Bones/skeleton";
  37980. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37981. import { Animatable } from "babylonjs/Animations/animatable";
  37982. import { Nullable } from "babylonjs/types";
  37983. import { Node } from "babylonjs/node";
  37984. /**
  37985. * Set of assets to keep when moving a scene into an asset container.
  37986. */
  37987. export class KeepAssets extends AbstractScene {
  37988. }
  37989. /**
  37990. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37991. */
  37992. export class InstantiatedEntries {
  37993. /**
  37994. * List of new root nodes (eg. nodes with no parent)
  37995. */
  37996. rootNodes: TransformNode[];
  37997. /**
  37998. * List of new skeletons
  37999. */
  38000. skeletons: Skeleton[];
  38001. /**
  38002. * List of new animation groups
  38003. */
  38004. animationGroups: AnimationGroup[];
  38005. }
  38006. /**
  38007. * Container with a set of assets that can be added or removed from a scene.
  38008. */
  38009. export class AssetContainer extends AbstractScene {
  38010. private _wasAddedToScene;
  38011. /**
  38012. * The scene the AssetContainer belongs to.
  38013. */
  38014. scene: Scene;
  38015. /**
  38016. * Instantiates an AssetContainer.
  38017. * @param scene The scene the AssetContainer belongs to.
  38018. */
  38019. constructor(scene: Scene);
  38020. /**
  38021. * Instantiate or clone all meshes and add the new ones to the scene.
  38022. * Skeletons and animation groups will all be cloned
  38023. * @param nameFunction defines an optional function used to get new names for clones
  38024. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38025. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38026. */
  38027. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38028. /**
  38029. * Adds all the assets from the container to the scene.
  38030. */
  38031. addAllToScene(): void;
  38032. /**
  38033. * Removes all the assets in the container from the scene
  38034. */
  38035. removeAllFromScene(): void;
  38036. /**
  38037. * Disposes all the assets in the container
  38038. */
  38039. dispose(): void;
  38040. private _moveAssets;
  38041. /**
  38042. * Removes all the assets contained in the scene and adds them to the container.
  38043. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38044. */
  38045. moveAllFromScene(keepAssets?: KeepAssets): void;
  38046. /**
  38047. * 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.
  38048. * @returns the root mesh
  38049. */
  38050. createRootMesh(): Mesh;
  38051. /**
  38052. * Merge animations from this asset container into a scene
  38053. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38054. * @param animatables set of animatables to retarget to a node from the scene
  38055. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38056. */
  38057. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38058. }
  38059. }
  38060. declare module "babylonjs/abstractScene" {
  38061. import { Scene } from "babylonjs/scene";
  38062. import { Nullable } from "babylonjs/types";
  38063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38064. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38065. import { Geometry } from "babylonjs/Meshes/geometry";
  38066. import { Skeleton } from "babylonjs/Bones/skeleton";
  38067. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38068. import { AssetContainer } from "babylonjs/assetContainer";
  38069. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38070. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38072. import { Material } from "babylonjs/Materials/material";
  38073. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38074. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38075. import { Camera } from "babylonjs/Cameras/camera";
  38076. import { Light } from "babylonjs/Lights/light";
  38077. import { Node } from "babylonjs/node";
  38078. import { Animation } from "babylonjs/Animations/animation";
  38079. /**
  38080. * Defines how the parser contract is defined.
  38081. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38082. */
  38083. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38084. /**
  38085. * Defines how the individual parser contract is defined.
  38086. * These parser can parse an individual asset
  38087. */
  38088. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38089. /**
  38090. * Base class of the scene acting as a container for the different elements composing a scene.
  38091. * This class is dynamically extended by the different components of the scene increasing
  38092. * flexibility and reducing coupling
  38093. */
  38094. export abstract class AbstractScene {
  38095. /**
  38096. * Stores the list of available parsers in the application.
  38097. */
  38098. private static _BabylonFileParsers;
  38099. /**
  38100. * Stores the list of available individual parsers in the application.
  38101. */
  38102. private static _IndividualBabylonFileParsers;
  38103. /**
  38104. * Adds a parser in the list of available ones
  38105. * @param name Defines the name of the parser
  38106. * @param parser Defines the parser to add
  38107. */
  38108. static AddParser(name: string, parser: BabylonFileParser): void;
  38109. /**
  38110. * Gets a general parser from the list of avaialble ones
  38111. * @param name Defines the name of the parser
  38112. * @returns the requested parser or null
  38113. */
  38114. static GetParser(name: string): Nullable<BabylonFileParser>;
  38115. /**
  38116. * Adds n individual parser in the list of available ones
  38117. * @param name Defines the name of the parser
  38118. * @param parser Defines the parser to add
  38119. */
  38120. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38121. /**
  38122. * Gets an individual parser from the list of avaialble ones
  38123. * @param name Defines the name of the parser
  38124. * @returns the requested parser or null
  38125. */
  38126. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38127. /**
  38128. * Parser json data and populate both a scene and its associated container object
  38129. * @param jsonData Defines the data to parse
  38130. * @param scene Defines the scene to parse the data for
  38131. * @param container Defines the container attached to the parsing sequence
  38132. * @param rootUrl Defines the root url of the data
  38133. */
  38134. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38135. /**
  38136. * Gets the list of root nodes (ie. nodes with no parent)
  38137. */
  38138. rootNodes: Node[];
  38139. /** All of the cameras added to this scene
  38140. * @see http://doc.babylonjs.com/babylon101/cameras
  38141. */
  38142. cameras: Camera[];
  38143. /**
  38144. * All of the lights added to this scene
  38145. * @see http://doc.babylonjs.com/babylon101/lights
  38146. */
  38147. lights: Light[];
  38148. /**
  38149. * All of the (abstract) meshes added to this scene
  38150. */
  38151. meshes: AbstractMesh[];
  38152. /**
  38153. * The list of skeletons added to the scene
  38154. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38155. */
  38156. skeletons: Skeleton[];
  38157. /**
  38158. * All of the particle systems added to this scene
  38159. * @see http://doc.babylonjs.com/babylon101/particles
  38160. */
  38161. particleSystems: IParticleSystem[];
  38162. /**
  38163. * Gets a list of Animations associated with the scene
  38164. */
  38165. animations: Animation[];
  38166. /**
  38167. * All of the animation groups added to this scene
  38168. * @see http://doc.babylonjs.com/how_to/group
  38169. */
  38170. animationGroups: AnimationGroup[];
  38171. /**
  38172. * All of the multi-materials added to this scene
  38173. * @see http://doc.babylonjs.com/how_to/multi_materials
  38174. */
  38175. multiMaterials: MultiMaterial[];
  38176. /**
  38177. * All of the materials added to this scene
  38178. * In the context of a Scene, it is not supposed to be modified manually.
  38179. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38180. * Note also that the order of the Material within the array is not significant and might change.
  38181. * @see http://doc.babylonjs.com/babylon101/materials
  38182. */
  38183. materials: Material[];
  38184. /**
  38185. * The list of morph target managers added to the scene
  38186. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38187. */
  38188. morphTargetManagers: MorphTargetManager[];
  38189. /**
  38190. * The list of geometries used in the scene.
  38191. */
  38192. geometries: Geometry[];
  38193. /**
  38194. * All of the tranform nodes added to this scene
  38195. * In the context of a Scene, it is not supposed to be modified manually.
  38196. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38197. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38198. * @see http://doc.babylonjs.com/how_to/transformnode
  38199. */
  38200. transformNodes: TransformNode[];
  38201. /**
  38202. * ActionManagers available on the scene.
  38203. */
  38204. actionManagers: AbstractActionManager[];
  38205. /**
  38206. * Textures to keep.
  38207. */
  38208. textures: BaseTexture[];
  38209. /**
  38210. * Environment texture for the scene
  38211. */
  38212. environmentTexture: Nullable<BaseTexture>;
  38213. /**
  38214. * @returns all meshes, lights, cameras, transformNodes and bones
  38215. */
  38216. getNodes(): Array<Node>;
  38217. }
  38218. }
  38219. declare module "babylonjs/Audio/sound" {
  38220. import { Observable } from "babylonjs/Misc/observable";
  38221. import { Vector3 } from "babylonjs/Maths/math.vector";
  38222. import { Nullable } from "babylonjs/types";
  38223. import { Scene } from "babylonjs/scene";
  38224. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38225. /**
  38226. * Interface used to define options for Sound class
  38227. */
  38228. export interface ISoundOptions {
  38229. /**
  38230. * Does the sound autoplay once loaded.
  38231. */
  38232. autoplay?: boolean;
  38233. /**
  38234. * Does the sound loop after it finishes playing once.
  38235. */
  38236. loop?: boolean;
  38237. /**
  38238. * Sound's volume
  38239. */
  38240. volume?: number;
  38241. /**
  38242. * Is it a spatial sound?
  38243. */
  38244. spatialSound?: boolean;
  38245. /**
  38246. * Maximum distance to hear that sound
  38247. */
  38248. maxDistance?: number;
  38249. /**
  38250. * Uses user defined attenuation function
  38251. */
  38252. useCustomAttenuation?: boolean;
  38253. /**
  38254. * Define the roll off factor of spatial sounds.
  38255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38256. */
  38257. rolloffFactor?: number;
  38258. /**
  38259. * Define the reference distance the sound should be heard perfectly.
  38260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38261. */
  38262. refDistance?: number;
  38263. /**
  38264. * Define the distance attenuation model the sound will follow.
  38265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38266. */
  38267. distanceModel?: string;
  38268. /**
  38269. * Defines the playback speed (1 by default)
  38270. */
  38271. playbackRate?: number;
  38272. /**
  38273. * Defines if the sound is from a streaming source
  38274. */
  38275. streaming?: boolean;
  38276. /**
  38277. * Defines an optional length (in seconds) inside the sound file
  38278. */
  38279. length?: number;
  38280. /**
  38281. * Defines an optional offset (in seconds) inside the sound file
  38282. */
  38283. offset?: number;
  38284. /**
  38285. * If true, URLs will not be required to state the audio file codec to use.
  38286. */
  38287. skipCodecCheck?: boolean;
  38288. }
  38289. /**
  38290. * Defines a sound that can be played in the application.
  38291. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38293. */
  38294. export class Sound {
  38295. /**
  38296. * The name of the sound in the scene.
  38297. */
  38298. name: string;
  38299. /**
  38300. * Does the sound autoplay once loaded.
  38301. */
  38302. autoplay: boolean;
  38303. /**
  38304. * Does the sound loop after it finishes playing once.
  38305. */
  38306. loop: boolean;
  38307. /**
  38308. * Does the sound use a custom attenuation curve to simulate the falloff
  38309. * happening when the source gets further away from the camera.
  38310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38311. */
  38312. useCustomAttenuation: boolean;
  38313. /**
  38314. * The sound track id this sound belongs to.
  38315. */
  38316. soundTrackId: number;
  38317. /**
  38318. * Is this sound currently played.
  38319. */
  38320. isPlaying: boolean;
  38321. /**
  38322. * Is this sound currently paused.
  38323. */
  38324. isPaused: boolean;
  38325. /**
  38326. * Does this sound enables spatial sound.
  38327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38328. */
  38329. spatialSound: boolean;
  38330. /**
  38331. * Define the reference distance the sound should be heard perfectly.
  38332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38333. */
  38334. refDistance: number;
  38335. /**
  38336. * Define the roll off factor of spatial sounds.
  38337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38338. */
  38339. rolloffFactor: number;
  38340. /**
  38341. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38343. */
  38344. maxDistance: number;
  38345. /**
  38346. * Define the distance attenuation model the sound will follow.
  38347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38348. */
  38349. distanceModel: string;
  38350. /**
  38351. * @hidden
  38352. * Back Compat
  38353. **/
  38354. onended: () => any;
  38355. /**
  38356. * Observable event when the current playing sound finishes.
  38357. */
  38358. onEndedObservable: Observable<Sound>;
  38359. private _panningModel;
  38360. private _playbackRate;
  38361. private _streaming;
  38362. private _startTime;
  38363. private _startOffset;
  38364. private _position;
  38365. /** @hidden */
  38366. _positionInEmitterSpace: boolean;
  38367. private _localDirection;
  38368. private _volume;
  38369. private _isReadyToPlay;
  38370. private _isDirectional;
  38371. private _readyToPlayCallback;
  38372. private _audioBuffer;
  38373. private _soundSource;
  38374. private _streamingSource;
  38375. private _soundPanner;
  38376. private _soundGain;
  38377. private _inputAudioNode;
  38378. private _outputAudioNode;
  38379. private _coneInnerAngle;
  38380. private _coneOuterAngle;
  38381. private _coneOuterGain;
  38382. private _scene;
  38383. private _connectedTransformNode;
  38384. private _customAttenuationFunction;
  38385. private _registerFunc;
  38386. private _isOutputConnected;
  38387. private _htmlAudioElement;
  38388. private _urlType;
  38389. private _length?;
  38390. private _offset?;
  38391. /** @hidden */
  38392. static _SceneComponentInitialization: (scene: Scene) => void;
  38393. /**
  38394. * Create a sound and attach it to a scene
  38395. * @param name Name of your sound
  38396. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38397. * @param scene defines the scene the sound belongs to
  38398. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38399. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38400. */
  38401. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38402. /**
  38403. * Release the sound and its associated resources
  38404. */
  38405. dispose(): void;
  38406. /**
  38407. * Gets if the sounds is ready to be played or not.
  38408. * @returns true if ready, otherwise false
  38409. */
  38410. isReady(): boolean;
  38411. private _soundLoaded;
  38412. /**
  38413. * Sets the data of the sound from an audiobuffer
  38414. * @param audioBuffer The audioBuffer containing the data
  38415. */
  38416. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38417. /**
  38418. * Updates the current sounds options such as maxdistance, loop...
  38419. * @param options A JSON object containing values named as the object properties
  38420. */
  38421. updateOptions(options: ISoundOptions): void;
  38422. private _createSpatialParameters;
  38423. private _updateSpatialParameters;
  38424. /**
  38425. * Switch the panning model to HRTF:
  38426. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38428. */
  38429. switchPanningModelToHRTF(): void;
  38430. /**
  38431. * Switch the panning model to Equal Power:
  38432. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38434. */
  38435. switchPanningModelToEqualPower(): void;
  38436. private _switchPanningModel;
  38437. /**
  38438. * Connect this sound to a sound track audio node like gain...
  38439. * @param soundTrackAudioNode the sound track audio node to connect to
  38440. */
  38441. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38442. /**
  38443. * Transform this sound into a directional source
  38444. * @param coneInnerAngle Size of the inner cone in degree
  38445. * @param coneOuterAngle Size of the outer cone in degree
  38446. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38447. */
  38448. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38449. /**
  38450. * Gets or sets the inner angle for the directional cone.
  38451. */
  38452. get directionalConeInnerAngle(): number;
  38453. /**
  38454. * Gets or sets the inner angle for the directional cone.
  38455. */
  38456. set directionalConeInnerAngle(value: number);
  38457. /**
  38458. * Gets or sets the outer angle for the directional cone.
  38459. */
  38460. get directionalConeOuterAngle(): number;
  38461. /**
  38462. * Gets or sets the outer angle for the directional cone.
  38463. */
  38464. set directionalConeOuterAngle(value: number);
  38465. /**
  38466. * Sets the position of the emitter if spatial sound is enabled
  38467. * @param newPosition Defines the new posisiton
  38468. */
  38469. setPosition(newPosition: Vector3): void;
  38470. /**
  38471. * Sets the local direction of the emitter if spatial sound is enabled
  38472. * @param newLocalDirection Defines the new local direction
  38473. */
  38474. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38475. private _updateDirection;
  38476. /** @hidden */
  38477. updateDistanceFromListener(): void;
  38478. /**
  38479. * Sets a new custom attenuation function for the sound.
  38480. * @param callback Defines the function used for the attenuation
  38481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38482. */
  38483. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38484. /**
  38485. * Play the sound
  38486. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38487. * @param offset (optional) Start the sound at a specific time in seconds
  38488. * @param length (optional) Sound duration (in seconds)
  38489. */
  38490. play(time?: number, offset?: number, length?: number): void;
  38491. private _onended;
  38492. /**
  38493. * Stop the sound
  38494. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38495. */
  38496. stop(time?: number): void;
  38497. /**
  38498. * Put the sound in pause
  38499. */
  38500. pause(): void;
  38501. /**
  38502. * Sets a dedicated volume for this sounds
  38503. * @param newVolume Define the new volume of the sound
  38504. * @param time Define time for gradual change to new volume
  38505. */
  38506. setVolume(newVolume: number, time?: number): void;
  38507. /**
  38508. * Set the sound play back rate
  38509. * @param newPlaybackRate Define the playback rate the sound should be played at
  38510. */
  38511. setPlaybackRate(newPlaybackRate: number): void;
  38512. /**
  38513. * Gets the volume of the sound.
  38514. * @returns the volume of the sound
  38515. */
  38516. getVolume(): number;
  38517. /**
  38518. * Attach the sound to a dedicated mesh
  38519. * @param transformNode The transform node to connect the sound with
  38520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38521. */
  38522. attachToMesh(transformNode: TransformNode): void;
  38523. /**
  38524. * Detach the sound from the previously attached mesh
  38525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38526. */
  38527. detachFromMesh(): void;
  38528. private _onRegisterAfterWorldMatrixUpdate;
  38529. /**
  38530. * Clone the current sound in the scene.
  38531. * @returns the new sound clone
  38532. */
  38533. clone(): Nullable<Sound>;
  38534. /**
  38535. * Gets the current underlying audio buffer containing the data
  38536. * @returns the audio buffer
  38537. */
  38538. getAudioBuffer(): Nullable<AudioBuffer>;
  38539. /**
  38540. * Serializes the Sound in a JSON representation
  38541. * @returns the JSON representation of the sound
  38542. */
  38543. serialize(): any;
  38544. /**
  38545. * Parse a JSON representation of a sound to innstantiate in a given scene
  38546. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38547. * @param scene Define the scene the new parsed sound should be created in
  38548. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38549. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38550. * @returns the newly parsed sound
  38551. */
  38552. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38553. }
  38554. }
  38555. declare module "babylonjs/Actions/directAudioActions" {
  38556. import { Action } from "babylonjs/Actions/action";
  38557. import { Condition } from "babylonjs/Actions/condition";
  38558. import { Sound } from "babylonjs/Audio/sound";
  38559. /**
  38560. * This defines an action helpful to play a defined sound on a triggered action.
  38561. */
  38562. export class PlaySoundAction extends Action {
  38563. private _sound;
  38564. /**
  38565. * Instantiate the action
  38566. * @param triggerOptions defines the trigger options
  38567. * @param sound defines the sound to play
  38568. * @param condition defines the trigger related conditions
  38569. */
  38570. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38571. /** @hidden */
  38572. _prepare(): void;
  38573. /**
  38574. * Execute the action and play the sound.
  38575. */
  38576. execute(): void;
  38577. /**
  38578. * Serializes the actions and its related information.
  38579. * @param parent defines the object to serialize in
  38580. * @returns the serialized object
  38581. */
  38582. serialize(parent: any): any;
  38583. }
  38584. /**
  38585. * This defines an action helpful to stop a defined sound on a triggered action.
  38586. */
  38587. export class StopSoundAction extends Action {
  38588. private _sound;
  38589. /**
  38590. * Instantiate the action
  38591. * @param triggerOptions defines the trigger options
  38592. * @param sound defines the sound to stop
  38593. * @param condition defines the trigger related conditions
  38594. */
  38595. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38596. /** @hidden */
  38597. _prepare(): void;
  38598. /**
  38599. * Execute the action and stop the sound.
  38600. */
  38601. execute(): void;
  38602. /**
  38603. * Serializes the actions and its related information.
  38604. * @param parent defines the object to serialize in
  38605. * @returns the serialized object
  38606. */
  38607. serialize(parent: any): any;
  38608. }
  38609. }
  38610. declare module "babylonjs/Actions/interpolateValueAction" {
  38611. import { Action } from "babylonjs/Actions/action";
  38612. import { Condition } from "babylonjs/Actions/condition";
  38613. import { Observable } from "babylonjs/Misc/observable";
  38614. /**
  38615. * This defines an action responsible to change the value of a property
  38616. * by interpolating between its current value and the newly set one once triggered.
  38617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38618. */
  38619. export class InterpolateValueAction extends Action {
  38620. /**
  38621. * Defines the path of the property where the value should be interpolated
  38622. */
  38623. propertyPath: string;
  38624. /**
  38625. * Defines the target value at the end of the interpolation.
  38626. */
  38627. value: any;
  38628. /**
  38629. * Defines the time it will take for the property to interpolate to the value.
  38630. */
  38631. duration: number;
  38632. /**
  38633. * Defines if the other scene animations should be stopped when the action has been triggered
  38634. */
  38635. stopOtherAnimations?: boolean;
  38636. /**
  38637. * Defines a callback raised once the interpolation animation has been done.
  38638. */
  38639. onInterpolationDone?: () => void;
  38640. /**
  38641. * Observable triggered once the interpolation animation has been done.
  38642. */
  38643. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38644. private _target;
  38645. private _effectiveTarget;
  38646. private _property;
  38647. /**
  38648. * Instantiate the action
  38649. * @param triggerOptions defines the trigger options
  38650. * @param target defines the object containing the value to interpolate
  38651. * @param propertyPath defines the path to the property in the target object
  38652. * @param value defines the target value at the end of the interpolation
  38653. * @param duration deines the time it will take for the property to interpolate to the value.
  38654. * @param condition defines the trigger related conditions
  38655. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38656. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38657. */
  38658. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38659. /** @hidden */
  38660. _prepare(): void;
  38661. /**
  38662. * Execute the action starts the value interpolation.
  38663. */
  38664. execute(): void;
  38665. /**
  38666. * Serializes the actions and its related information.
  38667. * @param parent defines the object to serialize in
  38668. * @returns the serialized object
  38669. */
  38670. serialize(parent: any): any;
  38671. }
  38672. }
  38673. declare module "babylonjs/Actions/index" {
  38674. export * from "babylonjs/Actions/abstractActionManager";
  38675. export * from "babylonjs/Actions/action";
  38676. export * from "babylonjs/Actions/actionEvent";
  38677. export * from "babylonjs/Actions/actionManager";
  38678. export * from "babylonjs/Actions/condition";
  38679. export * from "babylonjs/Actions/directActions";
  38680. export * from "babylonjs/Actions/directAudioActions";
  38681. export * from "babylonjs/Actions/interpolateValueAction";
  38682. }
  38683. declare module "babylonjs/Animations/index" {
  38684. export * from "babylonjs/Animations/animatable";
  38685. export * from "babylonjs/Animations/animation";
  38686. export * from "babylonjs/Animations/animationGroup";
  38687. export * from "babylonjs/Animations/animationPropertiesOverride";
  38688. export * from "babylonjs/Animations/easing";
  38689. export * from "babylonjs/Animations/runtimeAnimation";
  38690. export * from "babylonjs/Animations/animationEvent";
  38691. export * from "babylonjs/Animations/animationGroup";
  38692. export * from "babylonjs/Animations/animationKey";
  38693. export * from "babylonjs/Animations/animationRange";
  38694. export * from "babylonjs/Animations/animatable.interface";
  38695. }
  38696. declare module "babylonjs/Audio/soundTrack" {
  38697. import { Sound } from "babylonjs/Audio/sound";
  38698. import { Analyser } from "babylonjs/Audio/analyser";
  38699. import { Scene } from "babylonjs/scene";
  38700. /**
  38701. * Options allowed during the creation of a sound track.
  38702. */
  38703. export interface ISoundTrackOptions {
  38704. /**
  38705. * The volume the sound track should take during creation
  38706. */
  38707. volume?: number;
  38708. /**
  38709. * Define if the sound track is the main sound track of the scene
  38710. */
  38711. mainTrack?: boolean;
  38712. }
  38713. /**
  38714. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38715. * It will be also used in a future release to apply effects on a specific track.
  38716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38717. */
  38718. export class SoundTrack {
  38719. /**
  38720. * The unique identifier of the sound track in the scene.
  38721. */
  38722. id: number;
  38723. /**
  38724. * The list of sounds included in the sound track.
  38725. */
  38726. soundCollection: Array<Sound>;
  38727. private _outputAudioNode;
  38728. private _scene;
  38729. private _connectedAnalyser;
  38730. private _options;
  38731. private _isInitialized;
  38732. /**
  38733. * Creates a new sound track.
  38734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38735. * @param scene Define the scene the sound track belongs to
  38736. * @param options
  38737. */
  38738. constructor(scene: Scene, options?: ISoundTrackOptions);
  38739. private _initializeSoundTrackAudioGraph;
  38740. /**
  38741. * Release the sound track and its associated resources
  38742. */
  38743. dispose(): void;
  38744. /**
  38745. * Adds a sound to this sound track
  38746. * @param sound define the cound to add
  38747. * @ignoreNaming
  38748. */
  38749. AddSound(sound: Sound): void;
  38750. /**
  38751. * Removes a sound to this sound track
  38752. * @param sound define the cound to remove
  38753. * @ignoreNaming
  38754. */
  38755. RemoveSound(sound: Sound): void;
  38756. /**
  38757. * Set a global volume for the full sound track.
  38758. * @param newVolume Define the new volume of the sound track
  38759. */
  38760. setVolume(newVolume: number): void;
  38761. /**
  38762. * Switch the panning model to HRTF:
  38763. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38765. */
  38766. switchPanningModelToHRTF(): void;
  38767. /**
  38768. * Switch the panning model to Equal Power:
  38769. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38771. */
  38772. switchPanningModelToEqualPower(): void;
  38773. /**
  38774. * Connect the sound track to an audio analyser allowing some amazing
  38775. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38777. * @param analyser The analyser to connect to the engine
  38778. */
  38779. connectToAnalyser(analyser: Analyser): void;
  38780. }
  38781. }
  38782. declare module "babylonjs/Audio/audioSceneComponent" {
  38783. import { Sound } from "babylonjs/Audio/sound";
  38784. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38785. import { Nullable } from "babylonjs/types";
  38786. import { Vector3 } from "babylonjs/Maths/math.vector";
  38787. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38788. import { Scene } from "babylonjs/scene";
  38789. import { AbstractScene } from "babylonjs/abstractScene";
  38790. import "babylonjs/Audio/audioEngine";
  38791. module "babylonjs/abstractScene" {
  38792. interface AbstractScene {
  38793. /**
  38794. * The list of sounds used in the scene.
  38795. */
  38796. sounds: Nullable<Array<Sound>>;
  38797. }
  38798. }
  38799. module "babylonjs/scene" {
  38800. interface Scene {
  38801. /**
  38802. * @hidden
  38803. * Backing field
  38804. */
  38805. _mainSoundTrack: SoundTrack;
  38806. /**
  38807. * The main sound track played by the scene.
  38808. * It cotains your primary collection of sounds.
  38809. */
  38810. mainSoundTrack: SoundTrack;
  38811. /**
  38812. * The list of sound tracks added to the scene
  38813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38814. */
  38815. soundTracks: Nullable<Array<SoundTrack>>;
  38816. /**
  38817. * Gets a sound using a given name
  38818. * @param name defines the name to search for
  38819. * @return the found sound or null if not found at all.
  38820. */
  38821. getSoundByName(name: string): Nullable<Sound>;
  38822. /**
  38823. * Gets or sets if audio support is enabled
  38824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38825. */
  38826. audioEnabled: boolean;
  38827. /**
  38828. * Gets or sets if audio will be output to headphones
  38829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38830. */
  38831. headphone: boolean;
  38832. /**
  38833. * Gets or sets custom audio listener position provider
  38834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38835. */
  38836. audioListenerPositionProvider: Nullable<() => Vector3>;
  38837. /**
  38838. * Gets or sets a refresh rate when using 3D audio positioning
  38839. */
  38840. audioPositioningRefreshRate: number;
  38841. }
  38842. }
  38843. /**
  38844. * Defines the sound scene component responsible to manage any sounds
  38845. * in a given scene.
  38846. */
  38847. export class AudioSceneComponent implements ISceneSerializableComponent {
  38848. /**
  38849. * The component name helpfull to identify the component in the list of scene components.
  38850. */
  38851. readonly name: string;
  38852. /**
  38853. * The scene the component belongs to.
  38854. */
  38855. scene: Scene;
  38856. private _audioEnabled;
  38857. /**
  38858. * Gets whether audio is enabled or not.
  38859. * Please use related enable/disable method to switch state.
  38860. */
  38861. get audioEnabled(): boolean;
  38862. private _headphone;
  38863. /**
  38864. * Gets whether audio is outputing to headphone or not.
  38865. * Please use the according Switch methods to change output.
  38866. */
  38867. get headphone(): boolean;
  38868. /**
  38869. * Gets or sets a refresh rate when using 3D audio positioning
  38870. */
  38871. audioPositioningRefreshRate: number;
  38872. private _audioListenerPositionProvider;
  38873. /**
  38874. * Gets the current audio listener position provider
  38875. */
  38876. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38877. /**
  38878. * Sets a custom listener position for all sounds in the scene
  38879. * By default, this is the position of the first active camera
  38880. */
  38881. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38882. /**
  38883. * Creates a new instance of the component for the given scene
  38884. * @param scene Defines the scene to register the component in
  38885. */
  38886. constructor(scene: Scene);
  38887. /**
  38888. * Registers the component in a given scene
  38889. */
  38890. register(): void;
  38891. /**
  38892. * Rebuilds the elements related to this component in case of
  38893. * context lost for instance.
  38894. */
  38895. rebuild(): void;
  38896. /**
  38897. * Serializes the component data to the specified json object
  38898. * @param serializationObject The object to serialize to
  38899. */
  38900. serialize(serializationObject: any): void;
  38901. /**
  38902. * Adds all the elements from the container to the scene
  38903. * @param container the container holding the elements
  38904. */
  38905. addFromContainer(container: AbstractScene): void;
  38906. /**
  38907. * Removes all the elements in the container from the scene
  38908. * @param container contains the elements to remove
  38909. * @param dispose if the removed element should be disposed (default: false)
  38910. */
  38911. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38912. /**
  38913. * Disposes the component and the associated ressources.
  38914. */
  38915. dispose(): void;
  38916. /**
  38917. * Disables audio in the associated scene.
  38918. */
  38919. disableAudio(): void;
  38920. /**
  38921. * Enables audio in the associated scene.
  38922. */
  38923. enableAudio(): void;
  38924. /**
  38925. * Switch audio to headphone output.
  38926. */
  38927. switchAudioModeForHeadphones(): void;
  38928. /**
  38929. * Switch audio to normal speakers.
  38930. */
  38931. switchAudioModeForNormalSpeakers(): void;
  38932. private _cachedCameraDirection;
  38933. private _cachedCameraPosition;
  38934. private _lastCheck;
  38935. private _afterRender;
  38936. }
  38937. }
  38938. declare module "babylonjs/Audio/weightedsound" {
  38939. import { Sound } from "babylonjs/Audio/sound";
  38940. /**
  38941. * Wraps one or more Sound objects and selects one with random weight for playback.
  38942. */
  38943. export class WeightedSound {
  38944. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38945. loop: boolean;
  38946. private _coneInnerAngle;
  38947. private _coneOuterAngle;
  38948. private _volume;
  38949. /** A Sound is currently playing. */
  38950. isPlaying: boolean;
  38951. /** A Sound is currently paused. */
  38952. isPaused: boolean;
  38953. private _sounds;
  38954. private _weights;
  38955. private _currentIndex?;
  38956. /**
  38957. * Creates a new WeightedSound from the list of sounds given.
  38958. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38959. * @param sounds Array of Sounds that will be selected from.
  38960. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38961. */
  38962. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38963. /**
  38964. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38965. */
  38966. get directionalConeInnerAngle(): number;
  38967. /**
  38968. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38969. */
  38970. set directionalConeInnerAngle(value: number);
  38971. /**
  38972. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38973. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38974. */
  38975. get directionalConeOuterAngle(): number;
  38976. /**
  38977. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38978. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38979. */
  38980. set directionalConeOuterAngle(value: number);
  38981. /**
  38982. * Playback volume.
  38983. */
  38984. get volume(): number;
  38985. /**
  38986. * Playback volume.
  38987. */
  38988. set volume(value: number);
  38989. private _onended;
  38990. /**
  38991. * Suspend playback
  38992. */
  38993. pause(): void;
  38994. /**
  38995. * Stop playback
  38996. */
  38997. stop(): void;
  38998. /**
  38999. * Start playback.
  39000. * @param startOffset Position the clip head at a specific time in seconds.
  39001. */
  39002. play(startOffset?: number): void;
  39003. }
  39004. }
  39005. declare module "babylonjs/Audio/index" {
  39006. export * from "babylonjs/Audio/analyser";
  39007. export * from "babylonjs/Audio/audioEngine";
  39008. export * from "babylonjs/Audio/audioSceneComponent";
  39009. export * from "babylonjs/Audio/sound";
  39010. export * from "babylonjs/Audio/soundTrack";
  39011. export * from "babylonjs/Audio/weightedsound";
  39012. }
  39013. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39014. import { Behavior } from "babylonjs/Behaviors/behavior";
  39015. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39016. import { BackEase } from "babylonjs/Animations/easing";
  39017. /**
  39018. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39020. */
  39021. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39022. /**
  39023. * Gets the name of the behavior.
  39024. */
  39025. get name(): string;
  39026. /**
  39027. * The easing function used by animations
  39028. */
  39029. static EasingFunction: BackEase;
  39030. /**
  39031. * The easing mode used by animations
  39032. */
  39033. static EasingMode: number;
  39034. /**
  39035. * The duration of the animation, in milliseconds
  39036. */
  39037. transitionDuration: number;
  39038. /**
  39039. * Length of the distance animated by the transition when lower radius is reached
  39040. */
  39041. lowerRadiusTransitionRange: number;
  39042. /**
  39043. * Length of the distance animated by the transition when upper radius is reached
  39044. */
  39045. upperRadiusTransitionRange: number;
  39046. private _autoTransitionRange;
  39047. /**
  39048. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39049. */
  39050. get autoTransitionRange(): boolean;
  39051. /**
  39052. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39053. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39054. */
  39055. set autoTransitionRange(value: boolean);
  39056. private _attachedCamera;
  39057. private _onAfterCheckInputsObserver;
  39058. private _onMeshTargetChangedObserver;
  39059. /**
  39060. * Initializes the behavior.
  39061. */
  39062. init(): void;
  39063. /**
  39064. * Attaches the behavior to its arc rotate camera.
  39065. * @param camera Defines the camera to attach the behavior to
  39066. */
  39067. attach(camera: ArcRotateCamera): void;
  39068. /**
  39069. * Detaches the behavior from its current arc rotate camera.
  39070. */
  39071. detach(): void;
  39072. private _radiusIsAnimating;
  39073. private _radiusBounceTransition;
  39074. private _animatables;
  39075. private _cachedWheelPrecision;
  39076. /**
  39077. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39078. * @param radiusLimit The limit to check against.
  39079. * @return Bool to indicate if at limit.
  39080. */
  39081. private _isRadiusAtLimit;
  39082. /**
  39083. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39084. * @param radiusDelta The delta by which to animate to. Can be negative.
  39085. */
  39086. private _applyBoundRadiusAnimation;
  39087. /**
  39088. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39089. */
  39090. protected _clearAnimationLocks(): void;
  39091. /**
  39092. * Stops and removes all animations that have been applied to the camera
  39093. */
  39094. stopAllAnimations(): void;
  39095. }
  39096. }
  39097. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39098. import { Behavior } from "babylonjs/Behaviors/behavior";
  39099. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39100. import { ExponentialEase } from "babylonjs/Animations/easing";
  39101. import { Nullable } from "babylonjs/types";
  39102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39103. import { Vector3 } from "babylonjs/Maths/math.vector";
  39104. /**
  39105. * 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.
  39106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39107. */
  39108. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39109. /**
  39110. * Gets the name of the behavior.
  39111. */
  39112. get name(): string;
  39113. private _mode;
  39114. private _radiusScale;
  39115. private _positionScale;
  39116. private _defaultElevation;
  39117. private _elevationReturnTime;
  39118. private _elevationReturnWaitTime;
  39119. private _zoomStopsAnimation;
  39120. private _framingTime;
  39121. /**
  39122. * The easing function used by animations
  39123. */
  39124. static EasingFunction: ExponentialEase;
  39125. /**
  39126. * The easing mode used by animations
  39127. */
  39128. static EasingMode: number;
  39129. /**
  39130. * Sets the current mode used by the behavior
  39131. */
  39132. set mode(mode: number);
  39133. /**
  39134. * Gets current mode used by the behavior.
  39135. */
  39136. get mode(): number;
  39137. /**
  39138. * Sets the scale applied to the radius (1 by default)
  39139. */
  39140. set radiusScale(radius: number);
  39141. /**
  39142. * Gets the scale applied to the radius
  39143. */
  39144. get radiusScale(): number;
  39145. /**
  39146. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39147. */
  39148. set positionScale(scale: number);
  39149. /**
  39150. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39151. */
  39152. get positionScale(): number;
  39153. /**
  39154. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39155. * behaviour is triggered, in radians.
  39156. */
  39157. set defaultElevation(elevation: number);
  39158. /**
  39159. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39160. * behaviour is triggered, in radians.
  39161. */
  39162. get defaultElevation(): number;
  39163. /**
  39164. * Sets the time (in milliseconds) taken to return to the default beta position.
  39165. * Negative value indicates camera should not return to default.
  39166. */
  39167. set elevationReturnTime(speed: number);
  39168. /**
  39169. * Gets the time (in milliseconds) taken to return to the default beta position.
  39170. * Negative value indicates camera should not return to default.
  39171. */
  39172. get elevationReturnTime(): number;
  39173. /**
  39174. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39175. */
  39176. set elevationReturnWaitTime(time: number);
  39177. /**
  39178. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39179. */
  39180. get elevationReturnWaitTime(): number;
  39181. /**
  39182. * Sets the flag that indicates if user zooming should stop animation.
  39183. */
  39184. set zoomStopsAnimation(flag: boolean);
  39185. /**
  39186. * Gets the flag that indicates if user zooming should stop animation.
  39187. */
  39188. get zoomStopsAnimation(): boolean;
  39189. /**
  39190. * Sets the transition time when framing the mesh, in milliseconds
  39191. */
  39192. set framingTime(time: number);
  39193. /**
  39194. * Gets the transition time when framing the mesh, in milliseconds
  39195. */
  39196. get framingTime(): number;
  39197. /**
  39198. * Define if the behavior should automatically change the configured
  39199. * camera limits and sensibilities.
  39200. */
  39201. autoCorrectCameraLimitsAndSensibility: boolean;
  39202. private _onPrePointerObservableObserver;
  39203. private _onAfterCheckInputsObserver;
  39204. private _onMeshTargetChangedObserver;
  39205. private _attachedCamera;
  39206. private _isPointerDown;
  39207. private _lastInteractionTime;
  39208. /**
  39209. * Initializes the behavior.
  39210. */
  39211. init(): void;
  39212. /**
  39213. * Attaches the behavior to its arc rotate camera.
  39214. * @param camera Defines the camera to attach the behavior to
  39215. */
  39216. attach(camera: ArcRotateCamera): void;
  39217. /**
  39218. * Detaches the behavior from its current arc rotate camera.
  39219. */
  39220. detach(): void;
  39221. private _animatables;
  39222. private _betaIsAnimating;
  39223. private _betaTransition;
  39224. private _radiusTransition;
  39225. private _vectorTransition;
  39226. /**
  39227. * Targets the given mesh and updates zoom level accordingly.
  39228. * @param mesh The mesh to target.
  39229. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39230. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39231. */
  39232. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39233. /**
  39234. * Targets the given mesh with its children and updates zoom level accordingly.
  39235. * @param mesh The mesh to target.
  39236. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39237. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39238. */
  39239. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39240. /**
  39241. * Targets the given meshes with their children and updates zoom level accordingly.
  39242. * @param meshes The mesh to target.
  39243. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39244. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39245. */
  39246. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39247. /**
  39248. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39249. * @param minimumWorld Determines the smaller position of the bounding box extend
  39250. * @param maximumWorld Determines the bigger position of the bounding box extend
  39251. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39252. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39253. */
  39254. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39255. /**
  39256. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39257. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39258. * frustum width.
  39259. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39260. * to fully enclose the mesh in the viewing frustum.
  39261. */
  39262. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39263. /**
  39264. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39265. * is automatically returned to its default position (expected to be above ground plane).
  39266. */
  39267. private _maintainCameraAboveGround;
  39268. /**
  39269. * Returns the frustum slope based on the canvas ratio and camera FOV
  39270. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39271. */
  39272. private _getFrustumSlope;
  39273. /**
  39274. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39275. */
  39276. private _clearAnimationLocks;
  39277. /**
  39278. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39279. */
  39280. private _applyUserInteraction;
  39281. /**
  39282. * Stops and removes all animations that have been applied to the camera
  39283. */
  39284. stopAllAnimations(): void;
  39285. /**
  39286. * Gets a value indicating if the user is moving the camera
  39287. */
  39288. get isUserIsMoving(): boolean;
  39289. /**
  39290. * The camera can move all the way towards the mesh.
  39291. */
  39292. static IgnoreBoundsSizeMode: number;
  39293. /**
  39294. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39295. */
  39296. static FitFrustumSidesMode: number;
  39297. }
  39298. }
  39299. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39300. import { Nullable } from "babylonjs/types";
  39301. import { Camera } from "babylonjs/Cameras/camera";
  39302. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39303. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39304. /**
  39305. * Base class for Camera Pointer Inputs.
  39306. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39307. * for example usage.
  39308. */
  39309. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39310. /**
  39311. * Defines the camera the input is attached to.
  39312. */
  39313. abstract camera: Camera;
  39314. /**
  39315. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39316. */
  39317. protected _altKey: boolean;
  39318. protected _ctrlKey: boolean;
  39319. protected _metaKey: boolean;
  39320. protected _shiftKey: boolean;
  39321. /**
  39322. * Which mouse buttons were pressed at time of last mouse event.
  39323. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39324. */
  39325. protected _buttonsPressed: number;
  39326. /**
  39327. * Defines the buttons associated with the input to handle camera move.
  39328. */
  39329. buttons: number[];
  39330. /**
  39331. * Attach the input controls to a specific dom element to get the input from.
  39332. * @param element Defines the element the controls should be listened from
  39333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39334. */
  39335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39336. /**
  39337. * Detach the current controls from the specified dom element.
  39338. * @param element Defines the element to stop listening the inputs from
  39339. */
  39340. detachControl(element: Nullable<HTMLElement>): void;
  39341. /**
  39342. * Gets the class name of the current input.
  39343. * @returns the class name
  39344. */
  39345. getClassName(): string;
  39346. /**
  39347. * Get the friendly name associated with the input class.
  39348. * @returns the input friendly name
  39349. */
  39350. getSimpleName(): string;
  39351. /**
  39352. * Called on pointer POINTERDOUBLETAP event.
  39353. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39354. */
  39355. protected onDoubleTap(type: string): void;
  39356. /**
  39357. * Called on pointer POINTERMOVE event if only a single touch is active.
  39358. * Override this method to provide functionality.
  39359. */
  39360. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39361. /**
  39362. * Called on pointer POINTERMOVE event if multiple touches are active.
  39363. * Override this method to provide functionality.
  39364. */
  39365. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39366. /**
  39367. * Called on JS contextmenu event.
  39368. * Override this method to provide functionality.
  39369. */
  39370. protected onContextMenu(evt: PointerEvent): void;
  39371. /**
  39372. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39373. * press.
  39374. * Override this method to provide functionality.
  39375. */
  39376. protected onButtonDown(evt: PointerEvent): void;
  39377. /**
  39378. * Called each time a new POINTERUP event occurs. Ie, for each button
  39379. * release.
  39380. * Override this method to provide functionality.
  39381. */
  39382. protected onButtonUp(evt: PointerEvent): void;
  39383. /**
  39384. * Called when window becomes inactive.
  39385. * Override this method to provide functionality.
  39386. */
  39387. protected onLostFocus(): void;
  39388. private _pointerInput;
  39389. private _observer;
  39390. private _onLostFocus;
  39391. private pointA;
  39392. private pointB;
  39393. }
  39394. }
  39395. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39396. import { Nullable } from "babylonjs/types";
  39397. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39398. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39399. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39400. /**
  39401. * Manage the pointers inputs to control an arc rotate camera.
  39402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39403. */
  39404. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39405. /**
  39406. * Defines the camera the input is attached to.
  39407. */
  39408. camera: ArcRotateCamera;
  39409. /**
  39410. * Gets the class name of the current input.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Defines the buttons associated with the input to handle camera move.
  39416. */
  39417. buttons: number[];
  39418. /**
  39419. * Defines the pointer angular sensibility along the X axis or how fast is
  39420. * the camera rotating.
  39421. */
  39422. angularSensibilityX: number;
  39423. /**
  39424. * Defines the pointer angular sensibility along the Y axis or how fast is
  39425. * the camera rotating.
  39426. */
  39427. angularSensibilityY: number;
  39428. /**
  39429. * Defines the pointer pinch precision or how fast is the camera zooming.
  39430. */
  39431. pinchPrecision: number;
  39432. /**
  39433. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39434. * from 0.
  39435. * It defines the percentage of current camera.radius to use as delta when
  39436. * pinch zoom is used.
  39437. */
  39438. pinchDeltaPercentage: number;
  39439. /**
  39440. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39441. * that any object in the plane at the camera's target point will scale
  39442. * perfectly with finger motion.
  39443. * Overrides pinchDeltaPercentage and pinchPrecision.
  39444. */
  39445. useNaturalPinchZoom: boolean;
  39446. /**
  39447. * Defines the pointer panning sensibility or how fast is the camera moving.
  39448. */
  39449. panningSensibility: number;
  39450. /**
  39451. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39452. */
  39453. multiTouchPanning: boolean;
  39454. /**
  39455. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39456. * zoom (pinch) through multitouch.
  39457. */
  39458. multiTouchPanAndZoom: boolean;
  39459. /**
  39460. * Revers pinch action direction.
  39461. */
  39462. pinchInwards: boolean;
  39463. private _isPanClick;
  39464. private _twoFingerActivityCount;
  39465. private _isPinching;
  39466. /**
  39467. * Called on pointer POINTERMOVE event if only a single touch is active.
  39468. */
  39469. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39470. /**
  39471. * Called on pointer POINTERDOUBLETAP event.
  39472. */
  39473. protected onDoubleTap(type: string): void;
  39474. /**
  39475. * Called on pointer POINTERMOVE event if multiple touches are active.
  39476. */
  39477. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39478. /**
  39479. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39480. * press.
  39481. */
  39482. protected onButtonDown(evt: PointerEvent): void;
  39483. /**
  39484. * Called each time a new POINTERUP event occurs. Ie, for each button
  39485. * release.
  39486. */
  39487. protected onButtonUp(evt: PointerEvent): void;
  39488. /**
  39489. * Called when window becomes inactive.
  39490. */
  39491. protected onLostFocus(): void;
  39492. }
  39493. }
  39494. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39495. import { Nullable } from "babylonjs/types";
  39496. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39497. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39498. /**
  39499. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39501. */
  39502. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39503. /**
  39504. * Defines the camera the input is attached to.
  39505. */
  39506. camera: ArcRotateCamera;
  39507. /**
  39508. * Defines the list of key codes associated with the up action (increase alpha)
  39509. */
  39510. keysUp: number[];
  39511. /**
  39512. * Defines the list of key codes associated with the down action (decrease alpha)
  39513. */
  39514. keysDown: number[];
  39515. /**
  39516. * Defines the list of key codes associated with the left action (increase beta)
  39517. */
  39518. keysLeft: number[];
  39519. /**
  39520. * Defines the list of key codes associated with the right action (decrease beta)
  39521. */
  39522. keysRight: number[];
  39523. /**
  39524. * Defines the list of key codes associated with the reset action.
  39525. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39526. */
  39527. keysReset: number[];
  39528. /**
  39529. * Defines the panning sensibility of the inputs.
  39530. * (How fast is the camera panning)
  39531. */
  39532. panningSensibility: number;
  39533. /**
  39534. * Defines the zooming sensibility of the inputs.
  39535. * (How fast is the camera zooming)
  39536. */
  39537. zoomingSensibility: number;
  39538. /**
  39539. * Defines whether maintaining the alt key down switch the movement mode from
  39540. * orientation to zoom.
  39541. */
  39542. useAltToZoom: boolean;
  39543. /**
  39544. * Rotation speed of the camera
  39545. */
  39546. angularSpeed: number;
  39547. private _keys;
  39548. private _ctrlPressed;
  39549. private _altPressed;
  39550. private _onCanvasBlurObserver;
  39551. private _onKeyboardObserver;
  39552. private _engine;
  39553. private _scene;
  39554. /**
  39555. * Attach the input controls to a specific dom element to get the input from.
  39556. * @param element Defines the element the controls should be listened from
  39557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39558. */
  39559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39560. /**
  39561. * Detach the current controls from the specified dom element.
  39562. * @param element Defines the element to stop listening the inputs from
  39563. */
  39564. detachControl(element: Nullable<HTMLElement>): void;
  39565. /**
  39566. * Update the current camera state depending on the inputs that have been used this frame.
  39567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39568. */
  39569. checkInputs(): void;
  39570. /**
  39571. * Gets the class name of the current intput.
  39572. * @returns the class name
  39573. */
  39574. getClassName(): string;
  39575. /**
  39576. * Get the friendly name associated with the input class.
  39577. * @returns the input friendly name
  39578. */
  39579. getSimpleName(): string;
  39580. }
  39581. }
  39582. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39583. import { Nullable } from "babylonjs/types";
  39584. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39585. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39586. /**
  39587. * Manage the mouse wheel inputs to control an arc rotate camera.
  39588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39589. */
  39590. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39591. /**
  39592. * Defines the camera the input is attached to.
  39593. */
  39594. camera: ArcRotateCamera;
  39595. /**
  39596. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39597. */
  39598. wheelPrecision: number;
  39599. /**
  39600. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39601. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39602. */
  39603. wheelDeltaPercentage: number;
  39604. private _wheel;
  39605. private _observer;
  39606. private computeDeltaFromMouseWheelLegacyEvent;
  39607. /**
  39608. * Attach the input controls to a specific dom element to get the input from.
  39609. * @param element Defines the element the controls should be listened from
  39610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39611. */
  39612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39613. /**
  39614. * Detach the current controls from the specified dom element.
  39615. * @param element Defines the element to stop listening the inputs from
  39616. */
  39617. detachControl(element: Nullable<HTMLElement>): void;
  39618. /**
  39619. * Gets the class name of the current intput.
  39620. * @returns the class name
  39621. */
  39622. getClassName(): string;
  39623. /**
  39624. * Get the friendly name associated with the input class.
  39625. * @returns the input friendly name
  39626. */
  39627. getSimpleName(): string;
  39628. }
  39629. }
  39630. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39632. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39633. /**
  39634. * Default Inputs manager for the ArcRotateCamera.
  39635. * It groups all the default supported inputs for ease of use.
  39636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39637. */
  39638. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39639. /**
  39640. * Instantiates a new ArcRotateCameraInputsManager.
  39641. * @param camera Defines the camera the inputs belong to
  39642. */
  39643. constructor(camera: ArcRotateCamera);
  39644. /**
  39645. * Add mouse wheel input support to the input manager.
  39646. * @returns the current input manager
  39647. */
  39648. addMouseWheel(): ArcRotateCameraInputsManager;
  39649. /**
  39650. * Add pointers input support to the input manager.
  39651. * @returns the current input manager
  39652. */
  39653. addPointers(): ArcRotateCameraInputsManager;
  39654. /**
  39655. * Add keyboard input support to the input manager.
  39656. * @returns the current input manager
  39657. */
  39658. addKeyboard(): ArcRotateCameraInputsManager;
  39659. }
  39660. }
  39661. declare module "babylonjs/Cameras/arcRotateCamera" {
  39662. import { Observable } from "babylonjs/Misc/observable";
  39663. import { Nullable } from "babylonjs/types";
  39664. import { Scene } from "babylonjs/scene";
  39665. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39667. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39668. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39669. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39670. import { Camera } from "babylonjs/Cameras/camera";
  39671. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39672. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39673. import { Collider } from "babylonjs/Collisions/collider";
  39674. /**
  39675. * This represents an orbital type of camera.
  39676. *
  39677. * 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.
  39678. * 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.
  39679. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39680. */
  39681. export class ArcRotateCamera extends TargetCamera {
  39682. /**
  39683. * Defines the rotation angle of the camera along the longitudinal axis.
  39684. */
  39685. alpha: number;
  39686. /**
  39687. * Defines the rotation angle of the camera along the latitudinal axis.
  39688. */
  39689. beta: number;
  39690. /**
  39691. * Defines the radius of the camera from it s target point.
  39692. */
  39693. radius: number;
  39694. protected _target: Vector3;
  39695. protected _targetHost: Nullable<AbstractMesh>;
  39696. /**
  39697. * Defines the target point of the camera.
  39698. * The camera looks towards it form the radius distance.
  39699. */
  39700. get target(): Vector3;
  39701. set target(value: Vector3);
  39702. /**
  39703. * Define the current local position of the camera in the scene
  39704. */
  39705. get position(): Vector3;
  39706. set position(newPosition: Vector3);
  39707. protected _upVector: Vector3;
  39708. protected _upToYMatrix: Matrix;
  39709. protected _YToUpMatrix: Matrix;
  39710. /**
  39711. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39712. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39713. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39714. */
  39715. set upVector(vec: Vector3);
  39716. get upVector(): Vector3;
  39717. /**
  39718. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39719. */
  39720. setMatUp(): void;
  39721. /**
  39722. * Current inertia value on the longitudinal axis.
  39723. * The bigger this number the longer it will take for the camera to stop.
  39724. */
  39725. inertialAlphaOffset: number;
  39726. /**
  39727. * Current inertia value on the latitudinal axis.
  39728. * The bigger this number the longer it will take for the camera to stop.
  39729. */
  39730. inertialBetaOffset: number;
  39731. /**
  39732. * Current inertia value on the radius axis.
  39733. * The bigger this number the longer it will take for the camera to stop.
  39734. */
  39735. inertialRadiusOffset: number;
  39736. /**
  39737. * Minimum allowed angle on the longitudinal axis.
  39738. * This can help limiting how the Camera is able to move in the scene.
  39739. */
  39740. lowerAlphaLimit: Nullable<number>;
  39741. /**
  39742. * Maximum allowed angle on the longitudinal axis.
  39743. * This can help limiting how the Camera is able to move in the scene.
  39744. */
  39745. upperAlphaLimit: Nullable<number>;
  39746. /**
  39747. * Minimum allowed angle on the latitudinal axis.
  39748. * This can help limiting how the Camera is able to move in the scene.
  39749. */
  39750. lowerBetaLimit: number;
  39751. /**
  39752. * Maximum allowed angle on the latitudinal axis.
  39753. * This can help limiting how the Camera is able to move in the scene.
  39754. */
  39755. upperBetaLimit: number;
  39756. /**
  39757. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39758. * This can help limiting how the Camera is able to move in the scene.
  39759. */
  39760. lowerRadiusLimit: Nullable<number>;
  39761. /**
  39762. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39763. * This can help limiting how the Camera is able to move in the scene.
  39764. */
  39765. upperRadiusLimit: Nullable<number>;
  39766. /**
  39767. * Defines the current inertia value used during panning of the camera along the X axis.
  39768. */
  39769. inertialPanningX: number;
  39770. /**
  39771. * Defines the current inertia value used during panning of the camera along the Y axis.
  39772. */
  39773. inertialPanningY: number;
  39774. /**
  39775. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39776. * Basically if your fingers moves away from more than this distance you will be considered
  39777. * in pinch mode.
  39778. */
  39779. pinchToPanMaxDistance: number;
  39780. /**
  39781. * Defines the maximum distance the camera can pan.
  39782. * This could help keeping the cammera always in your scene.
  39783. */
  39784. panningDistanceLimit: Nullable<number>;
  39785. /**
  39786. * Defines the target of the camera before paning.
  39787. */
  39788. panningOriginTarget: Vector3;
  39789. /**
  39790. * Defines the value of the inertia used during panning.
  39791. * 0 would mean stop inertia and one would mean no decelleration at all.
  39792. */
  39793. panningInertia: number;
  39794. /**
  39795. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39796. */
  39797. get angularSensibilityX(): number;
  39798. set angularSensibilityX(value: number);
  39799. /**
  39800. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39801. */
  39802. get angularSensibilityY(): number;
  39803. set angularSensibilityY(value: number);
  39804. /**
  39805. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39806. */
  39807. get pinchPrecision(): number;
  39808. set pinchPrecision(value: number);
  39809. /**
  39810. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39811. * It will be used instead of pinchDeltaPrecision if different from 0.
  39812. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39813. */
  39814. get pinchDeltaPercentage(): number;
  39815. set pinchDeltaPercentage(value: number);
  39816. /**
  39817. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39818. * and pinch delta percentage.
  39819. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39820. * that any object in the plane at the camera's target point will scale
  39821. * perfectly with finger motion.
  39822. */
  39823. get useNaturalPinchZoom(): boolean;
  39824. set useNaturalPinchZoom(value: boolean);
  39825. /**
  39826. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39827. */
  39828. get panningSensibility(): number;
  39829. set panningSensibility(value: number);
  39830. /**
  39831. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39832. */
  39833. get keysUp(): number[];
  39834. set keysUp(value: number[]);
  39835. /**
  39836. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39837. */
  39838. get keysDown(): number[];
  39839. set keysDown(value: number[]);
  39840. /**
  39841. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39842. */
  39843. get keysLeft(): number[];
  39844. set keysLeft(value: number[]);
  39845. /**
  39846. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39847. */
  39848. get keysRight(): number[];
  39849. set keysRight(value: number[]);
  39850. /**
  39851. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39852. */
  39853. get wheelPrecision(): number;
  39854. set wheelPrecision(value: number);
  39855. /**
  39856. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39857. * It will be used instead of pinchDeltaPrecision if different from 0.
  39858. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39859. */
  39860. get wheelDeltaPercentage(): number;
  39861. set wheelDeltaPercentage(value: number);
  39862. /**
  39863. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39864. */
  39865. zoomOnFactor: number;
  39866. /**
  39867. * Defines a screen offset for the camera position.
  39868. */
  39869. targetScreenOffset: Vector2;
  39870. /**
  39871. * Allows the camera to be completely reversed.
  39872. * If false the camera can not arrive upside down.
  39873. */
  39874. allowUpsideDown: boolean;
  39875. /**
  39876. * Define if double tap/click is used to restore the previously saved state of the camera.
  39877. */
  39878. useInputToRestoreState: boolean;
  39879. /** @hidden */
  39880. _viewMatrix: Matrix;
  39881. /** @hidden */
  39882. _useCtrlForPanning: boolean;
  39883. /** @hidden */
  39884. _panningMouseButton: number;
  39885. /**
  39886. * Defines the input associated to the camera.
  39887. */
  39888. inputs: ArcRotateCameraInputsManager;
  39889. /** @hidden */
  39890. _reset: () => void;
  39891. /**
  39892. * Defines the allowed panning axis.
  39893. */
  39894. panningAxis: Vector3;
  39895. protected _localDirection: Vector3;
  39896. protected _transformedDirection: Vector3;
  39897. private _bouncingBehavior;
  39898. /**
  39899. * Gets the bouncing behavior of the camera if it has been enabled.
  39900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39901. */
  39902. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39903. /**
  39904. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39906. */
  39907. get useBouncingBehavior(): boolean;
  39908. set useBouncingBehavior(value: boolean);
  39909. private _framingBehavior;
  39910. /**
  39911. * Gets the framing behavior of the camera if it has been enabled.
  39912. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39913. */
  39914. get framingBehavior(): Nullable<FramingBehavior>;
  39915. /**
  39916. * Defines if the framing behavior of the camera is enabled on the camera.
  39917. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39918. */
  39919. get useFramingBehavior(): boolean;
  39920. set useFramingBehavior(value: boolean);
  39921. private _autoRotationBehavior;
  39922. /**
  39923. * Gets the auto rotation behavior of the camera if it has been enabled.
  39924. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39925. */
  39926. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39927. /**
  39928. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39929. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39930. */
  39931. get useAutoRotationBehavior(): boolean;
  39932. set useAutoRotationBehavior(value: boolean);
  39933. /**
  39934. * Observable triggered when the mesh target has been changed on the camera.
  39935. */
  39936. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39937. /**
  39938. * Event raised when the camera is colliding with a mesh.
  39939. */
  39940. onCollide: (collidedMesh: AbstractMesh) => void;
  39941. /**
  39942. * Defines whether the camera should check collision with the objects oh the scene.
  39943. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39944. */
  39945. checkCollisions: boolean;
  39946. /**
  39947. * Defines the collision radius of the camera.
  39948. * This simulates a sphere around the camera.
  39949. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39950. */
  39951. collisionRadius: Vector3;
  39952. protected _collider: Collider;
  39953. protected _previousPosition: Vector3;
  39954. protected _collisionVelocity: Vector3;
  39955. protected _newPosition: Vector3;
  39956. protected _previousAlpha: number;
  39957. protected _previousBeta: number;
  39958. protected _previousRadius: number;
  39959. protected _collisionTriggered: boolean;
  39960. protected _targetBoundingCenter: Nullable<Vector3>;
  39961. private _computationVector;
  39962. /**
  39963. * Instantiates a new ArcRotateCamera in a given scene
  39964. * @param name Defines the name of the camera
  39965. * @param alpha Defines the camera rotation along the logitudinal axis
  39966. * @param beta Defines the camera rotation along the latitudinal axis
  39967. * @param radius Defines the camera distance from its target
  39968. * @param target Defines the camera target
  39969. * @param scene Defines the scene the camera belongs to
  39970. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39971. */
  39972. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39973. /** @hidden */
  39974. _initCache(): void;
  39975. /** @hidden */
  39976. _updateCache(ignoreParentClass?: boolean): void;
  39977. protected _getTargetPosition(): Vector3;
  39978. private _storedAlpha;
  39979. private _storedBeta;
  39980. private _storedRadius;
  39981. private _storedTarget;
  39982. private _storedTargetScreenOffset;
  39983. /**
  39984. * Stores the current state of the camera (alpha, beta, radius and target)
  39985. * @returns the camera itself
  39986. */
  39987. storeState(): Camera;
  39988. /**
  39989. * @hidden
  39990. * Restored camera state. You must call storeState() first
  39991. */
  39992. _restoreStateValues(): boolean;
  39993. /** @hidden */
  39994. _isSynchronizedViewMatrix(): boolean;
  39995. /**
  39996. * Attached controls to the current camera.
  39997. * @param element Defines the element the controls should be listened from
  39998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39999. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40000. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40001. */
  40002. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40003. /**
  40004. * Detach the current controls from the camera.
  40005. * The camera will stop reacting to inputs.
  40006. * @param element Defines the element to stop listening the inputs from
  40007. */
  40008. detachControl(element: HTMLElement): void;
  40009. /** @hidden */
  40010. _checkInputs(): void;
  40011. protected _checkLimits(): void;
  40012. /**
  40013. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40014. */
  40015. rebuildAnglesAndRadius(): void;
  40016. /**
  40017. * Use a position to define the current camera related information like alpha, beta and radius
  40018. * @param position Defines the position to set the camera at
  40019. */
  40020. setPosition(position: Vector3): void;
  40021. /**
  40022. * Defines the target the camera should look at.
  40023. * This will automatically adapt alpha beta and radius to fit within the new target.
  40024. * @param target Defines the new target as a Vector or a mesh
  40025. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40026. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40027. */
  40028. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40029. /** @hidden */
  40030. _getViewMatrix(): Matrix;
  40031. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40032. /**
  40033. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40034. * @param meshes Defines the mesh to zoom on
  40035. * @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)
  40036. */
  40037. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40038. /**
  40039. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40040. * The target will be changed but the radius
  40041. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40042. * @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)
  40043. */
  40044. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40045. min: Vector3;
  40046. max: Vector3;
  40047. distance: number;
  40048. }, doNotUpdateMaxZ?: boolean): void;
  40049. /**
  40050. * @override
  40051. * Override Camera.createRigCamera
  40052. */
  40053. createRigCamera(name: string, cameraIndex: number): Camera;
  40054. /**
  40055. * @hidden
  40056. * @override
  40057. * Override Camera._updateRigCameras
  40058. */
  40059. _updateRigCameras(): void;
  40060. /**
  40061. * Destroy the camera and release the current resources hold by it.
  40062. */
  40063. dispose(): void;
  40064. /**
  40065. * Gets the current object class name.
  40066. * @return the class name
  40067. */
  40068. getClassName(): string;
  40069. }
  40070. }
  40071. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40072. import { Behavior } from "babylonjs/Behaviors/behavior";
  40073. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40074. /**
  40075. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40076. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40077. */
  40078. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40079. /**
  40080. * Gets the name of the behavior.
  40081. */
  40082. get name(): string;
  40083. private _zoomStopsAnimation;
  40084. private _idleRotationSpeed;
  40085. private _idleRotationWaitTime;
  40086. private _idleRotationSpinupTime;
  40087. /**
  40088. * Sets the flag that indicates if user zooming should stop animation.
  40089. */
  40090. set zoomStopsAnimation(flag: boolean);
  40091. /**
  40092. * Gets the flag that indicates if user zooming should stop animation.
  40093. */
  40094. get zoomStopsAnimation(): boolean;
  40095. /**
  40096. * Sets the default speed at which the camera rotates around the model.
  40097. */
  40098. set idleRotationSpeed(speed: number);
  40099. /**
  40100. * Gets the default speed at which the camera rotates around the model.
  40101. */
  40102. get idleRotationSpeed(): number;
  40103. /**
  40104. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40105. */
  40106. set idleRotationWaitTime(time: number);
  40107. /**
  40108. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40109. */
  40110. get idleRotationWaitTime(): number;
  40111. /**
  40112. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40113. */
  40114. set idleRotationSpinupTime(time: number);
  40115. /**
  40116. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40117. */
  40118. get idleRotationSpinupTime(): number;
  40119. /**
  40120. * Gets a value indicating if the camera is currently rotating because of this behavior
  40121. */
  40122. get rotationInProgress(): boolean;
  40123. private _onPrePointerObservableObserver;
  40124. private _onAfterCheckInputsObserver;
  40125. private _attachedCamera;
  40126. private _isPointerDown;
  40127. private _lastFrameTime;
  40128. private _lastInteractionTime;
  40129. private _cameraRotationSpeed;
  40130. /**
  40131. * Initializes the behavior.
  40132. */
  40133. init(): void;
  40134. /**
  40135. * Attaches the behavior to its arc rotate camera.
  40136. * @param camera Defines the camera to attach the behavior to
  40137. */
  40138. attach(camera: ArcRotateCamera): void;
  40139. /**
  40140. * Detaches the behavior from its current arc rotate camera.
  40141. */
  40142. detach(): void;
  40143. /**
  40144. * Returns true if user is scrolling.
  40145. * @return true if user is scrolling.
  40146. */
  40147. private _userIsZooming;
  40148. private _lastFrameRadius;
  40149. private _shouldAnimationStopForInteraction;
  40150. /**
  40151. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40152. */
  40153. private _applyUserInteraction;
  40154. private _userIsMoving;
  40155. }
  40156. }
  40157. declare module "babylonjs/Behaviors/Cameras/index" {
  40158. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40159. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40160. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40161. }
  40162. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40163. import { Mesh } from "babylonjs/Meshes/mesh";
  40164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40165. import { Behavior } from "babylonjs/Behaviors/behavior";
  40166. /**
  40167. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40168. */
  40169. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40170. private ui;
  40171. /**
  40172. * The name of the behavior
  40173. */
  40174. name: string;
  40175. /**
  40176. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40177. */
  40178. distanceAwayFromFace: number;
  40179. /**
  40180. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40181. */
  40182. distanceAwayFromBottomOfFace: number;
  40183. private _faceVectors;
  40184. private _target;
  40185. private _scene;
  40186. private _onRenderObserver;
  40187. private _tmpMatrix;
  40188. private _tmpVector;
  40189. /**
  40190. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40191. * @param ui The transform node that should be attched to the mesh
  40192. */
  40193. constructor(ui: TransformNode);
  40194. /**
  40195. * Initializes the behavior
  40196. */
  40197. init(): void;
  40198. private _closestFace;
  40199. private _zeroVector;
  40200. private _lookAtTmpMatrix;
  40201. private _lookAtToRef;
  40202. /**
  40203. * Attaches the AttachToBoxBehavior to the passed in mesh
  40204. * @param target The mesh that the specified node will be attached to
  40205. */
  40206. attach(target: Mesh): void;
  40207. /**
  40208. * Detaches the behavior from the mesh
  40209. */
  40210. detach(): void;
  40211. }
  40212. }
  40213. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40214. import { Behavior } from "babylonjs/Behaviors/behavior";
  40215. import { Mesh } from "babylonjs/Meshes/mesh";
  40216. /**
  40217. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40218. */
  40219. export class FadeInOutBehavior implements Behavior<Mesh> {
  40220. /**
  40221. * Time in milliseconds to delay before fading in (Default: 0)
  40222. */
  40223. delay: number;
  40224. /**
  40225. * Time in milliseconds for the mesh to fade in (Default: 300)
  40226. */
  40227. fadeInTime: number;
  40228. private _millisecondsPerFrame;
  40229. private _hovered;
  40230. private _hoverValue;
  40231. private _ownerNode;
  40232. /**
  40233. * Instatiates the FadeInOutBehavior
  40234. */
  40235. constructor();
  40236. /**
  40237. * The name of the behavior
  40238. */
  40239. get name(): string;
  40240. /**
  40241. * Initializes the behavior
  40242. */
  40243. init(): void;
  40244. /**
  40245. * Attaches the fade behavior on the passed in mesh
  40246. * @param ownerNode The mesh that will be faded in/out once attached
  40247. */
  40248. attach(ownerNode: Mesh): void;
  40249. /**
  40250. * Detaches the behavior from the mesh
  40251. */
  40252. detach(): void;
  40253. /**
  40254. * Triggers the mesh to begin fading in or out
  40255. * @param value if the object should fade in or out (true to fade in)
  40256. */
  40257. fadeIn(value: boolean): void;
  40258. private _update;
  40259. private _setAllVisibility;
  40260. }
  40261. }
  40262. declare module "babylonjs/Misc/pivotTools" {
  40263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40264. /**
  40265. * Class containing a set of static utilities functions for managing Pivots
  40266. * @hidden
  40267. */
  40268. export class PivotTools {
  40269. private static _PivotCached;
  40270. private static _OldPivotPoint;
  40271. private static _PivotTranslation;
  40272. private static _PivotTmpVector;
  40273. /** @hidden */
  40274. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40275. /** @hidden */
  40276. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40277. }
  40278. }
  40279. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40280. import { Scene } from "babylonjs/scene";
  40281. import { Vector4 } from "babylonjs/Maths/math.vector";
  40282. import { Mesh } from "babylonjs/Meshes/mesh";
  40283. import { Nullable } from "babylonjs/types";
  40284. import { Plane } from "babylonjs/Maths/math.plane";
  40285. /**
  40286. * Class containing static functions to help procedurally build meshes
  40287. */
  40288. export class PlaneBuilder {
  40289. /**
  40290. * Creates a plane mesh
  40291. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40292. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40293. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40297. * @param name defines the name of the mesh
  40298. * @param options defines the options used to create the mesh
  40299. * @param scene defines the hosting scene
  40300. * @returns the plane mesh
  40301. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40302. */
  40303. static CreatePlane(name: string, options: {
  40304. size?: number;
  40305. width?: number;
  40306. height?: number;
  40307. sideOrientation?: number;
  40308. frontUVs?: Vector4;
  40309. backUVs?: Vector4;
  40310. updatable?: boolean;
  40311. sourcePlane?: Plane;
  40312. }, scene?: Nullable<Scene>): Mesh;
  40313. }
  40314. }
  40315. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40316. import { Behavior } from "babylonjs/Behaviors/behavior";
  40317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40318. import { Observable } from "babylonjs/Misc/observable";
  40319. import { Vector3 } from "babylonjs/Maths/math.vector";
  40320. import { Ray } from "babylonjs/Culling/ray";
  40321. import "babylonjs/Meshes/Builders/planeBuilder";
  40322. /**
  40323. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40324. */
  40325. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40326. private static _AnyMouseID;
  40327. /**
  40328. * Abstract mesh the behavior is set on
  40329. */
  40330. attachedNode: AbstractMesh;
  40331. private _dragPlane;
  40332. private _scene;
  40333. private _pointerObserver;
  40334. private _beforeRenderObserver;
  40335. private static _planeScene;
  40336. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40337. /**
  40338. * 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)
  40339. */
  40340. maxDragAngle: number;
  40341. /**
  40342. * @hidden
  40343. */
  40344. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40345. /**
  40346. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40347. */
  40348. currentDraggingPointerID: number;
  40349. /**
  40350. * The last position where the pointer hit the drag plane in world space
  40351. */
  40352. lastDragPosition: Vector3;
  40353. /**
  40354. * If the behavior is currently in a dragging state
  40355. */
  40356. dragging: boolean;
  40357. /**
  40358. * 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)
  40359. */
  40360. dragDeltaRatio: number;
  40361. /**
  40362. * If the drag plane orientation should be updated during the dragging (Default: true)
  40363. */
  40364. updateDragPlane: boolean;
  40365. private _debugMode;
  40366. private _moving;
  40367. /**
  40368. * Fires each time the attached mesh is dragged with the pointer
  40369. * * delta between last drag position and current drag position in world space
  40370. * * dragDistance along the drag axis
  40371. * * dragPlaneNormal normal of the current drag plane used during the drag
  40372. * * dragPlanePoint in world space where the drag intersects the drag plane
  40373. */
  40374. onDragObservable: Observable<{
  40375. delta: Vector3;
  40376. dragPlanePoint: Vector3;
  40377. dragPlaneNormal: Vector3;
  40378. dragDistance: number;
  40379. pointerId: number;
  40380. }>;
  40381. /**
  40382. * Fires each time a drag begins (eg. mouse down on mesh)
  40383. */
  40384. onDragStartObservable: Observable<{
  40385. dragPlanePoint: Vector3;
  40386. pointerId: number;
  40387. }>;
  40388. /**
  40389. * Fires each time a drag ends (eg. mouse release after drag)
  40390. */
  40391. onDragEndObservable: Observable<{
  40392. dragPlanePoint: Vector3;
  40393. pointerId: number;
  40394. }>;
  40395. /**
  40396. * If the attached mesh should be moved when dragged
  40397. */
  40398. moveAttached: boolean;
  40399. /**
  40400. * If the drag behavior will react to drag events (Default: true)
  40401. */
  40402. enabled: boolean;
  40403. /**
  40404. * If pointer events should start and release the drag (Default: true)
  40405. */
  40406. startAndReleaseDragOnPointerEvents: boolean;
  40407. /**
  40408. * If camera controls should be detached during the drag
  40409. */
  40410. detachCameraControls: boolean;
  40411. /**
  40412. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40413. */
  40414. useObjectOrientationForDragging: boolean;
  40415. private _options;
  40416. /**
  40417. * Gets the options used by the behavior
  40418. */
  40419. get options(): {
  40420. dragAxis?: Vector3;
  40421. dragPlaneNormal?: Vector3;
  40422. };
  40423. /**
  40424. * Sets the options used by the behavior
  40425. */
  40426. set options(options: {
  40427. dragAxis?: Vector3;
  40428. dragPlaneNormal?: Vector3;
  40429. });
  40430. /**
  40431. * Creates a pointer drag behavior that can be attached to a mesh
  40432. * @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)
  40433. */
  40434. constructor(options?: {
  40435. dragAxis?: Vector3;
  40436. dragPlaneNormal?: Vector3;
  40437. });
  40438. /**
  40439. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40440. */
  40441. validateDrag: (targetPosition: Vector3) => boolean;
  40442. /**
  40443. * The name of the behavior
  40444. */
  40445. get name(): string;
  40446. /**
  40447. * Initializes the behavior
  40448. */
  40449. init(): void;
  40450. private _tmpVector;
  40451. private _alternatePickedPoint;
  40452. private _worldDragAxis;
  40453. private _targetPosition;
  40454. private _attachedElement;
  40455. /**
  40456. * Attaches the drag behavior the passed in mesh
  40457. * @param ownerNode The mesh that will be dragged around once attached
  40458. * @param predicate Predicate to use for pick filtering
  40459. */
  40460. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40461. /**
  40462. * Force relase the drag action by code.
  40463. */
  40464. releaseDrag(): void;
  40465. private _startDragRay;
  40466. private _lastPointerRay;
  40467. /**
  40468. * Simulates the start of a pointer drag event on the behavior
  40469. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40470. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40471. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40472. */
  40473. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40474. private _startDrag;
  40475. private _dragDelta;
  40476. private _moveDrag;
  40477. private _pickWithRayOnDragPlane;
  40478. private _pointA;
  40479. private _pointB;
  40480. private _pointC;
  40481. private _lineA;
  40482. private _lineB;
  40483. private _localAxis;
  40484. private _lookAt;
  40485. private _updateDragPlanePosition;
  40486. /**
  40487. * Detaches the behavior from the mesh
  40488. */
  40489. detach(): void;
  40490. }
  40491. }
  40492. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40493. import { Mesh } from "babylonjs/Meshes/mesh";
  40494. import { Behavior } from "babylonjs/Behaviors/behavior";
  40495. /**
  40496. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40497. */
  40498. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40499. private _dragBehaviorA;
  40500. private _dragBehaviorB;
  40501. private _startDistance;
  40502. private _initialScale;
  40503. private _targetScale;
  40504. private _ownerNode;
  40505. private _sceneRenderObserver;
  40506. /**
  40507. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40508. */
  40509. constructor();
  40510. /**
  40511. * The name of the behavior
  40512. */
  40513. get name(): string;
  40514. /**
  40515. * Initializes the behavior
  40516. */
  40517. init(): void;
  40518. private _getCurrentDistance;
  40519. /**
  40520. * Attaches the scale behavior the passed in mesh
  40521. * @param ownerNode The mesh that will be scaled around once attached
  40522. */
  40523. attach(ownerNode: Mesh): void;
  40524. /**
  40525. * Detaches the behavior from the mesh
  40526. */
  40527. detach(): void;
  40528. }
  40529. }
  40530. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40531. import { Behavior } from "babylonjs/Behaviors/behavior";
  40532. import { Mesh } from "babylonjs/Meshes/mesh";
  40533. import { Observable } from "babylonjs/Misc/observable";
  40534. /**
  40535. * 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
  40536. */
  40537. export class SixDofDragBehavior implements Behavior<Mesh> {
  40538. private static _virtualScene;
  40539. private _ownerNode;
  40540. private _sceneRenderObserver;
  40541. private _scene;
  40542. private _targetPosition;
  40543. private _virtualOriginMesh;
  40544. private _virtualDragMesh;
  40545. private _pointerObserver;
  40546. private _moving;
  40547. private _startingOrientation;
  40548. /**
  40549. * 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)
  40550. */
  40551. private zDragFactor;
  40552. /**
  40553. * If the object should rotate to face the drag origin
  40554. */
  40555. rotateDraggedObject: boolean;
  40556. /**
  40557. * If the behavior is currently in a dragging state
  40558. */
  40559. dragging: boolean;
  40560. /**
  40561. * 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)
  40562. */
  40563. dragDeltaRatio: number;
  40564. /**
  40565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40566. */
  40567. currentDraggingPointerID: number;
  40568. /**
  40569. * If camera controls should be detached during the drag
  40570. */
  40571. detachCameraControls: boolean;
  40572. /**
  40573. * Fires each time a drag starts
  40574. */
  40575. onDragStartObservable: Observable<{}>;
  40576. /**
  40577. * Fires each time a drag ends (eg. mouse release after drag)
  40578. */
  40579. onDragEndObservable: Observable<{}>;
  40580. /**
  40581. * 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
  40582. */
  40583. constructor();
  40584. /**
  40585. * The name of the behavior
  40586. */
  40587. get name(): string;
  40588. /**
  40589. * Initializes the behavior
  40590. */
  40591. init(): void;
  40592. /**
  40593. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40594. */
  40595. private get _pointerCamera();
  40596. /**
  40597. * Attaches the scale behavior the passed in mesh
  40598. * @param ownerNode The mesh that will be scaled around once attached
  40599. */
  40600. attach(ownerNode: Mesh): void;
  40601. /**
  40602. * Detaches the behavior from the mesh
  40603. */
  40604. detach(): void;
  40605. }
  40606. }
  40607. declare module "babylonjs/Behaviors/Meshes/index" {
  40608. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40609. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40610. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40611. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40612. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40613. }
  40614. declare module "babylonjs/Behaviors/index" {
  40615. export * from "babylonjs/Behaviors/behavior";
  40616. export * from "babylonjs/Behaviors/Cameras/index";
  40617. export * from "babylonjs/Behaviors/Meshes/index";
  40618. }
  40619. declare module "babylonjs/Bones/boneIKController" {
  40620. import { Bone } from "babylonjs/Bones/bone";
  40621. import { Vector3 } from "babylonjs/Maths/math.vector";
  40622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40623. import { Nullable } from "babylonjs/types";
  40624. /**
  40625. * Class used to apply inverse kinematics to bones
  40626. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40627. */
  40628. export class BoneIKController {
  40629. private static _tmpVecs;
  40630. private static _tmpQuat;
  40631. private static _tmpMats;
  40632. /**
  40633. * Gets or sets the target mesh
  40634. */
  40635. targetMesh: AbstractMesh;
  40636. /** Gets or sets the mesh used as pole */
  40637. poleTargetMesh: AbstractMesh;
  40638. /**
  40639. * Gets or sets the bone used as pole
  40640. */
  40641. poleTargetBone: Nullable<Bone>;
  40642. /**
  40643. * Gets or sets the target position
  40644. */
  40645. targetPosition: Vector3;
  40646. /**
  40647. * Gets or sets the pole target position
  40648. */
  40649. poleTargetPosition: Vector3;
  40650. /**
  40651. * Gets or sets the pole target local offset
  40652. */
  40653. poleTargetLocalOffset: Vector3;
  40654. /**
  40655. * Gets or sets the pole angle
  40656. */
  40657. poleAngle: number;
  40658. /**
  40659. * Gets or sets the mesh associated with the controller
  40660. */
  40661. mesh: AbstractMesh;
  40662. /**
  40663. * 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)
  40664. */
  40665. slerpAmount: number;
  40666. private _bone1Quat;
  40667. private _bone1Mat;
  40668. private _bone2Ang;
  40669. private _bone1;
  40670. private _bone2;
  40671. private _bone1Length;
  40672. private _bone2Length;
  40673. private _maxAngle;
  40674. private _maxReach;
  40675. private _rightHandedSystem;
  40676. private _bendAxis;
  40677. private _slerping;
  40678. private _adjustRoll;
  40679. /**
  40680. * Gets or sets maximum allowed angle
  40681. */
  40682. get maxAngle(): number;
  40683. set maxAngle(value: number);
  40684. /**
  40685. * Creates a new BoneIKController
  40686. * @param mesh defines the mesh to control
  40687. * @param bone defines the bone to control
  40688. * @param options defines options to set up the controller
  40689. */
  40690. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40691. targetMesh?: AbstractMesh;
  40692. poleTargetMesh?: AbstractMesh;
  40693. poleTargetBone?: Bone;
  40694. poleTargetLocalOffset?: Vector3;
  40695. poleAngle?: number;
  40696. bendAxis?: Vector3;
  40697. maxAngle?: number;
  40698. slerpAmount?: number;
  40699. });
  40700. private _setMaxAngle;
  40701. /**
  40702. * Force the controller to update the bones
  40703. */
  40704. update(): void;
  40705. }
  40706. }
  40707. declare module "babylonjs/Bones/boneLookController" {
  40708. import { Vector3 } from "babylonjs/Maths/math.vector";
  40709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40710. import { Bone } from "babylonjs/Bones/bone";
  40711. import { Space } from "babylonjs/Maths/math.axis";
  40712. /**
  40713. * Class used to make a bone look toward a point in space
  40714. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40715. */
  40716. export class BoneLookController {
  40717. private static _tmpVecs;
  40718. private static _tmpQuat;
  40719. private static _tmpMats;
  40720. /**
  40721. * The target Vector3 that the bone will look at
  40722. */
  40723. target: Vector3;
  40724. /**
  40725. * The mesh that the bone is attached to
  40726. */
  40727. mesh: AbstractMesh;
  40728. /**
  40729. * The bone that will be looking to the target
  40730. */
  40731. bone: Bone;
  40732. /**
  40733. * The up axis of the coordinate system that is used when the bone is rotated
  40734. */
  40735. upAxis: Vector3;
  40736. /**
  40737. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40738. */
  40739. upAxisSpace: Space;
  40740. /**
  40741. * Used to make an adjustment to the yaw of the bone
  40742. */
  40743. adjustYaw: number;
  40744. /**
  40745. * Used to make an adjustment to the pitch of the bone
  40746. */
  40747. adjustPitch: number;
  40748. /**
  40749. * Used to make an adjustment to the roll of the bone
  40750. */
  40751. adjustRoll: number;
  40752. /**
  40753. * 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)
  40754. */
  40755. slerpAmount: number;
  40756. private _minYaw;
  40757. private _maxYaw;
  40758. private _minPitch;
  40759. private _maxPitch;
  40760. private _minYawSin;
  40761. private _minYawCos;
  40762. private _maxYawSin;
  40763. private _maxYawCos;
  40764. private _midYawConstraint;
  40765. private _minPitchTan;
  40766. private _maxPitchTan;
  40767. private _boneQuat;
  40768. private _slerping;
  40769. private _transformYawPitch;
  40770. private _transformYawPitchInv;
  40771. private _firstFrameSkipped;
  40772. private _yawRange;
  40773. private _fowardAxis;
  40774. /**
  40775. * Gets or sets the minimum yaw angle that the bone can look to
  40776. */
  40777. get minYaw(): number;
  40778. set minYaw(value: number);
  40779. /**
  40780. * Gets or sets the maximum yaw angle that the bone can look to
  40781. */
  40782. get maxYaw(): number;
  40783. set maxYaw(value: number);
  40784. /**
  40785. * Gets or sets the minimum pitch angle that the bone can look to
  40786. */
  40787. get minPitch(): number;
  40788. set minPitch(value: number);
  40789. /**
  40790. * Gets or sets the maximum pitch angle that the bone can look to
  40791. */
  40792. get maxPitch(): number;
  40793. set maxPitch(value: number);
  40794. /**
  40795. * Create a BoneLookController
  40796. * @param mesh the mesh that the bone belongs to
  40797. * @param bone the bone that will be looking to the target
  40798. * @param target the target Vector3 to look at
  40799. * @param options optional settings:
  40800. * * maxYaw: the maximum angle the bone will yaw to
  40801. * * minYaw: the minimum angle the bone will yaw to
  40802. * * maxPitch: the maximum angle the bone will pitch to
  40803. * * minPitch: the minimum angle the bone will yaw to
  40804. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40805. * * upAxis: the up axis of the coordinate system
  40806. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40807. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40808. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40809. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40810. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40811. * * adjustRoll: used to make an adjustment to the roll of the bone
  40812. **/
  40813. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40814. maxYaw?: number;
  40815. minYaw?: number;
  40816. maxPitch?: number;
  40817. minPitch?: number;
  40818. slerpAmount?: number;
  40819. upAxis?: Vector3;
  40820. upAxisSpace?: Space;
  40821. yawAxis?: Vector3;
  40822. pitchAxis?: Vector3;
  40823. adjustYaw?: number;
  40824. adjustPitch?: number;
  40825. adjustRoll?: number;
  40826. });
  40827. /**
  40828. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40829. */
  40830. update(): void;
  40831. private _getAngleDiff;
  40832. private _getAngleBetween;
  40833. private _isAngleBetween;
  40834. }
  40835. }
  40836. declare module "babylonjs/Bones/index" {
  40837. export * from "babylonjs/Bones/bone";
  40838. export * from "babylonjs/Bones/boneIKController";
  40839. export * from "babylonjs/Bones/boneLookController";
  40840. export * from "babylonjs/Bones/skeleton";
  40841. }
  40842. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40843. import { Nullable } from "babylonjs/types";
  40844. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40845. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40846. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40847. /**
  40848. * Manage the gamepad inputs to control an arc rotate camera.
  40849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40850. */
  40851. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40852. /**
  40853. * Defines the camera the input is attached to.
  40854. */
  40855. camera: ArcRotateCamera;
  40856. /**
  40857. * Defines the gamepad the input is gathering event from.
  40858. */
  40859. gamepad: Nullable<Gamepad>;
  40860. /**
  40861. * Defines the gamepad rotation sensiblity.
  40862. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40863. */
  40864. gamepadRotationSensibility: number;
  40865. /**
  40866. * Defines the gamepad move sensiblity.
  40867. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40868. */
  40869. gamepadMoveSensibility: number;
  40870. private _yAxisScale;
  40871. /**
  40872. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40873. */
  40874. get invertYAxis(): boolean;
  40875. set invertYAxis(value: boolean);
  40876. private _onGamepadConnectedObserver;
  40877. private _onGamepadDisconnectedObserver;
  40878. /**
  40879. * Attach the input controls to a specific dom element to get the input from.
  40880. * @param element Defines the element the controls should be listened from
  40881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40882. */
  40883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40884. /**
  40885. * Detach the current controls from the specified dom element.
  40886. * @param element Defines the element to stop listening the inputs from
  40887. */
  40888. detachControl(element: Nullable<HTMLElement>): void;
  40889. /**
  40890. * Update the current camera state depending on the inputs that have been used this frame.
  40891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40892. */
  40893. checkInputs(): void;
  40894. /**
  40895. * Gets the class name of the current intput.
  40896. * @returns the class name
  40897. */
  40898. getClassName(): string;
  40899. /**
  40900. * Get the friendly name associated with the input class.
  40901. * @returns the input friendly name
  40902. */
  40903. getSimpleName(): string;
  40904. }
  40905. }
  40906. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40907. import { Nullable } from "babylonjs/types";
  40908. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40909. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40910. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40911. interface ArcRotateCameraInputsManager {
  40912. /**
  40913. * Add orientation input support to the input manager.
  40914. * @returns the current input manager
  40915. */
  40916. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40917. }
  40918. }
  40919. /**
  40920. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40922. */
  40923. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40924. /**
  40925. * Defines the camera the input is attached to.
  40926. */
  40927. camera: ArcRotateCamera;
  40928. /**
  40929. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40930. */
  40931. alphaCorrection: number;
  40932. /**
  40933. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40934. */
  40935. gammaCorrection: number;
  40936. private _alpha;
  40937. private _gamma;
  40938. private _dirty;
  40939. private _deviceOrientationHandler;
  40940. /**
  40941. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40942. */
  40943. constructor();
  40944. /**
  40945. * Attach the input controls to a specific dom element to get the input from.
  40946. * @param element Defines the element the controls should be listened from
  40947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40948. */
  40949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40950. /** @hidden */
  40951. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40952. /**
  40953. * Update the current camera state depending on the inputs that have been used this frame.
  40954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40955. */
  40956. checkInputs(): void;
  40957. /**
  40958. * Detach the current controls from the specified dom element.
  40959. * @param element Defines the element to stop listening the inputs from
  40960. */
  40961. detachControl(element: Nullable<HTMLElement>): void;
  40962. /**
  40963. * Gets the class name of the current intput.
  40964. * @returns the class name
  40965. */
  40966. getClassName(): string;
  40967. /**
  40968. * Get the friendly name associated with the input class.
  40969. * @returns the input friendly name
  40970. */
  40971. getSimpleName(): string;
  40972. }
  40973. }
  40974. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40975. import { Nullable } from "babylonjs/types";
  40976. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40977. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40978. /**
  40979. * Listen to mouse events to control the camera.
  40980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40981. */
  40982. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40983. /**
  40984. * Defines the camera the input is attached to.
  40985. */
  40986. camera: FlyCamera;
  40987. /**
  40988. * Defines if touch is enabled. (Default is true.)
  40989. */
  40990. touchEnabled: boolean;
  40991. /**
  40992. * Defines the buttons associated with the input to handle camera rotation.
  40993. */
  40994. buttons: number[];
  40995. /**
  40996. * Assign buttons for Yaw control.
  40997. */
  40998. buttonsYaw: number[];
  40999. /**
  41000. * Assign buttons for Pitch control.
  41001. */
  41002. buttonsPitch: number[];
  41003. /**
  41004. * Assign buttons for Roll control.
  41005. */
  41006. buttonsRoll: number[];
  41007. /**
  41008. * Detect if any button is being pressed while mouse is moved.
  41009. * -1 = Mouse locked.
  41010. * 0 = Left button.
  41011. * 1 = Middle Button.
  41012. * 2 = Right Button.
  41013. */
  41014. activeButton: number;
  41015. /**
  41016. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41017. * Higher values reduce its sensitivity.
  41018. */
  41019. angularSensibility: number;
  41020. private _mousemoveCallback;
  41021. private _observer;
  41022. private _rollObserver;
  41023. private previousPosition;
  41024. private noPreventDefault;
  41025. private element;
  41026. /**
  41027. * Listen to mouse events to control the camera.
  41028. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41030. */
  41031. constructor(touchEnabled?: boolean);
  41032. /**
  41033. * Attach the mouse control to the HTML DOM element.
  41034. * @param element Defines the element that listens to the input events.
  41035. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41036. */
  41037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41038. /**
  41039. * Detach the current controls from the specified dom element.
  41040. * @param element Defines the element to stop listening the inputs from
  41041. */
  41042. detachControl(element: Nullable<HTMLElement>): void;
  41043. /**
  41044. * Gets the class name of the current input.
  41045. * @returns the class name.
  41046. */
  41047. getClassName(): string;
  41048. /**
  41049. * Get the friendly name associated with the input class.
  41050. * @returns the input's friendly name.
  41051. */
  41052. getSimpleName(): string;
  41053. private _pointerInput;
  41054. private _onMouseMove;
  41055. /**
  41056. * Rotate camera by mouse offset.
  41057. */
  41058. private rotateCamera;
  41059. }
  41060. }
  41061. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41062. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41063. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41064. /**
  41065. * Default Inputs manager for the FlyCamera.
  41066. * It groups all the default supported inputs for ease of use.
  41067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41068. */
  41069. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41070. /**
  41071. * Instantiates a new FlyCameraInputsManager.
  41072. * @param camera Defines the camera the inputs belong to.
  41073. */
  41074. constructor(camera: FlyCamera);
  41075. /**
  41076. * Add keyboard input support to the input manager.
  41077. * @returns the new FlyCameraKeyboardMoveInput().
  41078. */
  41079. addKeyboard(): FlyCameraInputsManager;
  41080. /**
  41081. * Add mouse input support to the input manager.
  41082. * @param touchEnabled Enable touch screen support.
  41083. * @returns the new FlyCameraMouseInput().
  41084. */
  41085. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41086. }
  41087. }
  41088. declare module "babylonjs/Cameras/flyCamera" {
  41089. import { Scene } from "babylonjs/scene";
  41090. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41092. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41093. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41094. /**
  41095. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41096. * such as in a 3D Space Shooter or a Flight Simulator.
  41097. */
  41098. export class FlyCamera extends TargetCamera {
  41099. /**
  41100. * Define the collision ellipsoid of the camera.
  41101. * This is helpful for simulating a camera body, like a player's body.
  41102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41103. */
  41104. ellipsoid: Vector3;
  41105. /**
  41106. * Define an offset for the position of the ellipsoid around the camera.
  41107. * This can be helpful if the camera is attached away from the player's body center,
  41108. * such as at its head.
  41109. */
  41110. ellipsoidOffset: Vector3;
  41111. /**
  41112. * Enable or disable collisions of the camera with the rest of the scene objects.
  41113. */
  41114. checkCollisions: boolean;
  41115. /**
  41116. * Enable or disable gravity on the camera.
  41117. */
  41118. applyGravity: boolean;
  41119. /**
  41120. * Define the current direction the camera is moving to.
  41121. */
  41122. cameraDirection: Vector3;
  41123. /**
  41124. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41125. * This overrides and empties cameraRotation.
  41126. */
  41127. rotationQuaternion: Quaternion;
  41128. /**
  41129. * Track Roll to maintain the wanted Rolling when looking around.
  41130. */
  41131. _trackRoll: number;
  41132. /**
  41133. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41134. */
  41135. rollCorrect: number;
  41136. /**
  41137. * Mimic a banked turn, Rolling the camera when Yawing.
  41138. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41139. */
  41140. bankedTurn: boolean;
  41141. /**
  41142. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41143. */
  41144. bankedTurnLimit: number;
  41145. /**
  41146. * Value of 0 disables the banked Roll.
  41147. * Value of 1 is equal to the Yaw angle in radians.
  41148. */
  41149. bankedTurnMultiplier: number;
  41150. /**
  41151. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41152. */
  41153. inputs: FlyCameraInputsManager;
  41154. /**
  41155. * Gets the input sensibility for mouse input.
  41156. * Higher values reduce sensitivity.
  41157. */
  41158. get angularSensibility(): number;
  41159. /**
  41160. * Sets the input sensibility for a mouse input.
  41161. * Higher values reduce sensitivity.
  41162. */
  41163. set angularSensibility(value: number);
  41164. /**
  41165. * Get the keys for camera movement forward.
  41166. */
  41167. get keysForward(): number[];
  41168. /**
  41169. * Set the keys for camera movement forward.
  41170. */
  41171. set keysForward(value: number[]);
  41172. /**
  41173. * Get the keys for camera movement backward.
  41174. */
  41175. get keysBackward(): number[];
  41176. set keysBackward(value: number[]);
  41177. /**
  41178. * Get the keys for camera movement up.
  41179. */
  41180. get keysUp(): number[];
  41181. /**
  41182. * Set the keys for camera movement up.
  41183. */
  41184. set keysUp(value: number[]);
  41185. /**
  41186. * Get the keys for camera movement down.
  41187. */
  41188. get keysDown(): number[];
  41189. /**
  41190. * Set the keys for camera movement down.
  41191. */
  41192. set keysDown(value: number[]);
  41193. /**
  41194. * Get the keys for camera movement left.
  41195. */
  41196. get keysLeft(): number[];
  41197. /**
  41198. * Set the keys for camera movement left.
  41199. */
  41200. set keysLeft(value: number[]);
  41201. /**
  41202. * Set the keys for camera movement right.
  41203. */
  41204. get keysRight(): number[];
  41205. /**
  41206. * Set the keys for camera movement right.
  41207. */
  41208. set keysRight(value: number[]);
  41209. /**
  41210. * Event raised when the camera collides with a mesh in the scene.
  41211. */
  41212. onCollide: (collidedMesh: AbstractMesh) => void;
  41213. private _collider;
  41214. private _needMoveForGravity;
  41215. private _oldPosition;
  41216. private _diffPosition;
  41217. private _newPosition;
  41218. /** @hidden */
  41219. _localDirection: Vector3;
  41220. /** @hidden */
  41221. _transformedDirection: Vector3;
  41222. /**
  41223. * Instantiates a FlyCamera.
  41224. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41225. * such as in a 3D Space Shooter or a Flight Simulator.
  41226. * @param name Define the name of the camera in the scene.
  41227. * @param position Define the starting position of the camera in the scene.
  41228. * @param scene Define the scene the camera belongs to.
  41229. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41230. */
  41231. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41232. /**
  41233. * Attach a control to the HTML DOM element.
  41234. * @param element Defines the element that listens to the input events.
  41235. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41236. */
  41237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41238. /**
  41239. * Detach a control from the HTML DOM element.
  41240. * The camera will stop reacting to that input.
  41241. * @param element Defines the element that listens to the input events.
  41242. */
  41243. detachControl(element: HTMLElement): void;
  41244. private _collisionMask;
  41245. /**
  41246. * Get the mask that the camera ignores in collision events.
  41247. */
  41248. get collisionMask(): number;
  41249. /**
  41250. * Set the mask that the camera ignores in collision events.
  41251. */
  41252. set collisionMask(mask: number);
  41253. /** @hidden */
  41254. _collideWithWorld(displacement: Vector3): void;
  41255. /** @hidden */
  41256. private _onCollisionPositionChange;
  41257. /** @hidden */
  41258. _checkInputs(): void;
  41259. /** @hidden */
  41260. _decideIfNeedsToMove(): boolean;
  41261. /** @hidden */
  41262. _updatePosition(): void;
  41263. /**
  41264. * Restore the Roll to its target value at the rate specified.
  41265. * @param rate - Higher means slower restoring.
  41266. * @hidden
  41267. */
  41268. restoreRoll(rate: number): void;
  41269. /**
  41270. * Destroy the camera and release the current resources held by it.
  41271. */
  41272. dispose(): void;
  41273. /**
  41274. * Get the current object class name.
  41275. * @returns the class name.
  41276. */
  41277. getClassName(): string;
  41278. }
  41279. }
  41280. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41281. import { Nullable } from "babylonjs/types";
  41282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41283. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41284. /**
  41285. * Listen to keyboard events to control the camera.
  41286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41287. */
  41288. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41289. /**
  41290. * Defines the camera the input is attached to.
  41291. */
  41292. camera: FlyCamera;
  41293. /**
  41294. * The list of keyboard keys used to control the forward move of the camera.
  41295. */
  41296. keysForward: number[];
  41297. /**
  41298. * The list of keyboard keys used to control the backward move of the camera.
  41299. */
  41300. keysBackward: number[];
  41301. /**
  41302. * The list of keyboard keys used to control the forward move of the camera.
  41303. */
  41304. keysUp: number[];
  41305. /**
  41306. * The list of keyboard keys used to control the backward move of the camera.
  41307. */
  41308. keysDown: number[];
  41309. /**
  41310. * The list of keyboard keys used to control the right strafe move of the camera.
  41311. */
  41312. keysRight: number[];
  41313. /**
  41314. * The list of keyboard keys used to control the left strafe move of the camera.
  41315. */
  41316. keysLeft: number[];
  41317. private _keys;
  41318. private _onCanvasBlurObserver;
  41319. private _onKeyboardObserver;
  41320. private _engine;
  41321. private _scene;
  41322. /**
  41323. * Attach the input controls to a specific dom element to get the input from.
  41324. * @param element Defines the element the controls should be listened from
  41325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41326. */
  41327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41328. /**
  41329. * Detach the current controls from the specified dom element.
  41330. * @param element Defines the element to stop listening the inputs from
  41331. */
  41332. detachControl(element: Nullable<HTMLElement>): void;
  41333. /**
  41334. * Gets the class name of the current intput.
  41335. * @returns the class name
  41336. */
  41337. getClassName(): string;
  41338. /** @hidden */
  41339. _onLostFocus(e: FocusEvent): void;
  41340. /**
  41341. * Get the friendly name associated with the input class.
  41342. * @returns the input friendly name
  41343. */
  41344. getSimpleName(): string;
  41345. /**
  41346. * Update the current camera state depending on the inputs that have been used this frame.
  41347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41348. */
  41349. checkInputs(): void;
  41350. }
  41351. }
  41352. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41353. import { Nullable } from "babylonjs/types";
  41354. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41355. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41356. /**
  41357. * Manage the mouse wheel inputs to control a follow camera.
  41358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41359. */
  41360. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41361. /**
  41362. * Defines the camera the input is attached to.
  41363. */
  41364. camera: FollowCamera;
  41365. /**
  41366. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41367. */
  41368. axisControlRadius: boolean;
  41369. /**
  41370. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41371. */
  41372. axisControlHeight: boolean;
  41373. /**
  41374. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41375. */
  41376. axisControlRotation: boolean;
  41377. /**
  41378. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41379. * relation to mouseWheel events.
  41380. */
  41381. wheelPrecision: number;
  41382. /**
  41383. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41384. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41385. */
  41386. wheelDeltaPercentage: number;
  41387. private _wheel;
  41388. private _observer;
  41389. /**
  41390. * Attach the input controls to a specific dom element to get the input from.
  41391. * @param element Defines the element the controls should be listened from
  41392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41393. */
  41394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41395. /**
  41396. * Detach the current controls from the specified dom element.
  41397. * @param element Defines the element to stop listening the inputs from
  41398. */
  41399. detachControl(element: Nullable<HTMLElement>): void;
  41400. /**
  41401. * Gets the class name of the current intput.
  41402. * @returns the class name
  41403. */
  41404. getClassName(): string;
  41405. /**
  41406. * Get the friendly name associated with the input class.
  41407. * @returns the input friendly name
  41408. */
  41409. getSimpleName(): string;
  41410. }
  41411. }
  41412. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41413. import { Nullable } from "babylonjs/types";
  41414. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41415. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41416. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41417. /**
  41418. * Manage the pointers inputs to control an follow camera.
  41419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41420. */
  41421. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41422. /**
  41423. * Defines the camera the input is attached to.
  41424. */
  41425. camera: FollowCamera;
  41426. /**
  41427. * Gets the class name of the current input.
  41428. * @returns the class name
  41429. */
  41430. getClassName(): string;
  41431. /**
  41432. * Defines the pointer angular sensibility along the X axis or how fast is
  41433. * the camera rotating.
  41434. * A negative number will reverse the axis direction.
  41435. */
  41436. angularSensibilityX: number;
  41437. /**
  41438. * Defines the pointer angular sensibility along the Y axis or how fast is
  41439. * the camera rotating.
  41440. * A negative number will reverse the axis direction.
  41441. */
  41442. angularSensibilityY: number;
  41443. /**
  41444. * Defines the pointer pinch precision or how fast is the camera zooming.
  41445. * A negative number will reverse the axis direction.
  41446. */
  41447. pinchPrecision: number;
  41448. /**
  41449. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41450. * from 0.
  41451. * It defines the percentage of current camera.radius to use as delta when
  41452. * pinch zoom is used.
  41453. */
  41454. pinchDeltaPercentage: number;
  41455. /**
  41456. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41457. */
  41458. axisXControlRadius: boolean;
  41459. /**
  41460. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41461. */
  41462. axisXControlHeight: boolean;
  41463. /**
  41464. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41465. */
  41466. axisXControlRotation: boolean;
  41467. /**
  41468. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41469. */
  41470. axisYControlRadius: boolean;
  41471. /**
  41472. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41473. */
  41474. axisYControlHeight: boolean;
  41475. /**
  41476. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41477. */
  41478. axisYControlRotation: boolean;
  41479. /**
  41480. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41481. */
  41482. axisPinchControlRadius: boolean;
  41483. /**
  41484. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41485. */
  41486. axisPinchControlHeight: boolean;
  41487. /**
  41488. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41489. */
  41490. axisPinchControlRotation: boolean;
  41491. /**
  41492. * Log error messages if basic misconfiguration has occurred.
  41493. */
  41494. warningEnable: boolean;
  41495. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41496. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41497. private _warningCounter;
  41498. private _warning;
  41499. }
  41500. }
  41501. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41502. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41503. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41504. /**
  41505. * Default Inputs manager for the FollowCamera.
  41506. * It groups all the default supported inputs for ease of use.
  41507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41508. */
  41509. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41510. /**
  41511. * Instantiates a new FollowCameraInputsManager.
  41512. * @param camera Defines the camera the inputs belong to
  41513. */
  41514. constructor(camera: FollowCamera);
  41515. /**
  41516. * Add keyboard input support to the input manager.
  41517. * @returns the current input manager
  41518. */
  41519. addKeyboard(): FollowCameraInputsManager;
  41520. /**
  41521. * Add mouse wheel input support to the input manager.
  41522. * @returns the current input manager
  41523. */
  41524. addMouseWheel(): FollowCameraInputsManager;
  41525. /**
  41526. * Add pointers input support to the input manager.
  41527. * @returns the current input manager
  41528. */
  41529. addPointers(): FollowCameraInputsManager;
  41530. /**
  41531. * Add orientation input support to the input manager.
  41532. * @returns the current input manager
  41533. */
  41534. addVRDeviceOrientation(): FollowCameraInputsManager;
  41535. }
  41536. }
  41537. declare module "babylonjs/Cameras/followCamera" {
  41538. import { Nullable } from "babylonjs/types";
  41539. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41540. import { Scene } from "babylonjs/scene";
  41541. import { Vector3 } from "babylonjs/Maths/math.vector";
  41542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41543. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41544. /**
  41545. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41546. * an arc rotate version arcFollowCamera are available.
  41547. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41548. */
  41549. export class FollowCamera extends TargetCamera {
  41550. /**
  41551. * Distance the follow camera should follow an object at
  41552. */
  41553. radius: number;
  41554. /**
  41555. * Minimum allowed distance of the camera to the axis of rotation
  41556. * (The camera can not get closer).
  41557. * This can help limiting how the Camera is able to move in the scene.
  41558. */
  41559. lowerRadiusLimit: Nullable<number>;
  41560. /**
  41561. * Maximum allowed distance of the camera to the axis of rotation
  41562. * (The camera can not get further).
  41563. * This can help limiting how the Camera is able to move in the scene.
  41564. */
  41565. upperRadiusLimit: Nullable<number>;
  41566. /**
  41567. * Define a rotation offset between the camera and the object it follows
  41568. */
  41569. rotationOffset: number;
  41570. /**
  41571. * Minimum allowed angle to camera position relative to target object.
  41572. * This can help limiting how the Camera is able to move in the scene.
  41573. */
  41574. lowerRotationOffsetLimit: Nullable<number>;
  41575. /**
  41576. * Maximum allowed angle to camera position relative to target object.
  41577. * This can help limiting how the Camera is able to move in the scene.
  41578. */
  41579. upperRotationOffsetLimit: Nullable<number>;
  41580. /**
  41581. * Define a height offset between the camera and the object it follows.
  41582. * It can help following an object from the top (like a car chaing a plane)
  41583. */
  41584. heightOffset: number;
  41585. /**
  41586. * Minimum allowed height of camera position relative to target object.
  41587. * This can help limiting how the Camera is able to move in the scene.
  41588. */
  41589. lowerHeightOffsetLimit: Nullable<number>;
  41590. /**
  41591. * Maximum allowed height of camera position relative to target object.
  41592. * This can help limiting how the Camera is able to move in the scene.
  41593. */
  41594. upperHeightOffsetLimit: Nullable<number>;
  41595. /**
  41596. * Define how fast the camera can accelerate to follow it s target.
  41597. */
  41598. cameraAcceleration: number;
  41599. /**
  41600. * Define the speed limit of the camera following an object.
  41601. */
  41602. maxCameraSpeed: number;
  41603. /**
  41604. * Define the target of the camera.
  41605. */
  41606. lockedTarget: Nullable<AbstractMesh>;
  41607. /**
  41608. * Defines the input associated with the camera.
  41609. */
  41610. inputs: FollowCameraInputsManager;
  41611. /**
  41612. * Instantiates the follow camera.
  41613. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41614. * @param name Define the name of the camera in the scene
  41615. * @param position Define the position of the camera
  41616. * @param scene Define the scene the camera belong to
  41617. * @param lockedTarget Define the target of the camera
  41618. */
  41619. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41620. private _follow;
  41621. /**
  41622. * Attached controls to the current camera.
  41623. * @param element Defines the element the controls should be listened from
  41624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41625. */
  41626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41627. /**
  41628. * Detach the current controls from the camera.
  41629. * The camera will stop reacting to inputs.
  41630. * @param element Defines the element to stop listening the inputs from
  41631. */
  41632. detachControl(element: HTMLElement): void;
  41633. /** @hidden */
  41634. _checkInputs(): void;
  41635. private _checkLimits;
  41636. /**
  41637. * Gets the camera class name.
  41638. * @returns the class name
  41639. */
  41640. getClassName(): string;
  41641. }
  41642. /**
  41643. * Arc Rotate version of the follow camera.
  41644. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41645. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41646. */
  41647. export class ArcFollowCamera extends TargetCamera {
  41648. /** The longitudinal angle of the camera */
  41649. alpha: number;
  41650. /** The latitudinal angle of the camera */
  41651. beta: number;
  41652. /** The radius of the camera from its target */
  41653. radius: number;
  41654. /** Define the camera target (the messh it should follow) */
  41655. target: Nullable<AbstractMesh>;
  41656. private _cartesianCoordinates;
  41657. /**
  41658. * Instantiates a new ArcFollowCamera
  41659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41660. * @param name Define the name of the camera
  41661. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41662. * @param beta Define the rotation angle of the camera around the elevation axis
  41663. * @param radius Define the radius of the camera from its target point
  41664. * @param target Define the target of the camera
  41665. * @param scene Define the scene the camera belongs to
  41666. */
  41667. constructor(name: string,
  41668. /** The longitudinal angle of the camera */
  41669. alpha: number,
  41670. /** The latitudinal angle of the camera */
  41671. beta: number,
  41672. /** The radius of the camera from its target */
  41673. radius: number,
  41674. /** Define the camera target (the messh it should follow) */
  41675. target: Nullable<AbstractMesh>, scene: Scene);
  41676. private _follow;
  41677. /** @hidden */
  41678. _checkInputs(): void;
  41679. /**
  41680. * Returns the class name of the object.
  41681. * It is mostly used internally for serialization purposes.
  41682. */
  41683. getClassName(): string;
  41684. }
  41685. }
  41686. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41688. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41689. import { Nullable } from "babylonjs/types";
  41690. /**
  41691. * Manage the keyboard inputs to control the movement of a follow camera.
  41692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41693. */
  41694. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41695. /**
  41696. * Defines the camera the input is attached to.
  41697. */
  41698. camera: FollowCamera;
  41699. /**
  41700. * Defines the list of key codes associated with the up action (increase heightOffset)
  41701. */
  41702. keysHeightOffsetIncr: number[];
  41703. /**
  41704. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41705. */
  41706. keysHeightOffsetDecr: number[];
  41707. /**
  41708. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41709. */
  41710. keysHeightOffsetModifierAlt: boolean;
  41711. /**
  41712. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41713. */
  41714. keysHeightOffsetModifierCtrl: boolean;
  41715. /**
  41716. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41717. */
  41718. keysHeightOffsetModifierShift: boolean;
  41719. /**
  41720. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41721. */
  41722. keysRotationOffsetIncr: number[];
  41723. /**
  41724. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41725. */
  41726. keysRotationOffsetDecr: number[];
  41727. /**
  41728. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41729. */
  41730. keysRotationOffsetModifierAlt: boolean;
  41731. /**
  41732. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41733. */
  41734. keysRotationOffsetModifierCtrl: boolean;
  41735. /**
  41736. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41737. */
  41738. keysRotationOffsetModifierShift: boolean;
  41739. /**
  41740. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41741. */
  41742. keysRadiusIncr: number[];
  41743. /**
  41744. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41745. */
  41746. keysRadiusDecr: number[];
  41747. /**
  41748. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41749. */
  41750. keysRadiusModifierAlt: boolean;
  41751. /**
  41752. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41753. */
  41754. keysRadiusModifierCtrl: boolean;
  41755. /**
  41756. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41757. */
  41758. keysRadiusModifierShift: boolean;
  41759. /**
  41760. * Defines the rate of change of heightOffset.
  41761. */
  41762. heightSensibility: number;
  41763. /**
  41764. * Defines the rate of change of rotationOffset.
  41765. */
  41766. rotationSensibility: number;
  41767. /**
  41768. * Defines the rate of change of radius.
  41769. */
  41770. radiusSensibility: number;
  41771. private _keys;
  41772. private _ctrlPressed;
  41773. private _altPressed;
  41774. private _shiftPressed;
  41775. private _onCanvasBlurObserver;
  41776. private _onKeyboardObserver;
  41777. private _engine;
  41778. private _scene;
  41779. /**
  41780. * Attach the input controls to a specific dom element to get the input from.
  41781. * @param element Defines the element the controls should be listened from
  41782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41783. */
  41784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41785. /**
  41786. * Detach the current controls from the specified dom element.
  41787. * @param element Defines the element to stop listening the inputs from
  41788. */
  41789. detachControl(element: Nullable<HTMLElement>): void;
  41790. /**
  41791. * Update the current camera state depending on the inputs that have been used this frame.
  41792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41793. */
  41794. checkInputs(): void;
  41795. /**
  41796. * Gets the class name of the current input.
  41797. * @returns the class name
  41798. */
  41799. getClassName(): string;
  41800. /**
  41801. * Get the friendly name associated with the input class.
  41802. * @returns the input friendly name
  41803. */
  41804. getSimpleName(): string;
  41805. /**
  41806. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41807. * allow modification of the heightOffset value.
  41808. */
  41809. private _modifierHeightOffset;
  41810. /**
  41811. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41812. * allow modification of the rotationOffset value.
  41813. */
  41814. private _modifierRotationOffset;
  41815. /**
  41816. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41817. * allow modification of the radius value.
  41818. */
  41819. private _modifierRadius;
  41820. }
  41821. }
  41822. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41823. import { Nullable } from "babylonjs/types";
  41824. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41825. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41826. import { Observable } from "babylonjs/Misc/observable";
  41827. module "babylonjs/Cameras/freeCameraInputsManager" {
  41828. interface FreeCameraInputsManager {
  41829. /**
  41830. * @hidden
  41831. */
  41832. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41833. /**
  41834. * Add orientation input support to the input manager.
  41835. * @returns the current input manager
  41836. */
  41837. addDeviceOrientation(): FreeCameraInputsManager;
  41838. }
  41839. }
  41840. /**
  41841. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41842. * Screen rotation is taken into account.
  41843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41844. */
  41845. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41846. private _camera;
  41847. private _screenOrientationAngle;
  41848. private _constantTranform;
  41849. private _screenQuaternion;
  41850. private _alpha;
  41851. private _beta;
  41852. private _gamma;
  41853. /**
  41854. * Can be used to detect if a device orientation sensor is available on a device
  41855. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41856. * @returns a promise that will resolve on orientation change
  41857. */
  41858. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41859. /**
  41860. * @hidden
  41861. */
  41862. _onDeviceOrientationChangedObservable: Observable<void>;
  41863. /**
  41864. * Instantiates a new input
  41865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41866. */
  41867. constructor();
  41868. /**
  41869. * Define the camera controlled by the input.
  41870. */
  41871. get camera(): FreeCamera;
  41872. set camera(camera: FreeCamera);
  41873. /**
  41874. * Attach the input controls to a specific dom element to get the input from.
  41875. * @param element Defines the element the controls should be listened from
  41876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41877. */
  41878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41879. private _orientationChanged;
  41880. private _deviceOrientation;
  41881. /**
  41882. * Detach the current controls from the specified dom element.
  41883. * @param element Defines the element to stop listening the inputs from
  41884. */
  41885. detachControl(element: Nullable<HTMLElement>): void;
  41886. /**
  41887. * Update the current camera state depending on the inputs that have been used this frame.
  41888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41889. */
  41890. checkInputs(): void;
  41891. /**
  41892. * Gets the class name of the current intput.
  41893. * @returns the class name
  41894. */
  41895. getClassName(): string;
  41896. /**
  41897. * Get the friendly name associated with the input class.
  41898. * @returns the input friendly name
  41899. */
  41900. getSimpleName(): string;
  41901. }
  41902. }
  41903. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41904. import { Nullable } from "babylonjs/types";
  41905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41907. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41908. /**
  41909. * Manage the gamepad inputs to control a free camera.
  41910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41911. */
  41912. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41913. /**
  41914. * Define the camera the input is attached to.
  41915. */
  41916. camera: FreeCamera;
  41917. /**
  41918. * Define the Gamepad controlling the input
  41919. */
  41920. gamepad: Nullable<Gamepad>;
  41921. /**
  41922. * Defines the gamepad rotation sensiblity.
  41923. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41924. */
  41925. gamepadAngularSensibility: number;
  41926. /**
  41927. * Defines the gamepad move sensiblity.
  41928. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41929. */
  41930. gamepadMoveSensibility: number;
  41931. private _yAxisScale;
  41932. /**
  41933. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41934. */
  41935. get invertYAxis(): boolean;
  41936. set invertYAxis(value: boolean);
  41937. private _onGamepadConnectedObserver;
  41938. private _onGamepadDisconnectedObserver;
  41939. private _cameraTransform;
  41940. private _deltaTransform;
  41941. private _vector3;
  41942. private _vector2;
  41943. /**
  41944. * Attach the input controls to a specific dom element to get the input from.
  41945. * @param element Defines the element the controls should be listened from
  41946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41947. */
  41948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41949. /**
  41950. * Detach the current controls from the specified dom element.
  41951. * @param element Defines the element to stop listening the inputs from
  41952. */
  41953. detachControl(element: Nullable<HTMLElement>): void;
  41954. /**
  41955. * Update the current camera state depending on the inputs that have been used this frame.
  41956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41957. */
  41958. checkInputs(): void;
  41959. /**
  41960. * Gets the class name of the current intput.
  41961. * @returns the class name
  41962. */
  41963. getClassName(): string;
  41964. /**
  41965. * Get the friendly name associated with the input class.
  41966. * @returns the input friendly name
  41967. */
  41968. getSimpleName(): string;
  41969. }
  41970. }
  41971. declare module "babylonjs/Misc/virtualJoystick" {
  41972. import { Nullable } from "babylonjs/types";
  41973. import { Vector3 } from "babylonjs/Maths/math.vector";
  41974. /**
  41975. * Defines the potential axis of a Joystick
  41976. */
  41977. export enum JoystickAxis {
  41978. /** X axis */
  41979. X = 0,
  41980. /** Y axis */
  41981. Y = 1,
  41982. /** Z axis */
  41983. Z = 2
  41984. }
  41985. /**
  41986. * Class used to define virtual joystick (used in touch mode)
  41987. */
  41988. export class VirtualJoystick {
  41989. /**
  41990. * Gets or sets a boolean indicating that left and right values must be inverted
  41991. */
  41992. reverseLeftRight: boolean;
  41993. /**
  41994. * Gets or sets a boolean indicating that up and down values must be inverted
  41995. */
  41996. reverseUpDown: boolean;
  41997. /**
  41998. * Gets the offset value for the position (ie. the change of the position value)
  41999. */
  42000. deltaPosition: Vector3;
  42001. /**
  42002. * Gets a boolean indicating if the virtual joystick was pressed
  42003. */
  42004. pressed: boolean;
  42005. /**
  42006. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42007. */
  42008. static Canvas: Nullable<HTMLCanvasElement>;
  42009. private static _globalJoystickIndex;
  42010. private static vjCanvasContext;
  42011. private static vjCanvasWidth;
  42012. private static vjCanvasHeight;
  42013. private static halfWidth;
  42014. private _action;
  42015. private _axisTargetedByLeftAndRight;
  42016. private _axisTargetedByUpAndDown;
  42017. private _joystickSensibility;
  42018. private _inversedSensibility;
  42019. private _joystickPointerID;
  42020. private _joystickColor;
  42021. private _joystickPointerPos;
  42022. private _joystickPreviousPointerPos;
  42023. private _joystickPointerStartPos;
  42024. private _deltaJoystickVector;
  42025. private _leftJoystick;
  42026. private _touches;
  42027. private _onPointerDownHandlerRef;
  42028. private _onPointerMoveHandlerRef;
  42029. private _onPointerUpHandlerRef;
  42030. private _onResize;
  42031. /**
  42032. * Creates a new virtual joystick
  42033. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42034. */
  42035. constructor(leftJoystick?: boolean);
  42036. /**
  42037. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42038. * @param newJoystickSensibility defines the new sensibility
  42039. */
  42040. setJoystickSensibility(newJoystickSensibility: number): void;
  42041. private _onPointerDown;
  42042. private _onPointerMove;
  42043. private _onPointerUp;
  42044. /**
  42045. * Change the color of the virtual joystick
  42046. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42047. */
  42048. setJoystickColor(newColor: string): void;
  42049. /**
  42050. * Defines a callback to call when the joystick is touched
  42051. * @param action defines the callback
  42052. */
  42053. setActionOnTouch(action: () => any): void;
  42054. /**
  42055. * Defines which axis you'd like to control for left & right
  42056. * @param axis defines the axis to use
  42057. */
  42058. setAxisForLeftRight(axis: JoystickAxis): void;
  42059. /**
  42060. * Defines which axis you'd like to control for up & down
  42061. * @param axis defines the axis to use
  42062. */
  42063. setAxisForUpDown(axis: JoystickAxis): void;
  42064. private _drawVirtualJoystick;
  42065. /**
  42066. * Release internal HTML canvas
  42067. */
  42068. releaseCanvas(): void;
  42069. }
  42070. }
  42071. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42072. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42073. import { Nullable } from "babylonjs/types";
  42074. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42075. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42076. module "babylonjs/Cameras/freeCameraInputsManager" {
  42077. interface FreeCameraInputsManager {
  42078. /**
  42079. * Add virtual joystick input support to the input manager.
  42080. * @returns the current input manager
  42081. */
  42082. addVirtualJoystick(): FreeCameraInputsManager;
  42083. }
  42084. }
  42085. /**
  42086. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42088. */
  42089. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42090. /**
  42091. * Defines the camera the input is attached to.
  42092. */
  42093. camera: FreeCamera;
  42094. private _leftjoystick;
  42095. private _rightjoystick;
  42096. /**
  42097. * Gets the left stick of the virtual joystick.
  42098. * @returns The virtual Joystick
  42099. */
  42100. getLeftJoystick(): VirtualJoystick;
  42101. /**
  42102. * Gets the right stick of the virtual joystick.
  42103. * @returns The virtual Joystick
  42104. */
  42105. getRightJoystick(): VirtualJoystick;
  42106. /**
  42107. * Update the current camera state depending on the inputs that have been used this frame.
  42108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42109. */
  42110. checkInputs(): void;
  42111. /**
  42112. * Attach the input controls to a specific dom element to get the input from.
  42113. * @param element Defines the element the controls should be listened from
  42114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42115. */
  42116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42117. /**
  42118. * Detach the current controls from the specified dom element.
  42119. * @param element Defines the element to stop listening the inputs from
  42120. */
  42121. detachControl(element: Nullable<HTMLElement>): void;
  42122. /**
  42123. * Gets the class name of the current intput.
  42124. * @returns the class name
  42125. */
  42126. getClassName(): string;
  42127. /**
  42128. * Get the friendly name associated with the input class.
  42129. * @returns the input friendly name
  42130. */
  42131. getSimpleName(): string;
  42132. }
  42133. }
  42134. declare module "babylonjs/Cameras/Inputs/index" {
  42135. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42136. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42137. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42138. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42139. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42140. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42141. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42142. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42143. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42144. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42145. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42146. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42147. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42148. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42149. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42150. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42151. }
  42152. declare module "babylonjs/Cameras/touchCamera" {
  42153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42154. import { Scene } from "babylonjs/scene";
  42155. import { Vector3 } from "babylonjs/Maths/math.vector";
  42156. /**
  42157. * This represents a FPS type of camera controlled by touch.
  42158. * This is like a universal camera minus the Gamepad controls.
  42159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42160. */
  42161. export class TouchCamera extends FreeCamera {
  42162. /**
  42163. * Defines the touch sensibility for rotation.
  42164. * The higher the faster.
  42165. */
  42166. get touchAngularSensibility(): number;
  42167. set touchAngularSensibility(value: number);
  42168. /**
  42169. * Defines the touch sensibility for move.
  42170. * The higher the faster.
  42171. */
  42172. get touchMoveSensibility(): number;
  42173. set touchMoveSensibility(value: number);
  42174. /**
  42175. * Instantiates a new touch camera.
  42176. * This represents a FPS type of camera controlled by touch.
  42177. * This is like a universal camera minus the Gamepad controls.
  42178. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42179. * @param name Define the name of the camera in the scene
  42180. * @param position Define the start position of the camera in the scene
  42181. * @param scene Define the scene the camera belongs to
  42182. */
  42183. constructor(name: string, position: Vector3, scene: Scene);
  42184. /**
  42185. * Gets the current object class name.
  42186. * @return the class name
  42187. */
  42188. getClassName(): string;
  42189. /** @hidden */
  42190. _setupInputs(): void;
  42191. }
  42192. }
  42193. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42194. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42195. import { Scene } from "babylonjs/scene";
  42196. import { Vector3 } from "babylonjs/Maths/math.vector";
  42197. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42198. import { Axis } from "babylonjs/Maths/math.axis";
  42199. /**
  42200. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42201. * being tilted forward or back and left or right.
  42202. */
  42203. export class DeviceOrientationCamera extends FreeCamera {
  42204. private _initialQuaternion;
  42205. private _quaternionCache;
  42206. private _tmpDragQuaternion;
  42207. private _disablePointerInputWhenUsingDeviceOrientation;
  42208. /**
  42209. * Creates a new device orientation camera
  42210. * @param name The name of the camera
  42211. * @param position The start position camera
  42212. * @param scene The scene the camera belongs to
  42213. */
  42214. constructor(name: string, position: Vector3, scene: Scene);
  42215. /**
  42216. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42217. */
  42218. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42219. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42220. private _dragFactor;
  42221. /**
  42222. * Enabled turning on the y axis when the orientation sensor is active
  42223. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42224. */
  42225. enableHorizontalDragging(dragFactor?: number): void;
  42226. /**
  42227. * Gets the current instance class name ("DeviceOrientationCamera").
  42228. * This helps avoiding instanceof at run time.
  42229. * @returns the class name
  42230. */
  42231. getClassName(): string;
  42232. /**
  42233. * @hidden
  42234. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42235. */
  42236. _checkInputs(): void;
  42237. /**
  42238. * Reset the camera to its default orientation on the specified axis only.
  42239. * @param axis The axis to reset
  42240. */
  42241. resetToCurrentRotation(axis?: Axis): void;
  42242. }
  42243. }
  42244. declare module "babylonjs/Gamepads/xboxGamepad" {
  42245. import { Observable } from "babylonjs/Misc/observable";
  42246. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42247. /**
  42248. * Defines supported buttons for XBox360 compatible gamepads
  42249. */
  42250. export enum Xbox360Button {
  42251. /** A */
  42252. A = 0,
  42253. /** B */
  42254. B = 1,
  42255. /** X */
  42256. X = 2,
  42257. /** Y */
  42258. Y = 3,
  42259. /** Start */
  42260. Start = 4,
  42261. /** Back */
  42262. Back = 5,
  42263. /** Left button */
  42264. LB = 6,
  42265. /** Right button */
  42266. RB = 7,
  42267. /** Left stick */
  42268. LeftStick = 8,
  42269. /** Right stick */
  42270. RightStick = 9
  42271. }
  42272. /** Defines values for XBox360 DPad */
  42273. export enum Xbox360Dpad {
  42274. /** Up */
  42275. Up = 0,
  42276. /** Down */
  42277. Down = 1,
  42278. /** Left */
  42279. Left = 2,
  42280. /** Right */
  42281. Right = 3
  42282. }
  42283. /**
  42284. * Defines a XBox360 gamepad
  42285. */
  42286. export class Xbox360Pad extends Gamepad {
  42287. private _leftTrigger;
  42288. private _rightTrigger;
  42289. private _onlefttriggerchanged;
  42290. private _onrighttriggerchanged;
  42291. private _onbuttondown;
  42292. private _onbuttonup;
  42293. private _ondpaddown;
  42294. private _ondpadup;
  42295. /** Observable raised when a button is pressed */
  42296. onButtonDownObservable: Observable<Xbox360Button>;
  42297. /** Observable raised when a button is released */
  42298. onButtonUpObservable: Observable<Xbox360Button>;
  42299. /** Observable raised when a pad is pressed */
  42300. onPadDownObservable: Observable<Xbox360Dpad>;
  42301. /** Observable raised when a pad is released */
  42302. onPadUpObservable: Observable<Xbox360Dpad>;
  42303. private _buttonA;
  42304. private _buttonB;
  42305. private _buttonX;
  42306. private _buttonY;
  42307. private _buttonBack;
  42308. private _buttonStart;
  42309. private _buttonLB;
  42310. private _buttonRB;
  42311. private _buttonLeftStick;
  42312. private _buttonRightStick;
  42313. private _dPadUp;
  42314. private _dPadDown;
  42315. private _dPadLeft;
  42316. private _dPadRight;
  42317. private _isXboxOnePad;
  42318. /**
  42319. * Creates a new XBox360 gamepad object
  42320. * @param id defines the id of this gamepad
  42321. * @param index defines its index
  42322. * @param gamepad defines the internal HTML gamepad object
  42323. * @param xboxOne defines if it is a XBox One gamepad
  42324. */
  42325. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42326. /**
  42327. * Defines the callback to call when left trigger is pressed
  42328. * @param callback defines the callback to use
  42329. */
  42330. onlefttriggerchanged(callback: (value: number) => void): void;
  42331. /**
  42332. * Defines the callback to call when right trigger is pressed
  42333. * @param callback defines the callback to use
  42334. */
  42335. onrighttriggerchanged(callback: (value: number) => void): void;
  42336. /**
  42337. * Gets the left trigger value
  42338. */
  42339. get leftTrigger(): number;
  42340. /**
  42341. * Sets the left trigger value
  42342. */
  42343. set leftTrigger(newValue: number);
  42344. /**
  42345. * Gets the right trigger value
  42346. */
  42347. get rightTrigger(): number;
  42348. /**
  42349. * Sets the right trigger value
  42350. */
  42351. set rightTrigger(newValue: number);
  42352. /**
  42353. * Defines the callback to call when a button is pressed
  42354. * @param callback defines the callback to use
  42355. */
  42356. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42357. /**
  42358. * Defines the callback to call when a button is released
  42359. * @param callback defines the callback to use
  42360. */
  42361. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42362. /**
  42363. * Defines the callback to call when a pad is pressed
  42364. * @param callback defines the callback to use
  42365. */
  42366. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42367. /**
  42368. * Defines the callback to call when a pad is released
  42369. * @param callback defines the callback to use
  42370. */
  42371. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42372. private _setButtonValue;
  42373. private _setDPadValue;
  42374. /**
  42375. * Gets the value of the `A` button
  42376. */
  42377. get buttonA(): number;
  42378. /**
  42379. * Sets the value of the `A` button
  42380. */
  42381. set buttonA(value: number);
  42382. /**
  42383. * Gets the value of the `B` button
  42384. */
  42385. get buttonB(): number;
  42386. /**
  42387. * Sets the value of the `B` button
  42388. */
  42389. set buttonB(value: number);
  42390. /**
  42391. * Gets the value of the `X` button
  42392. */
  42393. get buttonX(): number;
  42394. /**
  42395. * Sets the value of the `X` button
  42396. */
  42397. set buttonX(value: number);
  42398. /**
  42399. * Gets the value of the `Y` button
  42400. */
  42401. get buttonY(): number;
  42402. /**
  42403. * Sets the value of the `Y` button
  42404. */
  42405. set buttonY(value: number);
  42406. /**
  42407. * Gets the value of the `Start` button
  42408. */
  42409. get buttonStart(): number;
  42410. /**
  42411. * Sets the value of the `Start` button
  42412. */
  42413. set buttonStart(value: number);
  42414. /**
  42415. * Gets the value of the `Back` button
  42416. */
  42417. get buttonBack(): number;
  42418. /**
  42419. * Sets the value of the `Back` button
  42420. */
  42421. set buttonBack(value: number);
  42422. /**
  42423. * Gets the value of the `Left` button
  42424. */
  42425. get buttonLB(): number;
  42426. /**
  42427. * Sets the value of the `Left` button
  42428. */
  42429. set buttonLB(value: number);
  42430. /**
  42431. * Gets the value of the `Right` button
  42432. */
  42433. get buttonRB(): number;
  42434. /**
  42435. * Sets the value of the `Right` button
  42436. */
  42437. set buttonRB(value: number);
  42438. /**
  42439. * Gets the value of the Left joystick
  42440. */
  42441. get buttonLeftStick(): number;
  42442. /**
  42443. * Sets the value of the Left joystick
  42444. */
  42445. set buttonLeftStick(value: number);
  42446. /**
  42447. * Gets the value of the Right joystick
  42448. */
  42449. get buttonRightStick(): number;
  42450. /**
  42451. * Sets the value of the Right joystick
  42452. */
  42453. set buttonRightStick(value: number);
  42454. /**
  42455. * Gets the value of D-pad up
  42456. */
  42457. get dPadUp(): number;
  42458. /**
  42459. * Sets the value of D-pad up
  42460. */
  42461. set dPadUp(value: number);
  42462. /**
  42463. * Gets the value of D-pad down
  42464. */
  42465. get dPadDown(): number;
  42466. /**
  42467. * Sets the value of D-pad down
  42468. */
  42469. set dPadDown(value: number);
  42470. /**
  42471. * Gets the value of D-pad left
  42472. */
  42473. get dPadLeft(): number;
  42474. /**
  42475. * Sets the value of D-pad left
  42476. */
  42477. set dPadLeft(value: number);
  42478. /**
  42479. * Gets the value of D-pad right
  42480. */
  42481. get dPadRight(): number;
  42482. /**
  42483. * Sets the value of D-pad right
  42484. */
  42485. set dPadRight(value: number);
  42486. /**
  42487. * Force the gamepad to synchronize with device values
  42488. */
  42489. update(): void;
  42490. /**
  42491. * Disposes the gamepad
  42492. */
  42493. dispose(): void;
  42494. }
  42495. }
  42496. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42497. import { Observable } from "babylonjs/Misc/observable";
  42498. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42499. /**
  42500. * Defines supported buttons for DualShock compatible gamepads
  42501. */
  42502. export enum DualShockButton {
  42503. /** Cross */
  42504. Cross = 0,
  42505. /** Circle */
  42506. Circle = 1,
  42507. /** Square */
  42508. Square = 2,
  42509. /** Triangle */
  42510. Triangle = 3,
  42511. /** Options */
  42512. Options = 4,
  42513. /** Share */
  42514. Share = 5,
  42515. /** L1 */
  42516. L1 = 6,
  42517. /** R1 */
  42518. R1 = 7,
  42519. /** Left stick */
  42520. LeftStick = 8,
  42521. /** Right stick */
  42522. RightStick = 9
  42523. }
  42524. /** Defines values for DualShock DPad */
  42525. export enum DualShockDpad {
  42526. /** Up */
  42527. Up = 0,
  42528. /** Down */
  42529. Down = 1,
  42530. /** Left */
  42531. Left = 2,
  42532. /** Right */
  42533. Right = 3
  42534. }
  42535. /**
  42536. * Defines a DualShock gamepad
  42537. */
  42538. export class DualShockPad extends Gamepad {
  42539. private _leftTrigger;
  42540. private _rightTrigger;
  42541. private _onlefttriggerchanged;
  42542. private _onrighttriggerchanged;
  42543. private _onbuttondown;
  42544. private _onbuttonup;
  42545. private _ondpaddown;
  42546. private _ondpadup;
  42547. /** Observable raised when a button is pressed */
  42548. onButtonDownObservable: Observable<DualShockButton>;
  42549. /** Observable raised when a button is released */
  42550. onButtonUpObservable: Observable<DualShockButton>;
  42551. /** Observable raised when a pad is pressed */
  42552. onPadDownObservable: Observable<DualShockDpad>;
  42553. /** Observable raised when a pad is released */
  42554. onPadUpObservable: Observable<DualShockDpad>;
  42555. private _buttonCross;
  42556. private _buttonCircle;
  42557. private _buttonSquare;
  42558. private _buttonTriangle;
  42559. private _buttonShare;
  42560. private _buttonOptions;
  42561. private _buttonL1;
  42562. private _buttonR1;
  42563. private _buttonLeftStick;
  42564. private _buttonRightStick;
  42565. private _dPadUp;
  42566. private _dPadDown;
  42567. private _dPadLeft;
  42568. private _dPadRight;
  42569. /**
  42570. * Creates a new DualShock gamepad object
  42571. * @param id defines the id of this gamepad
  42572. * @param index defines its index
  42573. * @param gamepad defines the internal HTML gamepad object
  42574. */
  42575. constructor(id: string, index: number, gamepad: any);
  42576. /**
  42577. * Defines the callback to call when left trigger is pressed
  42578. * @param callback defines the callback to use
  42579. */
  42580. onlefttriggerchanged(callback: (value: number) => void): void;
  42581. /**
  42582. * Defines the callback to call when right trigger is pressed
  42583. * @param callback defines the callback to use
  42584. */
  42585. onrighttriggerchanged(callback: (value: number) => void): void;
  42586. /**
  42587. * Gets the left trigger value
  42588. */
  42589. get leftTrigger(): number;
  42590. /**
  42591. * Sets the left trigger value
  42592. */
  42593. set leftTrigger(newValue: number);
  42594. /**
  42595. * Gets the right trigger value
  42596. */
  42597. get rightTrigger(): number;
  42598. /**
  42599. * Sets the right trigger value
  42600. */
  42601. set rightTrigger(newValue: number);
  42602. /**
  42603. * Defines the callback to call when a button is pressed
  42604. * @param callback defines the callback to use
  42605. */
  42606. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42607. /**
  42608. * Defines the callback to call when a button is released
  42609. * @param callback defines the callback to use
  42610. */
  42611. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42612. /**
  42613. * Defines the callback to call when a pad is pressed
  42614. * @param callback defines the callback to use
  42615. */
  42616. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42617. /**
  42618. * Defines the callback to call when a pad is released
  42619. * @param callback defines the callback to use
  42620. */
  42621. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42622. private _setButtonValue;
  42623. private _setDPadValue;
  42624. /**
  42625. * Gets the value of the `Cross` button
  42626. */
  42627. get buttonCross(): number;
  42628. /**
  42629. * Sets the value of the `Cross` button
  42630. */
  42631. set buttonCross(value: number);
  42632. /**
  42633. * Gets the value of the `Circle` button
  42634. */
  42635. get buttonCircle(): number;
  42636. /**
  42637. * Sets the value of the `Circle` button
  42638. */
  42639. set buttonCircle(value: number);
  42640. /**
  42641. * Gets the value of the `Square` button
  42642. */
  42643. get buttonSquare(): number;
  42644. /**
  42645. * Sets the value of the `Square` button
  42646. */
  42647. set buttonSquare(value: number);
  42648. /**
  42649. * Gets the value of the `Triangle` button
  42650. */
  42651. get buttonTriangle(): number;
  42652. /**
  42653. * Sets the value of the `Triangle` button
  42654. */
  42655. set buttonTriangle(value: number);
  42656. /**
  42657. * Gets the value of the `Options` button
  42658. */
  42659. get buttonOptions(): number;
  42660. /**
  42661. * Sets the value of the `Options` button
  42662. */
  42663. set buttonOptions(value: number);
  42664. /**
  42665. * Gets the value of the `Share` button
  42666. */
  42667. get buttonShare(): number;
  42668. /**
  42669. * Sets the value of the `Share` button
  42670. */
  42671. set buttonShare(value: number);
  42672. /**
  42673. * Gets the value of the `L1` button
  42674. */
  42675. get buttonL1(): number;
  42676. /**
  42677. * Sets the value of the `L1` button
  42678. */
  42679. set buttonL1(value: number);
  42680. /**
  42681. * Gets the value of the `R1` button
  42682. */
  42683. get buttonR1(): number;
  42684. /**
  42685. * Sets the value of the `R1` button
  42686. */
  42687. set buttonR1(value: number);
  42688. /**
  42689. * Gets the value of the Left joystick
  42690. */
  42691. get buttonLeftStick(): number;
  42692. /**
  42693. * Sets the value of the Left joystick
  42694. */
  42695. set buttonLeftStick(value: number);
  42696. /**
  42697. * Gets the value of the Right joystick
  42698. */
  42699. get buttonRightStick(): number;
  42700. /**
  42701. * Sets the value of the Right joystick
  42702. */
  42703. set buttonRightStick(value: number);
  42704. /**
  42705. * Gets the value of D-pad up
  42706. */
  42707. get dPadUp(): number;
  42708. /**
  42709. * Sets the value of D-pad up
  42710. */
  42711. set dPadUp(value: number);
  42712. /**
  42713. * Gets the value of D-pad down
  42714. */
  42715. get dPadDown(): number;
  42716. /**
  42717. * Sets the value of D-pad down
  42718. */
  42719. set dPadDown(value: number);
  42720. /**
  42721. * Gets the value of D-pad left
  42722. */
  42723. get dPadLeft(): number;
  42724. /**
  42725. * Sets the value of D-pad left
  42726. */
  42727. set dPadLeft(value: number);
  42728. /**
  42729. * Gets the value of D-pad right
  42730. */
  42731. get dPadRight(): number;
  42732. /**
  42733. * Sets the value of D-pad right
  42734. */
  42735. set dPadRight(value: number);
  42736. /**
  42737. * Force the gamepad to synchronize with device values
  42738. */
  42739. update(): void;
  42740. /**
  42741. * Disposes the gamepad
  42742. */
  42743. dispose(): void;
  42744. }
  42745. }
  42746. declare module "babylonjs/Gamepads/gamepadManager" {
  42747. import { Observable } from "babylonjs/Misc/observable";
  42748. import { Nullable } from "babylonjs/types";
  42749. import { Scene } from "babylonjs/scene";
  42750. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42751. /**
  42752. * Manager for handling gamepads
  42753. */
  42754. export class GamepadManager {
  42755. private _scene?;
  42756. private _babylonGamepads;
  42757. private _oneGamepadConnected;
  42758. /** @hidden */
  42759. _isMonitoring: boolean;
  42760. private _gamepadEventSupported;
  42761. private _gamepadSupport?;
  42762. /**
  42763. * observable to be triggered when the gamepad controller has been connected
  42764. */
  42765. onGamepadConnectedObservable: Observable<Gamepad>;
  42766. /**
  42767. * observable to be triggered when the gamepad controller has been disconnected
  42768. */
  42769. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42770. private _onGamepadConnectedEvent;
  42771. private _onGamepadDisconnectedEvent;
  42772. /**
  42773. * Initializes the gamepad manager
  42774. * @param _scene BabylonJS scene
  42775. */
  42776. constructor(_scene?: Scene | undefined);
  42777. /**
  42778. * The gamepads in the game pad manager
  42779. */
  42780. get gamepads(): Gamepad[];
  42781. /**
  42782. * Get the gamepad controllers based on type
  42783. * @param type The type of gamepad controller
  42784. * @returns Nullable gamepad
  42785. */
  42786. getGamepadByType(type?: number): Nullable<Gamepad>;
  42787. /**
  42788. * Disposes the gamepad manager
  42789. */
  42790. dispose(): void;
  42791. private _addNewGamepad;
  42792. private _startMonitoringGamepads;
  42793. private _stopMonitoringGamepads;
  42794. /** @hidden */
  42795. _checkGamepadsStatus(): void;
  42796. private _updateGamepadObjects;
  42797. }
  42798. }
  42799. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42800. import { Nullable } from "babylonjs/types";
  42801. import { Scene } from "babylonjs/scene";
  42802. import { ISceneComponent } from "babylonjs/sceneComponent";
  42803. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42804. module "babylonjs/scene" {
  42805. interface Scene {
  42806. /** @hidden */
  42807. _gamepadManager: Nullable<GamepadManager>;
  42808. /**
  42809. * Gets the gamepad manager associated with the scene
  42810. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42811. */
  42812. gamepadManager: GamepadManager;
  42813. }
  42814. }
  42815. module "babylonjs/Cameras/freeCameraInputsManager" {
  42816. /**
  42817. * Interface representing a free camera inputs manager
  42818. */
  42819. interface FreeCameraInputsManager {
  42820. /**
  42821. * Adds gamepad input support to the FreeCameraInputsManager.
  42822. * @returns the FreeCameraInputsManager
  42823. */
  42824. addGamepad(): FreeCameraInputsManager;
  42825. }
  42826. }
  42827. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42828. /**
  42829. * Interface representing an arc rotate camera inputs manager
  42830. */
  42831. interface ArcRotateCameraInputsManager {
  42832. /**
  42833. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42834. * @returns the camera inputs manager
  42835. */
  42836. addGamepad(): ArcRotateCameraInputsManager;
  42837. }
  42838. }
  42839. /**
  42840. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42841. */
  42842. export class GamepadSystemSceneComponent implements ISceneComponent {
  42843. /**
  42844. * The component name helpfull to identify the component in the list of scene components.
  42845. */
  42846. readonly name: string;
  42847. /**
  42848. * The scene the component belongs to.
  42849. */
  42850. scene: Scene;
  42851. /**
  42852. * Creates a new instance of the component for the given scene
  42853. * @param scene Defines the scene to register the component in
  42854. */
  42855. constructor(scene: Scene);
  42856. /**
  42857. * Registers the component in a given scene
  42858. */
  42859. register(): void;
  42860. /**
  42861. * Rebuilds the elements related to this component in case of
  42862. * context lost for instance.
  42863. */
  42864. rebuild(): void;
  42865. /**
  42866. * Disposes the component and the associated ressources
  42867. */
  42868. dispose(): void;
  42869. private _beforeCameraUpdate;
  42870. }
  42871. }
  42872. declare module "babylonjs/Cameras/universalCamera" {
  42873. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42874. import { Scene } from "babylonjs/scene";
  42875. import { Vector3 } from "babylonjs/Maths/math.vector";
  42876. import "babylonjs/Gamepads/gamepadSceneComponent";
  42877. /**
  42878. * 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,
  42879. * which still works and will still be found in many Playgrounds.
  42880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42881. */
  42882. export class UniversalCamera extends TouchCamera {
  42883. /**
  42884. * Defines the gamepad rotation sensiblity.
  42885. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42886. */
  42887. get gamepadAngularSensibility(): number;
  42888. set gamepadAngularSensibility(value: number);
  42889. /**
  42890. * Defines the gamepad move sensiblity.
  42891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42892. */
  42893. get gamepadMoveSensibility(): number;
  42894. set gamepadMoveSensibility(value: number);
  42895. /**
  42896. * 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,
  42897. * which still works and will still be found in many Playgrounds.
  42898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42899. * @param name Define the name of the camera in the scene
  42900. * @param position Define the start position of the camera in the scene
  42901. * @param scene Define the scene the camera belongs to
  42902. */
  42903. constructor(name: string, position: Vector3, scene: Scene);
  42904. /**
  42905. * Gets the current object class name.
  42906. * @return the class name
  42907. */
  42908. getClassName(): string;
  42909. }
  42910. }
  42911. declare module "babylonjs/Cameras/gamepadCamera" {
  42912. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42913. import { Scene } from "babylonjs/scene";
  42914. import { Vector3 } from "babylonjs/Maths/math.vector";
  42915. /**
  42916. * This represents a FPS type of camera. This is only here for back compat purpose.
  42917. * Please use the UniversalCamera instead as both are identical.
  42918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42919. */
  42920. export class GamepadCamera extends UniversalCamera {
  42921. /**
  42922. * Instantiates a new Gamepad Camera
  42923. * This represents a FPS type of camera. This is only here for back compat purpose.
  42924. * Please use the UniversalCamera instead as both are identical.
  42925. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42926. * @param name Define the name of the camera in the scene
  42927. * @param position Define the start position of the camera in the scene
  42928. * @param scene Define the scene the camera belongs to
  42929. */
  42930. constructor(name: string, position: Vector3, scene: Scene);
  42931. /**
  42932. * Gets the current object class name.
  42933. * @return the class name
  42934. */
  42935. getClassName(): string;
  42936. }
  42937. }
  42938. declare module "babylonjs/Shaders/pass.fragment" {
  42939. /** @hidden */
  42940. export var passPixelShader: {
  42941. name: string;
  42942. shader: string;
  42943. };
  42944. }
  42945. declare module "babylonjs/Shaders/passCube.fragment" {
  42946. /** @hidden */
  42947. export var passCubePixelShader: {
  42948. name: string;
  42949. shader: string;
  42950. };
  42951. }
  42952. declare module "babylonjs/PostProcesses/passPostProcess" {
  42953. import { Nullable } from "babylonjs/types";
  42954. import { Camera } from "babylonjs/Cameras/camera";
  42955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42956. import { Engine } from "babylonjs/Engines/engine";
  42957. import "babylonjs/Shaders/pass.fragment";
  42958. import "babylonjs/Shaders/passCube.fragment";
  42959. /**
  42960. * PassPostProcess which produces an output the same as it's input
  42961. */
  42962. export class PassPostProcess extends PostProcess {
  42963. /**
  42964. * Creates the PassPostProcess
  42965. * @param name The name of the effect.
  42966. * @param options The required width/height ratio to downsize to before computing the render pass.
  42967. * @param camera The camera to apply the render pass to.
  42968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42969. * @param engine The engine which the post process will be applied. (default: current engine)
  42970. * @param reusable If the post process can be reused on the same frame. (default: false)
  42971. * @param textureType The type of texture to be used when performing the post processing.
  42972. * @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)
  42973. */
  42974. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42975. }
  42976. /**
  42977. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42978. */
  42979. export class PassCubePostProcess extends PostProcess {
  42980. private _face;
  42981. /**
  42982. * Gets or sets the cube face to display.
  42983. * * 0 is +X
  42984. * * 1 is -X
  42985. * * 2 is +Y
  42986. * * 3 is -Y
  42987. * * 4 is +Z
  42988. * * 5 is -Z
  42989. */
  42990. get face(): number;
  42991. set face(value: number);
  42992. /**
  42993. * Creates the PassCubePostProcess
  42994. * @param name The name of the effect.
  42995. * @param options The required width/height ratio to downsize to before computing the render pass.
  42996. * @param camera The camera to apply the render pass to.
  42997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42998. * @param engine The engine which the post process will be applied. (default: current engine)
  42999. * @param reusable If the post process can be reused on the same frame. (default: false)
  43000. * @param textureType The type of texture to be used when performing the post processing.
  43001. * @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)
  43002. */
  43003. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43004. }
  43005. }
  43006. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43007. /** @hidden */
  43008. export var anaglyphPixelShader: {
  43009. name: string;
  43010. shader: string;
  43011. };
  43012. }
  43013. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43014. import { Engine } from "babylonjs/Engines/engine";
  43015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43016. import { Camera } from "babylonjs/Cameras/camera";
  43017. import "babylonjs/Shaders/anaglyph.fragment";
  43018. /**
  43019. * Postprocess used to generate anaglyphic rendering
  43020. */
  43021. export class AnaglyphPostProcess extends PostProcess {
  43022. private _passedProcess;
  43023. /**
  43024. * Creates a new AnaglyphPostProcess
  43025. * @param name defines postprocess name
  43026. * @param options defines creation options or target ratio scale
  43027. * @param rigCameras defines cameras using this postprocess
  43028. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43029. * @param engine defines hosting engine
  43030. * @param reusable defines if the postprocess will be reused multiple times per frame
  43031. */
  43032. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43033. }
  43034. }
  43035. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43036. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43037. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43038. import { Scene } from "babylonjs/scene";
  43039. import { Vector3 } from "babylonjs/Maths/math.vector";
  43040. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43041. /**
  43042. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43043. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43044. */
  43045. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43046. /**
  43047. * Creates a new AnaglyphArcRotateCamera
  43048. * @param name defines camera name
  43049. * @param alpha defines alpha angle (in radians)
  43050. * @param beta defines beta angle (in radians)
  43051. * @param radius defines radius
  43052. * @param target defines camera target
  43053. * @param interaxialDistance defines distance between each color axis
  43054. * @param scene defines the hosting scene
  43055. */
  43056. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43057. /**
  43058. * Gets camera class name
  43059. * @returns AnaglyphArcRotateCamera
  43060. */
  43061. getClassName(): string;
  43062. }
  43063. }
  43064. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43065. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43066. import { Scene } from "babylonjs/scene";
  43067. import { Vector3 } from "babylonjs/Maths/math.vector";
  43068. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43069. /**
  43070. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43071. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43072. */
  43073. export class AnaglyphFreeCamera extends FreeCamera {
  43074. /**
  43075. * Creates a new AnaglyphFreeCamera
  43076. * @param name defines camera name
  43077. * @param position defines initial position
  43078. * @param interaxialDistance defines distance between each color axis
  43079. * @param scene defines the hosting scene
  43080. */
  43081. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43082. /**
  43083. * Gets camera class name
  43084. * @returns AnaglyphFreeCamera
  43085. */
  43086. getClassName(): string;
  43087. }
  43088. }
  43089. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43090. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43091. import { Scene } from "babylonjs/scene";
  43092. import { Vector3 } from "babylonjs/Maths/math.vector";
  43093. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43094. /**
  43095. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43096. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43097. */
  43098. export class AnaglyphGamepadCamera extends GamepadCamera {
  43099. /**
  43100. * Creates a new AnaglyphGamepadCamera
  43101. * @param name defines camera name
  43102. * @param position defines initial position
  43103. * @param interaxialDistance defines distance between each color axis
  43104. * @param scene defines the hosting scene
  43105. */
  43106. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43107. /**
  43108. * Gets camera class name
  43109. * @returns AnaglyphGamepadCamera
  43110. */
  43111. getClassName(): string;
  43112. }
  43113. }
  43114. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43115. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43116. import { Scene } from "babylonjs/scene";
  43117. import { Vector3 } from "babylonjs/Maths/math.vector";
  43118. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43119. /**
  43120. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43121. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43122. */
  43123. export class AnaglyphUniversalCamera extends UniversalCamera {
  43124. /**
  43125. * Creates a new AnaglyphUniversalCamera
  43126. * @param name defines camera name
  43127. * @param position defines initial position
  43128. * @param interaxialDistance defines distance between each color axis
  43129. * @param scene defines the hosting scene
  43130. */
  43131. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43132. /**
  43133. * Gets camera class name
  43134. * @returns AnaglyphUniversalCamera
  43135. */
  43136. getClassName(): string;
  43137. }
  43138. }
  43139. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43140. /** @hidden */
  43141. export var stereoscopicInterlacePixelShader: {
  43142. name: string;
  43143. shader: string;
  43144. };
  43145. }
  43146. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43147. import { Camera } from "babylonjs/Cameras/camera";
  43148. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43149. import { Engine } from "babylonjs/Engines/engine";
  43150. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43151. /**
  43152. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43153. */
  43154. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43155. private _stepSize;
  43156. private _passedProcess;
  43157. /**
  43158. * Initializes a StereoscopicInterlacePostProcessI
  43159. * @param name The name of the effect.
  43160. * @param rigCameras The rig cameras to be appled to the post process
  43161. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43162. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43164. * @param engine The engine which the post process will be applied. (default: current engine)
  43165. * @param reusable If the post process can be reused on the same frame. (default: false)
  43166. */
  43167. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43168. }
  43169. /**
  43170. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43171. */
  43172. export class StereoscopicInterlacePostProcess extends PostProcess {
  43173. private _stepSize;
  43174. private _passedProcess;
  43175. /**
  43176. * Initializes a StereoscopicInterlacePostProcess
  43177. * @param name The name of the effect.
  43178. * @param rigCameras The rig cameras to be appled to the post process
  43179. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43181. * @param engine The engine which the post process will be applied. (default: current engine)
  43182. * @param reusable If the post process can be reused on the same frame. (default: false)
  43183. */
  43184. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43185. }
  43186. }
  43187. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43188. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43189. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43190. import { Scene } from "babylonjs/scene";
  43191. import { Vector3 } from "babylonjs/Maths/math.vector";
  43192. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43193. /**
  43194. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43195. * @see http://doc.babylonjs.com/features/cameras
  43196. */
  43197. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43198. /**
  43199. * Creates a new StereoscopicArcRotateCamera
  43200. * @param name defines camera name
  43201. * @param alpha defines alpha angle (in radians)
  43202. * @param beta defines beta angle (in radians)
  43203. * @param radius defines radius
  43204. * @param target defines camera target
  43205. * @param interaxialDistance defines distance between each color axis
  43206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43207. * @param scene defines the hosting scene
  43208. */
  43209. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43210. /**
  43211. * Gets camera class name
  43212. * @returns StereoscopicArcRotateCamera
  43213. */
  43214. getClassName(): string;
  43215. }
  43216. }
  43217. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43218. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43219. import { Scene } from "babylonjs/scene";
  43220. import { Vector3 } from "babylonjs/Maths/math.vector";
  43221. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43222. /**
  43223. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43224. * @see http://doc.babylonjs.com/features/cameras
  43225. */
  43226. export class StereoscopicFreeCamera extends FreeCamera {
  43227. /**
  43228. * Creates a new StereoscopicFreeCamera
  43229. * @param name defines camera name
  43230. * @param position defines initial position
  43231. * @param interaxialDistance defines distance between each color axis
  43232. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43233. * @param scene defines the hosting scene
  43234. */
  43235. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43236. /**
  43237. * Gets camera class name
  43238. * @returns StereoscopicFreeCamera
  43239. */
  43240. getClassName(): string;
  43241. }
  43242. }
  43243. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43244. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43245. import { Scene } from "babylonjs/scene";
  43246. import { Vector3 } from "babylonjs/Maths/math.vector";
  43247. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43248. /**
  43249. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43250. * @see http://doc.babylonjs.com/features/cameras
  43251. */
  43252. export class StereoscopicGamepadCamera extends GamepadCamera {
  43253. /**
  43254. * Creates a new StereoscopicGamepadCamera
  43255. * @param name defines camera name
  43256. * @param position defines initial position
  43257. * @param interaxialDistance defines distance between each color axis
  43258. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43259. * @param scene defines the hosting scene
  43260. */
  43261. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43262. /**
  43263. * Gets camera class name
  43264. * @returns StereoscopicGamepadCamera
  43265. */
  43266. getClassName(): string;
  43267. }
  43268. }
  43269. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43270. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43271. import { Scene } from "babylonjs/scene";
  43272. import { Vector3 } from "babylonjs/Maths/math.vector";
  43273. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43274. /**
  43275. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43276. * @see http://doc.babylonjs.com/features/cameras
  43277. */
  43278. export class StereoscopicUniversalCamera extends UniversalCamera {
  43279. /**
  43280. * Creates a new StereoscopicUniversalCamera
  43281. * @param name defines camera name
  43282. * @param position defines initial position
  43283. * @param interaxialDistance defines distance between each color axis
  43284. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43285. * @param scene defines the hosting scene
  43286. */
  43287. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43288. /**
  43289. * Gets camera class name
  43290. * @returns StereoscopicUniversalCamera
  43291. */
  43292. getClassName(): string;
  43293. }
  43294. }
  43295. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43296. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43297. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43298. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43299. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43300. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43301. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43302. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43303. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43304. }
  43305. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43306. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43307. import { Scene } from "babylonjs/scene";
  43308. import { Vector3 } from "babylonjs/Maths/math.vector";
  43309. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43310. /**
  43311. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43312. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43313. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43314. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43315. */
  43316. export class VirtualJoysticksCamera extends FreeCamera {
  43317. /**
  43318. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43319. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43320. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43321. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43322. * @param name Define the name of the camera in the scene
  43323. * @param position Define the start position of the camera in the scene
  43324. * @param scene Define the scene the camera belongs to
  43325. */
  43326. constructor(name: string, position: Vector3, scene: Scene);
  43327. /**
  43328. * Gets the current object class name.
  43329. * @return the class name
  43330. */
  43331. getClassName(): string;
  43332. }
  43333. }
  43334. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43335. import { Matrix } from "babylonjs/Maths/math.vector";
  43336. /**
  43337. * This represents all the required metrics to create a VR camera.
  43338. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43339. */
  43340. export class VRCameraMetrics {
  43341. /**
  43342. * Define the horizontal resolution off the screen.
  43343. */
  43344. hResolution: number;
  43345. /**
  43346. * Define the vertical resolution off the screen.
  43347. */
  43348. vResolution: number;
  43349. /**
  43350. * Define the horizontal screen size.
  43351. */
  43352. hScreenSize: number;
  43353. /**
  43354. * Define the vertical screen size.
  43355. */
  43356. vScreenSize: number;
  43357. /**
  43358. * Define the vertical screen center position.
  43359. */
  43360. vScreenCenter: number;
  43361. /**
  43362. * Define the distance of the eyes to the screen.
  43363. */
  43364. eyeToScreenDistance: number;
  43365. /**
  43366. * Define the distance between both lenses
  43367. */
  43368. lensSeparationDistance: number;
  43369. /**
  43370. * Define the distance between both viewer's eyes.
  43371. */
  43372. interpupillaryDistance: number;
  43373. /**
  43374. * Define the distortion factor of the VR postprocess.
  43375. * Please, touch with care.
  43376. */
  43377. distortionK: number[];
  43378. /**
  43379. * Define the chromatic aberration correction factors for the VR post process.
  43380. */
  43381. chromaAbCorrection: number[];
  43382. /**
  43383. * Define the scale factor of the post process.
  43384. * The smaller the better but the slower.
  43385. */
  43386. postProcessScaleFactor: number;
  43387. /**
  43388. * Define an offset for the lens center.
  43389. */
  43390. lensCenterOffset: number;
  43391. /**
  43392. * Define if the current vr camera should compensate the distortion of the lense or not.
  43393. */
  43394. compensateDistortion: boolean;
  43395. /**
  43396. * Defines if multiview should be enabled when rendering (Default: false)
  43397. */
  43398. multiviewEnabled: boolean;
  43399. /**
  43400. * Gets the rendering aspect ratio based on the provided resolutions.
  43401. */
  43402. get aspectRatio(): number;
  43403. /**
  43404. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43405. */
  43406. get aspectRatioFov(): number;
  43407. /**
  43408. * @hidden
  43409. */
  43410. get leftHMatrix(): Matrix;
  43411. /**
  43412. * @hidden
  43413. */
  43414. get rightHMatrix(): Matrix;
  43415. /**
  43416. * @hidden
  43417. */
  43418. get leftPreViewMatrix(): Matrix;
  43419. /**
  43420. * @hidden
  43421. */
  43422. get rightPreViewMatrix(): Matrix;
  43423. /**
  43424. * Get the default VRMetrics based on the most generic setup.
  43425. * @returns the default vr metrics
  43426. */
  43427. static GetDefault(): VRCameraMetrics;
  43428. }
  43429. }
  43430. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43431. /** @hidden */
  43432. export var vrDistortionCorrectionPixelShader: {
  43433. name: string;
  43434. shader: string;
  43435. };
  43436. }
  43437. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43438. import { Camera } from "babylonjs/Cameras/camera";
  43439. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43441. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43442. /**
  43443. * VRDistortionCorrectionPostProcess used for mobile VR
  43444. */
  43445. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43446. private _isRightEye;
  43447. private _distortionFactors;
  43448. private _postProcessScaleFactor;
  43449. private _lensCenterOffset;
  43450. private _scaleIn;
  43451. private _scaleFactor;
  43452. private _lensCenter;
  43453. /**
  43454. * Initializes the VRDistortionCorrectionPostProcess
  43455. * @param name The name of the effect.
  43456. * @param camera The camera to apply the render pass to.
  43457. * @param isRightEye If this is for the right eye distortion
  43458. * @param vrMetrics All the required metrics for the VR camera
  43459. */
  43460. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43461. }
  43462. }
  43463. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43464. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43465. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43466. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43467. import { Scene } from "babylonjs/scene";
  43468. import { Vector3 } from "babylonjs/Maths/math.vector";
  43469. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43470. import "babylonjs/Cameras/RigModes/vrRigMode";
  43471. /**
  43472. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43473. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43474. */
  43475. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43476. /**
  43477. * Creates a new VRDeviceOrientationArcRotateCamera
  43478. * @param name defines camera name
  43479. * @param alpha defines the camera rotation along the logitudinal axis
  43480. * @param beta defines the camera rotation along the latitudinal axis
  43481. * @param radius defines the camera distance from its target
  43482. * @param target defines the camera target
  43483. * @param scene defines the scene the camera belongs to
  43484. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43485. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43486. */
  43487. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43488. /**
  43489. * Gets camera class name
  43490. * @returns VRDeviceOrientationArcRotateCamera
  43491. */
  43492. getClassName(): string;
  43493. }
  43494. }
  43495. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43496. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43497. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43498. import { Scene } from "babylonjs/scene";
  43499. import { Vector3 } from "babylonjs/Maths/math.vector";
  43500. import "babylonjs/Cameras/RigModes/vrRigMode";
  43501. /**
  43502. * Camera used to simulate VR rendering (based on FreeCamera)
  43503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43504. */
  43505. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43506. /**
  43507. * Creates a new VRDeviceOrientationFreeCamera
  43508. * @param name defines camera name
  43509. * @param position defines the start position of the camera
  43510. * @param scene defines the scene the camera belongs to
  43511. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43512. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43513. */
  43514. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43515. /**
  43516. * Gets camera class name
  43517. * @returns VRDeviceOrientationFreeCamera
  43518. */
  43519. getClassName(): string;
  43520. }
  43521. }
  43522. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43523. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43524. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43525. import { Scene } from "babylonjs/scene";
  43526. import { Vector3 } from "babylonjs/Maths/math.vector";
  43527. import "babylonjs/Gamepads/gamepadSceneComponent";
  43528. /**
  43529. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43530. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43531. */
  43532. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43533. /**
  43534. * Creates a new VRDeviceOrientationGamepadCamera
  43535. * @param name defines camera name
  43536. * @param position defines the start position of the camera
  43537. * @param scene defines the scene the camera belongs to
  43538. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43539. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43540. */
  43541. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43542. /**
  43543. * Gets camera class name
  43544. * @returns VRDeviceOrientationGamepadCamera
  43545. */
  43546. getClassName(): string;
  43547. }
  43548. }
  43549. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43550. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43552. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43553. /** @hidden */
  43554. export var imageProcessingPixelShader: {
  43555. name: string;
  43556. shader: string;
  43557. };
  43558. }
  43559. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43560. import { Nullable } from "babylonjs/types";
  43561. import { Color4 } from "babylonjs/Maths/math.color";
  43562. import { Camera } from "babylonjs/Cameras/camera";
  43563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43564. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43567. import { Engine } from "babylonjs/Engines/engine";
  43568. import "babylonjs/Shaders/imageProcessing.fragment";
  43569. import "babylonjs/Shaders/postprocess.vertex";
  43570. /**
  43571. * ImageProcessingPostProcess
  43572. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43573. */
  43574. export class ImageProcessingPostProcess extends PostProcess {
  43575. /**
  43576. * Default configuration related to image processing available in the PBR Material.
  43577. */
  43578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43579. /**
  43580. * Gets the image processing configuration used either in this material.
  43581. */
  43582. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43583. /**
  43584. * Sets the Default image processing configuration used either in the this material.
  43585. *
  43586. * If sets to null, the scene one is in use.
  43587. */
  43588. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43589. /**
  43590. * Keep track of the image processing observer to allow dispose and replace.
  43591. */
  43592. private _imageProcessingObserver;
  43593. /**
  43594. * Attaches a new image processing configuration to the PBR Material.
  43595. * @param configuration
  43596. */
  43597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43598. /**
  43599. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43600. */
  43601. get colorCurves(): Nullable<ColorCurves>;
  43602. /**
  43603. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43604. */
  43605. set colorCurves(value: Nullable<ColorCurves>);
  43606. /**
  43607. * Gets wether the color curves effect is enabled.
  43608. */
  43609. get colorCurvesEnabled(): boolean;
  43610. /**
  43611. * Sets wether the color curves effect is enabled.
  43612. */
  43613. set colorCurvesEnabled(value: boolean);
  43614. /**
  43615. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43616. */
  43617. get colorGradingTexture(): Nullable<BaseTexture>;
  43618. /**
  43619. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43620. */
  43621. set colorGradingTexture(value: Nullable<BaseTexture>);
  43622. /**
  43623. * Gets wether the color grading effect is enabled.
  43624. */
  43625. get colorGradingEnabled(): boolean;
  43626. /**
  43627. * Gets wether the color grading effect is enabled.
  43628. */
  43629. set colorGradingEnabled(value: boolean);
  43630. /**
  43631. * Gets exposure used in the effect.
  43632. */
  43633. get exposure(): number;
  43634. /**
  43635. * Sets exposure used in the effect.
  43636. */
  43637. set exposure(value: number);
  43638. /**
  43639. * Gets wether tonemapping is enabled or not.
  43640. */
  43641. get toneMappingEnabled(): boolean;
  43642. /**
  43643. * Sets wether tonemapping is enabled or not
  43644. */
  43645. set toneMappingEnabled(value: boolean);
  43646. /**
  43647. * Gets the type of tone mapping effect.
  43648. */
  43649. get toneMappingType(): number;
  43650. /**
  43651. * Sets the type of tone mapping effect.
  43652. */
  43653. set toneMappingType(value: number);
  43654. /**
  43655. * Gets contrast used in the effect.
  43656. */
  43657. get contrast(): number;
  43658. /**
  43659. * Sets contrast used in the effect.
  43660. */
  43661. set contrast(value: number);
  43662. /**
  43663. * Gets Vignette stretch size.
  43664. */
  43665. get vignetteStretch(): number;
  43666. /**
  43667. * Sets Vignette stretch size.
  43668. */
  43669. set vignetteStretch(value: number);
  43670. /**
  43671. * Gets Vignette centre X Offset.
  43672. */
  43673. get vignetteCentreX(): number;
  43674. /**
  43675. * Sets Vignette centre X Offset.
  43676. */
  43677. set vignetteCentreX(value: number);
  43678. /**
  43679. * Gets Vignette centre Y Offset.
  43680. */
  43681. get vignetteCentreY(): number;
  43682. /**
  43683. * Sets Vignette centre Y Offset.
  43684. */
  43685. set vignetteCentreY(value: number);
  43686. /**
  43687. * Gets Vignette weight or intensity of the vignette effect.
  43688. */
  43689. get vignetteWeight(): number;
  43690. /**
  43691. * Sets Vignette weight or intensity of the vignette effect.
  43692. */
  43693. set vignetteWeight(value: number);
  43694. /**
  43695. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43696. * if vignetteEnabled is set to true.
  43697. */
  43698. get vignetteColor(): Color4;
  43699. /**
  43700. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43701. * if vignetteEnabled is set to true.
  43702. */
  43703. set vignetteColor(value: Color4);
  43704. /**
  43705. * Gets Camera field of view used by the Vignette effect.
  43706. */
  43707. get vignetteCameraFov(): number;
  43708. /**
  43709. * Sets Camera field of view used by the Vignette effect.
  43710. */
  43711. set vignetteCameraFov(value: number);
  43712. /**
  43713. * Gets the vignette blend mode allowing different kind of effect.
  43714. */
  43715. get vignetteBlendMode(): number;
  43716. /**
  43717. * Sets the vignette blend mode allowing different kind of effect.
  43718. */
  43719. set vignetteBlendMode(value: number);
  43720. /**
  43721. * Gets wether the vignette effect is enabled.
  43722. */
  43723. get vignetteEnabled(): boolean;
  43724. /**
  43725. * Sets wether the vignette effect is enabled.
  43726. */
  43727. set vignetteEnabled(value: boolean);
  43728. private _fromLinearSpace;
  43729. /**
  43730. * Gets wether the input of the processing is in Gamma or Linear Space.
  43731. */
  43732. get fromLinearSpace(): boolean;
  43733. /**
  43734. * Sets wether the input of the processing is in Gamma or Linear Space.
  43735. */
  43736. set fromLinearSpace(value: boolean);
  43737. /**
  43738. * Defines cache preventing GC.
  43739. */
  43740. private _defines;
  43741. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43742. /**
  43743. * "ImageProcessingPostProcess"
  43744. * @returns "ImageProcessingPostProcess"
  43745. */
  43746. getClassName(): string;
  43747. protected _updateParameters(): void;
  43748. dispose(camera?: Camera): void;
  43749. }
  43750. }
  43751. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43752. import { Scene } from "babylonjs/scene";
  43753. import { Color3 } from "babylonjs/Maths/math.color";
  43754. import { Mesh } from "babylonjs/Meshes/mesh";
  43755. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43756. import { Nullable } from "babylonjs/types";
  43757. /**
  43758. * Class containing static functions to help procedurally build meshes
  43759. */
  43760. export class GroundBuilder {
  43761. /**
  43762. * Creates a ground mesh
  43763. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43764. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43766. * @param name defines the name of the mesh
  43767. * @param options defines the options used to create the mesh
  43768. * @param scene defines the hosting scene
  43769. * @returns the ground mesh
  43770. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43771. */
  43772. static CreateGround(name: string, options: {
  43773. width?: number;
  43774. height?: number;
  43775. subdivisions?: number;
  43776. subdivisionsX?: number;
  43777. subdivisionsY?: number;
  43778. updatable?: boolean;
  43779. }, scene: any): Mesh;
  43780. /**
  43781. * Creates a tiled ground mesh
  43782. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43783. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43784. * * 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
  43785. * * 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
  43786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43787. * @param name defines the name of the mesh
  43788. * @param options defines the options used to create the mesh
  43789. * @param scene defines the hosting scene
  43790. * @returns the tiled ground mesh
  43791. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43792. */
  43793. static CreateTiledGround(name: string, options: {
  43794. xmin: number;
  43795. zmin: number;
  43796. xmax: number;
  43797. zmax: number;
  43798. subdivisions?: {
  43799. w: number;
  43800. h: number;
  43801. };
  43802. precision?: {
  43803. w: number;
  43804. h: number;
  43805. };
  43806. updatable?: boolean;
  43807. }, scene?: Nullable<Scene>): Mesh;
  43808. /**
  43809. * Creates a ground mesh from a height map
  43810. * * The parameter `url` sets the URL of the height map image resource.
  43811. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43812. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43813. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43814. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43815. * * 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.
  43816. * * 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).
  43817. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43819. * @param name defines the name of the mesh
  43820. * @param url defines the url to the height map
  43821. * @param options defines the options used to create the mesh
  43822. * @param scene defines the hosting scene
  43823. * @returns the ground mesh
  43824. * @see https://doc.babylonjs.com/babylon101/height_map
  43825. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43826. */
  43827. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43828. width?: number;
  43829. height?: number;
  43830. subdivisions?: number;
  43831. minHeight?: number;
  43832. maxHeight?: number;
  43833. colorFilter?: Color3;
  43834. alphaFilter?: number;
  43835. updatable?: boolean;
  43836. onReady?: (mesh: GroundMesh) => void;
  43837. }, scene?: Nullable<Scene>): GroundMesh;
  43838. }
  43839. }
  43840. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43841. import { Vector4 } from "babylonjs/Maths/math.vector";
  43842. import { Mesh } from "babylonjs/Meshes/mesh";
  43843. /**
  43844. * Class containing static functions to help procedurally build meshes
  43845. */
  43846. export class TorusBuilder {
  43847. /**
  43848. * Creates a torus mesh
  43849. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43850. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43851. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43855. * @param name defines the name of the mesh
  43856. * @param options defines the options used to create the mesh
  43857. * @param scene defines the hosting scene
  43858. * @returns the torus mesh
  43859. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43860. */
  43861. static CreateTorus(name: string, options: {
  43862. diameter?: number;
  43863. thickness?: number;
  43864. tessellation?: number;
  43865. updatable?: boolean;
  43866. sideOrientation?: number;
  43867. frontUVs?: Vector4;
  43868. backUVs?: Vector4;
  43869. }, scene: any): Mesh;
  43870. }
  43871. }
  43872. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43873. import { Vector4 } from "babylonjs/Maths/math.vector";
  43874. import { Color4 } from "babylonjs/Maths/math.color";
  43875. import { Mesh } from "babylonjs/Meshes/mesh";
  43876. /**
  43877. * Class containing static functions to help procedurally build meshes
  43878. */
  43879. export class CylinderBuilder {
  43880. /**
  43881. * Creates a cylinder or a cone mesh
  43882. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43883. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43884. * * 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.
  43885. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43886. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43887. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43888. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43889. * * 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).
  43890. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43891. * * 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).
  43892. * * 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
  43893. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43894. * * 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
  43895. * * 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.
  43896. * * If `enclose` is false, a ring surface is one element.
  43897. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43898. * * 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
  43899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43902. * @param name defines the name of the mesh
  43903. * @param options defines the options used to create the mesh
  43904. * @param scene defines the hosting scene
  43905. * @returns the cylinder mesh
  43906. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43907. */
  43908. static CreateCylinder(name: string, options: {
  43909. height?: number;
  43910. diameterTop?: number;
  43911. diameterBottom?: number;
  43912. diameter?: number;
  43913. tessellation?: number;
  43914. subdivisions?: number;
  43915. arc?: number;
  43916. faceColors?: Color4[];
  43917. faceUV?: Vector4[];
  43918. updatable?: boolean;
  43919. hasRings?: boolean;
  43920. enclose?: boolean;
  43921. cap?: number;
  43922. sideOrientation?: number;
  43923. frontUVs?: Vector4;
  43924. backUVs?: Vector4;
  43925. }, scene: any): Mesh;
  43926. }
  43927. }
  43928. declare module "babylonjs/XR/webXRTypes" {
  43929. import { Nullable } from "babylonjs/types";
  43930. import { IDisposable } from "babylonjs/scene";
  43931. /**
  43932. * States of the webXR experience
  43933. */
  43934. export enum WebXRState {
  43935. /**
  43936. * Transitioning to being in XR mode
  43937. */
  43938. ENTERING_XR = 0,
  43939. /**
  43940. * Transitioning to non XR mode
  43941. */
  43942. EXITING_XR = 1,
  43943. /**
  43944. * In XR mode and presenting
  43945. */
  43946. IN_XR = 2,
  43947. /**
  43948. * Not entered XR mode
  43949. */
  43950. NOT_IN_XR = 3
  43951. }
  43952. /**
  43953. * Abstraction of the XR render target
  43954. */
  43955. export interface WebXRRenderTarget extends IDisposable {
  43956. /**
  43957. * xrpresent context of the canvas which can be used to display/mirror xr content
  43958. */
  43959. canvasContext: WebGLRenderingContext;
  43960. /**
  43961. * xr layer for the canvas
  43962. */
  43963. xrLayer: Nullable<XRWebGLLayer>;
  43964. /**
  43965. * Initializes the xr layer for the session
  43966. * @param xrSession xr session
  43967. * @returns a promise that will resolve once the XR Layer has been created
  43968. */
  43969. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43970. }
  43971. }
  43972. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  43973. import { Nullable } from "babylonjs/types";
  43974. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43975. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  43976. /**
  43977. * COnfiguration object for WebXR output canvas
  43978. */
  43979. export class WebXRManagedOutputCanvasOptions {
  43980. /**
  43981. * An optional canvas in case you wish to create it yourself and provide it here.
  43982. * If not provided, a new canvas will be created
  43983. */
  43984. canvasElement?: HTMLCanvasElement;
  43985. /**
  43986. * Options for this XR Layer output
  43987. */
  43988. canvasOptions?: XRWebGLLayerOptions;
  43989. /**
  43990. * CSS styling for a newly created canvas (if not provided)
  43991. */
  43992. newCanvasCssStyle?: string;
  43993. /**
  43994. * Get the default values of the configuration object
  43995. * @returns default values of this configuration object
  43996. */
  43997. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43998. }
  43999. /**
  44000. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44001. */
  44002. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44003. private _options;
  44004. private _canvas;
  44005. private _engine;
  44006. /**
  44007. * Rendering context of the canvas which can be used to display/mirror xr content
  44008. */
  44009. canvasContext: WebGLRenderingContext;
  44010. /**
  44011. * xr layer for the canvas
  44012. */
  44013. xrLayer: Nullable<XRWebGLLayer>;
  44014. /**
  44015. * Initializes the canvas to be added/removed upon entering/exiting xr
  44016. * @param _xrSessionManager The XR Session manager
  44017. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44018. */
  44019. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44020. /**
  44021. * Disposes of the object
  44022. */
  44023. dispose(): void;
  44024. /**
  44025. * Initializes the xr layer for the session
  44026. * @param xrSession xr session
  44027. * @returns a promise that will resolve once the XR Layer has been created
  44028. */
  44029. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44030. private _addCanvas;
  44031. private _removeCanvas;
  44032. private _setManagedOutputCanvas;
  44033. }
  44034. }
  44035. declare module "babylonjs/XR/webXRSessionManager" {
  44036. import { Observable } from "babylonjs/Misc/observable";
  44037. import { Nullable } from "babylonjs/types";
  44038. import { IDisposable, Scene } from "babylonjs/scene";
  44039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44040. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44041. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44042. /**
  44043. * Manages an XRSession to work with Babylon's engine
  44044. * @see https://doc.babylonjs.com/how_to/webxr
  44045. */
  44046. export class WebXRSessionManager implements IDisposable {
  44047. /** The scene which the session should be created for */
  44048. scene: Scene;
  44049. private _referenceSpace;
  44050. private _rttProvider;
  44051. private _sessionEnded;
  44052. private _xrNavigator;
  44053. private baseLayer;
  44054. /**
  44055. * The base reference space from which the session started. good if you want to reset your
  44056. * reference space
  44057. */
  44058. baseReferenceSpace: XRReferenceSpace;
  44059. /**
  44060. * Current XR frame
  44061. */
  44062. currentFrame: Nullable<XRFrame>;
  44063. /** WebXR timestamp updated every frame */
  44064. currentTimestamp: number;
  44065. /**
  44066. * Used just in case of a failure to initialize an immersive session.
  44067. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44068. */
  44069. defaultHeightCompensation: number;
  44070. /**
  44071. * Fires every time a new xrFrame arrives which can be used to update the camera
  44072. */
  44073. onXRFrameObservable: Observable<XRFrame>;
  44074. /**
  44075. * Fires when the reference space changed
  44076. */
  44077. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44078. /**
  44079. * Fires when the xr session is ended either by the device or manually done
  44080. */
  44081. onXRSessionEnded: Observable<any>;
  44082. /**
  44083. * Fires when the xr session is ended either by the device or manually done
  44084. */
  44085. onXRSessionInit: Observable<XRSession>;
  44086. /**
  44087. * Underlying xr session
  44088. */
  44089. session: XRSession;
  44090. /**
  44091. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44092. * or get the offset the player is currently at.
  44093. */
  44094. viewerReferenceSpace: XRReferenceSpace;
  44095. /**
  44096. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44097. * @param scene The scene which the session should be created for
  44098. */
  44099. constructor(
  44100. /** The scene which the session should be created for */
  44101. scene: Scene);
  44102. /**
  44103. * The current reference space used in this session. This reference space can constantly change!
  44104. * It is mainly used to offset the camera's position.
  44105. */
  44106. get referenceSpace(): XRReferenceSpace;
  44107. /**
  44108. * Set a new reference space and triggers the observable
  44109. */
  44110. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44111. /**
  44112. * Disposes of the session manager
  44113. */
  44114. dispose(): void;
  44115. /**
  44116. * Stops the xrSession and restores the render loop
  44117. * @returns Promise which resolves after it exits XR
  44118. */
  44119. exitXRAsync(): Promise<void>;
  44120. /**
  44121. * Gets the correct render target texture to be rendered this frame for this eye
  44122. * @param eye the eye for which to get the render target
  44123. * @returns the render target for the specified eye
  44124. */
  44125. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44126. /**
  44127. * Creates a WebXRRenderTarget object for the XR session
  44128. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44129. * @param options optional options to provide when creating a new render target
  44130. * @returns a WebXR render target to which the session can render
  44131. */
  44132. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44133. /**
  44134. * Initializes the manager
  44135. * After initialization enterXR can be called to start an XR session
  44136. * @returns Promise which resolves after it is initialized
  44137. */
  44138. initializeAsync(): Promise<void>;
  44139. /**
  44140. * Initializes an xr session
  44141. * @param xrSessionMode mode to initialize
  44142. * @param xrSessionInit defines optional and required values to pass to the session builder
  44143. * @returns a promise which will resolve once the session has been initialized
  44144. */
  44145. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44146. /**
  44147. * Checks if a session would be supported for the creation options specified
  44148. * @param sessionMode session mode to check if supported eg. immersive-vr
  44149. * @returns A Promise that resolves to true if supported and false if not
  44150. */
  44151. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44152. /**
  44153. * Resets the reference space to the one started the session
  44154. */
  44155. resetReferenceSpace(): void;
  44156. /**
  44157. * Starts rendering to the xr layer
  44158. */
  44159. runXRRenderLoop(): void;
  44160. /**
  44161. * Sets the reference space on the xr session
  44162. * @param referenceSpaceType space to set
  44163. * @returns a promise that will resolve once the reference space has been set
  44164. */
  44165. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44166. /**
  44167. * Updates the render state of the session
  44168. * @param state state to set
  44169. * @returns a promise that resolves once the render state has been updated
  44170. */
  44171. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44172. /**
  44173. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44174. * @param sessionMode defines the session to test
  44175. * @returns a promise with boolean as final value
  44176. */
  44177. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44178. /**
  44179. * @hidden
  44180. * Converts the render layer of xrSession to a render target
  44181. * @param session session to create render target for
  44182. * @param scene scene the new render target should be created for
  44183. * @param baseLayer the webgl layer to create the render target for
  44184. */
  44185. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44186. }
  44187. }
  44188. declare module "babylonjs/XR/webXRCamera" {
  44189. import { Scene } from "babylonjs/scene";
  44190. import { Camera } from "babylonjs/Cameras/camera";
  44191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44192. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44193. /**
  44194. * WebXR Camera which holds the views for the xrSession
  44195. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44196. */
  44197. export class WebXRCamera extends FreeCamera {
  44198. private _xrSessionManager;
  44199. private _firstFrame;
  44200. private _referenceQuaternion;
  44201. private _referencedPosition;
  44202. private _xrInvPositionCache;
  44203. private _xrInvQuaternionCache;
  44204. /**
  44205. * Should position compensation execute on first frame.
  44206. * This is used when copying the position from a native (non XR) camera
  44207. */
  44208. compensateOnFirstFrame: boolean;
  44209. /**
  44210. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44211. * @param name the name of the camera
  44212. * @param scene the scene to add the camera to
  44213. * @param _xrSessionManager a constructed xr session manager
  44214. */
  44215. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44216. /**
  44217. * Return the user's height, unrelated to the current ground.
  44218. * This will be the y position of this camera, when ground level is 0.
  44219. */
  44220. get realWorldHeight(): number;
  44221. /** @hidden */
  44222. _updateForDualEyeDebugging(): void;
  44223. /**
  44224. * Sets this camera's transformation based on a non-vr camera
  44225. * @param otherCamera the non-vr camera to copy the transformation from
  44226. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44227. */
  44228. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44229. private _updateFromXRSession;
  44230. private _updateNumberOfRigCameras;
  44231. private _updateReferenceSpace;
  44232. private _updateReferenceSpaceOffset;
  44233. }
  44234. }
  44235. declare module "babylonjs/XR/webXRFeaturesManager" {
  44236. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44237. import { IDisposable } from "babylonjs/scene";
  44238. /**
  44239. * Defining the interface required for a (webxr) feature
  44240. */
  44241. export interface IWebXRFeature extends IDisposable {
  44242. /**
  44243. * Is this feature attached
  44244. */
  44245. attached: boolean;
  44246. /**
  44247. * Should auto-attach be disabled?
  44248. */
  44249. disableAutoAttach: boolean;
  44250. /**
  44251. * Attach the feature to the session
  44252. * Will usually be called by the features manager
  44253. *
  44254. * @param force should attachment be forced (even when already attached)
  44255. * @returns true if successful.
  44256. */
  44257. attach(force?: boolean): boolean;
  44258. /**
  44259. * Detach the feature from the session
  44260. * Will usually be called by the features manager
  44261. *
  44262. * @returns true if successful.
  44263. */
  44264. detach(): boolean;
  44265. }
  44266. /**
  44267. * A list of the currently available features without referencing them
  44268. */
  44269. export class WebXRFeatureName {
  44270. /**
  44271. * The name of the anchor system feature
  44272. */
  44273. static ANCHOR_SYSTEM: string;
  44274. /**
  44275. * The name of the background remover feature
  44276. */
  44277. static BACKGROUND_REMOVER: string;
  44278. /**
  44279. * The name of the hit test feature
  44280. */
  44281. static HIT_TEST: string;
  44282. /**
  44283. * physics impostors for xr controllers feature
  44284. */
  44285. static PHYSICS_CONTROLLERS: string;
  44286. /**
  44287. * The name of the plane detection feature
  44288. */
  44289. static PLANE_DETECTION: string;
  44290. /**
  44291. * The name of the pointer selection feature
  44292. */
  44293. static POINTER_SELECTION: string;
  44294. /**
  44295. * The name of the teleportation feature
  44296. */
  44297. static TELEPORTATION: string;
  44298. }
  44299. /**
  44300. * Defining the constructor of a feature. Used to register the modules.
  44301. */
  44302. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44303. /**
  44304. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44305. * It is mainly used in AR sessions.
  44306. *
  44307. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44308. */
  44309. export class WebXRFeaturesManager implements IDisposable {
  44310. private _xrSessionManager;
  44311. private static readonly _AvailableFeatures;
  44312. private _features;
  44313. /**
  44314. * constructs a new features manages.
  44315. *
  44316. * @param _xrSessionManager an instance of WebXRSessionManager
  44317. */
  44318. constructor(_xrSessionManager: WebXRSessionManager);
  44319. /**
  44320. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44321. * Mainly used internally.
  44322. *
  44323. * @param featureName the name of the feature to register
  44324. * @param constructorFunction the function used to construct the module
  44325. * @param version the (babylon) version of the module
  44326. * @param stable is that a stable version of this module
  44327. */
  44328. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44329. /**
  44330. * Returns a constructor of a specific feature.
  44331. *
  44332. * @param featureName the name of the feature to construct
  44333. * @param version the version of the feature to load
  44334. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44335. * @param options optional options provided to the module.
  44336. * @returns a function that, when called, will return a new instance of this feature
  44337. */
  44338. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44339. /**
  44340. * Can be used to return the list of features currently registered
  44341. *
  44342. * @returns an Array of available features
  44343. */
  44344. static GetAvailableFeatures(): string[];
  44345. /**
  44346. * Gets the versions available for a specific feature
  44347. * @param featureName the name of the feature
  44348. * @returns an array with the available versions
  44349. */
  44350. static GetAvailableVersions(featureName: string): string[];
  44351. /**
  44352. * Return the latest unstable version of this feature
  44353. * @param featureName the name of the feature to search
  44354. * @returns the version number. if not found will return -1
  44355. */
  44356. static GetLatestVersionOfFeature(featureName: string): number;
  44357. /**
  44358. * Return the latest stable version of this feature
  44359. * @param featureName the name of the feature to search
  44360. * @returns the version number. if not found will return -1
  44361. */
  44362. static GetStableVersionOfFeature(featureName: string): number;
  44363. /**
  44364. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44365. * Can be used during a session to start a feature
  44366. * @param featureName the name of feature to attach
  44367. */
  44368. attachFeature(featureName: string): void;
  44369. /**
  44370. * Can be used inside a session or when the session ends to detach a specific feature
  44371. * @param featureName the name of the feature to detach
  44372. */
  44373. detachFeature(featureName: string): void;
  44374. /**
  44375. * Used to disable an already-enabled feature
  44376. * The feature will be disposed and will be recreated once enabled.
  44377. * @param featureName the feature to disable
  44378. * @returns true if disable was successful
  44379. */
  44380. disableFeature(featureName: string | {
  44381. Name: string;
  44382. }): boolean;
  44383. /**
  44384. * dispose this features manager
  44385. */
  44386. dispose(): void;
  44387. /**
  44388. * 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.
  44389. * 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.
  44390. *
  44391. * @param featureName the name of the feature to load or the class of the feature
  44392. * @param version optional version to load. if not provided the latest version will be enabled
  44393. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44394. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44395. * @returns a new constructed feature or throws an error if feature not found.
  44396. */
  44397. enableFeature(featureName: string | {
  44398. Name: string;
  44399. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44400. /**
  44401. * get the implementation of an enabled feature.
  44402. * @param featureName the name of the feature to load
  44403. * @returns the feature class, if found
  44404. */
  44405. getEnabledFeature(featureName: string): IWebXRFeature;
  44406. /**
  44407. * Get the list of enabled features
  44408. * @returns an array of enabled features
  44409. */
  44410. getEnabledFeatures(): string[];
  44411. }
  44412. }
  44413. declare module "babylonjs/XR/webXRExperienceHelper" {
  44414. import { Observable } from "babylonjs/Misc/observable";
  44415. import { IDisposable, Scene } from "babylonjs/scene";
  44416. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44417. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44418. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44419. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44420. /**
  44421. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44422. * @see https://doc.babylonjs.com/how_to/webxr
  44423. */
  44424. export class WebXRExperienceHelper implements IDisposable {
  44425. private scene;
  44426. private _nonVRCamera;
  44427. private _originalSceneAutoClear;
  44428. private _supported;
  44429. /**
  44430. * Camera used to render xr content
  44431. */
  44432. camera: WebXRCamera;
  44433. /** A features manager for this xr session */
  44434. featuresManager: WebXRFeaturesManager;
  44435. /**
  44436. * Observers registered here will be triggered after the camera's initial transformation is set
  44437. * This can be used to set a different ground level or an extra rotation.
  44438. *
  44439. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44440. * to the position set after this observable is done executing.
  44441. */
  44442. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44443. /**
  44444. * Fires when the state of the experience helper has changed
  44445. */
  44446. onStateChangedObservable: Observable<WebXRState>;
  44447. /** Session manager used to keep track of xr session */
  44448. sessionManager: WebXRSessionManager;
  44449. /**
  44450. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44451. */
  44452. state: WebXRState;
  44453. /**
  44454. * Creates a WebXRExperienceHelper
  44455. * @param scene The scene the helper should be created in
  44456. */
  44457. private constructor();
  44458. /**
  44459. * Creates the experience helper
  44460. * @param scene the scene to attach the experience helper to
  44461. * @returns a promise for the experience helper
  44462. */
  44463. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44464. /**
  44465. * Disposes of the experience helper
  44466. */
  44467. dispose(): void;
  44468. /**
  44469. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44470. * @param sessionMode options for the XR session
  44471. * @param referenceSpaceType frame of reference of the XR session
  44472. * @param renderTarget the output canvas that will be used to enter XR mode
  44473. * @returns promise that resolves after xr mode has entered
  44474. */
  44475. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44476. /**
  44477. * Exits XR mode and returns the scene to its original state
  44478. * @returns promise that resolves after xr mode has exited
  44479. */
  44480. exitXRAsync(): Promise<void>;
  44481. private _nonXRToXRCamera;
  44482. private _setState;
  44483. }
  44484. }
  44485. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44486. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44487. import { Observable } from "babylonjs/Misc/observable";
  44488. import { IDisposable } from "babylonjs/scene";
  44489. /**
  44490. * X-Y values for axes in WebXR
  44491. */
  44492. export interface IWebXRMotionControllerAxesValue {
  44493. /**
  44494. * The value of the x axis
  44495. */
  44496. x: number;
  44497. /**
  44498. * The value of the y-axis
  44499. */
  44500. y: number;
  44501. }
  44502. /**
  44503. * changed / previous values for the values of this component
  44504. */
  44505. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44506. /**
  44507. * current (this frame) value
  44508. */
  44509. current: T;
  44510. /**
  44511. * previous (last change) value
  44512. */
  44513. previous: T;
  44514. }
  44515. /**
  44516. * Represents changes in the component between current frame and last values recorded
  44517. */
  44518. export interface IWebXRMotionControllerComponentChanges {
  44519. /**
  44520. * will be populated with previous and current values if axes changed
  44521. */
  44522. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44523. /**
  44524. * will be populated with previous and current values if pressed changed
  44525. */
  44526. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44527. /**
  44528. * will be populated with previous and current values if touched changed
  44529. */
  44530. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44531. /**
  44532. * will be populated with previous and current values if value changed
  44533. */
  44534. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44535. }
  44536. /**
  44537. * This class represents a single component (for example button or thumbstick) of a motion controller
  44538. */
  44539. export class WebXRControllerComponent implements IDisposable {
  44540. /**
  44541. * the id of this component
  44542. */
  44543. id: string;
  44544. /**
  44545. * the type of the component
  44546. */
  44547. type: MotionControllerComponentType;
  44548. private _buttonIndex;
  44549. private _axesIndices;
  44550. private _axes;
  44551. private _changes;
  44552. private _currentValue;
  44553. private _hasChanges;
  44554. private _pressed;
  44555. private _touched;
  44556. /**
  44557. * button component type
  44558. */
  44559. static BUTTON_TYPE: MotionControllerComponentType;
  44560. /**
  44561. * squeeze component type
  44562. */
  44563. static SQUEEZE_TYPE: MotionControllerComponentType;
  44564. /**
  44565. * Thumbstick component type
  44566. */
  44567. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44568. /**
  44569. * Touchpad component type
  44570. */
  44571. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44572. /**
  44573. * trigger component type
  44574. */
  44575. static TRIGGER_TYPE: MotionControllerComponentType;
  44576. /**
  44577. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44578. * the axes data changes
  44579. */
  44580. onAxisValueChangedObservable: Observable<{
  44581. x: number;
  44582. y: number;
  44583. }>;
  44584. /**
  44585. * Observers registered here will be triggered when the state of a button changes
  44586. * State change is either pressed / touched / value
  44587. */
  44588. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44589. /**
  44590. * Creates a new component for a motion controller.
  44591. * It is created by the motion controller itself
  44592. *
  44593. * @param id the id of this component
  44594. * @param type the type of the component
  44595. * @param _buttonIndex index in the buttons array of the gamepad
  44596. * @param _axesIndices indices of the values in the axes array of the gamepad
  44597. */
  44598. constructor(
  44599. /**
  44600. * the id of this component
  44601. */
  44602. id: string,
  44603. /**
  44604. * the type of the component
  44605. */
  44606. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44607. /**
  44608. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44609. */
  44610. get axes(): IWebXRMotionControllerAxesValue;
  44611. /**
  44612. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44613. */
  44614. get changes(): IWebXRMotionControllerComponentChanges;
  44615. /**
  44616. * Return whether or not the component changed the last frame
  44617. */
  44618. get hasChanges(): boolean;
  44619. /**
  44620. * is the button currently pressed
  44621. */
  44622. get pressed(): boolean;
  44623. /**
  44624. * is the button currently touched
  44625. */
  44626. get touched(): boolean;
  44627. /**
  44628. * Get the current value of this component
  44629. */
  44630. get value(): number;
  44631. /**
  44632. * Dispose this component
  44633. */
  44634. dispose(): void;
  44635. /**
  44636. * Are there axes correlating to this component
  44637. * @return true is axes data is available
  44638. */
  44639. isAxes(): boolean;
  44640. /**
  44641. * Is this component a button (hence - pressable)
  44642. * @returns true if can be pressed
  44643. */
  44644. isButton(): boolean;
  44645. /**
  44646. * update this component using the gamepad object it is in. Called on every frame
  44647. * @param nativeController the native gamepad controller object
  44648. */
  44649. update(nativeController: IMinimalMotionControllerObject): void;
  44650. }
  44651. }
  44652. declare module "babylonjs/Loading/sceneLoader" {
  44653. import { Observable } from "babylonjs/Misc/observable";
  44654. import { Nullable } from "babylonjs/types";
  44655. import { Scene } from "babylonjs/scene";
  44656. import { Engine } from "babylonjs/Engines/engine";
  44657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44658. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44659. import { AssetContainer } from "babylonjs/assetContainer";
  44660. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44661. import { Skeleton } from "babylonjs/Bones/skeleton";
  44662. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44663. import { WebRequest } from "babylonjs/Misc/webRequest";
  44664. /**
  44665. * Class used to represent data loading progression
  44666. */
  44667. export class SceneLoaderProgressEvent {
  44668. /** defines if data length to load can be evaluated */
  44669. readonly lengthComputable: boolean;
  44670. /** defines the loaded data length */
  44671. readonly loaded: number;
  44672. /** defines the data length to load */
  44673. readonly total: number;
  44674. /**
  44675. * Create a new progress event
  44676. * @param lengthComputable defines if data length to load can be evaluated
  44677. * @param loaded defines the loaded data length
  44678. * @param total defines the data length to load
  44679. */
  44680. constructor(
  44681. /** defines if data length to load can be evaluated */
  44682. lengthComputable: boolean,
  44683. /** defines the loaded data length */
  44684. loaded: number,
  44685. /** defines the data length to load */
  44686. total: number);
  44687. /**
  44688. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44689. * @param event defines the source event
  44690. * @returns a new SceneLoaderProgressEvent
  44691. */
  44692. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44693. }
  44694. /**
  44695. * Interface used by SceneLoader plugins to define supported file extensions
  44696. */
  44697. export interface ISceneLoaderPluginExtensions {
  44698. /**
  44699. * Defines the list of supported extensions
  44700. */
  44701. [extension: string]: {
  44702. isBinary: boolean;
  44703. };
  44704. }
  44705. /**
  44706. * Interface used by SceneLoader plugin factory
  44707. */
  44708. export interface ISceneLoaderPluginFactory {
  44709. /**
  44710. * Defines the name of the factory
  44711. */
  44712. name: string;
  44713. /**
  44714. * Function called to create a new plugin
  44715. * @return the new plugin
  44716. */
  44717. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44718. /**
  44719. * The callback that returns true if the data can be directly loaded.
  44720. * @param data string containing the file data
  44721. * @returns if the data can be loaded directly
  44722. */
  44723. canDirectLoad?(data: string): boolean;
  44724. }
  44725. /**
  44726. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44727. */
  44728. export interface ISceneLoaderPluginBase {
  44729. /**
  44730. * The friendly name of this plugin.
  44731. */
  44732. name: string;
  44733. /**
  44734. * The file extensions supported by this plugin.
  44735. */
  44736. extensions: string | ISceneLoaderPluginExtensions;
  44737. /**
  44738. * The callback called when loading from a url.
  44739. * @param scene scene loading this url
  44740. * @param url url to load
  44741. * @param onSuccess callback called when the file successfully loads
  44742. * @param onProgress callback called while file is loading (if the server supports this mode)
  44743. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44744. * @param onError callback called when the file fails to load
  44745. * @returns a file request object
  44746. */
  44747. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44748. /**
  44749. * The callback called when loading from a file object.
  44750. * @param scene scene loading this file
  44751. * @param file defines the file to load
  44752. * @param onSuccess defines the callback to call when data is loaded
  44753. * @param onProgress defines the callback to call during loading process
  44754. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44755. * @param onError defines the callback to call when an error occurs
  44756. * @returns a file request object
  44757. */
  44758. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44759. /**
  44760. * The callback that returns true if the data can be directly loaded.
  44761. * @param data string containing the file data
  44762. * @returns if the data can be loaded directly
  44763. */
  44764. canDirectLoad?(data: string): boolean;
  44765. /**
  44766. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44767. * @param scene scene loading this data
  44768. * @param data string containing the data
  44769. * @returns data to pass to the plugin
  44770. */
  44771. directLoad?(scene: Scene, data: string): any;
  44772. /**
  44773. * The callback that allows custom handling of the root url based on the response url.
  44774. * @param rootUrl the original root url
  44775. * @param responseURL the response url if available
  44776. * @returns the new root url
  44777. */
  44778. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44779. }
  44780. /**
  44781. * Interface used to define a SceneLoader plugin
  44782. */
  44783. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44784. /**
  44785. * Import meshes into a scene.
  44786. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44787. * @param scene The scene to import into
  44788. * @param data The data to import
  44789. * @param rootUrl The root url for scene and resources
  44790. * @param meshes The meshes array to import into
  44791. * @param particleSystems The particle systems array to import into
  44792. * @param skeletons The skeletons array to import into
  44793. * @param onError The callback when import fails
  44794. * @returns True if successful or false otherwise
  44795. */
  44796. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44797. /**
  44798. * Load into a scene.
  44799. * @param scene The scene to load into
  44800. * @param data The data to import
  44801. * @param rootUrl The root url for scene and resources
  44802. * @param onError The callback when import fails
  44803. * @returns True if successful or false otherwise
  44804. */
  44805. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44806. /**
  44807. * Load into an asset container.
  44808. * @param scene The scene to load into
  44809. * @param data The data to import
  44810. * @param rootUrl The root url for scene and resources
  44811. * @param onError The callback when import fails
  44812. * @returns The loaded asset container
  44813. */
  44814. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44815. }
  44816. /**
  44817. * Interface used to define an async SceneLoader plugin
  44818. */
  44819. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44820. /**
  44821. * Import meshes into a scene.
  44822. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44823. * @param scene The scene to import into
  44824. * @param data The data to import
  44825. * @param rootUrl The root url for scene and resources
  44826. * @param onProgress The callback when the load progresses
  44827. * @param fileName Defines the name of the file to load
  44828. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44829. */
  44830. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44831. meshes: AbstractMesh[];
  44832. particleSystems: IParticleSystem[];
  44833. skeletons: Skeleton[];
  44834. animationGroups: AnimationGroup[];
  44835. }>;
  44836. /**
  44837. * Load into a scene.
  44838. * @param scene The scene to load into
  44839. * @param data The data to import
  44840. * @param rootUrl The root url for scene and resources
  44841. * @param onProgress The callback when the load progresses
  44842. * @param fileName Defines the name of the file to load
  44843. * @returns Nothing
  44844. */
  44845. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44846. /**
  44847. * Load into an asset container.
  44848. * @param scene The scene to load into
  44849. * @param data The data to import
  44850. * @param rootUrl The root url for scene and resources
  44851. * @param onProgress The callback when the load progresses
  44852. * @param fileName Defines the name of the file to load
  44853. * @returns The loaded asset container
  44854. */
  44855. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44856. }
  44857. /**
  44858. * Mode that determines how to handle old animation groups before loading new ones.
  44859. */
  44860. export enum SceneLoaderAnimationGroupLoadingMode {
  44861. /**
  44862. * Reset all old animations to initial state then dispose them.
  44863. */
  44864. Clean = 0,
  44865. /**
  44866. * Stop all old animations.
  44867. */
  44868. Stop = 1,
  44869. /**
  44870. * Restart old animations from first frame.
  44871. */
  44872. Sync = 2,
  44873. /**
  44874. * Old animations remains untouched.
  44875. */
  44876. NoSync = 3
  44877. }
  44878. /**
  44879. * Class used to load scene from various file formats using registered plugins
  44880. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44881. */
  44882. export class SceneLoader {
  44883. /**
  44884. * No logging while loading
  44885. */
  44886. static readonly NO_LOGGING: number;
  44887. /**
  44888. * Minimal logging while loading
  44889. */
  44890. static readonly MINIMAL_LOGGING: number;
  44891. /**
  44892. * Summary logging while loading
  44893. */
  44894. static readonly SUMMARY_LOGGING: number;
  44895. /**
  44896. * Detailled logging while loading
  44897. */
  44898. static readonly DETAILED_LOGGING: number;
  44899. /**
  44900. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44901. */
  44902. static get ForceFullSceneLoadingForIncremental(): boolean;
  44903. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44904. /**
  44905. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44906. */
  44907. static get ShowLoadingScreen(): boolean;
  44908. static set ShowLoadingScreen(value: boolean);
  44909. /**
  44910. * Defines the current logging level (while loading the scene)
  44911. * @ignorenaming
  44912. */
  44913. static get loggingLevel(): number;
  44914. static set loggingLevel(value: number);
  44915. /**
  44916. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44917. */
  44918. static get CleanBoneMatrixWeights(): boolean;
  44919. static set CleanBoneMatrixWeights(value: boolean);
  44920. /**
  44921. * Event raised when a plugin is used to load a scene
  44922. */
  44923. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44924. private static _registeredPlugins;
  44925. private static _getDefaultPlugin;
  44926. private static _getPluginForExtension;
  44927. private static _getPluginForDirectLoad;
  44928. private static _getPluginForFilename;
  44929. private static _getDirectLoad;
  44930. private static _loadData;
  44931. private static _getFileInfo;
  44932. /**
  44933. * Gets a plugin that can load the given extension
  44934. * @param extension defines the extension to load
  44935. * @returns a plugin or null if none works
  44936. */
  44937. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44938. /**
  44939. * Gets a boolean indicating that the given extension can be loaded
  44940. * @param extension defines the extension to load
  44941. * @returns true if the extension is supported
  44942. */
  44943. static IsPluginForExtensionAvailable(extension: string): boolean;
  44944. /**
  44945. * Adds a new plugin to the list of registered plugins
  44946. * @param plugin defines the plugin to add
  44947. */
  44948. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44949. /**
  44950. * Import meshes into a scene
  44951. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44952. * @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)
  44953. * @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)
  44954. * @param scene the instance of BABYLON.Scene to append to
  44955. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44956. * @param onProgress a callback with a progress event for each file being loaded
  44957. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44958. * @param pluginExtension the extension used to determine the plugin
  44959. * @returns The loaded plugin
  44960. */
  44961. 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>;
  44962. /**
  44963. * Import meshes into a scene
  44964. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44965. * @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)
  44966. * @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)
  44967. * @param scene the instance of BABYLON.Scene to append to
  44968. * @param onProgress a callback with a progress event for each file being loaded
  44969. * @param pluginExtension the extension used to determine the plugin
  44970. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44971. */
  44972. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44973. meshes: AbstractMesh[];
  44974. particleSystems: IParticleSystem[];
  44975. skeletons: Skeleton[];
  44976. animationGroups: AnimationGroup[];
  44977. }>;
  44978. /**
  44979. * Load a scene
  44980. * @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)
  44981. * @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)
  44982. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44983. * @param onSuccess a callback with the scene when import succeeds
  44984. * @param onProgress a callback with a progress event for each file being loaded
  44985. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44986. * @param pluginExtension the extension used to determine the plugin
  44987. * @returns The loaded plugin
  44988. */
  44989. 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>;
  44990. /**
  44991. * Load a scene
  44992. * @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)
  44993. * @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)
  44994. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44995. * @param onProgress a callback with a progress event for each file being loaded
  44996. * @param pluginExtension the extension used to determine the plugin
  44997. * @returns The loaded scene
  44998. */
  44999. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45000. /**
  45001. * Append a scene
  45002. * @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)
  45003. * @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)
  45004. * @param scene is the instance of BABYLON.Scene to append to
  45005. * @param onSuccess a callback with the scene when import succeeds
  45006. * @param onProgress a callback with a progress event for each file being loaded
  45007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45008. * @param pluginExtension the extension used to determine the plugin
  45009. * @returns The loaded plugin
  45010. */
  45011. 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>;
  45012. /**
  45013. * Append 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
  45017. * @param onProgress a callback with a progress event for each file being loaded
  45018. * @param pluginExtension the extension used to determine the plugin
  45019. * @returns The given scene
  45020. */
  45021. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45022. /**
  45023. * Load a scene into an asset container
  45024. * @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)
  45025. * @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)
  45026. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45027. * @param onSuccess a callback with the scene when import succeeds
  45028. * @param onProgress a callback with a progress event for each file being loaded
  45029. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45030. * @param pluginExtension the extension used to determine the plugin
  45031. * @returns The loaded plugin
  45032. */
  45033. 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>;
  45034. /**
  45035. * Load a scene into an asset container
  45036. * @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)
  45037. * @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)
  45038. * @param scene is the instance of Scene to append to
  45039. * @param onProgress a callback with a progress event for each file being loaded
  45040. * @param pluginExtension the extension used to determine the plugin
  45041. * @returns The loaded asset container
  45042. */
  45043. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45044. /**
  45045. * Import animations from a file into a scene
  45046. * @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)
  45047. * @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)
  45048. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45049. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45050. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45051. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45052. * @param onSuccess a callback with the scene when import succeeds
  45053. * @param onProgress a callback with a progress event for each file being loaded
  45054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45055. */
  45056. 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;
  45057. /**
  45058. * Import animations from a file into a scene
  45059. * @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)
  45060. * @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)
  45061. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45062. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45063. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45064. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45065. * @param onSuccess a callback with the scene when import succeeds
  45066. * @param onProgress a callback with a progress event for each file being loaded
  45067. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45068. * @returns the updated scene with imported animations
  45069. */
  45070. 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>;
  45071. }
  45072. }
  45073. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45074. import { IDisposable, Scene } from "babylonjs/scene";
  45075. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45076. import { Observable } from "babylonjs/Misc/observable";
  45077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45078. import { Nullable } from "babylonjs/types";
  45079. /**
  45080. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45081. */
  45082. export type MotionControllerHandness = "none" | "left" | "right";
  45083. /**
  45084. * The type of components available in motion controllers.
  45085. * This is not the name of the component.
  45086. */
  45087. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45088. /**
  45089. * The state of a controller component
  45090. */
  45091. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45092. /**
  45093. * The schema of motion controller layout.
  45094. * No object will be initialized using this interface
  45095. * This is used just to define the profile.
  45096. */
  45097. export interface IMotionControllerLayout {
  45098. /**
  45099. * Path to load the assets. Usually relative to the base path
  45100. */
  45101. assetPath: string;
  45102. /**
  45103. * Available components (unsorted)
  45104. */
  45105. components: {
  45106. /**
  45107. * A map of component Ids
  45108. */
  45109. [componentId: string]: {
  45110. /**
  45111. * The type of input the component outputs
  45112. */
  45113. type: MotionControllerComponentType;
  45114. /**
  45115. * The indices of this component in the gamepad object
  45116. */
  45117. gamepadIndices: {
  45118. /**
  45119. * Index of button
  45120. */
  45121. button?: number;
  45122. /**
  45123. * If available, index of x-axis
  45124. */
  45125. xAxis?: number;
  45126. /**
  45127. * If available, index of y-axis
  45128. */
  45129. yAxis?: number;
  45130. };
  45131. /**
  45132. * The mesh's root node name
  45133. */
  45134. rootNodeName: string;
  45135. /**
  45136. * Animation definitions for this model
  45137. */
  45138. visualResponses: {
  45139. [stateKey: string]: {
  45140. /**
  45141. * What property will be animated
  45142. */
  45143. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45144. /**
  45145. * What states influence this visual response
  45146. */
  45147. states: MotionControllerComponentStateType[];
  45148. /**
  45149. * Type of animation - movement or visibility
  45150. */
  45151. valueNodeProperty: "transform" | "visibility";
  45152. /**
  45153. * Base node name to move. Its position will be calculated according to the min and max nodes
  45154. */
  45155. valueNodeName?: string;
  45156. /**
  45157. * Minimum movement node
  45158. */
  45159. minNodeName?: string;
  45160. /**
  45161. * Max movement node
  45162. */
  45163. maxNodeName?: string;
  45164. };
  45165. };
  45166. /**
  45167. * If touch enabled, what is the name of node to display user feedback
  45168. */
  45169. touchPointNodeName?: string;
  45170. };
  45171. };
  45172. /**
  45173. * Is it xr standard mapping or not
  45174. */
  45175. gamepadMapping: "" | "xr-standard";
  45176. /**
  45177. * Base root node of this entire model
  45178. */
  45179. rootNodeName: string;
  45180. /**
  45181. * Defines the main button component id
  45182. */
  45183. selectComponentId: string;
  45184. }
  45185. /**
  45186. * A definition for the layout map in the input profile
  45187. */
  45188. export interface IMotionControllerLayoutMap {
  45189. /**
  45190. * Layouts with handness type as a key
  45191. */
  45192. [handness: string]: IMotionControllerLayout;
  45193. }
  45194. /**
  45195. * The XR Input profile schema
  45196. * Profiles can be found here:
  45197. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45198. */
  45199. export interface IMotionControllerProfile {
  45200. /**
  45201. * fallback profiles for this profileId
  45202. */
  45203. fallbackProfileIds: string[];
  45204. /**
  45205. * The layout map, with handness as key
  45206. */
  45207. layouts: IMotionControllerLayoutMap;
  45208. /**
  45209. * The id of this profile
  45210. * correlates to the profile(s) in the xrInput.profiles array
  45211. */
  45212. profileId: string;
  45213. }
  45214. /**
  45215. * A helper-interface for the 3 meshes needed for controller button animation
  45216. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45217. */
  45218. export interface IMotionControllerButtonMeshMap {
  45219. /**
  45220. * the mesh that defines the pressed value mesh position.
  45221. * This is used to find the max-position of this button
  45222. */
  45223. pressedMesh: AbstractMesh;
  45224. /**
  45225. * the mesh that defines the unpressed value mesh position.
  45226. * This is used to find the min (or initial) position of this button
  45227. */
  45228. unpressedMesh: AbstractMesh;
  45229. /**
  45230. * The mesh that will be changed when value changes
  45231. */
  45232. valueMesh: AbstractMesh;
  45233. }
  45234. /**
  45235. * A helper-interface for the 3 meshes needed for controller axis animation.
  45236. * This will be expanded when touchpad animations are fully supported
  45237. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45238. */
  45239. export interface IMotionControllerMeshMap {
  45240. /**
  45241. * the mesh that defines the maximum value mesh position.
  45242. */
  45243. maxMesh?: AbstractMesh;
  45244. /**
  45245. * the mesh that defines the minimum value mesh position.
  45246. */
  45247. minMesh?: AbstractMesh;
  45248. /**
  45249. * The mesh that will be changed when axis value changes
  45250. */
  45251. valueMesh: AbstractMesh;
  45252. }
  45253. /**
  45254. * The elements needed for change-detection of the gamepad objects in motion controllers
  45255. */
  45256. export interface IMinimalMotionControllerObject {
  45257. /**
  45258. * Available axes of this controller
  45259. */
  45260. axes: number[];
  45261. /**
  45262. * An array of available buttons
  45263. */
  45264. buttons: Array<{
  45265. /**
  45266. * Value of the button/trigger
  45267. */
  45268. value: number;
  45269. /**
  45270. * If the button/trigger is currently touched
  45271. */
  45272. touched: boolean;
  45273. /**
  45274. * If the button/trigger is currently pressed
  45275. */
  45276. pressed: boolean;
  45277. }>;
  45278. }
  45279. /**
  45280. * An Abstract Motion controller
  45281. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45282. * Each component has an observable to check for changes in value and state
  45283. */
  45284. export abstract class WebXRAbstractMotionController implements IDisposable {
  45285. protected scene: Scene;
  45286. protected layout: IMotionControllerLayout;
  45287. /**
  45288. * The gamepad object correlating to this controller
  45289. */
  45290. gamepadObject: IMinimalMotionControllerObject;
  45291. /**
  45292. * handness (left/right/none) of this controller
  45293. */
  45294. handness: MotionControllerHandness;
  45295. private _initComponent;
  45296. private _modelReady;
  45297. /**
  45298. * A map of components (WebXRControllerComponent) in this motion controller
  45299. * Components have a ComponentType and can also have both button and axis definitions
  45300. */
  45301. readonly components: {
  45302. [id: string]: WebXRControllerComponent;
  45303. };
  45304. /**
  45305. * Disable the model's animation. Can be set at any time.
  45306. */
  45307. disableAnimation: boolean;
  45308. /**
  45309. * Observers registered here will be triggered when the model of this controller is done loading
  45310. */
  45311. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45312. /**
  45313. * The profile id of this motion controller
  45314. */
  45315. abstract profileId: string;
  45316. /**
  45317. * The root mesh of the model. It is null if the model was not yet initialized
  45318. */
  45319. rootMesh: Nullable<AbstractMesh>;
  45320. /**
  45321. * constructs a new abstract motion controller
  45322. * @param scene the scene to which the model of the controller will be added
  45323. * @param layout The profile layout to load
  45324. * @param gamepadObject The gamepad object correlating to this controller
  45325. * @param handness handness (left/right/none) of this controller
  45326. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45327. */
  45328. constructor(scene: Scene, layout: IMotionControllerLayout,
  45329. /**
  45330. * The gamepad object correlating to this controller
  45331. */
  45332. gamepadObject: IMinimalMotionControllerObject,
  45333. /**
  45334. * handness (left/right/none) of this controller
  45335. */
  45336. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45337. /**
  45338. * Dispose this controller, the model mesh and all its components
  45339. */
  45340. dispose(): void;
  45341. /**
  45342. * Returns all components of specific type
  45343. * @param type the type to search for
  45344. * @return an array of components with this type
  45345. */
  45346. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45347. /**
  45348. * get a component based an its component id as defined in layout.components
  45349. * @param id the id of the component
  45350. * @returns the component correlates to the id or undefined if not found
  45351. */
  45352. getComponent(id: string): WebXRControllerComponent;
  45353. /**
  45354. * Get the list of components available in this motion controller
  45355. * @returns an array of strings correlating to available components
  45356. */
  45357. getComponentIds(): string[];
  45358. /**
  45359. * Get the first component of specific type
  45360. * @param type type of component to find
  45361. * @return a controller component or null if not found
  45362. */
  45363. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45364. /**
  45365. * Get the main (Select) component of this controller as defined in the layout
  45366. * @returns the main component of this controller
  45367. */
  45368. getMainComponent(): WebXRControllerComponent;
  45369. /**
  45370. * Loads the model correlating to this controller
  45371. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45372. * @returns A promise fulfilled with the result of the model loading
  45373. */
  45374. loadModel(): Promise<boolean>;
  45375. /**
  45376. * Update this model using the current XRFrame
  45377. * @param xrFrame the current xr frame to use and update the model
  45378. */
  45379. updateFromXRFrame(xrFrame: XRFrame): void;
  45380. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45381. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45382. /**
  45383. * Moves the axis on the controller mesh based on its current state
  45384. * @param axis the index of the axis
  45385. * @param axisValue the value of the axis which determines the meshes new position
  45386. * @hidden
  45387. */
  45388. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45389. /**
  45390. * Update the model itself with the current frame data
  45391. * @param xrFrame the frame to use for updating the model mesh
  45392. */
  45393. protected updateModel(xrFrame: XRFrame): void;
  45394. /**
  45395. * Get the filename and path for this controller's model
  45396. * @returns a map of filename and path
  45397. */
  45398. protected abstract _getFilenameAndPath(): {
  45399. filename: string;
  45400. path: string;
  45401. };
  45402. /**
  45403. * This function is called before the mesh is loaded. It checks for loading constraints.
  45404. * For example, this function can check if the GLB loader is available
  45405. * If this function returns false, the generic controller will be loaded instead
  45406. * @returns Is the client ready to load the mesh
  45407. */
  45408. protected abstract _getModelLoadingConstraints(): boolean;
  45409. /**
  45410. * This function will be called after the model was successfully loaded and can be used
  45411. * for mesh transformations before it is available for the user
  45412. * @param meshes the loaded meshes
  45413. */
  45414. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45415. /**
  45416. * Set the root mesh for this controller. Important for the WebXR controller class
  45417. * @param meshes the loaded meshes
  45418. */
  45419. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45420. /**
  45421. * A function executed each frame that updates the mesh (if needed)
  45422. * @param xrFrame the current xrFrame
  45423. */
  45424. protected abstract _updateModel(xrFrame: XRFrame): void;
  45425. private _getGenericFilenameAndPath;
  45426. private _getGenericParentMesh;
  45427. }
  45428. }
  45429. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45430. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45432. import { Scene } from "babylonjs/scene";
  45433. /**
  45434. * A generic trigger-only motion controller for WebXR
  45435. */
  45436. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45437. /**
  45438. * Static version of the profile id of this controller
  45439. */
  45440. static ProfileId: string;
  45441. profileId: string;
  45442. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45443. protected _getFilenameAndPath(): {
  45444. filename: string;
  45445. path: string;
  45446. };
  45447. protected _getModelLoadingConstraints(): boolean;
  45448. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45449. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45450. protected _updateModel(): void;
  45451. }
  45452. }
  45453. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45454. import { Vector4 } from "babylonjs/Maths/math.vector";
  45455. import { Mesh } from "babylonjs/Meshes/mesh";
  45456. import { Scene } from "babylonjs/scene";
  45457. import { Nullable } from "babylonjs/types";
  45458. /**
  45459. * Class containing static functions to help procedurally build meshes
  45460. */
  45461. export class SphereBuilder {
  45462. /**
  45463. * Creates a sphere mesh
  45464. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45465. * * 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`)
  45466. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45467. * * 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
  45468. * * 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)
  45469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45472. * @param name defines the name of the mesh
  45473. * @param options defines the options used to create the mesh
  45474. * @param scene defines the hosting scene
  45475. * @returns the sphere mesh
  45476. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45477. */
  45478. static CreateSphere(name: string, options: {
  45479. segments?: number;
  45480. diameter?: number;
  45481. diameterX?: number;
  45482. diameterY?: number;
  45483. diameterZ?: number;
  45484. arc?: number;
  45485. slice?: number;
  45486. sideOrientation?: number;
  45487. frontUVs?: Vector4;
  45488. backUVs?: Vector4;
  45489. updatable?: boolean;
  45490. }, scene?: Nullable<Scene>): Mesh;
  45491. }
  45492. }
  45493. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45495. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45496. import { Scene } from "babylonjs/scene";
  45497. /**
  45498. * A profiled motion controller has its profile loaded from an online repository.
  45499. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45500. */
  45501. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45502. private _repositoryUrl;
  45503. private _buttonMeshMapping;
  45504. private _touchDots;
  45505. /**
  45506. * The profile ID of this controller. Will be populated when the controller initializes.
  45507. */
  45508. profileId: string;
  45509. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45510. dispose(): void;
  45511. protected _getFilenameAndPath(): {
  45512. filename: string;
  45513. path: string;
  45514. };
  45515. protected _getModelLoadingConstraints(): boolean;
  45516. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45517. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45518. protected _updateModel(_xrFrame: XRFrame): void;
  45519. }
  45520. }
  45521. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45522. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45523. import { Scene } from "babylonjs/scene";
  45524. /**
  45525. * A construction function type to create a new controller based on an xrInput object
  45526. */
  45527. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45528. /**
  45529. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45530. *
  45531. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45532. * it should be replaced with auto-loaded controllers.
  45533. *
  45534. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45535. */
  45536. export class WebXRMotionControllerManager {
  45537. private static _AvailableControllers;
  45538. private static _Fallbacks;
  45539. private static _ProfileLoadingPromises;
  45540. private static _ProfilesList;
  45541. /**
  45542. * The base URL of the online controller repository. Can be changed at any time.
  45543. */
  45544. static BaseRepositoryUrl: string;
  45545. /**
  45546. * Which repository gets priority - local or online
  45547. */
  45548. static PrioritizeOnlineRepository: boolean;
  45549. /**
  45550. * Use the online repository, or use only locally-defined controllers
  45551. */
  45552. static UseOnlineRepository: boolean;
  45553. /**
  45554. * Clear the cache used for profile loading and reload when requested again
  45555. */
  45556. static ClearProfilesCache(): 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. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45564. * @param profileId the profile to which a fallback needs to be found
  45565. * @return an array with corresponding fallback profiles
  45566. */
  45567. static FindFallbackWithProfileId(profileId: string): string[];
  45568. /**
  45569. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45570. * The order of search:
  45571. *
  45572. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45573. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45574. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45575. * 4) return the generic trigger controller if none were found
  45576. *
  45577. * @param xrInput the xrInput to which a new controller is initialized
  45578. * @param scene the scene to which the model will be added
  45579. * @param forceProfile force a certain profile for this controller
  45580. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45581. */
  45582. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45583. /**
  45584. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45585. *
  45586. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45587. *
  45588. * @param type the profile type to register
  45589. * @param constructFunction the function to be called when loading this profile
  45590. */
  45591. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45592. /**
  45593. * Register a fallback to a specific profile.
  45594. * @param profileId the profileId that will receive the fallbacks
  45595. * @param fallbacks A list of fallback profiles
  45596. */
  45597. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45598. /**
  45599. * Will update the list of profiles available in the repository
  45600. * @return a promise that resolves to a map of profiles available online
  45601. */
  45602. static UpdateProfilesList(): Promise<{
  45603. [profile: string]: string;
  45604. }>;
  45605. private static _LoadProfileFromRepository;
  45606. private static _LoadProfilesFromAvailableControllers;
  45607. }
  45608. }
  45609. declare module "babylonjs/XR/webXRInputSource" {
  45610. import { Observable } from "babylonjs/Misc/observable";
  45611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45612. import { Ray } from "babylonjs/Culling/ray";
  45613. import { Scene } from "babylonjs/scene";
  45614. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45615. /**
  45616. * Configuration options for the WebXR controller creation
  45617. */
  45618. export interface IWebXRControllerOptions {
  45619. /**
  45620. * Should the controller mesh be animated when a user interacts with it
  45621. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45622. */
  45623. disableMotionControllerAnimation?: boolean;
  45624. /**
  45625. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45626. */
  45627. doNotLoadControllerMesh?: boolean;
  45628. /**
  45629. * Force a specific controller type for this controller.
  45630. * This can be used when creating your own profile or when testing different controllers
  45631. */
  45632. forceControllerProfile?: string;
  45633. }
  45634. /**
  45635. * Represents an XR controller
  45636. */
  45637. export class WebXRInputSource {
  45638. private _scene;
  45639. /** The underlying input source for the controller */
  45640. inputSource: XRInputSource;
  45641. private _options;
  45642. private _tmpQuaternion;
  45643. private _tmpVector;
  45644. private _uniqueId;
  45645. /**
  45646. * 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
  45647. */
  45648. grip?: AbstractMesh;
  45649. /**
  45650. * If available, this is the gamepad object related to this controller.
  45651. * Using this object it is possible to get click events and trackpad changes of the
  45652. * webxr controller that is currently being used.
  45653. */
  45654. motionController?: WebXRAbstractMotionController;
  45655. /**
  45656. * Event that fires when the controller is removed/disposed.
  45657. * The object provided as event data is this controller, after associated assets were disposed.
  45658. * uniqueId is still available.
  45659. */
  45660. onDisposeObservable: Observable<WebXRInputSource>;
  45661. /**
  45662. * Will be triggered when the mesh associated with the motion controller is done loading.
  45663. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45664. * A shortened version of controller -> motion controller -> on mesh loaded.
  45665. */
  45666. onMeshLoadedObservable: Observable<AbstractMesh>;
  45667. /**
  45668. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45669. */
  45670. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45671. /**
  45672. * Pointer which can be used to select objects or attach a visible laser to
  45673. */
  45674. pointer: AbstractMesh;
  45675. /**
  45676. * Creates the controller
  45677. * @see https://doc.babylonjs.com/how_to/webxr
  45678. * @param _scene the scene which the controller should be associated to
  45679. * @param inputSource the underlying input source for the controller
  45680. * @param _options options for this controller creation
  45681. */
  45682. constructor(_scene: Scene,
  45683. /** The underlying input source for the controller */
  45684. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45685. /**
  45686. * Get this controllers unique id
  45687. */
  45688. get uniqueId(): string;
  45689. /**
  45690. * Disposes of the object
  45691. */
  45692. dispose(): void;
  45693. /**
  45694. * Gets a world space ray coming from the pointer or grip
  45695. * @param result the resulting ray
  45696. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45697. */
  45698. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45699. /**
  45700. * Updates the controller pose based on the given XRFrame
  45701. * @param xrFrame xr frame to update the pose with
  45702. * @param referenceSpace reference space to use
  45703. */
  45704. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45705. }
  45706. }
  45707. declare module "babylonjs/XR/webXRInput" {
  45708. import { Observable } from "babylonjs/Misc/observable";
  45709. import { IDisposable } from "babylonjs/scene";
  45710. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45711. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45712. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45713. /**
  45714. * The schema for initialization options of the XR Input class
  45715. */
  45716. export interface IWebXRInputOptions {
  45717. /**
  45718. * If set to true no model will be automatically loaded
  45719. */
  45720. doNotLoadControllerMeshes?: boolean;
  45721. /**
  45722. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45723. * If not found, the xr input profile data will be used.
  45724. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45725. */
  45726. forceInputProfile?: string;
  45727. /**
  45728. * Do not send a request to the controller repository to load the profile.
  45729. *
  45730. * Instead, use the controllers available in babylon itself.
  45731. */
  45732. disableOnlineControllerRepository?: boolean;
  45733. /**
  45734. * A custom URL for the controllers repository
  45735. */
  45736. customControllersRepositoryURL?: string;
  45737. /**
  45738. * Should the controller model's components not move according to the user input
  45739. */
  45740. disableControllerAnimation?: boolean;
  45741. }
  45742. /**
  45743. * XR input used to track XR inputs such as controllers/rays
  45744. */
  45745. export class WebXRInput implements IDisposable {
  45746. /**
  45747. * the xr session manager for this session
  45748. */
  45749. xrSessionManager: WebXRSessionManager;
  45750. /**
  45751. * the WebXR camera for this session. Mainly used for teleportation
  45752. */
  45753. xrCamera: WebXRCamera;
  45754. private readonly options;
  45755. /**
  45756. * XR controllers being tracked
  45757. */
  45758. controllers: Array<WebXRInputSource>;
  45759. private _frameObserver;
  45760. private _sessionEndedObserver;
  45761. private _sessionInitObserver;
  45762. /**
  45763. * Event when a controller has been connected/added
  45764. */
  45765. onControllerAddedObservable: Observable<WebXRInputSource>;
  45766. /**
  45767. * Event when a controller has been removed/disconnected
  45768. */
  45769. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45770. /**
  45771. * Initializes the WebXRInput
  45772. * @param xrSessionManager the xr session manager for this session
  45773. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45774. * @param options = initialization options for this xr input
  45775. */
  45776. constructor(
  45777. /**
  45778. * the xr session manager for this session
  45779. */
  45780. xrSessionManager: WebXRSessionManager,
  45781. /**
  45782. * the WebXR camera for this session. Mainly used for teleportation
  45783. */
  45784. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45785. private _onInputSourcesChange;
  45786. private _addAndRemoveControllers;
  45787. /**
  45788. * Disposes of the object
  45789. */
  45790. dispose(): void;
  45791. }
  45792. }
  45793. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45794. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45795. import { Observable, EventState } from "babylonjs/Misc/observable";
  45796. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45797. /**
  45798. * This is the base class for all WebXR features.
  45799. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45800. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45801. */
  45802. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45803. protected _xrSessionManager: WebXRSessionManager;
  45804. private _attached;
  45805. private _removeOnDetach;
  45806. /**
  45807. * Should auto-attach be disabled?
  45808. */
  45809. disableAutoAttach: boolean;
  45810. /**
  45811. * Construct a new (abstract) WebXR feature
  45812. * @param _xrSessionManager the xr session manager for this feature
  45813. */
  45814. constructor(_xrSessionManager: WebXRSessionManager);
  45815. /**
  45816. * Is this feature attached
  45817. */
  45818. get attached(): boolean;
  45819. /**
  45820. * attach this feature
  45821. *
  45822. * @param force should attachment be forced (even when already attached)
  45823. * @returns true if successful, false is failed or already attached
  45824. */
  45825. attach(force?: boolean): boolean;
  45826. /**
  45827. * detach this feature.
  45828. *
  45829. * @returns true if successful, false if failed or already detached
  45830. */
  45831. detach(): boolean;
  45832. /**
  45833. * Dispose this feature and all of the resources attached
  45834. */
  45835. dispose(): void;
  45836. /**
  45837. * This is used to register callbacks that will automatically be removed when detach is called.
  45838. * @param observable the observable to which the observer will be attached
  45839. * @param callback the callback to register
  45840. */
  45841. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45842. /**
  45843. * Code in this function will be executed on each xrFrame received from the browser.
  45844. * This function will not execute after the feature is detached.
  45845. * @param _xrFrame the current frame
  45846. */
  45847. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45848. }
  45849. }
  45850. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45851. import { IDisposable, Scene } from "babylonjs/scene";
  45852. import { Nullable } from "babylonjs/types";
  45853. import { Observable } from "babylonjs/Misc/observable";
  45854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45855. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45856. import { Camera } from "babylonjs/Cameras/camera";
  45857. /**
  45858. * Renders a layer on top of an existing scene
  45859. */
  45860. export class UtilityLayerRenderer implements IDisposable {
  45861. /** the original scene that will be rendered on top of */
  45862. originalScene: Scene;
  45863. private _pointerCaptures;
  45864. private _lastPointerEvents;
  45865. private static _DefaultUtilityLayer;
  45866. private static _DefaultKeepDepthUtilityLayer;
  45867. private _sharedGizmoLight;
  45868. private _renderCamera;
  45869. /**
  45870. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45871. * @returns the camera that is used when rendering the utility layer
  45872. */
  45873. getRenderCamera(): Camera;
  45874. /**
  45875. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45876. * @param cam the camera that should be used when rendering the utility layer
  45877. */
  45878. setRenderCamera(cam: Nullable<Camera>): void;
  45879. /**
  45880. * @hidden
  45881. * Light which used by gizmos to get light shading
  45882. */
  45883. _getSharedGizmoLight(): HemisphericLight;
  45884. /**
  45885. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45886. */
  45887. pickUtilitySceneFirst: boolean;
  45888. /**
  45889. * 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)
  45890. */
  45891. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45892. /**
  45893. * 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)
  45894. */
  45895. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45896. /**
  45897. * The scene that is rendered on top of the original scene
  45898. */
  45899. utilityLayerScene: Scene;
  45900. /**
  45901. * If the utility layer should automatically be rendered on top of existing scene
  45902. */
  45903. shouldRender: boolean;
  45904. /**
  45905. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45906. */
  45907. onlyCheckPointerDownEvents: boolean;
  45908. /**
  45909. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45910. */
  45911. processAllEvents: boolean;
  45912. /**
  45913. * Observable raised when the pointer move from the utility layer scene to the main scene
  45914. */
  45915. onPointerOutObservable: Observable<number>;
  45916. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45917. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45918. private _afterRenderObserver;
  45919. private _sceneDisposeObserver;
  45920. private _originalPointerObserver;
  45921. /**
  45922. * Instantiates a UtilityLayerRenderer
  45923. * @param originalScene the original scene that will be rendered on top of
  45924. * @param handleEvents boolean indicating if the utility layer should handle events
  45925. */
  45926. constructor(
  45927. /** the original scene that will be rendered on top of */
  45928. originalScene: Scene, handleEvents?: boolean);
  45929. private _notifyObservers;
  45930. /**
  45931. * Renders the utility layers scene on top of the original scene
  45932. */
  45933. render(): void;
  45934. /**
  45935. * Disposes of the renderer
  45936. */
  45937. dispose(): void;
  45938. private _updateCamera;
  45939. }
  45940. }
  45941. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45942. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45944. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45945. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45946. import { Scene } from "babylonjs/scene";
  45947. import { Nullable } from "babylonjs/types";
  45948. import { Color3 } from "babylonjs/Maths/math.color";
  45949. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45950. /**
  45951. * Options interface for the pointer selection module
  45952. */
  45953. export interface IWebXRControllerPointerSelectionOptions {
  45954. /**
  45955. * if provided, this scene will be used to render meshes.
  45956. */
  45957. customUtilityLayerScene?: Scene;
  45958. /**
  45959. * 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)
  45960. * If not disabled, the last picked point will be used to execute a pointer up event
  45961. * If disabled, pointer up event will be triggered right after the pointer down event.
  45962. * Used in screen and gaze target ray mode only
  45963. */
  45964. disablePointerUpOnTouchOut: boolean;
  45965. /**
  45966. * For gaze mode (time to select instead of press)
  45967. */
  45968. forceGazeMode: boolean;
  45969. /**
  45970. * 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
  45971. * to start a new countdown to the pointer down event.
  45972. * Defaults to 1.
  45973. */
  45974. gazeModePointerMovedFactor?: number;
  45975. /**
  45976. * Different button type to use instead of the main component
  45977. */
  45978. overrideButtonId?: string;
  45979. /**
  45980. * use this rendering group id for the meshes (optional)
  45981. */
  45982. renderingGroupId?: number;
  45983. /**
  45984. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45985. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45986. * 3000 means 3 seconds between pointing at something and selecting it
  45987. */
  45988. timeToSelect?: number;
  45989. /**
  45990. * Should meshes created here be added to a utility layer or the main scene
  45991. */
  45992. useUtilityLayer?: boolean;
  45993. /**
  45994. * the xr input to use with this pointer selection
  45995. */
  45996. xrInput: WebXRInput;
  45997. }
  45998. /**
  45999. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46000. */
  46001. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46002. private readonly _options;
  46003. private static _idCounter;
  46004. private _attachController;
  46005. private _controllers;
  46006. private _scene;
  46007. private _tmpVectorForPickCompare;
  46008. /**
  46009. * The module's name
  46010. */
  46011. static readonly Name: string;
  46012. /**
  46013. * The (Babylon) version of this module.
  46014. * This is an integer representing the implementation version.
  46015. * This number does not correspond to the WebXR specs version
  46016. */
  46017. static readonly Version: number;
  46018. /**
  46019. * Disable lighting on the laser pointer (so it will always be visible)
  46020. */
  46021. disablePointerLighting: boolean;
  46022. /**
  46023. * Disable lighting on the selection mesh (so it will always be visible)
  46024. */
  46025. disableSelectionMeshLighting: boolean;
  46026. /**
  46027. * Should the laser pointer be displayed
  46028. */
  46029. displayLaserPointer: boolean;
  46030. /**
  46031. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46032. */
  46033. displaySelectionMesh: boolean;
  46034. /**
  46035. * This color will be set to the laser pointer when selection is triggered
  46036. */
  46037. laserPointerPickedColor: Color3;
  46038. /**
  46039. * Default color of the laser pointer
  46040. */
  46041. lasterPointerDefaultColor: Color3;
  46042. /**
  46043. * default color of the selection ring
  46044. */
  46045. selectionMeshDefaultColor: Color3;
  46046. /**
  46047. * This color will be applied to the selection ring when selection is triggered
  46048. */
  46049. selectionMeshPickedColor: Color3;
  46050. /**
  46051. * constructs a new background remover module
  46052. * @param _xrSessionManager the session manager for this module
  46053. * @param _options read-only options to be used in this module
  46054. */
  46055. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46056. /**
  46057. * attach this feature
  46058. * Will usually be called by the features manager
  46059. *
  46060. * @returns true if successful.
  46061. */
  46062. attach(): boolean;
  46063. /**
  46064. * detach this feature.
  46065. * Will usually be called by the features manager
  46066. *
  46067. * @returns true if successful.
  46068. */
  46069. detach(): boolean;
  46070. /**
  46071. * Will get the mesh under a specific pointer.
  46072. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46073. * @param controllerId the controllerId to check
  46074. * @returns The mesh under pointer or null if no mesh is under the pointer
  46075. */
  46076. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46077. /**
  46078. * Get the xr controller that correlates to the pointer id in the pointer event
  46079. *
  46080. * @param id the pointer id to search for
  46081. * @returns the controller that correlates to this id or null if not found
  46082. */
  46083. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46084. protected _onXRFrame(_xrFrame: XRFrame): void;
  46085. private _attachGazeMode;
  46086. private _attachScreenRayMode;
  46087. private _attachTrackedPointerRayMode;
  46088. private _convertNormalToDirectionOfRay;
  46089. private _detachController;
  46090. private _generateNewMeshPair;
  46091. private _pickingMoved;
  46092. private _updatePointerDistance;
  46093. }
  46094. }
  46095. declare module "babylonjs/XR/webXREnterExitUI" {
  46096. import { Nullable } from "babylonjs/types";
  46097. import { Observable } from "babylonjs/Misc/observable";
  46098. import { IDisposable, Scene } from "babylonjs/scene";
  46099. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46100. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46101. /**
  46102. * Button which can be used to enter a different mode of XR
  46103. */
  46104. export class WebXREnterExitUIButton {
  46105. /** button element */
  46106. element: HTMLElement;
  46107. /** XR initialization options for the button */
  46108. sessionMode: XRSessionMode;
  46109. /** Reference space type */
  46110. referenceSpaceType: XRReferenceSpaceType;
  46111. /**
  46112. * Creates a WebXREnterExitUIButton
  46113. * @param element button element
  46114. * @param sessionMode XR initialization session mode
  46115. * @param referenceSpaceType the type of reference space to be used
  46116. */
  46117. constructor(
  46118. /** button element */
  46119. element: HTMLElement,
  46120. /** XR initialization options for the button */
  46121. sessionMode: XRSessionMode,
  46122. /** Reference space type */
  46123. referenceSpaceType: XRReferenceSpaceType);
  46124. /**
  46125. * Extendable function which can be used to update the button's visuals when the state changes
  46126. * @param activeButton the current active button in the UI
  46127. */
  46128. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46129. }
  46130. /**
  46131. * Options to create the webXR UI
  46132. */
  46133. export class WebXREnterExitUIOptions {
  46134. /**
  46135. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46136. */
  46137. customButtons?: Array<WebXREnterExitUIButton>;
  46138. /**
  46139. * A reference space type to use when creating the default button.
  46140. * Default is local-floor
  46141. */
  46142. referenceSpaceType?: XRReferenceSpaceType;
  46143. /**
  46144. * Context to enter xr with
  46145. */
  46146. renderTarget?: Nullable<WebXRRenderTarget>;
  46147. /**
  46148. * A session mode to use when creating the default button.
  46149. * Default is immersive-vr
  46150. */
  46151. sessionMode?: XRSessionMode;
  46152. }
  46153. /**
  46154. * UI to allow the user to enter/exit XR mode
  46155. */
  46156. export class WebXREnterExitUI implements IDisposable {
  46157. private scene;
  46158. /** version of the options passed to this UI */
  46159. options: WebXREnterExitUIOptions;
  46160. private _activeButton;
  46161. private _buttons;
  46162. private _overlay;
  46163. /**
  46164. * Fired every time the active button is changed.
  46165. *
  46166. * When xr is entered via a button that launches xr that button will be the callback parameter
  46167. *
  46168. * When exiting xr the callback parameter will be null)
  46169. */
  46170. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46171. /**
  46172. *
  46173. * @param scene babylon scene object to use
  46174. * @param options (read-only) version of the options passed to this UI
  46175. */
  46176. private constructor();
  46177. /**
  46178. * Creates UI to allow the user to enter/exit XR mode
  46179. * @param scene the scene to add the ui to
  46180. * @param helper the xr experience helper to enter/exit xr with
  46181. * @param options options to configure the UI
  46182. * @returns the created ui
  46183. */
  46184. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46185. /**
  46186. * Disposes of the XR UI component
  46187. */
  46188. dispose(): void;
  46189. private _updateButtons;
  46190. }
  46191. }
  46192. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46193. import { Vector3 } from "babylonjs/Maths/math.vector";
  46194. import { Color4 } from "babylonjs/Maths/math.color";
  46195. import { Nullable } from "babylonjs/types";
  46196. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46197. import { Scene } from "babylonjs/scene";
  46198. /**
  46199. * Class containing static functions to help procedurally build meshes
  46200. */
  46201. export class LinesBuilder {
  46202. /**
  46203. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46204. * * 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
  46205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46206. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46207. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46208. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46209. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46210. * * 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
  46211. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46214. * @param name defines the name of the new line system
  46215. * @param options defines the options used to create the line system
  46216. * @param scene defines the hosting scene
  46217. * @returns a new line system mesh
  46218. */
  46219. static CreateLineSystem(name: string, options: {
  46220. lines: Vector3[][];
  46221. updatable?: boolean;
  46222. instance?: Nullable<LinesMesh>;
  46223. colors?: Nullable<Color4[][]>;
  46224. useVertexAlpha?: boolean;
  46225. }, scene: Nullable<Scene>): LinesMesh;
  46226. /**
  46227. * Creates a line mesh
  46228. * 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
  46229. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46230. * * The parameter `points` is an array successive Vector3
  46231. * * 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
  46232. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46233. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46234. * * When updating an instance, remember that only point positions can change, not the number of points
  46235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46236. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46237. * @param name defines the name of the new line system
  46238. * @param options defines the options used to create the line system
  46239. * @param scene defines the hosting scene
  46240. * @returns a new line mesh
  46241. */
  46242. static CreateLines(name: string, options: {
  46243. points: Vector3[];
  46244. updatable?: boolean;
  46245. instance?: Nullable<LinesMesh>;
  46246. colors?: Color4[];
  46247. useVertexAlpha?: boolean;
  46248. }, scene?: Nullable<Scene>): LinesMesh;
  46249. /**
  46250. * Creates a dashed line mesh
  46251. * * 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
  46252. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46253. * * The parameter `points` is an array successive Vector3
  46254. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46255. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46256. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46257. * * 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
  46258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46259. * * When updating an instance, remember that only point positions can change, not the number of points
  46260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46261. * @param name defines the name of the mesh
  46262. * @param options defines the options used to create the mesh
  46263. * @param scene defines the hosting scene
  46264. * @returns the dashed line mesh
  46265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46266. */
  46267. static CreateDashedLines(name: string, options: {
  46268. points: Vector3[];
  46269. dashSize?: number;
  46270. gapSize?: number;
  46271. dashNb?: number;
  46272. updatable?: boolean;
  46273. instance?: LinesMesh;
  46274. useVertexAlpha?: boolean;
  46275. }, scene?: Nullable<Scene>): LinesMesh;
  46276. }
  46277. }
  46278. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46279. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46280. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46281. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46283. import { Vector3 } from "babylonjs/Maths/math.vector";
  46284. import { Material } from "babylonjs/Materials/material";
  46285. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46286. import { Scene } from "babylonjs/scene";
  46287. /**
  46288. * The options container for the teleportation module
  46289. */
  46290. export interface IWebXRTeleportationOptions {
  46291. /**
  46292. * if provided, this scene will be used to render meshes.
  46293. */
  46294. customUtilityLayerScene?: Scene;
  46295. /**
  46296. * Values to configure the default target mesh
  46297. */
  46298. defaultTargetMeshOptions?: {
  46299. /**
  46300. * Fill color of the teleportation area
  46301. */
  46302. teleportationFillColor?: string;
  46303. /**
  46304. * Border color for the teleportation area
  46305. */
  46306. teleportationBorderColor?: string;
  46307. /**
  46308. * Disable the mesh's animation sequence
  46309. */
  46310. disableAnimation?: boolean;
  46311. /**
  46312. * Disable lighting on the material or the ring and arrow
  46313. */
  46314. disableLighting?: boolean;
  46315. /**
  46316. * Override the default material of the torus and arrow
  46317. */
  46318. torusArrowMaterial?: Material;
  46319. };
  46320. /**
  46321. * A list of meshes to use as floor meshes.
  46322. * Meshes can be added and removed after initializing the feature using the
  46323. * addFloorMesh and removeFloorMesh functions
  46324. * If empty, rotation will still work
  46325. */
  46326. floorMeshes?: AbstractMesh[];
  46327. /**
  46328. * use this rendering group id for the meshes (optional)
  46329. */
  46330. renderingGroupId?: number;
  46331. /**
  46332. * Should teleportation move only to snap points
  46333. */
  46334. snapPointsOnly?: boolean;
  46335. /**
  46336. * An array of points to which the teleportation will snap to.
  46337. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46338. */
  46339. snapPositions?: Vector3[];
  46340. /**
  46341. * How close should the teleportation ray be in order to snap to position.
  46342. * Default to 0.8 units (meters)
  46343. */
  46344. snapToPositionRadius?: number;
  46345. /**
  46346. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46347. * If you want to support rotation, make sure your mesh has a direction indicator.
  46348. *
  46349. * When left untouched, the default mesh will be initialized.
  46350. */
  46351. teleportationTargetMesh?: AbstractMesh;
  46352. /**
  46353. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46354. */
  46355. timeToTeleport?: number;
  46356. /**
  46357. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46358. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46359. */
  46360. useMainComponentOnly?: boolean;
  46361. /**
  46362. * Should meshes created here be added to a utility layer or the main scene
  46363. */
  46364. useUtilityLayer?: boolean;
  46365. /**
  46366. * Babylon XR Input class for controller
  46367. */
  46368. xrInput: WebXRInput;
  46369. }
  46370. /**
  46371. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46372. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46373. * the input of the attached controllers.
  46374. */
  46375. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46376. private _options;
  46377. private _controllers;
  46378. private _currentTeleportationControllerId;
  46379. private _floorMeshes;
  46380. private _quadraticBezierCurve;
  46381. private _selectionFeature;
  46382. private _snapToPositions;
  46383. private _snappedToPoint;
  46384. private _teleportationRingMaterial?;
  46385. private _tmpRay;
  46386. private _tmpVector;
  46387. /**
  46388. * The module's name
  46389. */
  46390. static readonly Name: string;
  46391. /**
  46392. * The (Babylon) version of this module.
  46393. * This is an integer representing the implementation version.
  46394. * This number does not correspond to the webxr specs version
  46395. */
  46396. static readonly Version: number;
  46397. /**
  46398. * Is movement backwards enabled
  46399. */
  46400. backwardsMovementEnabled: boolean;
  46401. /**
  46402. * Distance to travel when moving backwards
  46403. */
  46404. backwardsTeleportationDistance: number;
  46405. /**
  46406. * The distance from the user to the inspection point in the direction of the controller
  46407. * A higher number will allow the user to move further
  46408. * defaults to 5 (meters, in xr units)
  46409. */
  46410. parabolicCheckRadius: number;
  46411. /**
  46412. * Should the module support parabolic ray on top of direct ray
  46413. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46414. * Very helpful when moving between floors / different heights
  46415. */
  46416. parabolicRayEnabled: boolean;
  46417. /**
  46418. * How much rotation should be applied when rotating right and left
  46419. */
  46420. rotationAngle: number;
  46421. /**
  46422. * Is rotation enabled when moving forward?
  46423. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46424. */
  46425. rotationEnabled: boolean;
  46426. /**
  46427. * constructs a new anchor system
  46428. * @param _xrSessionManager an instance of WebXRSessionManager
  46429. * @param _options configuration object for this feature
  46430. */
  46431. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46432. /**
  46433. * Get the snapPointsOnly flag
  46434. */
  46435. get snapPointsOnly(): boolean;
  46436. /**
  46437. * Sets the snapPointsOnly flag
  46438. * @param snapToPoints should teleportation be exclusively to snap points
  46439. */
  46440. set snapPointsOnly(snapToPoints: boolean);
  46441. /**
  46442. * Add a new mesh to the floor meshes array
  46443. * @param mesh the mesh to use as floor mesh
  46444. */
  46445. addFloorMesh(mesh: AbstractMesh): void;
  46446. /**
  46447. * Add a new snap-to point to fix teleportation to this position
  46448. * @param newSnapPoint The new Snap-To point
  46449. */
  46450. addSnapPoint(newSnapPoint: Vector3): void;
  46451. attach(): boolean;
  46452. detach(): boolean;
  46453. dispose(): void;
  46454. /**
  46455. * Remove a mesh from the floor meshes array
  46456. * @param mesh the mesh to remove
  46457. */
  46458. removeFloorMesh(mesh: AbstractMesh): void;
  46459. /**
  46460. * Remove a mesh from the floor meshes array using its name
  46461. * @param name the mesh name to remove
  46462. */
  46463. removeFloorMeshByName(name: string): void;
  46464. /**
  46465. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  46466. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46467. * @returns was the point found and removed or not
  46468. */
  46469. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46470. /**
  46471. * This function sets a selection feature that will be disabled when
  46472. * the forward ray is shown and will be reattached when hidden.
  46473. * This is used to remove the selection rays when moving.
  46474. * @param selectionFeature the feature to disable when forward movement is enabled
  46475. */
  46476. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46477. protected _onXRFrame(_xrFrame: XRFrame): void;
  46478. private _attachController;
  46479. private _createDefaultTargetMesh;
  46480. private _detachController;
  46481. private _findClosestSnapPointWithRadius;
  46482. private _setTargetMeshPosition;
  46483. private _setTargetMeshVisibility;
  46484. private _showParabolicPath;
  46485. private _teleportForward;
  46486. }
  46487. }
  46488. declare module "babylonjs/XR/webXRDefaultExperience" {
  46489. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46490. import { Scene } from "babylonjs/scene";
  46491. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46492. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46493. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46494. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46496. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46497. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46498. /**
  46499. * Options for the default xr helper
  46500. */
  46501. export class WebXRDefaultExperienceOptions {
  46502. /**
  46503. * Enable or disable default UI to enter XR
  46504. */
  46505. disableDefaultUI?: boolean;
  46506. /**
  46507. * Should teleportation not initialize. defaults to false.
  46508. */
  46509. disableTeleportation?: boolean;
  46510. /**
  46511. * Floor meshes that will be used for teleport
  46512. */
  46513. floorMeshes?: Array<AbstractMesh>;
  46514. /**
  46515. * If set to true, the first frame will not be used to reset position
  46516. * The first frame is mainly used when copying transformation from the old camera
  46517. * Mainly used in AR
  46518. */
  46519. ignoreNativeCameraTransformation?: boolean;
  46520. /**
  46521. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46522. */
  46523. inputOptions?: IWebXRInputOptions;
  46524. /**
  46525. * optional configuration for the output canvas
  46526. */
  46527. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46528. /**
  46529. * optional UI options. This can be used among other to change session mode and reference space type
  46530. */
  46531. uiOptions?: WebXREnterExitUIOptions;
  46532. /**
  46533. * When loading teleportation and pointer select, use stable versions instead of latest.
  46534. */
  46535. useStablePlugins?: boolean;
  46536. }
  46537. /**
  46538. * Default experience which provides a similar setup to the previous webVRExperience
  46539. */
  46540. export class WebXRDefaultExperience {
  46541. /**
  46542. * Base experience
  46543. */
  46544. baseExperience: WebXRExperienceHelper;
  46545. /**
  46546. * Enables ui for entering/exiting xr
  46547. */
  46548. enterExitUI: WebXREnterExitUI;
  46549. /**
  46550. * Input experience extension
  46551. */
  46552. input: WebXRInput;
  46553. /**
  46554. * Enables laser pointer and selection
  46555. */
  46556. pointerSelection: WebXRControllerPointerSelection;
  46557. /**
  46558. * Default target xr should render to
  46559. */
  46560. renderTarget: WebXRRenderTarget;
  46561. /**
  46562. * Enables teleportation
  46563. */
  46564. teleportation: WebXRMotionControllerTeleportation;
  46565. private constructor();
  46566. /**
  46567. * Creates the default xr experience
  46568. * @param scene scene
  46569. * @param options options for basic configuration
  46570. * @returns resulting WebXRDefaultExperience
  46571. */
  46572. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46573. /**
  46574. * DIsposes of the experience helper
  46575. */
  46576. dispose(): void;
  46577. }
  46578. }
  46579. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46580. import { Observable } from "babylonjs/Misc/observable";
  46581. import { Nullable } from "babylonjs/types";
  46582. import { Camera } from "babylonjs/Cameras/camera";
  46583. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46584. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46585. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46586. import { Scene } from "babylonjs/scene";
  46587. import { Vector3 } from "babylonjs/Maths/math.vector";
  46588. import { Color3 } from "babylonjs/Maths/math.color";
  46589. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46591. import { Mesh } from "babylonjs/Meshes/mesh";
  46592. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46593. import { EasingFunction } from "babylonjs/Animations/easing";
  46594. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46595. import "babylonjs/Meshes/Builders/groundBuilder";
  46596. import "babylonjs/Meshes/Builders/torusBuilder";
  46597. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46598. import "babylonjs/Gamepads/gamepadSceneComponent";
  46599. import "babylonjs/Animations/animatable";
  46600. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46601. /**
  46602. * Options to modify the vr teleportation behavior.
  46603. */
  46604. export interface VRTeleportationOptions {
  46605. /**
  46606. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46607. */
  46608. floorMeshName?: string;
  46609. /**
  46610. * A list of meshes to be used as the teleportation floor. (default: empty)
  46611. */
  46612. floorMeshes?: Mesh[];
  46613. /**
  46614. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46615. */
  46616. teleportationMode?: number;
  46617. /**
  46618. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46619. */
  46620. teleportationTime?: number;
  46621. /**
  46622. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46623. */
  46624. teleportationSpeed?: number;
  46625. /**
  46626. * The easing function used in the animation or null for Linear. (default CircleEase)
  46627. */
  46628. easingFunction?: EasingFunction;
  46629. }
  46630. /**
  46631. * Options to modify the vr experience helper's behavior.
  46632. */
  46633. export interface VRExperienceHelperOptions extends WebVROptions {
  46634. /**
  46635. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46636. */
  46637. createDeviceOrientationCamera?: boolean;
  46638. /**
  46639. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46640. */
  46641. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46642. /**
  46643. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46644. */
  46645. laserToggle?: boolean;
  46646. /**
  46647. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46648. */
  46649. floorMeshes?: Mesh[];
  46650. /**
  46651. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46652. */
  46653. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46654. /**
  46655. * Defines if WebXR should be used instead of WebVR (if available)
  46656. */
  46657. useXR?: boolean;
  46658. }
  46659. /**
  46660. * Event containing information after VR has been entered
  46661. */
  46662. export class OnAfterEnteringVRObservableEvent {
  46663. /**
  46664. * If entering vr was successful
  46665. */
  46666. success: boolean;
  46667. }
  46668. /**
  46669. * Helps to quickly add VR support to an existing scene.
  46670. * See http://doc.babylonjs.com/how_to/webvr_helper
  46671. */
  46672. export class VRExperienceHelper {
  46673. /** Options to modify the vr experience helper's behavior. */
  46674. webVROptions: VRExperienceHelperOptions;
  46675. private _scene;
  46676. private _position;
  46677. private _btnVR;
  46678. private _btnVRDisplayed;
  46679. private _webVRsupported;
  46680. private _webVRready;
  46681. private _webVRrequesting;
  46682. private _webVRpresenting;
  46683. private _hasEnteredVR;
  46684. private _fullscreenVRpresenting;
  46685. private _inputElement;
  46686. private _webVRCamera;
  46687. private _vrDeviceOrientationCamera;
  46688. private _deviceOrientationCamera;
  46689. private _existingCamera;
  46690. private _onKeyDown;
  46691. private _onVrDisplayPresentChange;
  46692. private _onVRDisplayChanged;
  46693. private _onVRRequestPresentStart;
  46694. private _onVRRequestPresentComplete;
  46695. /**
  46696. * 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)
  46697. */
  46698. enableGazeEvenWhenNoPointerLock: boolean;
  46699. /**
  46700. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46701. */
  46702. exitVROnDoubleTap: boolean;
  46703. /**
  46704. * Observable raised right before entering VR.
  46705. */
  46706. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46707. /**
  46708. * Observable raised when entering VR has completed.
  46709. */
  46710. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46711. /**
  46712. * Observable raised when exiting VR.
  46713. */
  46714. onExitingVRObservable: Observable<VRExperienceHelper>;
  46715. /**
  46716. * Observable raised when controller mesh is loaded.
  46717. */
  46718. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46719. /** Return this.onEnteringVRObservable
  46720. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46721. */
  46722. get onEnteringVR(): Observable<VRExperienceHelper>;
  46723. /** Return this.onExitingVRObservable
  46724. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46725. */
  46726. get onExitingVR(): Observable<VRExperienceHelper>;
  46727. /** Return this.onControllerMeshLoadedObservable
  46728. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46729. */
  46730. get onControllerMeshLoaded(): Observable<WebVRController>;
  46731. private _rayLength;
  46732. private _useCustomVRButton;
  46733. private _teleportationRequested;
  46734. private _teleportActive;
  46735. private _floorMeshName;
  46736. private _floorMeshesCollection;
  46737. private _teleportationMode;
  46738. private _teleportationTime;
  46739. private _teleportationSpeed;
  46740. private _teleportationEasing;
  46741. private _rotationAllowed;
  46742. private _teleportBackwardsVector;
  46743. private _teleportationTarget;
  46744. private _isDefaultTeleportationTarget;
  46745. private _postProcessMove;
  46746. private _teleportationFillColor;
  46747. private _teleportationBorderColor;
  46748. private _rotationAngle;
  46749. private _haloCenter;
  46750. private _cameraGazer;
  46751. private _padSensibilityUp;
  46752. private _padSensibilityDown;
  46753. private _leftController;
  46754. private _rightController;
  46755. private _gazeColor;
  46756. private _laserColor;
  46757. private _pickedLaserColor;
  46758. private _pickedGazeColor;
  46759. /**
  46760. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46761. */
  46762. onNewMeshSelected: Observable<AbstractMesh>;
  46763. /**
  46764. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46765. * This observable will provide the mesh and the controller used to select the mesh
  46766. */
  46767. onMeshSelectedWithController: Observable<{
  46768. mesh: AbstractMesh;
  46769. controller: WebVRController;
  46770. }>;
  46771. /**
  46772. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46773. */
  46774. onNewMeshPicked: Observable<PickingInfo>;
  46775. private _circleEase;
  46776. /**
  46777. * Observable raised before camera teleportation
  46778. */
  46779. onBeforeCameraTeleport: Observable<Vector3>;
  46780. /**
  46781. * Observable raised after camera teleportation
  46782. */
  46783. onAfterCameraTeleport: Observable<Vector3>;
  46784. /**
  46785. * Observable raised when current selected mesh gets unselected
  46786. */
  46787. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46788. private _raySelectionPredicate;
  46789. /**
  46790. * To be optionaly changed by user to define custom ray selection
  46791. */
  46792. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46793. /**
  46794. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46795. */
  46796. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46797. /**
  46798. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46799. */
  46800. teleportationEnabled: boolean;
  46801. private _defaultHeight;
  46802. private _teleportationInitialized;
  46803. private _interactionsEnabled;
  46804. private _interactionsRequested;
  46805. private _displayGaze;
  46806. private _displayLaserPointer;
  46807. /**
  46808. * The mesh used to display where the user is going to teleport.
  46809. */
  46810. get teleportationTarget(): Mesh;
  46811. /**
  46812. * Sets the mesh to be used to display where the user is going to teleport.
  46813. */
  46814. set teleportationTarget(value: Mesh);
  46815. /**
  46816. * 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
  46817. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46818. * See http://doc.babylonjs.com/resources/baking_transformations
  46819. */
  46820. get gazeTrackerMesh(): Mesh;
  46821. set gazeTrackerMesh(value: Mesh);
  46822. /**
  46823. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46824. */
  46825. updateGazeTrackerScale: boolean;
  46826. /**
  46827. * If the gaze trackers color should be updated when selecting meshes
  46828. */
  46829. updateGazeTrackerColor: boolean;
  46830. /**
  46831. * If the controller laser color should be updated when selecting meshes
  46832. */
  46833. updateControllerLaserColor: boolean;
  46834. /**
  46835. * The gaze tracking mesh corresponding to the left controller
  46836. */
  46837. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46838. /**
  46839. * The gaze tracking mesh corresponding to the right controller
  46840. */
  46841. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46842. /**
  46843. * If the ray of the gaze should be displayed.
  46844. */
  46845. get displayGaze(): boolean;
  46846. /**
  46847. * Sets if the ray of the gaze should be displayed.
  46848. */
  46849. set displayGaze(value: boolean);
  46850. /**
  46851. * If the ray of the LaserPointer should be displayed.
  46852. */
  46853. get displayLaserPointer(): boolean;
  46854. /**
  46855. * Sets if the ray of the LaserPointer should be displayed.
  46856. */
  46857. set displayLaserPointer(value: boolean);
  46858. /**
  46859. * The deviceOrientationCamera used as the camera when not in VR.
  46860. */
  46861. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46862. /**
  46863. * Based on the current WebVR support, returns the current VR camera used.
  46864. */
  46865. get currentVRCamera(): Nullable<Camera>;
  46866. /**
  46867. * The webVRCamera which is used when in VR.
  46868. */
  46869. get webVRCamera(): WebVRFreeCamera;
  46870. /**
  46871. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46872. */
  46873. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46874. /**
  46875. * The html button that is used to trigger entering into VR.
  46876. */
  46877. get vrButton(): Nullable<HTMLButtonElement>;
  46878. private get _teleportationRequestInitiated();
  46879. /**
  46880. * Defines whether or not Pointer lock should be requested when switching to
  46881. * full screen.
  46882. */
  46883. requestPointerLockOnFullScreen: boolean;
  46884. /**
  46885. * If asking to force XR, this will be populated with the default xr experience
  46886. */
  46887. xr: WebXRDefaultExperience;
  46888. /**
  46889. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46890. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46891. */
  46892. xrTestDone: boolean;
  46893. /**
  46894. * Instantiates a VRExperienceHelper.
  46895. * Helps to quickly add VR support to an existing scene.
  46896. * @param scene The scene the VRExperienceHelper belongs to.
  46897. * @param webVROptions Options to modify the vr experience helper's behavior.
  46898. */
  46899. constructor(scene: Scene,
  46900. /** Options to modify the vr experience helper's behavior. */
  46901. webVROptions?: VRExperienceHelperOptions);
  46902. private completeVRInit;
  46903. private _onDefaultMeshLoaded;
  46904. private _onResize;
  46905. private _onFullscreenChange;
  46906. /**
  46907. * Gets a value indicating if we are currently in VR mode.
  46908. */
  46909. get isInVRMode(): boolean;
  46910. private onVrDisplayPresentChange;
  46911. private onVRDisplayChanged;
  46912. private moveButtonToBottomRight;
  46913. private displayVRButton;
  46914. private updateButtonVisibility;
  46915. private _cachedAngularSensibility;
  46916. /**
  46917. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46918. * Otherwise, will use the fullscreen API.
  46919. */
  46920. enterVR(): void;
  46921. /**
  46922. * Attempt to exit VR, or fullscreen.
  46923. */
  46924. exitVR(): void;
  46925. /**
  46926. * The position of the vr experience helper.
  46927. */
  46928. get position(): Vector3;
  46929. /**
  46930. * Sets the position of the vr experience helper.
  46931. */
  46932. set position(value: Vector3);
  46933. /**
  46934. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46935. */
  46936. enableInteractions(): void;
  46937. private get _noControllerIsActive();
  46938. private beforeRender;
  46939. private _isTeleportationFloor;
  46940. /**
  46941. * Adds a floor mesh to be used for teleportation.
  46942. * @param floorMesh the mesh to be used for teleportation.
  46943. */
  46944. addFloorMesh(floorMesh: Mesh): void;
  46945. /**
  46946. * Removes a floor mesh from being used for teleportation.
  46947. * @param floorMesh the mesh to be removed.
  46948. */
  46949. removeFloorMesh(floorMesh: Mesh): void;
  46950. /**
  46951. * Enables interactions and teleportation using the VR controllers and gaze.
  46952. * @param vrTeleportationOptions options to modify teleportation behavior.
  46953. */
  46954. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46955. private _onNewGamepadConnected;
  46956. private _tryEnableInteractionOnController;
  46957. private _onNewGamepadDisconnected;
  46958. private _enableInteractionOnController;
  46959. private _checkTeleportWithRay;
  46960. private _checkRotate;
  46961. private _checkTeleportBackwards;
  46962. private _enableTeleportationOnController;
  46963. private _createTeleportationCircles;
  46964. private _displayTeleportationTarget;
  46965. private _hideTeleportationTarget;
  46966. private _rotateCamera;
  46967. private _moveTeleportationSelectorTo;
  46968. private _workingVector;
  46969. private _workingQuaternion;
  46970. private _workingMatrix;
  46971. /**
  46972. * Time Constant Teleportation Mode
  46973. */
  46974. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46975. /**
  46976. * Speed Constant Teleportation Mode
  46977. */
  46978. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46979. /**
  46980. * Teleports the users feet to the desired location
  46981. * @param location The location where the user's feet should be placed
  46982. */
  46983. teleportCamera(location: Vector3): void;
  46984. private _convertNormalToDirectionOfRay;
  46985. private _castRayAndSelectObject;
  46986. private _notifySelectedMeshUnselected;
  46987. /**
  46988. * Permanently set new colors for the laser pointer
  46989. * @param color the new laser color
  46990. * @param pickedColor the new laser color when picked mesh detected
  46991. */
  46992. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46993. /**
  46994. * Set lighting enabled / disabled on the laser pointer of both controllers
  46995. * @param enabled should the lighting be enabled on the laser pointer
  46996. */
  46997. setLaserLightingState(enabled?: boolean): void;
  46998. /**
  46999. * Permanently set new colors for the gaze pointer
  47000. * @param color the new gaze color
  47001. * @param pickedColor the new gaze color when picked mesh detected
  47002. */
  47003. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47004. /**
  47005. * Sets the color of the laser ray from the vr controllers.
  47006. * @param color new color for the ray.
  47007. */
  47008. changeLaserColor(color: Color3): void;
  47009. /**
  47010. * Sets the color of the ray from the vr headsets gaze.
  47011. * @param color new color for the ray.
  47012. */
  47013. changeGazeColor(color: Color3): void;
  47014. /**
  47015. * Exits VR and disposes of the vr experience helper
  47016. */
  47017. dispose(): void;
  47018. /**
  47019. * Gets the name of the VRExperienceHelper class
  47020. * @returns "VRExperienceHelper"
  47021. */
  47022. getClassName(): string;
  47023. }
  47024. }
  47025. declare module "babylonjs/Cameras/VR/index" {
  47026. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47027. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47028. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47029. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47030. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47031. export * from "babylonjs/Cameras/VR/webVRCamera";
  47032. }
  47033. declare module "babylonjs/Cameras/RigModes/index" {
  47034. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47035. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47036. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47037. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47038. }
  47039. declare module "babylonjs/Cameras/index" {
  47040. export * from "babylonjs/Cameras/Inputs/index";
  47041. export * from "babylonjs/Cameras/cameraInputsManager";
  47042. export * from "babylonjs/Cameras/camera";
  47043. export * from "babylonjs/Cameras/targetCamera";
  47044. export * from "babylonjs/Cameras/freeCamera";
  47045. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47046. export * from "babylonjs/Cameras/touchCamera";
  47047. export * from "babylonjs/Cameras/arcRotateCamera";
  47048. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47049. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47050. export * from "babylonjs/Cameras/flyCamera";
  47051. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47052. export * from "babylonjs/Cameras/followCamera";
  47053. export * from "babylonjs/Cameras/followCameraInputsManager";
  47054. export * from "babylonjs/Cameras/gamepadCamera";
  47055. export * from "babylonjs/Cameras/Stereoscopic/index";
  47056. export * from "babylonjs/Cameras/universalCamera";
  47057. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47058. export * from "babylonjs/Cameras/VR/index";
  47059. export * from "babylonjs/Cameras/RigModes/index";
  47060. }
  47061. declare module "babylonjs/Collisions/index" {
  47062. export * from "babylonjs/Collisions/collider";
  47063. export * from "babylonjs/Collisions/collisionCoordinator";
  47064. export * from "babylonjs/Collisions/pickingInfo";
  47065. export * from "babylonjs/Collisions/intersectionInfo";
  47066. export * from "babylonjs/Collisions/meshCollisionData";
  47067. }
  47068. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47069. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47070. import { Vector3 } from "babylonjs/Maths/math.vector";
  47071. import { Ray } from "babylonjs/Culling/ray";
  47072. import { Plane } from "babylonjs/Maths/math.plane";
  47073. /**
  47074. * Contains an array of blocks representing the octree
  47075. */
  47076. export interface IOctreeContainer<T> {
  47077. /**
  47078. * Blocks within the octree
  47079. */
  47080. blocks: Array<OctreeBlock<T>>;
  47081. }
  47082. /**
  47083. * Class used to store a cell in an octree
  47084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47085. */
  47086. export class OctreeBlock<T> {
  47087. /**
  47088. * Gets the content of the current block
  47089. */
  47090. entries: T[];
  47091. /**
  47092. * Gets the list of block children
  47093. */
  47094. blocks: Array<OctreeBlock<T>>;
  47095. private _depth;
  47096. private _maxDepth;
  47097. private _capacity;
  47098. private _minPoint;
  47099. private _maxPoint;
  47100. private _boundingVectors;
  47101. private _creationFunc;
  47102. /**
  47103. * Creates a new block
  47104. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47105. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47106. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47107. * @param depth defines the current depth of this block in the octree
  47108. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47109. * @param creationFunc defines a callback to call when an element is added to the block
  47110. */
  47111. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47112. /**
  47113. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47114. */
  47115. get capacity(): number;
  47116. /**
  47117. * Gets the minimum vector (in world space) of the block's bounding box
  47118. */
  47119. get minPoint(): Vector3;
  47120. /**
  47121. * Gets the maximum vector (in world space) of the block's bounding box
  47122. */
  47123. get maxPoint(): Vector3;
  47124. /**
  47125. * Add a new element to this block
  47126. * @param entry defines the element to add
  47127. */
  47128. addEntry(entry: T): void;
  47129. /**
  47130. * Remove an element from this block
  47131. * @param entry defines the element to remove
  47132. */
  47133. removeEntry(entry: T): void;
  47134. /**
  47135. * Add an array of elements to this block
  47136. * @param entries defines the array of elements to add
  47137. */
  47138. addEntries(entries: T[]): void;
  47139. /**
  47140. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47141. * @param frustumPlanes defines the frustum planes to test
  47142. * @param selection defines the array to store current content if selection is positive
  47143. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47144. */
  47145. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47146. /**
  47147. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47148. * @param sphereCenter defines the bounding sphere center
  47149. * @param sphereRadius defines the bounding sphere radius
  47150. * @param selection defines the array to store current content if selection is positive
  47151. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47152. */
  47153. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47154. /**
  47155. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47156. * @param ray defines the ray to test with
  47157. * @param selection defines the array to store current content if selection is positive
  47158. */
  47159. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47160. /**
  47161. * Subdivide the content into child blocks (this block will then be empty)
  47162. */
  47163. createInnerBlocks(): void;
  47164. /**
  47165. * @hidden
  47166. */
  47167. 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;
  47168. }
  47169. }
  47170. declare module "babylonjs/Culling/Octrees/octree" {
  47171. import { SmartArray } from "babylonjs/Misc/smartArray";
  47172. import { Vector3 } from "babylonjs/Maths/math.vector";
  47173. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47175. import { Ray } from "babylonjs/Culling/ray";
  47176. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47177. import { Plane } from "babylonjs/Maths/math.plane";
  47178. /**
  47179. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47180. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47181. */
  47182. export class Octree<T> {
  47183. /** 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.) */
  47184. maxDepth: number;
  47185. /**
  47186. * Blocks within the octree containing objects
  47187. */
  47188. blocks: Array<OctreeBlock<T>>;
  47189. /**
  47190. * Content stored in the octree
  47191. */
  47192. dynamicContent: T[];
  47193. private _maxBlockCapacity;
  47194. private _selectionContent;
  47195. private _creationFunc;
  47196. /**
  47197. * Creates a octree
  47198. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47199. * @param creationFunc function to be used to instatiate the octree
  47200. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47201. * @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.)
  47202. */
  47203. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47204. /** 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.) */
  47205. maxDepth?: number);
  47206. /**
  47207. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47208. * @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);
  47209. * @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);
  47210. * @param entries meshes to be added to the octree blocks
  47211. */
  47212. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47213. /**
  47214. * Adds a mesh to the octree
  47215. * @param entry Mesh to add to the octree
  47216. */
  47217. addMesh(entry: T): void;
  47218. /**
  47219. * Remove an element from the octree
  47220. * @param entry defines the element to remove
  47221. */
  47222. removeMesh(entry: T): void;
  47223. /**
  47224. * Selects an array of meshes within the frustum
  47225. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47226. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47227. * @returns array of meshes within the frustum
  47228. */
  47229. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47230. /**
  47231. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47232. * @param sphereCenter defines the bounding sphere center
  47233. * @param sphereRadius defines the bounding sphere radius
  47234. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47235. * @returns an array of objects that intersect the sphere
  47236. */
  47237. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47238. /**
  47239. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47240. * @param ray defines the ray to test with
  47241. * @returns array of intersected objects
  47242. */
  47243. intersectsRay(ray: Ray): SmartArray<T>;
  47244. /**
  47245. * Adds a mesh into the octree block if it intersects the block
  47246. */
  47247. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47248. /**
  47249. * Adds a submesh into the octree block if it intersects the block
  47250. */
  47251. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47252. }
  47253. }
  47254. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47255. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47256. import { Scene } from "babylonjs/scene";
  47257. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47259. import { Ray } from "babylonjs/Culling/ray";
  47260. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47261. import { Collider } from "babylonjs/Collisions/collider";
  47262. module "babylonjs/scene" {
  47263. interface Scene {
  47264. /**
  47265. * @hidden
  47266. * Backing Filed
  47267. */
  47268. _selectionOctree: Octree<AbstractMesh>;
  47269. /**
  47270. * Gets the octree used to boost mesh selection (picking)
  47271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47272. */
  47273. selectionOctree: Octree<AbstractMesh>;
  47274. /**
  47275. * Creates or updates the octree used to boost selection (picking)
  47276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47277. * @param maxCapacity defines the maximum capacity per leaf
  47278. * @param maxDepth defines the maximum depth of the octree
  47279. * @returns an octree of AbstractMesh
  47280. */
  47281. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47282. }
  47283. }
  47284. module "babylonjs/Meshes/abstractMesh" {
  47285. interface AbstractMesh {
  47286. /**
  47287. * @hidden
  47288. * Backing Field
  47289. */
  47290. _submeshesOctree: Octree<SubMesh>;
  47291. /**
  47292. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47293. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47294. * @param maxCapacity defines the maximum size of each block (64 by default)
  47295. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47296. * @returns the new octree
  47297. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47299. */
  47300. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47301. }
  47302. }
  47303. /**
  47304. * Defines the octree scene component responsible to manage any octrees
  47305. * in a given scene.
  47306. */
  47307. export class OctreeSceneComponent {
  47308. /**
  47309. * The component name help to identify the component in the list of scene components.
  47310. */
  47311. readonly name: string;
  47312. /**
  47313. * The scene the component belongs to.
  47314. */
  47315. scene: Scene;
  47316. /**
  47317. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47318. */
  47319. readonly checksIsEnabled: boolean;
  47320. /**
  47321. * Creates a new instance of the component for the given scene
  47322. * @param scene Defines the scene to register the component in
  47323. */
  47324. constructor(scene: Scene);
  47325. /**
  47326. * Registers the component in a given scene
  47327. */
  47328. register(): void;
  47329. /**
  47330. * Return the list of active meshes
  47331. * @returns the list of active meshes
  47332. */
  47333. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47334. /**
  47335. * Return the list of active sub meshes
  47336. * @param mesh The mesh to get the candidates sub meshes from
  47337. * @returns the list of active sub meshes
  47338. */
  47339. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47340. private _tempRay;
  47341. /**
  47342. * Return the list of sub meshes intersecting with a given local ray
  47343. * @param mesh defines the mesh to find the submesh for
  47344. * @param localRay defines the ray in local space
  47345. * @returns the list of intersecting sub meshes
  47346. */
  47347. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47348. /**
  47349. * Return the list of sub meshes colliding with a collider
  47350. * @param mesh defines the mesh to find the submesh for
  47351. * @param collider defines the collider to evaluate the collision against
  47352. * @returns the list of colliding sub meshes
  47353. */
  47354. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47355. /**
  47356. * Rebuilds the elements related to this component in case of
  47357. * context lost for instance.
  47358. */
  47359. rebuild(): void;
  47360. /**
  47361. * Disposes the component and the associated ressources.
  47362. */
  47363. dispose(): void;
  47364. }
  47365. }
  47366. declare module "babylonjs/Culling/Octrees/index" {
  47367. export * from "babylonjs/Culling/Octrees/octree";
  47368. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47369. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47370. }
  47371. declare module "babylonjs/Culling/index" {
  47372. export * from "babylonjs/Culling/boundingBox";
  47373. export * from "babylonjs/Culling/boundingInfo";
  47374. export * from "babylonjs/Culling/boundingSphere";
  47375. export * from "babylonjs/Culling/Octrees/index";
  47376. export * from "babylonjs/Culling/ray";
  47377. }
  47378. declare module "babylonjs/Gizmos/gizmo" {
  47379. import { Nullable } from "babylonjs/types";
  47380. import { IDisposable } from "babylonjs/scene";
  47381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47382. import { Mesh } from "babylonjs/Meshes/mesh";
  47383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47384. /**
  47385. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47386. */
  47387. export class Gizmo implements IDisposable {
  47388. /** The utility layer the gizmo will be added to */
  47389. gizmoLayer: UtilityLayerRenderer;
  47390. /**
  47391. * The root mesh of the gizmo
  47392. */
  47393. _rootMesh: Mesh;
  47394. private _attachedMesh;
  47395. /**
  47396. * Ratio for the scale of the gizmo (Default: 1)
  47397. */
  47398. scaleRatio: number;
  47399. /**
  47400. * If a custom mesh has been set (Default: false)
  47401. */
  47402. protected _customMeshSet: boolean;
  47403. /**
  47404. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47405. * * When set, interactions will be enabled
  47406. */
  47407. get attachedMesh(): Nullable<AbstractMesh>;
  47408. set attachedMesh(value: Nullable<AbstractMesh>);
  47409. /**
  47410. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47411. * @param mesh The mesh to replace the default mesh of the gizmo
  47412. */
  47413. setCustomMesh(mesh: Mesh): void;
  47414. /**
  47415. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47416. */
  47417. updateGizmoRotationToMatchAttachedMesh: boolean;
  47418. /**
  47419. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47420. */
  47421. updateGizmoPositionToMatchAttachedMesh: boolean;
  47422. /**
  47423. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47424. */
  47425. updateScale: boolean;
  47426. protected _interactionsEnabled: boolean;
  47427. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47428. private _beforeRenderObserver;
  47429. private _tempVector;
  47430. /**
  47431. * Creates a gizmo
  47432. * @param gizmoLayer The utility layer the gizmo will be added to
  47433. */
  47434. constructor(
  47435. /** The utility layer the gizmo will be added to */
  47436. gizmoLayer?: UtilityLayerRenderer);
  47437. /**
  47438. * Updates the gizmo to match the attached mesh's position/rotation
  47439. */
  47440. protected _update(): void;
  47441. /**
  47442. * Disposes of the gizmo
  47443. */
  47444. dispose(): void;
  47445. }
  47446. }
  47447. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47448. import { Observable } from "babylonjs/Misc/observable";
  47449. import { Nullable } from "babylonjs/types";
  47450. import { Vector3 } from "babylonjs/Maths/math.vector";
  47451. import { Color3 } from "babylonjs/Maths/math.color";
  47452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47454. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47455. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47456. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47457. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47458. import { Scene } from "babylonjs/scene";
  47459. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47460. /**
  47461. * Single plane drag gizmo
  47462. */
  47463. export class PlaneDragGizmo extends Gizmo {
  47464. /**
  47465. * Drag behavior responsible for the gizmos dragging interactions
  47466. */
  47467. dragBehavior: PointerDragBehavior;
  47468. private _pointerObserver;
  47469. /**
  47470. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47471. */
  47472. snapDistance: number;
  47473. /**
  47474. * Event that fires each time the gizmo snaps to a new location.
  47475. * * snapDistance is the the change in distance
  47476. */
  47477. onSnapObservable: Observable<{
  47478. snapDistance: number;
  47479. }>;
  47480. private _plane;
  47481. private _coloredMaterial;
  47482. private _hoverMaterial;
  47483. private _isEnabled;
  47484. private _parent;
  47485. /** @hidden */
  47486. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47487. /** @hidden */
  47488. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47489. /**
  47490. * Creates a PlaneDragGizmo
  47491. * @param gizmoLayer The utility layer the gizmo will be added to
  47492. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47493. * @param color The color of the gizmo
  47494. */
  47495. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47496. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47497. /**
  47498. * If the gizmo is enabled
  47499. */
  47500. set isEnabled(value: boolean);
  47501. get isEnabled(): boolean;
  47502. /**
  47503. * Disposes of the gizmo
  47504. */
  47505. dispose(): void;
  47506. }
  47507. }
  47508. declare module "babylonjs/Gizmos/positionGizmo" {
  47509. import { Observable } from "babylonjs/Misc/observable";
  47510. import { Nullable } from "babylonjs/types";
  47511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47512. import { Mesh } from "babylonjs/Meshes/mesh";
  47513. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47514. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47515. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47516. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47517. /**
  47518. * Gizmo that enables dragging a mesh along 3 axis
  47519. */
  47520. export class PositionGizmo extends Gizmo {
  47521. /**
  47522. * Internal gizmo used for interactions on the x axis
  47523. */
  47524. xGizmo: AxisDragGizmo;
  47525. /**
  47526. * Internal gizmo used for interactions on the y axis
  47527. */
  47528. yGizmo: AxisDragGizmo;
  47529. /**
  47530. * Internal gizmo used for interactions on the z axis
  47531. */
  47532. zGizmo: AxisDragGizmo;
  47533. /**
  47534. * Internal gizmo used for interactions on the yz plane
  47535. */
  47536. xPlaneGizmo: PlaneDragGizmo;
  47537. /**
  47538. * Internal gizmo used for interactions on the xz plane
  47539. */
  47540. yPlaneGizmo: PlaneDragGizmo;
  47541. /**
  47542. * Internal gizmo used for interactions on the xy plane
  47543. */
  47544. zPlaneGizmo: PlaneDragGizmo;
  47545. /**
  47546. * private variables
  47547. */
  47548. private _meshAttached;
  47549. private _updateGizmoRotationToMatchAttachedMesh;
  47550. private _snapDistance;
  47551. private _scaleRatio;
  47552. /** Fires an event when any of it's sub gizmos are dragged */
  47553. onDragStartObservable: Observable<unknown>;
  47554. /** Fires an event when any of it's sub gizmos are released from dragging */
  47555. onDragEndObservable: Observable<unknown>;
  47556. /**
  47557. * If set to true, planar drag is enabled
  47558. */
  47559. private _planarGizmoEnabled;
  47560. get attachedMesh(): Nullable<AbstractMesh>;
  47561. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47562. /**
  47563. * Creates a PositionGizmo
  47564. * @param gizmoLayer The utility layer the gizmo will be added to
  47565. */
  47566. constructor(gizmoLayer?: UtilityLayerRenderer);
  47567. /**
  47568. * If the planar drag gizmo is enabled
  47569. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47570. */
  47571. set planarGizmoEnabled(value: boolean);
  47572. get planarGizmoEnabled(): boolean;
  47573. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47574. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47575. /**
  47576. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47577. */
  47578. set snapDistance(value: number);
  47579. get snapDistance(): number;
  47580. /**
  47581. * Ratio for the scale of the gizmo (Default: 1)
  47582. */
  47583. set scaleRatio(value: number);
  47584. get scaleRatio(): number;
  47585. /**
  47586. * Disposes of the gizmo
  47587. */
  47588. dispose(): void;
  47589. /**
  47590. * CustomMeshes are not supported by this gizmo
  47591. * @param mesh The mesh to replace the default mesh of the gizmo
  47592. */
  47593. setCustomMesh(mesh: Mesh): void;
  47594. }
  47595. }
  47596. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47597. import { Observable } from "babylonjs/Misc/observable";
  47598. import { Nullable } from "babylonjs/types";
  47599. import { Vector3 } from "babylonjs/Maths/math.vector";
  47600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47602. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47603. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47604. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47605. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47606. import { Scene } from "babylonjs/scene";
  47607. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47608. import { Color3 } from "babylonjs/Maths/math.color";
  47609. /**
  47610. * Single axis drag gizmo
  47611. */
  47612. export class AxisDragGizmo extends Gizmo {
  47613. /**
  47614. * Drag behavior responsible for the gizmos dragging interactions
  47615. */
  47616. dragBehavior: PointerDragBehavior;
  47617. private _pointerObserver;
  47618. /**
  47619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47620. */
  47621. snapDistance: number;
  47622. /**
  47623. * Event that fires each time the gizmo snaps to a new location.
  47624. * * snapDistance is the the change in distance
  47625. */
  47626. onSnapObservable: Observable<{
  47627. snapDistance: number;
  47628. }>;
  47629. private _isEnabled;
  47630. private _parent;
  47631. private _arrow;
  47632. private _coloredMaterial;
  47633. private _hoverMaterial;
  47634. /** @hidden */
  47635. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47636. /** @hidden */
  47637. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47638. /**
  47639. * Creates an AxisDragGizmo
  47640. * @param gizmoLayer The utility layer the gizmo will be added to
  47641. * @param dragAxis The axis which the gizmo will be able to drag on
  47642. * @param color The color of the gizmo
  47643. */
  47644. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47645. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47646. /**
  47647. * If the gizmo is enabled
  47648. */
  47649. set isEnabled(value: boolean);
  47650. get isEnabled(): boolean;
  47651. /**
  47652. * Disposes of the gizmo
  47653. */
  47654. dispose(): void;
  47655. }
  47656. }
  47657. declare module "babylonjs/Debug/axesViewer" {
  47658. import { Vector3 } from "babylonjs/Maths/math.vector";
  47659. import { Nullable } from "babylonjs/types";
  47660. import { Scene } from "babylonjs/scene";
  47661. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47662. /**
  47663. * The Axes viewer will show 3 axes in a specific point in space
  47664. */
  47665. export class AxesViewer {
  47666. private _xAxis;
  47667. private _yAxis;
  47668. private _zAxis;
  47669. private _scaleLinesFactor;
  47670. private _instanced;
  47671. /**
  47672. * Gets the hosting scene
  47673. */
  47674. scene: Scene;
  47675. /**
  47676. * Gets or sets a number used to scale line length
  47677. */
  47678. scaleLines: number;
  47679. /** Gets the node hierarchy used to render x-axis */
  47680. get xAxis(): TransformNode;
  47681. /** Gets the node hierarchy used to render y-axis */
  47682. get yAxis(): TransformNode;
  47683. /** Gets the node hierarchy used to render z-axis */
  47684. get zAxis(): TransformNode;
  47685. /**
  47686. * Creates a new AxesViewer
  47687. * @param scene defines the hosting scene
  47688. * @param scaleLines defines a number used to scale line length (1 by default)
  47689. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47690. * @param xAxis defines the node hierarchy used to render the x-axis
  47691. * @param yAxis defines the node hierarchy used to render the y-axis
  47692. * @param zAxis defines the node hierarchy used to render the z-axis
  47693. */
  47694. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47695. /**
  47696. * Force the viewer to update
  47697. * @param position defines the position of the viewer
  47698. * @param xaxis defines the x axis of the viewer
  47699. * @param yaxis defines the y axis of the viewer
  47700. * @param zaxis defines the z axis of the viewer
  47701. */
  47702. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47703. /**
  47704. * Creates an instance of this axes viewer.
  47705. * @returns a new axes viewer with instanced meshes
  47706. */
  47707. createInstance(): AxesViewer;
  47708. /** Releases resources */
  47709. dispose(): void;
  47710. private static _SetRenderingGroupId;
  47711. }
  47712. }
  47713. declare module "babylonjs/Debug/boneAxesViewer" {
  47714. import { Nullable } from "babylonjs/types";
  47715. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47716. import { Vector3 } from "babylonjs/Maths/math.vector";
  47717. import { Mesh } from "babylonjs/Meshes/mesh";
  47718. import { Bone } from "babylonjs/Bones/bone";
  47719. import { Scene } from "babylonjs/scene";
  47720. /**
  47721. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47722. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47723. */
  47724. export class BoneAxesViewer extends AxesViewer {
  47725. /**
  47726. * Gets or sets the target mesh where to display the axes viewer
  47727. */
  47728. mesh: Nullable<Mesh>;
  47729. /**
  47730. * Gets or sets the target bone where to display the axes viewer
  47731. */
  47732. bone: Nullable<Bone>;
  47733. /** Gets current position */
  47734. pos: Vector3;
  47735. /** Gets direction of X axis */
  47736. xaxis: Vector3;
  47737. /** Gets direction of Y axis */
  47738. yaxis: Vector3;
  47739. /** Gets direction of Z axis */
  47740. zaxis: Vector3;
  47741. /**
  47742. * Creates a new BoneAxesViewer
  47743. * @param scene defines the hosting scene
  47744. * @param bone defines the target bone
  47745. * @param mesh defines the target mesh
  47746. * @param scaleLines defines a scaling factor for line length (1 by default)
  47747. */
  47748. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47749. /**
  47750. * Force the viewer to update
  47751. */
  47752. update(): void;
  47753. /** Releases resources */
  47754. dispose(): void;
  47755. }
  47756. }
  47757. declare module "babylonjs/Debug/debugLayer" {
  47758. import { Scene } from "babylonjs/scene";
  47759. /**
  47760. * Interface used to define scene explorer extensibility option
  47761. */
  47762. export interface IExplorerExtensibilityOption {
  47763. /**
  47764. * Define the option label
  47765. */
  47766. label: string;
  47767. /**
  47768. * Defines the action to execute on click
  47769. */
  47770. action: (entity: any) => void;
  47771. }
  47772. /**
  47773. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47774. */
  47775. export interface IExplorerExtensibilityGroup {
  47776. /**
  47777. * Defines a predicate to test if a given type mut be extended
  47778. */
  47779. predicate: (entity: any) => boolean;
  47780. /**
  47781. * Gets the list of options added to a type
  47782. */
  47783. entries: IExplorerExtensibilityOption[];
  47784. }
  47785. /**
  47786. * Interface used to define the options to use to create the Inspector
  47787. */
  47788. export interface IInspectorOptions {
  47789. /**
  47790. * Display in overlay mode (default: false)
  47791. */
  47792. overlay?: boolean;
  47793. /**
  47794. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47795. */
  47796. globalRoot?: HTMLElement;
  47797. /**
  47798. * Display the Scene explorer
  47799. */
  47800. showExplorer?: boolean;
  47801. /**
  47802. * Display the property inspector
  47803. */
  47804. showInspector?: boolean;
  47805. /**
  47806. * Display in embed mode (both panes on the right)
  47807. */
  47808. embedMode?: boolean;
  47809. /**
  47810. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47811. */
  47812. handleResize?: boolean;
  47813. /**
  47814. * Allow the panes to popup (default: true)
  47815. */
  47816. enablePopup?: boolean;
  47817. /**
  47818. * Allow the panes to be closed by users (default: true)
  47819. */
  47820. enableClose?: boolean;
  47821. /**
  47822. * Optional list of extensibility entries
  47823. */
  47824. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47825. /**
  47826. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47827. */
  47828. inspectorURL?: string;
  47829. /**
  47830. * Optional initial tab (default to DebugLayerTab.Properties)
  47831. */
  47832. initialTab?: DebugLayerTab;
  47833. }
  47834. module "babylonjs/scene" {
  47835. interface Scene {
  47836. /**
  47837. * @hidden
  47838. * Backing field
  47839. */
  47840. _debugLayer: DebugLayer;
  47841. /**
  47842. * Gets the debug layer (aka Inspector) associated with the scene
  47843. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47844. */
  47845. debugLayer: DebugLayer;
  47846. }
  47847. }
  47848. /**
  47849. * Enum of inspector action tab
  47850. */
  47851. export enum DebugLayerTab {
  47852. /**
  47853. * Properties tag (default)
  47854. */
  47855. Properties = 0,
  47856. /**
  47857. * Debug tab
  47858. */
  47859. Debug = 1,
  47860. /**
  47861. * Statistics tab
  47862. */
  47863. Statistics = 2,
  47864. /**
  47865. * Tools tab
  47866. */
  47867. Tools = 3,
  47868. /**
  47869. * Settings tab
  47870. */
  47871. Settings = 4
  47872. }
  47873. /**
  47874. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47875. * what is happening in your scene
  47876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47877. */
  47878. export class DebugLayer {
  47879. /**
  47880. * Define the url to get the inspector script from.
  47881. * By default it uses the babylonjs CDN.
  47882. * @ignoreNaming
  47883. */
  47884. static InspectorURL: string;
  47885. private _scene;
  47886. private BJSINSPECTOR;
  47887. private _onPropertyChangedObservable?;
  47888. /**
  47889. * Observable triggered when a property is changed through the inspector.
  47890. */
  47891. get onPropertyChangedObservable(): any;
  47892. /**
  47893. * Instantiates a new debug layer.
  47894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47895. * what is happening in your scene
  47896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47897. * @param scene Defines the scene to inspect
  47898. */
  47899. constructor(scene: Scene);
  47900. /** Creates the inspector window. */
  47901. private _createInspector;
  47902. /**
  47903. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47904. * @param entity defines the entity to select
  47905. * @param lineContainerTitle defines the specific block to highlight
  47906. */
  47907. select(entity: any, lineContainerTitle?: string): void;
  47908. /** Get the inspector from bundle or global */
  47909. private _getGlobalInspector;
  47910. /**
  47911. * Get if the inspector is visible or not.
  47912. * @returns true if visible otherwise, false
  47913. */
  47914. isVisible(): boolean;
  47915. /**
  47916. * Hide the inspector and close its window.
  47917. */
  47918. hide(): void;
  47919. /**
  47920. * Launch the debugLayer.
  47921. * @param config Define the configuration of the inspector
  47922. * @return a promise fulfilled when the debug layer is visible
  47923. */
  47924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47925. }
  47926. }
  47927. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47928. import { Nullable } from "babylonjs/types";
  47929. import { Scene } from "babylonjs/scene";
  47930. import { Vector4 } from "babylonjs/Maths/math.vector";
  47931. import { Color4 } from "babylonjs/Maths/math.color";
  47932. import { Mesh } from "babylonjs/Meshes/mesh";
  47933. /**
  47934. * Class containing static functions to help procedurally build meshes
  47935. */
  47936. export class BoxBuilder {
  47937. /**
  47938. * Creates a box mesh
  47939. * * The parameter `size` sets the size (float) of each box side (default 1)
  47940. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47941. * * 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)
  47942. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47946. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47947. * @param name defines the name of the mesh
  47948. * @param options defines the options used to create the mesh
  47949. * @param scene defines the hosting scene
  47950. * @returns the box mesh
  47951. */
  47952. static CreateBox(name: string, options: {
  47953. size?: number;
  47954. width?: number;
  47955. height?: number;
  47956. depth?: number;
  47957. faceUV?: Vector4[];
  47958. faceColors?: Color4[];
  47959. sideOrientation?: number;
  47960. frontUVs?: Vector4;
  47961. backUVs?: Vector4;
  47962. wrap?: boolean;
  47963. topBaseAt?: number;
  47964. bottomBaseAt?: number;
  47965. updatable?: boolean;
  47966. }, scene?: Nullable<Scene>): Mesh;
  47967. }
  47968. }
  47969. declare module "babylonjs/Debug/physicsViewer" {
  47970. import { Nullable } from "babylonjs/types";
  47971. import { Scene } from "babylonjs/scene";
  47972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47973. import { Mesh } from "babylonjs/Meshes/mesh";
  47974. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47975. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47976. /**
  47977. * Used to show the physics impostor around the specific mesh
  47978. */
  47979. export class PhysicsViewer {
  47980. /** @hidden */
  47981. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47982. /** @hidden */
  47983. protected _meshes: Array<Nullable<AbstractMesh>>;
  47984. /** @hidden */
  47985. protected _scene: Nullable<Scene>;
  47986. /** @hidden */
  47987. protected _numMeshes: number;
  47988. /** @hidden */
  47989. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47990. private _renderFunction;
  47991. private _utilityLayer;
  47992. private _debugBoxMesh;
  47993. private _debugSphereMesh;
  47994. private _debugCylinderMesh;
  47995. private _debugMaterial;
  47996. private _debugMeshMeshes;
  47997. /**
  47998. * Creates a new PhysicsViewer
  47999. * @param scene defines the hosting scene
  48000. */
  48001. constructor(scene: Scene);
  48002. /** @hidden */
  48003. protected _updateDebugMeshes(): void;
  48004. /**
  48005. * Renders a specified physic impostor
  48006. * @param impostor defines the impostor to render
  48007. * @param targetMesh defines the mesh represented by the impostor
  48008. * @returns the new debug mesh used to render the impostor
  48009. */
  48010. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48011. /**
  48012. * Hides a specified physic impostor
  48013. * @param impostor defines the impostor to hide
  48014. */
  48015. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48016. private _getDebugMaterial;
  48017. private _getDebugBoxMesh;
  48018. private _getDebugSphereMesh;
  48019. private _getDebugCylinderMesh;
  48020. private _getDebugMeshMesh;
  48021. private _getDebugMesh;
  48022. /** Releases all resources */
  48023. dispose(): void;
  48024. }
  48025. }
  48026. declare module "babylonjs/Debug/rayHelper" {
  48027. import { Nullable } from "babylonjs/types";
  48028. import { Ray } from "babylonjs/Culling/ray";
  48029. import { Vector3 } from "babylonjs/Maths/math.vector";
  48030. import { Color3 } from "babylonjs/Maths/math.color";
  48031. import { Scene } from "babylonjs/scene";
  48032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48033. import "babylonjs/Meshes/Builders/linesBuilder";
  48034. /**
  48035. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48036. * in order to better appreciate the issue one might have.
  48037. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48038. */
  48039. export class RayHelper {
  48040. /**
  48041. * Defines the ray we are currently tryin to visualize.
  48042. */
  48043. ray: Nullable<Ray>;
  48044. private _renderPoints;
  48045. private _renderLine;
  48046. private _renderFunction;
  48047. private _scene;
  48048. private _updateToMeshFunction;
  48049. private _attachedToMesh;
  48050. private _meshSpaceDirection;
  48051. private _meshSpaceOrigin;
  48052. /**
  48053. * Helper function to create a colored helper in a scene in one line.
  48054. * @param ray Defines the ray we are currently tryin to visualize
  48055. * @param scene Defines the scene the ray is used in
  48056. * @param color Defines the color we want to see the ray in
  48057. * @returns The newly created ray helper.
  48058. */
  48059. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48060. /**
  48061. * Instantiate a new ray helper.
  48062. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48063. * in order to better appreciate the issue one might have.
  48064. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48065. * @param ray Defines the ray we are currently tryin to visualize
  48066. */
  48067. constructor(ray: Ray);
  48068. /**
  48069. * Shows the ray we are willing to debug.
  48070. * @param scene Defines the scene the ray needs to be rendered in
  48071. * @param color Defines the color the ray needs to be rendered in
  48072. */
  48073. show(scene: Scene, color?: Color3): void;
  48074. /**
  48075. * Hides the ray we are debugging.
  48076. */
  48077. hide(): void;
  48078. private _render;
  48079. /**
  48080. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48081. * @param mesh Defines the mesh we want the helper attached to
  48082. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48083. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48084. * @param length Defines the length of the ray
  48085. */
  48086. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48087. /**
  48088. * Detach the ray helper from the mesh it has previously been attached to.
  48089. */
  48090. detachFromMesh(): void;
  48091. private _updateToMesh;
  48092. /**
  48093. * Dispose the helper and release its associated resources.
  48094. */
  48095. dispose(): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Debug/skeletonViewer" {
  48099. import { Color3 } from "babylonjs/Maths/math.color";
  48100. import { Scene } from "babylonjs/scene";
  48101. import { Nullable } from "babylonjs/types";
  48102. import { Skeleton } from "babylonjs/Bones/skeleton";
  48103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48104. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48105. /**
  48106. * Class used to render a debug view of a given skeleton
  48107. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48108. */
  48109. export class SkeletonViewer {
  48110. /** defines the skeleton to render */
  48111. skeleton: Skeleton;
  48112. /** defines the mesh attached to the skeleton */
  48113. mesh: AbstractMesh;
  48114. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48115. autoUpdateBonesMatrices: boolean;
  48116. /** defines the rendering group id to use with the viewer */
  48117. renderingGroupId: number;
  48118. /** Gets or sets the color used to render the skeleton */
  48119. color: Color3;
  48120. private _scene;
  48121. private _debugLines;
  48122. private _debugMesh;
  48123. private _isEnabled;
  48124. private _renderFunction;
  48125. private _utilityLayer;
  48126. /**
  48127. * Returns the mesh used to render the bones
  48128. */
  48129. get debugMesh(): Nullable<LinesMesh>;
  48130. /**
  48131. * Creates a new SkeletonViewer
  48132. * @param skeleton defines the skeleton to render
  48133. * @param mesh defines the mesh attached to the skeleton
  48134. * @param scene defines the hosting scene
  48135. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48136. * @param renderingGroupId defines the rendering group id to use with the viewer
  48137. */
  48138. constructor(
  48139. /** defines the skeleton to render */
  48140. skeleton: Skeleton,
  48141. /** defines the mesh attached to the skeleton */
  48142. mesh: AbstractMesh, scene: Scene,
  48143. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48144. autoUpdateBonesMatrices?: boolean,
  48145. /** defines the rendering group id to use with the viewer */
  48146. renderingGroupId?: number);
  48147. /** Gets or sets a boolean indicating if the viewer is enabled */
  48148. set isEnabled(value: boolean);
  48149. get isEnabled(): boolean;
  48150. private _getBonePosition;
  48151. private _getLinesForBonesWithLength;
  48152. private _getLinesForBonesNoLength;
  48153. /** Update the viewer to sync with current skeleton state */
  48154. update(): void;
  48155. /** Release associated resources */
  48156. dispose(): void;
  48157. }
  48158. }
  48159. declare module "babylonjs/Debug/index" {
  48160. export * from "babylonjs/Debug/axesViewer";
  48161. export * from "babylonjs/Debug/boneAxesViewer";
  48162. export * from "babylonjs/Debug/debugLayer";
  48163. export * from "babylonjs/Debug/physicsViewer";
  48164. export * from "babylonjs/Debug/rayHelper";
  48165. export * from "babylonjs/Debug/skeletonViewer";
  48166. }
  48167. declare module "babylonjs/Engines/nullEngine" {
  48168. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48169. import { Engine } from "babylonjs/Engines/engine";
  48170. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48171. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48173. import { Effect } from "babylonjs/Materials/effect";
  48174. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48175. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48176. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48177. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48178. /**
  48179. * Options to create the null engine
  48180. */
  48181. export class NullEngineOptions {
  48182. /**
  48183. * Render width (Default: 512)
  48184. */
  48185. renderWidth: number;
  48186. /**
  48187. * Render height (Default: 256)
  48188. */
  48189. renderHeight: number;
  48190. /**
  48191. * Texture size (Default: 512)
  48192. */
  48193. textureSize: number;
  48194. /**
  48195. * If delta time between frames should be constant
  48196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48197. */
  48198. deterministicLockstep: boolean;
  48199. /**
  48200. * Maximum about of steps between frames (Default: 4)
  48201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48202. */
  48203. lockstepMaxSteps: number;
  48204. }
  48205. /**
  48206. * The null engine class provides support for headless version of babylon.js.
  48207. * This can be used in server side scenario or for testing purposes
  48208. */
  48209. export class NullEngine extends Engine {
  48210. private _options;
  48211. /**
  48212. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48214. * @returns true if engine is in deterministic lock step mode
  48215. */
  48216. isDeterministicLockStep(): boolean;
  48217. /**
  48218. * Gets the max steps when engine is running in deterministic lock step
  48219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48220. * @returns the max steps
  48221. */
  48222. getLockstepMaxSteps(): number;
  48223. /**
  48224. * Gets the current hardware scaling level.
  48225. * By default the hardware scaling level is computed from the window device ratio.
  48226. * 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.
  48227. * @returns a number indicating the current hardware scaling level
  48228. */
  48229. getHardwareScalingLevel(): number;
  48230. constructor(options?: NullEngineOptions);
  48231. /**
  48232. * Creates a vertex buffer
  48233. * @param vertices the data for the vertex buffer
  48234. * @returns the new WebGL static buffer
  48235. */
  48236. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48237. /**
  48238. * Creates a new index buffer
  48239. * @param indices defines the content of the index buffer
  48240. * @param updatable defines if the index buffer must be updatable
  48241. * @returns a new webGL buffer
  48242. */
  48243. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48244. /**
  48245. * Clear the current render buffer or the current render target (if any is set up)
  48246. * @param color defines the color to use
  48247. * @param backBuffer defines if the back buffer must be cleared
  48248. * @param depth defines if the depth buffer must be cleared
  48249. * @param stencil defines if the stencil buffer must be cleared
  48250. */
  48251. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48252. /**
  48253. * Gets the current render width
  48254. * @param useScreen defines if screen size must be used (or the current render target if any)
  48255. * @returns a number defining the current render width
  48256. */
  48257. getRenderWidth(useScreen?: boolean): number;
  48258. /**
  48259. * Gets the current render height
  48260. * @param useScreen defines if screen size must be used (or the current render target if any)
  48261. * @returns a number defining the current render height
  48262. */
  48263. getRenderHeight(useScreen?: boolean): number;
  48264. /**
  48265. * Set the WebGL's viewport
  48266. * @param viewport defines the viewport element to be used
  48267. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48268. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48269. */
  48270. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48272. /**
  48273. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48274. * @param pipelineContext defines the pipeline context to use
  48275. * @param uniformsNames defines the list of uniform names
  48276. * @returns an array of webGL uniform locations
  48277. */
  48278. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48279. /**
  48280. * Gets the lsit of active attributes for a given webGL program
  48281. * @param pipelineContext defines the pipeline context to use
  48282. * @param attributesNames defines the list of attribute names to get
  48283. * @returns an array of indices indicating the offset of each attribute
  48284. */
  48285. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48286. /**
  48287. * Binds an effect to the webGL context
  48288. * @param effect defines the effect to bind
  48289. */
  48290. bindSamplers(effect: Effect): void;
  48291. /**
  48292. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48293. * @param effect defines the effect to activate
  48294. */
  48295. enableEffect(effect: Effect): void;
  48296. /**
  48297. * Set various states to the webGL context
  48298. * @param culling defines backface culling state
  48299. * @param zOffset defines the value to apply to zOffset (0 by default)
  48300. * @param force defines if states must be applied even if cache is up to date
  48301. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48302. */
  48303. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48304. /**
  48305. * Set the value of an uniform to an array of int32
  48306. * @param uniform defines the webGL uniform location where to store the value
  48307. * @param array defines the array of int32 to store
  48308. */
  48309. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48310. /**
  48311. * Set the value of an uniform to an array of int32 (stored as vec2)
  48312. * @param uniform defines the webGL uniform location where to store the value
  48313. * @param array defines the array of int32 to store
  48314. */
  48315. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48316. /**
  48317. * Set the value of an uniform to an array of int32 (stored as vec3)
  48318. * @param uniform defines the webGL uniform location where to store the value
  48319. * @param array defines the array of int32 to store
  48320. */
  48321. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48322. /**
  48323. * Set the value of an uniform to an array of int32 (stored as vec4)
  48324. * @param uniform defines the webGL uniform location where to store the value
  48325. * @param array defines the array of int32 to store
  48326. */
  48327. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48328. /**
  48329. * Set the value of an uniform to an array of float32
  48330. * @param uniform defines the webGL uniform location where to store the value
  48331. * @param array defines the array of float32 to store
  48332. */
  48333. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48334. /**
  48335. * Set the value of an uniform to an array of float32 (stored as vec2)
  48336. * @param uniform defines the webGL uniform location where to store the value
  48337. * @param array defines the array of float32 to store
  48338. */
  48339. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48340. /**
  48341. * Set the value of an uniform to an array of float32 (stored as vec3)
  48342. * @param uniform defines the webGL uniform location where to store the value
  48343. * @param array defines the array of float32 to store
  48344. */
  48345. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48346. /**
  48347. * Set the value of an uniform to an array of float32 (stored as vec4)
  48348. * @param uniform defines the webGL uniform location where to store the value
  48349. * @param array defines the array of float32 to store
  48350. */
  48351. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48352. /**
  48353. * Set the value of an uniform to an array of number
  48354. * @param uniform defines the webGL uniform location where to store the value
  48355. * @param array defines the array of number to store
  48356. */
  48357. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48358. /**
  48359. * Set the value of an uniform to an array of number (stored as vec2)
  48360. * @param uniform defines the webGL uniform location where to store the value
  48361. * @param array defines the array of number to store
  48362. */
  48363. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48364. /**
  48365. * Set the value of an uniform to an array of number (stored as vec3)
  48366. * @param uniform defines the webGL uniform location where to store the value
  48367. * @param array defines the array of number to store
  48368. */
  48369. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48370. /**
  48371. * Set the value of an uniform to an array of number (stored as vec4)
  48372. * @param uniform defines the webGL uniform location where to store the value
  48373. * @param array defines the array of number to store
  48374. */
  48375. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48376. /**
  48377. * Set the value of an uniform to an array of float32 (stored as matrices)
  48378. * @param uniform defines the webGL uniform location where to store the value
  48379. * @param matrices defines the array of float32 to store
  48380. */
  48381. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48382. /**
  48383. * Set the value of an uniform to a matrix (3x3)
  48384. * @param uniform defines the webGL uniform location where to store the value
  48385. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48386. */
  48387. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48388. /**
  48389. * Set the value of an uniform to a matrix (2x2)
  48390. * @param uniform defines the webGL uniform location where to store the value
  48391. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48392. */
  48393. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48394. /**
  48395. * Set the value of an uniform to a number (float)
  48396. * @param uniform defines the webGL uniform location where to store the value
  48397. * @param value defines the float number to store
  48398. */
  48399. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48400. /**
  48401. * Set the value of an uniform to a vec2
  48402. * @param uniform defines the webGL uniform location where to store the value
  48403. * @param x defines the 1st component of the value
  48404. * @param y defines the 2nd component of the value
  48405. */
  48406. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48407. /**
  48408. * Set the value of an uniform to a vec3
  48409. * @param uniform defines the webGL uniform location where to store the value
  48410. * @param x defines the 1st component of the value
  48411. * @param y defines the 2nd component of the value
  48412. * @param z defines the 3rd component of the value
  48413. */
  48414. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48415. /**
  48416. * Set the value of an uniform to a boolean
  48417. * @param uniform defines the webGL uniform location where to store the value
  48418. * @param bool defines the boolean to store
  48419. */
  48420. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48421. /**
  48422. * Set the value of an uniform to a vec4
  48423. * @param uniform defines the webGL uniform location where to store the value
  48424. * @param x defines the 1st component of the value
  48425. * @param y defines the 2nd component of the value
  48426. * @param z defines the 3rd component of the value
  48427. * @param w defines the 4th component of the value
  48428. */
  48429. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48430. /**
  48431. * Sets the current alpha mode
  48432. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48433. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48435. */
  48436. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48437. /**
  48438. * Bind webGl buffers directly to the webGL context
  48439. * @param vertexBuffers defines the vertex buffer to bind
  48440. * @param indexBuffer defines the index buffer to bind
  48441. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48442. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48443. * @param effect defines the effect associated with the vertex buffer
  48444. */
  48445. bindBuffers(vertexBuffers: {
  48446. [key: string]: VertexBuffer;
  48447. }, indexBuffer: DataBuffer, effect: Effect): void;
  48448. /**
  48449. * Force the entire cache to be cleared
  48450. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48451. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48452. */
  48453. wipeCaches(bruteForce?: boolean): void;
  48454. /**
  48455. * Send a draw order
  48456. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48457. * @param indexStart defines the starting index
  48458. * @param indexCount defines the number of index to draw
  48459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48460. */
  48461. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48462. /**
  48463. * Draw a list of indexed primitives
  48464. * @param fillMode defines the primitive to use
  48465. * @param indexStart defines the starting index
  48466. * @param indexCount defines the number of index to draw
  48467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48468. */
  48469. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48470. /**
  48471. * Draw a list of unindexed primitives
  48472. * @param fillMode defines the primitive to use
  48473. * @param verticesStart defines the index of first vertex to draw
  48474. * @param verticesCount defines the count of vertices to draw
  48475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48476. */
  48477. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48478. /** @hidden */
  48479. _createTexture(): WebGLTexture;
  48480. /** @hidden */
  48481. _releaseTexture(texture: InternalTexture): void;
  48482. /**
  48483. * Usually called from Texture.ts.
  48484. * Passed information to create a WebGLTexture
  48485. * @param urlArg defines a value which contains one of the following:
  48486. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48487. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48488. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48489. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48490. * @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)
  48491. * @param scene needed for loading to the correct scene
  48492. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48493. * @param onLoad optional callback to be called upon successful completion
  48494. * @param onError optional callback to be called upon failure
  48495. * @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
  48496. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48497. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48498. * @param forcedExtension defines the extension to use to pick the right loader
  48499. * @param mimeType defines an optional mime type
  48500. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48501. */
  48502. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48503. /**
  48504. * Creates a new render target texture
  48505. * @param size defines the size of the texture
  48506. * @param options defines the options used to create the texture
  48507. * @returns a new render target texture stored in an InternalTexture
  48508. */
  48509. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48510. /**
  48511. * Update the sampling mode of a given texture
  48512. * @param samplingMode defines the required sampling mode
  48513. * @param texture defines the texture to update
  48514. */
  48515. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48516. /**
  48517. * Binds the frame buffer to the specified texture.
  48518. * @param texture The texture to render to or null for the default canvas
  48519. * @param faceIndex The face of the texture to render to in case of cube texture
  48520. * @param requiredWidth The width of the target to render to
  48521. * @param requiredHeight The height of the target to render to
  48522. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48523. * @param lodLevel defines le lod level to bind to the frame buffer
  48524. */
  48525. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48526. /**
  48527. * Unbind the current render target texture from the webGL context
  48528. * @param texture defines the render target texture to unbind
  48529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48531. */
  48532. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48533. /**
  48534. * Creates a dynamic vertex buffer
  48535. * @param vertices the data for the dynamic vertex buffer
  48536. * @returns the new WebGL dynamic buffer
  48537. */
  48538. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48539. /**
  48540. * Update the content of a dynamic texture
  48541. * @param texture defines the texture to update
  48542. * @param canvas defines the canvas containing the source
  48543. * @param invertY defines if data must be stored with Y axis inverted
  48544. * @param premulAlpha defines if alpha is stored as premultiplied
  48545. * @param format defines the format of the data
  48546. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48547. */
  48548. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48549. /**
  48550. * Gets a boolean indicating if all created effects are ready
  48551. * @returns true if all effects are ready
  48552. */
  48553. areAllEffectsReady(): boolean;
  48554. /**
  48555. * @hidden
  48556. * Get the current error code of the webGL context
  48557. * @returns the error code
  48558. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48559. */
  48560. getError(): number;
  48561. /** @hidden */
  48562. _getUnpackAlignement(): number;
  48563. /** @hidden */
  48564. _unpackFlipY(value: boolean): void;
  48565. /**
  48566. * Update a dynamic index buffer
  48567. * @param indexBuffer defines the target index buffer
  48568. * @param indices defines the data to update
  48569. * @param offset defines the offset in the target index buffer where update should start
  48570. */
  48571. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48572. /**
  48573. * Updates a dynamic vertex buffer.
  48574. * @param vertexBuffer the vertex buffer to update
  48575. * @param vertices the data used to update the vertex buffer
  48576. * @param byteOffset the byte offset of the data (optional)
  48577. * @param byteLength the byte length of the data (optional)
  48578. */
  48579. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48580. /** @hidden */
  48581. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48582. /** @hidden */
  48583. _bindTexture(channel: number, texture: InternalTexture): void;
  48584. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48585. /**
  48586. * 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
  48587. */
  48588. releaseEffects(): void;
  48589. displayLoadingUI(): void;
  48590. hideLoadingUI(): void;
  48591. /** @hidden */
  48592. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48593. /** @hidden */
  48594. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48595. /** @hidden */
  48596. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48597. /** @hidden */
  48598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48599. }
  48600. }
  48601. declare module "babylonjs/Instrumentation/timeToken" {
  48602. import { Nullable } from "babylonjs/types";
  48603. /**
  48604. * @hidden
  48605. **/
  48606. export class _TimeToken {
  48607. _startTimeQuery: Nullable<WebGLQuery>;
  48608. _endTimeQuery: Nullable<WebGLQuery>;
  48609. _timeElapsedQuery: Nullable<WebGLQuery>;
  48610. _timeElapsedQueryEnded: boolean;
  48611. }
  48612. }
  48613. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48614. import { Nullable, int } from "babylonjs/types";
  48615. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48616. /** @hidden */
  48617. export class _OcclusionDataStorage {
  48618. /** @hidden */
  48619. occlusionInternalRetryCounter: number;
  48620. /** @hidden */
  48621. isOcclusionQueryInProgress: boolean;
  48622. /** @hidden */
  48623. isOccluded: boolean;
  48624. /** @hidden */
  48625. occlusionRetryCount: number;
  48626. /** @hidden */
  48627. occlusionType: number;
  48628. /** @hidden */
  48629. occlusionQueryAlgorithmType: number;
  48630. }
  48631. module "babylonjs/Engines/engine" {
  48632. interface Engine {
  48633. /**
  48634. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48635. * @return the new query
  48636. */
  48637. createQuery(): WebGLQuery;
  48638. /**
  48639. * Delete and release a webGL query
  48640. * @param query defines the query to delete
  48641. * @return the current engine
  48642. */
  48643. deleteQuery(query: WebGLQuery): Engine;
  48644. /**
  48645. * Check if a given query has resolved and got its value
  48646. * @param query defines the query to check
  48647. * @returns true if the query got its value
  48648. */
  48649. isQueryResultAvailable(query: WebGLQuery): boolean;
  48650. /**
  48651. * Gets the value of a given query
  48652. * @param query defines the query to check
  48653. * @returns the value of the query
  48654. */
  48655. getQueryResult(query: WebGLQuery): number;
  48656. /**
  48657. * Initiates an occlusion query
  48658. * @param algorithmType defines the algorithm to use
  48659. * @param query defines the query to use
  48660. * @returns the current engine
  48661. * @see http://doc.babylonjs.com/features/occlusionquery
  48662. */
  48663. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48664. /**
  48665. * Ends an occlusion query
  48666. * @see http://doc.babylonjs.com/features/occlusionquery
  48667. * @param algorithmType defines the algorithm to use
  48668. * @returns the current engine
  48669. */
  48670. endOcclusionQuery(algorithmType: number): Engine;
  48671. /**
  48672. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48673. * Please note that only one query can be issued at a time
  48674. * @returns a time token used to track the time span
  48675. */
  48676. startTimeQuery(): Nullable<_TimeToken>;
  48677. /**
  48678. * Ends a time query
  48679. * @param token defines the token used to measure the time span
  48680. * @returns the time spent (in ns)
  48681. */
  48682. endTimeQuery(token: _TimeToken): int;
  48683. /** @hidden */
  48684. _currentNonTimestampToken: Nullable<_TimeToken>;
  48685. /** @hidden */
  48686. _createTimeQuery(): WebGLQuery;
  48687. /** @hidden */
  48688. _deleteTimeQuery(query: WebGLQuery): void;
  48689. /** @hidden */
  48690. _getGlAlgorithmType(algorithmType: number): number;
  48691. /** @hidden */
  48692. _getTimeQueryResult(query: WebGLQuery): any;
  48693. /** @hidden */
  48694. _getTimeQueryAvailability(query: WebGLQuery): any;
  48695. }
  48696. }
  48697. module "babylonjs/Meshes/abstractMesh" {
  48698. interface AbstractMesh {
  48699. /**
  48700. * Backing filed
  48701. * @hidden
  48702. */
  48703. __occlusionDataStorage: _OcclusionDataStorage;
  48704. /**
  48705. * Access property
  48706. * @hidden
  48707. */
  48708. _occlusionDataStorage: _OcclusionDataStorage;
  48709. /**
  48710. * 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.
  48711. * The default value is -1 which means don't break the query and wait till the result
  48712. * @see http://doc.babylonjs.com/features/occlusionquery
  48713. */
  48714. occlusionRetryCount: number;
  48715. /**
  48716. * 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:
  48717. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48718. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48719. * * 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.
  48720. * @see http://doc.babylonjs.com/features/occlusionquery
  48721. */
  48722. occlusionType: number;
  48723. /**
  48724. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48725. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48726. * * 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.
  48727. * @see http://doc.babylonjs.com/features/occlusionquery
  48728. */
  48729. occlusionQueryAlgorithmType: number;
  48730. /**
  48731. * 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
  48732. * @see http://doc.babylonjs.com/features/occlusionquery
  48733. */
  48734. isOccluded: boolean;
  48735. /**
  48736. * Flag to check the progress status of the query
  48737. * @see http://doc.babylonjs.com/features/occlusionquery
  48738. */
  48739. isOcclusionQueryInProgress: boolean;
  48740. }
  48741. }
  48742. }
  48743. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48744. import { Nullable } from "babylonjs/types";
  48745. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48746. /** @hidden */
  48747. export var _forceTransformFeedbackToBundle: boolean;
  48748. module "babylonjs/Engines/engine" {
  48749. interface Engine {
  48750. /**
  48751. * Creates a webGL transform feedback object
  48752. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48753. * @returns the webGL transform feedback object
  48754. */
  48755. createTransformFeedback(): WebGLTransformFeedback;
  48756. /**
  48757. * Delete a webGL transform feedback object
  48758. * @param value defines the webGL transform feedback object to delete
  48759. */
  48760. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48761. /**
  48762. * Bind a webGL transform feedback object to the webgl context
  48763. * @param value defines the webGL transform feedback object to bind
  48764. */
  48765. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48766. /**
  48767. * Begins a transform feedback operation
  48768. * @param usePoints defines if points or triangles must be used
  48769. */
  48770. beginTransformFeedback(usePoints: boolean): void;
  48771. /**
  48772. * Ends a transform feedback operation
  48773. */
  48774. endTransformFeedback(): void;
  48775. /**
  48776. * Specify the varyings to use with transform feedback
  48777. * @param program defines the associated webGL program
  48778. * @param value defines the list of strings representing the varying names
  48779. */
  48780. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48781. /**
  48782. * Bind a webGL buffer for a transform feedback operation
  48783. * @param value defines the webGL buffer to bind
  48784. */
  48785. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48786. }
  48787. }
  48788. }
  48789. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48790. import { Scene } from "babylonjs/scene";
  48791. import { Engine } from "babylonjs/Engines/engine";
  48792. import { Texture } from "babylonjs/Materials/Textures/texture";
  48793. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48794. import "babylonjs/Engines/Extensions/engine.multiRender";
  48795. /**
  48796. * Creation options of the multi render target texture.
  48797. */
  48798. export interface IMultiRenderTargetOptions {
  48799. /**
  48800. * Define if the texture needs to create mip maps after render.
  48801. */
  48802. generateMipMaps?: boolean;
  48803. /**
  48804. * Define the types of all the draw buffers we want to create
  48805. */
  48806. types?: number[];
  48807. /**
  48808. * Define the sampling modes of all the draw buffers we want to create
  48809. */
  48810. samplingModes?: number[];
  48811. /**
  48812. * Define if a depth buffer is required
  48813. */
  48814. generateDepthBuffer?: boolean;
  48815. /**
  48816. * Define if a stencil buffer is required
  48817. */
  48818. generateStencilBuffer?: boolean;
  48819. /**
  48820. * Define if a depth texture is required instead of a depth buffer
  48821. */
  48822. generateDepthTexture?: boolean;
  48823. /**
  48824. * Define the number of desired draw buffers
  48825. */
  48826. textureCount?: number;
  48827. /**
  48828. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48829. */
  48830. doNotChangeAspectRatio?: boolean;
  48831. /**
  48832. * Define the default type of the buffers we are creating
  48833. */
  48834. defaultType?: number;
  48835. }
  48836. /**
  48837. * A multi render target, like a render target provides the ability to render to a texture.
  48838. * Unlike the render target, it can render to several draw buffers in one draw.
  48839. * This is specially interesting in deferred rendering or for any effects requiring more than
  48840. * just one color from a single pass.
  48841. */
  48842. export class MultiRenderTarget extends RenderTargetTexture {
  48843. private _internalTextures;
  48844. private _textures;
  48845. private _multiRenderTargetOptions;
  48846. /**
  48847. * Get if draw buffers are currently supported by the used hardware and browser.
  48848. */
  48849. get isSupported(): boolean;
  48850. /**
  48851. * Get the list of textures generated by the multi render target.
  48852. */
  48853. get textures(): Texture[];
  48854. /**
  48855. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48856. */
  48857. get depthTexture(): Texture;
  48858. /**
  48859. * Set the wrapping mode on U of all the textures we are rendering to.
  48860. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48861. */
  48862. set wrapU(wrap: number);
  48863. /**
  48864. * Set the wrapping mode on V of all the textures we are rendering to.
  48865. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48866. */
  48867. set wrapV(wrap: number);
  48868. /**
  48869. * Instantiate a new multi render target texture.
  48870. * A multi render target, like a render target provides the ability to render to a texture.
  48871. * Unlike the render target, it can render to several draw buffers in one draw.
  48872. * This is specially interesting in deferred rendering or for any effects requiring more than
  48873. * just one color from a single pass.
  48874. * @param name Define the name of the texture
  48875. * @param size Define the size of the buffers to render to
  48876. * @param count Define the number of target we are rendering into
  48877. * @param scene Define the scene the texture belongs to
  48878. * @param options Define the options used to create the multi render target
  48879. */
  48880. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48881. /** @hidden */
  48882. _rebuild(): void;
  48883. private _createInternalTextures;
  48884. private _createTextures;
  48885. /**
  48886. * Define the number of samples used if MSAA is enabled.
  48887. */
  48888. get samples(): number;
  48889. set samples(value: number);
  48890. /**
  48891. * Resize all the textures in the multi render target.
  48892. * Be carrefull as it will recreate all the data in the new texture.
  48893. * @param size Define the new size
  48894. */
  48895. resize(size: any): void;
  48896. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48897. /**
  48898. * Dispose the render targets and their associated resources
  48899. */
  48900. dispose(): void;
  48901. /**
  48902. * Release all the underlying texture used as draw buffers.
  48903. */
  48904. releaseInternalTextures(): void;
  48905. }
  48906. }
  48907. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48908. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48909. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48910. import { Nullable } from "babylonjs/types";
  48911. module "babylonjs/Engines/thinEngine" {
  48912. interface ThinEngine {
  48913. /**
  48914. * Unbind a list of render target textures from the webGL context
  48915. * This is used only when drawBuffer extension or webGL2 are active
  48916. * @param textures defines the render target textures to unbind
  48917. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48918. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48919. */
  48920. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48921. /**
  48922. * Create a multi render target texture
  48923. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48924. * @param size defines the size of the texture
  48925. * @param options defines the creation options
  48926. * @returns the cube texture as an InternalTexture
  48927. */
  48928. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48929. /**
  48930. * Update the sample count for a given multiple render target texture
  48931. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48932. * @param textures defines the textures to update
  48933. * @param samples defines the sample count to set
  48934. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48935. */
  48936. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48937. }
  48938. }
  48939. }
  48940. declare module "babylonjs/Engines/Extensions/engine.views" {
  48941. import { Camera } from "babylonjs/Cameras/camera";
  48942. import { Nullable } from "babylonjs/types";
  48943. /**
  48944. * Class used to define an additional view for the engine
  48945. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48946. */
  48947. export class EngineView {
  48948. /** Defines the canvas where to render the view */
  48949. target: HTMLCanvasElement;
  48950. /** Defines an optional camera used to render the view (will use active camera else) */
  48951. camera?: Camera;
  48952. }
  48953. module "babylonjs/Engines/engine" {
  48954. interface Engine {
  48955. /**
  48956. * Gets or sets the HTML element to use for attaching events
  48957. */
  48958. inputElement: Nullable<HTMLElement>;
  48959. /**
  48960. * Gets the current engine view
  48961. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48962. */
  48963. activeView: Nullable<EngineView>;
  48964. /** Gets or sets the list of views */
  48965. views: EngineView[];
  48966. /**
  48967. * Register a new child canvas
  48968. * @param canvas defines the canvas to register
  48969. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48970. * @returns the associated view
  48971. */
  48972. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48973. /**
  48974. * Remove a registered child canvas
  48975. * @param canvas defines the canvas to remove
  48976. * @returns the current engine
  48977. */
  48978. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48979. }
  48980. }
  48981. }
  48982. declare module "babylonjs/Engines/Extensions/index" {
  48983. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48984. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48985. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48986. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48987. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48988. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48989. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48990. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48991. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48992. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48993. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48994. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48995. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48996. export * from "babylonjs/Engines/Extensions/engine.views";
  48997. }
  48998. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48999. import { Nullable } from "babylonjs/types";
  49000. /**
  49001. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49002. */
  49003. export interface CubeMapInfo {
  49004. /**
  49005. * The pixel array for the front face.
  49006. * This is stored in format, left to right, up to down format.
  49007. */
  49008. front: Nullable<ArrayBufferView>;
  49009. /**
  49010. * The pixel array for the back face.
  49011. * This is stored in format, left to right, up to down format.
  49012. */
  49013. back: Nullable<ArrayBufferView>;
  49014. /**
  49015. * The pixel array for the left face.
  49016. * This is stored in format, left to right, up to down format.
  49017. */
  49018. left: Nullable<ArrayBufferView>;
  49019. /**
  49020. * The pixel array for the right face.
  49021. * This is stored in format, left to right, up to down format.
  49022. */
  49023. right: Nullable<ArrayBufferView>;
  49024. /**
  49025. * The pixel array for the up face.
  49026. * This is stored in format, left to right, up to down format.
  49027. */
  49028. up: Nullable<ArrayBufferView>;
  49029. /**
  49030. * The pixel array for the down face.
  49031. * This is stored in format, left to right, up to down format.
  49032. */
  49033. down: Nullable<ArrayBufferView>;
  49034. /**
  49035. * The size of the cubemap stored.
  49036. *
  49037. * Each faces will be size * size pixels.
  49038. */
  49039. size: number;
  49040. /**
  49041. * The format of the texture.
  49042. *
  49043. * RGBA, RGB.
  49044. */
  49045. format: number;
  49046. /**
  49047. * The type of the texture data.
  49048. *
  49049. * UNSIGNED_INT, FLOAT.
  49050. */
  49051. type: number;
  49052. /**
  49053. * Specifies whether the texture is in gamma space.
  49054. */
  49055. gammaSpace: boolean;
  49056. }
  49057. /**
  49058. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49059. */
  49060. export class PanoramaToCubeMapTools {
  49061. private static FACE_FRONT;
  49062. private static FACE_BACK;
  49063. private static FACE_RIGHT;
  49064. private static FACE_LEFT;
  49065. private static FACE_DOWN;
  49066. private static FACE_UP;
  49067. /**
  49068. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49069. *
  49070. * @param float32Array The source data.
  49071. * @param inputWidth The width of the input panorama.
  49072. * @param inputHeight The height of the input panorama.
  49073. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49074. * @return The cubemap data
  49075. */
  49076. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49077. private static CreateCubemapTexture;
  49078. private static CalcProjectionSpherical;
  49079. }
  49080. }
  49081. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49082. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49084. import { Nullable } from "babylonjs/types";
  49085. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49086. /**
  49087. * Helper class dealing with the extraction of spherical polynomial dataArray
  49088. * from a cube map.
  49089. */
  49090. export class CubeMapToSphericalPolynomialTools {
  49091. private static FileFaces;
  49092. /**
  49093. * Converts a texture to the according Spherical Polynomial data.
  49094. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49095. *
  49096. * @param texture The texture to extract the information from.
  49097. * @return The Spherical Polynomial data.
  49098. */
  49099. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49100. /**
  49101. * Converts a cubemap to the according Spherical Polynomial data.
  49102. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49103. *
  49104. * @param cubeInfo The Cube map to extract the information from.
  49105. * @return The Spherical Polynomial data.
  49106. */
  49107. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49108. }
  49109. }
  49110. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49111. import { Nullable } from "babylonjs/types";
  49112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49113. module "babylonjs/Materials/Textures/baseTexture" {
  49114. interface BaseTexture {
  49115. /**
  49116. * Get the polynomial representation of the texture data.
  49117. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49118. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49119. */
  49120. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49121. }
  49122. }
  49123. }
  49124. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49125. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49126. /** @hidden */
  49127. export var rgbdEncodePixelShader: {
  49128. name: string;
  49129. shader: string;
  49130. };
  49131. }
  49132. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49133. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49134. /** @hidden */
  49135. export var rgbdDecodePixelShader: {
  49136. name: string;
  49137. shader: string;
  49138. };
  49139. }
  49140. declare module "babylonjs/Misc/environmentTextureTools" {
  49141. import { Nullable } from "babylonjs/types";
  49142. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49143. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49144. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49145. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49146. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49147. import "babylonjs/Shaders/rgbdEncode.fragment";
  49148. import "babylonjs/Shaders/rgbdDecode.fragment";
  49149. /**
  49150. * Raw texture data and descriptor sufficient for WebGL texture upload
  49151. */
  49152. export interface EnvironmentTextureInfo {
  49153. /**
  49154. * Version of the environment map
  49155. */
  49156. version: number;
  49157. /**
  49158. * Width of image
  49159. */
  49160. width: number;
  49161. /**
  49162. * Irradiance information stored in the file.
  49163. */
  49164. irradiance: any;
  49165. /**
  49166. * Specular information stored in the file.
  49167. */
  49168. specular: any;
  49169. }
  49170. /**
  49171. * Defines One Image in the file. It requires only the position in the file
  49172. * as well as the length.
  49173. */
  49174. interface BufferImageData {
  49175. /**
  49176. * Length of the image data.
  49177. */
  49178. length: number;
  49179. /**
  49180. * Position of the data from the null terminator delimiting the end of the JSON.
  49181. */
  49182. position: number;
  49183. }
  49184. /**
  49185. * Defines the specular data enclosed in the file.
  49186. * This corresponds to the version 1 of the data.
  49187. */
  49188. export interface EnvironmentTextureSpecularInfoV1 {
  49189. /**
  49190. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49191. */
  49192. specularDataPosition?: number;
  49193. /**
  49194. * This contains all the images data needed to reconstruct the cubemap.
  49195. */
  49196. mipmaps: Array<BufferImageData>;
  49197. /**
  49198. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49199. */
  49200. lodGenerationScale: number;
  49201. }
  49202. /**
  49203. * Sets of helpers addressing the serialization and deserialization of environment texture
  49204. * stored in a BabylonJS env file.
  49205. * Those files are usually stored as .env files.
  49206. */
  49207. export class EnvironmentTextureTools {
  49208. /**
  49209. * Magic number identifying the env file.
  49210. */
  49211. private static _MagicBytes;
  49212. /**
  49213. * Gets the environment info from an env file.
  49214. * @param data The array buffer containing the .env bytes.
  49215. * @returns the environment file info (the json header) if successfully parsed.
  49216. */
  49217. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49218. /**
  49219. * Creates an environment texture from a loaded cube texture.
  49220. * @param texture defines the cube texture to convert in env file
  49221. * @return a promise containing the environment data if succesfull.
  49222. */
  49223. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49224. /**
  49225. * Creates a JSON representation of the spherical data.
  49226. * @param texture defines the texture containing the polynomials
  49227. * @return the JSON representation of the spherical info
  49228. */
  49229. private static _CreateEnvTextureIrradiance;
  49230. /**
  49231. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49232. * @param data the image data
  49233. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49234. * @return the views described by info providing access to the underlying buffer
  49235. */
  49236. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49237. /**
  49238. * Uploads the texture info contained in the env file to the GPU.
  49239. * @param texture defines the internal texture to upload to
  49240. * @param data defines the data to load
  49241. * @param info defines the texture info retrieved through the GetEnvInfo method
  49242. * @returns a promise
  49243. */
  49244. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49245. private static _OnImageReadyAsync;
  49246. /**
  49247. * Uploads the levels of image data to the GPU.
  49248. * @param texture defines the internal texture to upload to
  49249. * @param imageData defines the array buffer views of image data [mipmap][face]
  49250. * @returns a promise
  49251. */
  49252. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49253. /**
  49254. * Uploads spherical polynomials information to the texture.
  49255. * @param texture defines the texture we are trying to upload the information to
  49256. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49257. */
  49258. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49259. /** @hidden */
  49260. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49261. }
  49262. }
  49263. declare module "babylonjs/Maths/math.vertexFormat" {
  49264. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49265. /**
  49266. * Contains position and normal vectors for a vertex
  49267. */
  49268. export class PositionNormalVertex {
  49269. /** the position of the vertex (defaut: 0,0,0) */
  49270. position: Vector3;
  49271. /** the normal of the vertex (defaut: 0,1,0) */
  49272. normal: Vector3;
  49273. /**
  49274. * Creates a PositionNormalVertex
  49275. * @param position the position of the vertex (defaut: 0,0,0)
  49276. * @param normal the normal of the vertex (defaut: 0,1,0)
  49277. */
  49278. constructor(
  49279. /** the position of the vertex (defaut: 0,0,0) */
  49280. position?: Vector3,
  49281. /** the normal of the vertex (defaut: 0,1,0) */
  49282. normal?: Vector3);
  49283. /**
  49284. * Clones the PositionNormalVertex
  49285. * @returns the cloned PositionNormalVertex
  49286. */
  49287. clone(): PositionNormalVertex;
  49288. }
  49289. /**
  49290. * Contains position, normal and uv vectors for a vertex
  49291. */
  49292. export class PositionNormalTextureVertex {
  49293. /** the position of the vertex (defaut: 0,0,0) */
  49294. position: Vector3;
  49295. /** the normal of the vertex (defaut: 0,1,0) */
  49296. normal: Vector3;
  49297. /** the uv of the vertex (default: 0,0) */
  49298. uv: Vector2;
  49299. /**
  49300. * Creates a PositionNormalTextureVertex
  49301. * @param position the position of the vertex (defaut: 0,0,0)
  49302. * @param normal the normal of the vertex (defaut: 0,1,0)
  49303. * @param uv the uv of the vertex (default: 0,0)
  49304. */
  49305. constructor(
  49306. /** the position of the vertex (defaut: 0,0,0) */
  49307. position?: Vector3,
  49308. /** the normal of the vertex (defaut: 0,1,0) */
  49309. normal?: Vector3,
  49310. /** the uv of the vertex (default: 0,0) */
  49311. uv?: Vector2);
  49312. /**
  49313. * Clones the PositionNormalTextureVertex
  49314. * @returns the cloned PositionNormalTextureVertex
  49315. */
  49316. clone(): PositionNormalTextureVertex;
  49317. }
  49318. }
  49319. declare module "babylonjs/Maths/math" {
  49320. export * from "babylonjs/Maths/math.axis";
  49321. export * from "babylonjs/Maths/math.color";
  49322. export * from "babylonjs/Maths/math.constants";
  49323. export * from "babylonjs/Maths/math.frustum";
  49324. export * from "babylonjs/Maths/math.path";
  49325. export * from "babylonjs/Maths/math.plane";
  49326. export * from "babylonjs/Maths/math.size";
  49327. export * from "babylonjs/Maths/math.vector";
  49328. export * from "babylonjs/Maths/math.vertexFormat";
  49329. export * from "babylonjs/Maths/math.viewport";
  49330. }
  49331. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49332. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49333. /** @hidden */
  49334. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49335. private _genericAttributeLocation;
  49336. private _varyingLocationCount;
  49337. private _varyingLocationMap;
  49338. private _replacements;
  49339. private _textureCount;
  49340. private _uniforms;
  49341. lineProcessor(line: string): string;
  49342. attributeProcessor(attribute: string): string;
  49343. varyingProcessor(varying: string, isFragment: boolean): string;
  49344. uniformProcessor(uniform: string): string;
  49345. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49346. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49347. }
  49348. }
  49349. declare module "babylonjs/Engines/nativeEngine" {
  49350. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49351. import { Engine } from "babylonjs/Engines/engine";
  49352. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49353. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49355. import { Effect } from "babylonjs/Materials/effect";
  49356. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49357. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49358. import { IColor4Like } from "babylonjs/Maths/math.like";
  49359. import { Scene } from "babylonjs/scene";
  49360. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49361. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49362. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49363. /**
  49364. * Container for accessors for natively-stored mesh data buffers.
  49365. */
  49366. class NativeDataBuffer extends DataBuffer {
  49367. /**
  49368. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49369. */
  49370. nativeIndexBuffer?: any;
  49371. /**
  49372. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49373. */
  49374. nativeVertexBuffer?: any;
  49375. }
  49376. /** @hidden */
  49377. class NativeTexture extends InternalTexture {
  49378. getInternalTexture(): InternalTexture;
  49379. getViewCount(): number;
  49380. }
  49381. /** @hidden */
  49382. export class NativeEngine extends Engine {
  49383. private readonly _native;
  49384. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49385. private readonly INVALID_HANDLE;
  49386. getHardwareScalingLevel(): number;
  49387. constructor();
  49388. /**
  49389. * Can be used to override the current requestAnimationFrame requester.
  49390. * @hidden
  49391. */
  49392. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49393. /**
  49394. * Override default engine behavior.
  49395. * @param color
  49396. * @param backBuffer
  49397. * @param depth
  49398. * @param stencil
  49399. */
  49400. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49401. /**
  49402. * Gets host document
  49403. * @returns the host document object
  49404. */
  49405. getHostDocument(): Nullable<Document>;
  49406. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49407. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49408. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49409. recordVertexArrayObject(vertexBuffers: {
  49410. [key: string]: VertexBuffer;
  49411. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49412. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49413. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49414. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49415. /**
  49416. * Draw a list of indexed primitives
  49417. * @param fillMode defines the primitive to use
  49418. * @param indexStart defines the starting index
  49419. * @param indexCount defines the number of index to draw
  49420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49421. */
  49422. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49423. /**
  49424. * Draw a list of unindexed primitives
  49425. * @param fillMode defines the primitive to use
  49426. * @param verticesStart defines the index of first vertex to draw
  49427. * @param verticesCount defines the count of vertices to draw
  49428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49429. */
  49430. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49431. createPipelineContext(): IPipelineContext;
  49432. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49433. /** @hidden */
  49434. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49435. /** @hidden */
  49436. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49437. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49438. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49439. protected _setProgram(program: WebGLProgram): void;
  49440. _releaseEffect(effect: Effect): void;
  49441. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49442. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49443. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49444. bindSamplers(effect: Effect): void;
  49445. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49446. getRenderWidth(useScreen?: boolean): number;
  49447. getRenderHeight(useScreen?: boolean): number;
  49448. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49449. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49450. /**
  49451. * Set the z offset to apply to current rendering
  49452. * @param value defines the offset to apply
  49453. */
  49454. setZOffset(value: number): void;
  49455. /**
  49456. * Gets the current value of the zOffset
  49457. * @returns the current zOffset state
  49458. */
  49459. getZOffset(): number;
  49460. /**
  49461. * Enable or disable depth buffering
  49462. * @param enable defines the state to set
  49463. */
  49464. setDepthBuffer(enable: boolean): void;
  49465. /**
  49466. * Gets a boolean indicating if depth writing is enabled
  49467. * @returns the current depth writing state
  49468. */
  49469. getDepthWrite(): boolean;
  49470. /**
  49471. * Enable or disable depth writing
  49472. * @param enable defines the state to set
  49473. */
  49474. setDepthWrite(enable: boolean): void;
  49475. /**
  49476. * Enable or disable color writing
  49477. * @param enable defines the state to set
  49478. */
  49479. setColorWrite(enable: boolean): void;
  49480. /**
  49481. * Gets a boolean indicating if color writing is enabled
  49482. * @returns the current color writing state
  49483. */
  49484. getColorWrite(): boolean;
  49485. /**
  49486. * Sets alpha constants used by some alpha blending modes
  49487. * @param r defines the red component
  49488. * @param g defines the green component
  49489. * @param b defines the blue component
  49490. * @param a defines the alpha component
  49491. */
  49492. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49493. /**
  49494. * Sets the current alpha mode
  49495. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49496. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49498. */
  49499. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49500. /**
  49501. * Gets the current alpha mode
  49502. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49503. * @returns the current alpha mode
  49504. */
  49505. getAlphaMode(): number;
  49506. setInt(uniform: WebGLUniformLocation, int: number): void;
  49507. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49508. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49509. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49510. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49511. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49512. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49513. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49514. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49515. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49516. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49517. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49518. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49519. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49520. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49521. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49522. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49523. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49524. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49525. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49526. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49527. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49528. wipeCaches(bruteForce?: boolean): void;
  49529. _createTexture(): WebGLTexture;
  49530. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49531. /**
  49532. * Usually called from Texture.ts.
  49533. * Passed information to create a WebGLTexture
  49534. * @param urlArg defines a value which contains one of the following:
  49535. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49536. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49537. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49538. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49539. * @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)
  49540. * @param scene needed for loading to the correct scene
  49541. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49542. * @param onLoad optional callback to be called upon successful completion
  49543. * @param onError optional callback to be called upon failure
  49544. * @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
  49545. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49546. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49547. * @param forcedExtension defines the extension to use to pick the right loader
  49548. * @param mimeType defines an optional mime type
  49549. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49550. */
  49551. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49552. /**
  49553. * Creates a cube texture
  49554. * @param rootUrl defines the url where the files to load is located
  49555. * @param scene defines the current scene
  49556. * @param files defines the list of files to load (1 per face)
  49557. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49558. * @param onLoad defines an optional callback raised when the texture is loaded
  49559. * @param onError defines an optional callback raised if there is an issue to load the texture
  49560. * @param format defines the format of the data
  49561. * @param forcedExtension defines the extension to use to pick the right loader
  49562. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49563. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49564. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49565. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49566. * @returns the cube texture as an InternalTexture
  49567. */
  49568. 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;
  49569. private _getSamplingFilter;
  49570. private static _GetNativeTextureFormat;
  49571. createRenderTargetTexture(size: number | {
  49572. width: number;
  49573. height: number;
  49574. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49575. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49576. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49577. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49578. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49579. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49580. /**
  49581. * Updates a dynamic vertex buffer.
  49582. * @param vertexBuffer the vertex buffer to update
  49583. * @param data the data used to update the vertex buffer
  49584. * @param byteOffset the byte offset of the data (optional)
  49585. * @param byteLength the byte length of the data (optional)
  49586. */
  49587. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49588. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49589. private _updateAnisotropicLevel;
  49590. private _getAddressMode;
  49591. /** @hidden */
  49592. _bindTexture(channel: number, texture: InternalTexture): void;
  49593. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49594. releaseEffects(): void;
  49595. /** @hidden */
  49596. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49597. /** @hidden */
  49598. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49599. /** @hidden */
  49600. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49601. /** @hidden */
  49602. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49603. }
  49604. }
  49605. declare module "babylonjs/Engines/index" {
  49606. export * from "babylonjs/Engines/constants";
  49607. export * from "babylonjs/Engines/engineCapabilities";
  49608. export * from "babylonjs/Engines/instancingAttributeInfo";
  49609. export * from "babylonjs/Engines/thinEngine";
  49610. export * from "babylonjs/Engines/engine";
  49611. export * from "babylonjs/Engines/engineStore";
  49612. export * from "babylonjs/Engines/nullEngine";
  49613. export * from "babylonjs/Engines/Extensions/index";
  49614. export * from "babylonjs/Engines/IPipelineContext";
  49615. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49616. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49617. export * from "babylonjs/Engines/nativeEngine";
  49618. }
  49619. declare module "babylonjs/Events/clipboardEvents" {
  49620. /**
  49621. * Gather the list of clipboard event types as constants.
  49622. */
  49623. export class ClipboardEventTypes {
  49624. /**
  49625. * The clipboard event is fired when a copy command is active (pressed).
  49626. */
  49627. static readonly COPY: number;
  49628. /**
  49629. * The clipboard event is fired when a cut command is active (pressed).
  49630. */
  49631. static readonly CUT: number;
  49632. /**
  49633. * The clipboard event is fired when a paste command is active (pressed).
  49634. */
  49635. static readonly PASTE: number;
  49636. }
  49637. /**
  49638. * This class is used to store clipboard related info for the onClipboardObservable event.
  49639. */
  49640. export class ClipboardInfo {
  49641. /**
  49642. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49643. */
  49644. type: number;
  49645. /**
  49646. * Defines the related dom event
  49647. */
  49648. event: ClipboardEvent;
  49649. /**
  49650. *Creates an instance of ClipboardInfo.
  49651. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49652. * @param event Defines the related dom event
  49653. */
  49654. constructor(
  49655. /**
  49656. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49657. */
  49658. type: number,
  49659. /**
  49660. * Defines the related dom event
  49661. */
  49662. event: ClipboardEvent);
  49663. /**
  49664. * Get the clipboard event's type from the keycode.
  49665. * @param keyCode Defines the keyCode for the current keyboard event.
  49666. * @return {number}
  49667. */
  49668. static GetTypeFromCharacter(keyCode: number): number;
  49669. }
  49670. }
  49671. declare module "babylonjs/Events/index" {
  49672. export * from "babylonjs/Events/keyboardEvents";
  49673. export * from "babylonjs/Events/pointerEvents";
  49674. export * from "babylonjs/Events/clipboardEvents";
  49675. }
  49676. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49677. import { Scene } from "babylonjs/scene";
  49678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49679. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49680. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49681. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49682. /**
  49683. * Google Daydream controller
  49684. */
  49685. export class DaydreamController extends WebVRController {
  49686. /**
  49687. * Base Url for the controller model.
  49688. */
  49689. static MODEL_BASE_URL: string;
  49690. /**
  49691. * File name for the controller model.
  49692. */
  49693. static MODEL_FILENAME: string;
  49694. /**
  49695. * Gamepad Id prefix used to identify Daydream Controller.
  49696. */
  49697. static readonly GAMEPAD_ID_PREFIX: string;
  49698. /**
  49699. * Creates a new DaydreamController from a gamepad
  49700. * @param vrGamepad the gamepad that the controller should be created from
  49701. */
  49702. constructor(vrGamepad: any);
  49703. /**
  49704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49705. * @param scene scene in which to add meshes
  49706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49707. */
  49708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49709. /**
  49710. * Called once for each button that changed state since the last frame
  49711. * @param buttonIdx Which button index changed
  49712. * @param state New state of the button
  49713. * @param changes Which properties on the state changed since last frame
  49714. */
  49715. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49716. }
  49717. }
  49718. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49719. import { Scene } from "babylonjs/scene";
  49720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49721. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49722. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49723. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49724. /**
  49725. * Gear VR Controller
  49726. */
  49727. export class GearVRController extends WebVRController {
  49728. /**
  49729. * Base Url for the controller model.
  49730. */
  49731. static MODEL_BASE_URL: string;
  49732. /**
  49733. * File name for the controller model.
  49734. */
  49735. static MODEL_FILENAME: string;
  49736. /**
  49737. * Gamepad Id prefix used to identify this controller.
  49738. */
  49739. static readonly GAMEPAD_ID_PREFIX: string;
  49740. private readonly _buttonIndexToObservableNameMap;
  49741. /**
  49742. * Creates a new GearVRController from a gamepad
  49743. * @param vrGamepad the gamepad that the controller should be created from
  49744. */
  49745. constructor(vrGamepad: any);
  49746. /**
  49747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49748. * @param scene scene in which to add meshes
  49749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49750. */
  49751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49752. /**
  49753. * Called once for each button that changed state since the last frame
  49754. * @param buttonIdx Which button index changed
  49755. * @param state New state of the button
  49756. * @param changes Which properties on the state changed since last frame
  49757. */
  49758. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49759. }
  49760. }
  49761. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49762. import { Scene } from "babylonjs/scene";
  49763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49764. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49765. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49766. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49767. /**
  49768. * Generic Controller
  49769. */
  49770. export class GenericController extends WebVRController {
  49771. /**
  49772. * Base Url for the controller model.
  49773. */
  49774. static readonly MODEL_BASE_URL: string;
  49775. /**
  49776. * File name for the controller model.
  49777. */
  49778. static readonly MODEL_FILENAME: string;
  49779. /**
  49780. * Creates a new GenericController from a gamepad
  49781. * @param vrGamepad the gamepad that the controller should be created from
  49782. */
  49783. constructor(vrGamepad: any);
  49784. /**
  49785. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49786. * @param scene scene in which to add meshes
  49787. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49788. */
  49789. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49790. /**
  49791. * Called once for each button that changed state since the last frame
  49792. * @param buttonIdx Which button index changed
  49793. * @param state New state of the button
  49794. * @param changes Which properties on the state changed since last frame
  49795. */
  49796. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49797. }
  49798. }
  49799. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49800. import { Observable } from "babylonjs/Misc/observable";
  49801. import { Scene } from "babylonjs/scene";
  49802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49804. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49805. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49806. /**
  49807. * Oculus Touch Controller
  49808. */
  49809. export class OculusTouchController extends WebVRController {
  49810. /**
  49811. * Base Url for the controller model.
  49812. */
  49813. static MODEL_BASE_URL: string;
  49814. /**
  49815. * File name for the left controller model.
  49816. */
  49817. static MODEL_LEFT_FILENAME: string;
  49818. /**
  49819. * File name for the right controller model.
  49820. */
  49821. static MODEL_RIGHT_FILENAME: string;
  49822. /**
  49823. * Base Url for the Quest controller model.
  49824. */
  49825. static QUEST_MODEL_BASE_URL: string;
  49826. /**
  49827. * @hidden
  49828. * If the controllers are running on a device that needs the updated Quest controller models
  49829. */
  49830. static _IsQuest: boolean;
  49831. /**
  49832. * Fired when the secondary trigger on this controller is modified
  49833. */
  49834. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49835. /**
  49836. * Fired when the thumb rest on this controller is modified
  49837. */
  49838. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49839. /**
  49840. * Creates a new OculusTouchController from a gamepad
  49841. * @param vrGamepad the gamepad that the controller should be created from
  49842. */
  49843. constructor(vrGamepad: any);
  49844. /**
  49845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49846. * @param scene scene in which to add meshes
  49847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49848. */
  49849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49850. /**
  49851. * Fired when the A button on this controller is modified
  49852. */
  49853. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49854. /**
  49855. * Fired when the B button on this controller is modified
  49856. */
  49857. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49858. /**
  49859. * Fired when the X button on this controller is modified
  49860. */
  49861. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49862. /**
  49863. * Fired when the Y button on this controller is modified
  49864. */
  49865. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49866. /**
  49867. * Called once for each button that changed state since the last frame
  49868. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49869. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49870. * 2) secondary trigger (same)
  49871. * 3) A (right) X (left), touch, pressed = value
  49872. * 4) B / Y
  49873. * 5) thumb rest
  49874. * @param buttonIdx Which button index changed
  49875. * @param state New state of the button
  49876. * @param changes Which properties on the state changed since last frame
  49877. */
  49878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49879. }
  49880. }
  49881. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49882. import { Scene } from "babylonjs/scene";
  49883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49884. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49885. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49886. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49887. import { Observable } from "babylonjs/Misc/observable";
  49888. /**
  49889. * Vive Controller
  49890. */
  49891. export class ViveController extends WebVRController {
  49892. /**
  49893. * Base Url for the controller model.
  49894. */
  49895. static MODEL_BASE_URL: string;
  49896. /**
  49897. * File name for the controller model.
  49898. */
  49899. static MODEL_FILENAME: string;
  49900. /**
  49901. * Creates a new ViveController from a gamepad
  49902. * @param vrGamepad the gamepad that the controller should be created from
  49903. */
  49904. constructor(vrGamepad: any);
  49905. /**
  49906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49907. * @param scene scene in which to add meshes
  49908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49909. */
  49910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49911. /**
  49912. * Fired when the left button on this controller is modified
  49913. */
  49914. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49915. /**
  49916. * Fired when the right button on this controller is modified
  49917. */
  49918. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49919. /**
  49920. * Fired when the menu button on this controller is modified
  49921. */
  49922. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49923. /**
  49924. * Called once for each button that changed state since the last frame
  49925. * Vive mapping:
  49926. * 0: touchpad
  49927. * 1: trigger
  49928. * 2: left AND right buttons
  49929. * 3: menu button
  49930. * @param buttonIdx Which button index changed
  49931. * @param state New state of the button
  49932. * @param changes Which properties on the state changed since last frame
  49933. */
  49934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49935. }
  49936. }
  49937. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49938. import { Observable } from "babylonjs/Misc/observable";
  49939. import { Scene } from "babylonjs/scene";
  49940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49941. import { Ray } from "babylonjs/Culling/ray";
  49942. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49943. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49944. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49945. /**
  49946. * Defines the WindowsMotionController object that the state of the windows motion controller
  49947. */
  49948. export class WindowsMotionController extends WebVRController {
  49949. /**
  49950. * The base url used to load the left and right controller models
  49951. */
  49952. static MODEL_BASE_URL: string;
  49953. /**
  49954. * The name of the left controller model file
  49955. */
  49956. static MODEL_LEFT_FILENAME: string;
  49957. /**
  49958. * The name of the right controller model file
  49959. */
  49960. static MODEL_RIGHT_FILENAME: string;
  49961. /**
  49962. * The controller name prefix for this controller type
  49963. */
  49964. static readonly GAMEPAD_ID_PREFIX: string;
  49965. /**
  49966. * The controller id pattern for this controller type
  49967. */
  49968. private static readonly GAMEPAD_ID_PATTERN;
  49969. private _loadedMeshInfo;
  49970. protected readonly _mapping: {
  49971. buttons: string[];
  49972. buttonMeshNames: {
  49973. 'trigger': string;
  49974. 'menu': string;
  49975. 'grip': string;
  49976. 'thumbstick': string;
  49977. 'trackpad': string;
  49978. };
  49979. buttonObservableNames: {
  49980. 'trigger': string;
  49981. 'menu': string;
  49982. 'grip': string;
  49983. 'thumbstick': string;
  49984. 'trackpad': string;
  49985. };
  49986. axisMeshNames: string[];
  49987. pointingPoseMeshName: string;
  49988. };
  49989. /**
  49990. * Fired when the trackpad on this controller is clicked
  49991. */
  49992. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49993. /**
  49994. * Fired when the trackpad on this controller is modified
  49995. */
  49996. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49997. /**
  49998. * The current x and y values of this controller's trackpad
  49999. */
  50000. trackpad: StickValues;
  50001. /**
  50002. * Creates a new WindowsMotionController from a gamepad
  50003. * @param vrGamepad the gamepad that the controller should be created from
  50004. */
  50005. constructor(vrGamepad: any);
  50006. /**
  50007. * Fired when the trigger on this controller is modified
  50008. */
  50009. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50010. /**
  50011. * Fired when the menu button on this controller is modified
  50012. */
  50013. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50014. /**
  50015. * Fired when the grip button on this controller is modified
  50016. */
  50017. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50018. /**
  50019. * Fired when the thumbstick button on this controller is modified
  50020. */
  50021. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50022. /**
  50023. * Fired when the touchpad button on this controller is modified
  50024. */
  50025. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50026. /**
  50027. * Fired when the touchpad values on this controller are modified
  50028. */
  50029. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50030. protected _updateTrackpad(): void;
  50031. /**
  50032. * Called once per frame by the engine.
  50033. */
  50034. update(): void;
  50035. /**
  50036. * Called once for each button that changed state since the last frame
  50037. * @param buttonIdx Which button index changed
  50038. * @param state New state of the button
  50039. * @param changes Which properties on the state changed since last frame
  50040. */
  50041. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50042. /**
  50043. * Moves the buttons on the controller mesh based on their current state
  50044. * @param buttonName the name of the button to move
  50045. * @param buttonValue the value of the button which determines the buttons new position
  50046. */
  50047. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50048. /**
  50049. * Moves the axis on the controller mesh based on its current state
  50050. * @param axis the index of the axis
  50051. * @param axisValue the value of the axis which determines the meshes new position
  50052. * @hidden
  50053. */
  50054. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50055. /**
  50056. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50057. * @param scene scene in which to add meshes
  50058. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50059. */
  50060. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50061. /**
  50062. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50063. * can be transformed by button presses and axes values, based on this._mapping.
  50064. *
  50065. * @param scene scene in which the meshes exist
  50066. * @param meshes list of meshes that make up the controller model to process
  50067. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50068. */
  50069. private processModel;
  50070. private createMeshInfo;
  50071. /**
  50072. * Gets the ray of the controller in the direction the controller is pointing
  50073. * @param length the length the resulting ray should be
  50074. * @returns a ray in the direction the controller is pointing
  50075. */
  50076. getForwardRay(length?: number): Ray;
  50077. /**
  50078. * Disposes of the controller
  50079. */
  50080. dispose(): void;
  50081. }
  50082. /**
  50083. * This class represents a new windows motion controller in XR.
  50084. */
  50085. export class XRWindowsMotionController extends WindowsMotionController {
  50086. /**
  50087. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50088. */
  50089. protected readonly _mapping: {
  50090. buttons: string[];
  50091. buttonMeshNames: {
  50092. 'trigger': string;
  50093. 'menu': string;
  50094. 'grip': string;
  50095. 'thumbstick': string;
  50096. 'trackpad': string;
  50097. };
  50098. buttonObservableNames: {
  50099. 'trigger': string;
  50100. 'menu': string;
  50101. 'grip': string;
  50102. 'thumbstick': string;
  50103. 'trackpad': string;
  50104. };
  50105. axisMeshNames: string[];
  50106. pointingPoseMeshName: string;
  50107. };
  50108. /**
  50109. * Construct a new XR-Based windows motion controller
  50110. *
  50111. * @param gamepadInfo the gamepad object from the browser
  50112. */
  50113. constructor(gamepadInfo: any);
  50114. /**
  50115. * holds the thumbstick values (X,Y)
  50116. */
  50117. thumbstickValues: StickValues;
  50118. /**
  50119. * Fired when the thumbstick on this controller is clicked
  50120. */
  50121. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50122. /**
  50123. * Fired when the thumbstick on this controller is modified
  50124. */
  50125. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50126. /**
  50127. * Fired when the touchpad button on this controller is modified
  50128. */
  50129. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50130. /**
  50131. * Fired when the touchpad values on this controller are modified
  50132. */
  50133. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50134. /**
  50135. * Fired when the thumbstick button on this controller is modified
  50136. * here to prevent breaking changes
  50137. */
  50138. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50139. /**
  50140. * updating the thumbstick(!) and not the trackpad.
  50141. * This is named this way due to the difference between WebVR and XR and to avoid
  50142. * changing the parent class.
  50143. */
  50144. protected _updateTrackpad(): void;
  50145. /**
  50146. * Disposes the class with joy
  50147. */
  50148. dispose(): void;
  50149. }
  50150. }
  50151. declare module "babylonjs/Gamepads/Controllers/index" {
  50152. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50153. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50154. export * from "babylonjs/Gamepads/Controllers/genericController";
  50155. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50156. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50157. export * from "babylonjs/Gamepads/Controllers/viveController";
  50158. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50159. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50160. }
  50161. declare module "babylonjs/Gamepads/index" {
  50162. export * from "babylonjs/Gamepads/Controllers/index";
  50163. export * from "babylonjs/Gamepads/gamepad";
  50164. export * from "babylonjs/Gamepads/gamepadManager";
  50165. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50166. export * from "babylonjs/Gamepads/xboxGamepad";
  50167. export * from "babylonjs/Gamepads/dualShockGamepad";
  50168. }
  50169. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50170. import { Scene } from "babylonjs/scene";
  50171. import { Vector4 } from "babylonjs/Maths/math.vector";
  50172. import { Color4 } from "babylonjs/Maths/math.color";
  50173. import { Mesh } from "babylonjs/Meshes/mesh";
  50174. import { Nullable } from "babylonjs/types";
  50175. /**
  50176. * Class containing static functions to help procedurally build meshes
  50177. */
  50178. export class PolyhedronBuilder {
  50179. /**
  50180. * Creates a polyhedron mesh
  50181. * * 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
  50182. * * The parameter `size` (positive float, default 1) sets the polygon size
  50183. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50184. * * 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`
  50185. * * 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
  50186. * * 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)`)
  50187. * * 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
  50188. * * 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
  50189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50192. * @param name defines the name of the mesh
  50193. * @param options defines the options used to create the mesh
  50194. * @param scene defines the hosting scene
  50195. * @returns the polyhedron mesh
  50196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50197. */
  50198. static CreatePolyhedron(name: string, options: {
  50199. type?: number;
  50200. size?: number;
  50201. sizeX?: number;
  50202. sizeY?: number;
  50203. sizeZ?: number;
  50204. custom?: any;
  50205. faceUV?: Vector4[];
  50206. faceColors?: Color4[];
  50207. flat?: boolean;
  50208. updatable?: boolean;
  50209. sideOrientation?: number;
  50210. frontUVs?: Vector4;
  50211. backUVs?: Vector4;
  50212. }, scene?: Nullable<Scene>): Mesh;
  50213. }
  50214. }
  50215. declare module "babylonjs/Gizmos/scaleGizmo" {
  50216. import { Observable } from "babylonjs/Misc/observable";
  50217. import { Nullable } from "babylonjs/types";
  50218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50219. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50220. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50221. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50222. /**
  50223. * Gizmo that enables scaling a mesh along 3 axis
  50224. */
  50225. export class ScaleGizmo extends Gizmo {
  50226. /**
  50227. * Internal gizmo used for interactions on the x axis
  50228. */
  50229. xGizmo: AxisScaleGizmo;
  50230. /**
  50231. * Internal gizmo used for interactions on the y axis
  50232. */
  50233. yGizmo: AxisScaleGizmo;
  50234. /**
  50235. * Internal gizmo used for interactions on the z axis
  50236. */
  50237. zGizmo: AxisScaleGizmo;
  50238. /**
  50239. * Internal gizmo used to scale all axis equally
  50240. */
  50241. uniformScaleGizmo: AxisScaleGizmo;
  50242. private _meshAttached;
  50243. private _updateGizmoRotationToMatchAttachedMesh;
  50244. private _snapDistance;
  50245. private _scaleRatio;
  50246. private _uniformScalingMesh;
  50247. private _octahedron;
  50248. private _sensitivity;
  50249. /** Fires an event when any of it's sub gizmos are dragged */
  50250. onDragStartObservable: Observable<unknown>;
  50251. /** Fires an event when any of it's sub gizmos are released from dragging */
  50252. onDragEndObservable: Observable<unknown>;
  50253. get attachedMesh(): Nullable<AbstractMesh>;
  50254. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50255. /**
  50256. * Creates a ScaleGizmo
  50257. * @param gizmoLayer The utility layer the gizmo will be added to
  50258. */
  50259. constructor(gizmoLayer?: UtilityLayerRenderer);
  50260. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50261. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50262. /**
  50263. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50264. */
  50265. set snapDistance(value: number);
  50266. get snapDistance(): number;
  50267. /**
  50268. * Ratio for the scale of the gizmo (Default: 1)
  50269. */
  50270. set scaleRatio(value: number);
  50271. get scaleRatio(): number;
  50272. /**
  50273. * Sensitivity factor for dragging (Default: 1)
  50274. */
  50275. set sensitivity(value: number);
  50276. get sensitivity(): number;
  50277. /**
  50278. * Disposes of the gizmo
  50279. */
  50280. dispose(): void;
  50281. }
  50282. }
  50283. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50284. import { Observable } from "babylonjs/Misc/observable";
  50285. import { Nullable } from "babylonjs/types";
  50286. import { Vector3 } from "babylonjs/Maths/math.vector";
  50287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50288. import { Mesh } from "babylonjs/Meshes/mesh";
  50289. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50290. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50291. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50292. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50293. import { Color3 } from "babylonjs/Maths/math.color";
  50294. /**
  50295. * Single axis scale gizmo
  50296. */
  50297. export class AxisScaleGizmo extends Gizmo {
  50298. /**
  50299. * Drag behavior responsible for the gizmos dragging interactions
  50300. */
  50301. dragBehavior: PointerDragBehavior;
  50302. private _pointerObserver;
  50303. /**
  50304. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50305. */
  50306. snapDistance: number;
  50307. /**
  50308. * Event that fires each time the gizmo snaps to a new location.
  50309. * * snapDistance is the the change in distance
  50310. */
  50311. onSnapObservable: Observable<{
  50312. snapDistance: number;
  50313. }>;
  50314. /**
  50315. * If the scaling operation should be done on all axis (default: false)
  50316. */
  50317. uniformScaling: boolean;
  50318. /**
  50319. * Custom sensitivity value for the drag strength
  50320. */
  50321. sensitivity: number;
  50322. private _isEnabled;
  50323. private _parent;
  50324. private _arrow;
  50325. private _coloredMaterial;
  50326. private _hoverMaterial;
  50327. /**
  50328. * Creates an AxisScaleGizmo
  50329. * @param gizmoLayer The utility layer the gizmo will be added to
  50330. * @param dragAxis The axis which the gizmo will be able to scale on
  50331. * @param color The color of the gizmo
  50332. */
  50333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50335. /**
  50336. * If the gizmo is enabled
  50337. */
  50338. set isEnabled(value: boolean);
  50339. get isEnabled(): boolean;
  50340. /**
  50341. * Disposes of the gizmo
  50342. */
  50343. dispose(): void;
  50344. /**
  50345. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50346. * @param mesh The mesh to replace the default mesh of the gizmo
  50347. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50348. */
  50349. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50350. }
  50351. }
  50352. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50353. import { Observable } from "babylonjs/Misc/observable";
  50354. import { Nullable } from "babylonjs/types";
  50355. import { Vector3 } from "babylonjs/Maths/math.vector";
  50356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50357. import { Mesh } from "babylonjs/Meshes/mesh";
  50358. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50359. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50360. import { Color3 } from "babylonjs/Maths/math.color";
  50361. import "babylonjs/Meshes/Builders/boxBuilder";
  50362. /**
  50363. * Bounding box gizmo
  50364. */
  50365. export class BoundingBoxGizmo extends Gizmo {
  50366. private _lineBoundingBox;
  50367. private _rotateSpheresParent;
  50368. private _scaleBoxesParent;
  50369. private _boundingDimensions;
  50370. private _renderObserver;
  50371. private _pointerObserver;
  50372. private _scaleDragSpeed;
  50373. private _tmpQuaternion;
  50374. private _tmpVector;
  50375. private _tmpRotationMatrix;
  50376. /**
  50377. * 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)
  50378. */
  50379. ignoreChildren: boolean;
  50380. /**
  50381. * 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)
  50382. */
  50383. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50384. /**
  50385. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50386. */
  50387. rotationSphereSize: number;
  50388. /**
  50389. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50390. */
  50391. scaleBoxSize: number;
  50392. /**
  50393. * 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)
  50394. */
  50395. fixedDragMeshScreenSize: boolean;
  50396. /**
  50397. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50398. */
  50399. fixedDragMeshScreenSizeDistanceFactor: number;
  50400. /**
  50401. * Fired when a rotation sphere or scale box is dragged
  50402. */
  50403. onDragStartObservable: Observable<{}>;
  50404. /**
  50405. * Fired when a scale box is dragged
  50406. */
  50407. onScaleBoxDragObservable: Observable<{}>;
  50408. /**
  50409. * Fired when a scale box drag is ended
  50410. */
  50411. onScaleBoxDragEndObservable: Observable<{}>;
  50412. /**
  50413. * Fired when a rotation sphere is dragged
  50414. */
  50415. onRotationSphereDragObservable: Observable<{}>;
  50416. /**
  50417. * Fired when a rotation sphere drag is ended
  50418. */
  50419. onRotationSphereDragEndObservable: Observable<{}>;
  50420. /**
  50421. * 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)
  50422. */
  50423. scalePivot: Nullable<Vector3>;
  50424. /**
  50425. * Mesh used as a pivot to rotate the attached mesh
  50426. */
  50427. private _anchorMesh;
  50428. private _existingMeshScale;
  50429. private _dragMesh;
  50430. private pointerDragBehavior;
  50431. private coloredMaterial;
  50432. private hoverColoredMaterial;
  50433. /**
  50434. * Sets the color of the bounding box gizmo
  50435. * @param color the color to set
  50436. */
  50437. setColor(color: Color3): void;
  50438. /**
  50439. * Creates an BoundingBoxGizmo
  50440. * @param gizmoLayer The utility layer the gizmo will be added to
  50441. * @param color The color of the gizmo
  50442. */
  50443. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50444. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50445. private _selectNode;
  50446. /**
  50447. * Updates the bounding box information for the Gizmo
  50448. */
  50449. updateBoundingBox(): void;
  50450. private _updateRotationSpheres;
  50451. private _updateScaleBoxes;
  50452. /**
  50453. * Enables rotation on the specified axis and disables rotation on the others
  50454. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50455. */
  50456. setEnabledRotationAxis(axis: string): void;
  50457. /**
  50458. * Enables/disables scaling
  50459. * @param enable if scaling should be enabled
  50460. */
  50461. setEnabledScaling(enable: boolean): void;
  50462. private _updateDummy;
  50463. /**
  50464. * Enables a pointer drag behavior on the bounding box of the gizmo
  50465. */
  50466. enableDragBehavior(): void;
  50467. /**
  50468. * Disposes of the gizmo
  50469. */
  50470. dispose(): void;
  50471. /**
  50472. * 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)
  50473. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50474. * @returns the bounding box mesh with the passed in mesh as a child
  50475. */
  50476. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50477. /**
  50478. * CustomMeshes are not supported by this gizmo
  50479. * @param mesh The mesh to replace the default mesh of the gizmo
  50480. */
  50481. setCustomMesh(mesh: Mesh): void;
  50482. }
  50483. }
  50484. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50485. import { Observable } from "babylonjs/Misc/observable";
  50486. import { Nullable } from "babylonjs/types";
  50487. import { Vector3 } from "babylonjs/Maths/math.vector";
  50488. import { Color3 } from "babylonjs/Maths/math.color";
  50489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50490. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50491. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50492. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50493. import "babylonjs/Meshes/Builders/linesBuilder";
  50494. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50495. /**
  50496. * Single plane rotation gizmo
  50497. */
  50498. export class PlaneRotationGizmo extends Gizmo {
  50499. /**
  50500. * Drag behavior responsible for the gizmos dragging interactions
  50501. */
  50502. dragBehavior: PointerDragBehavior;
  50503. private _pointerObserver;
  50504. /**
  50505. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50506. */
  50507. snapDistance: number;
  50508. /**
  50509. * Event that fires each time the gizmo snaps to a new location.
  50510. * * snapDistance is the the change in distance
  50511. */
  50512. onSnapObservable: Observable<{
  50513. snapDistance: number;
  50514. }>;
  50515. private _isEnabled;
  50516. private _parent;
  50517. /**
  50518. * Creates a PlaneRotationGizmo
  50519. * @param gizmoLayer The utility layer the gizmo will be added to
  50520. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50521. * @param color The color of the gizmo
  50522. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50523. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50524. */
  50525. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50526. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50527. /**
  50528. * If the gizmo is enabled
  50529. */
  50530. set isEnabled(value: boolean);
  50531. get isEnabled(): boolean;
  50532. /**
  50533. * Disposes of the gizmo
  50534. */
  50535. dispose(): void;
  50536. }
  50537. }
  50538. declare module "babylonjs/Gizmos/rotationGizmo" {
  50539. import { Observable } from "babylonjs/Misc/observable";
  50540. import { Nullable } from "babylonjs/types";
  50541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50542. import { Mesh } from "babylonjs/Meshes/mesh";
  50543. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50544. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50545. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50546. /**
  50547. * Gizmo that enables rotating a mesh along 3 axis
  50548. */
  50549. export class RotationGizmo extends Gizmo {
  50550. /**
  50551. * Internal gizmo used for interactions on the x axis
  50552. */
  50553. xGizmo: PlaneRotationGizmo;
  50554. /**
  50555. * Internal gizmo used for interactions on the y axis
  50556. */
  50557. yGizmo: PlaneRotationGizmo;
  50558. /**
  50559. * Internal gizmo used for interactions on the z axis
  50560. */
  50561. zGizmo: PlaneRotationGizmo;
  50562. /** Fires an event when any of it's sub gizmos are dragged */
  50563. onDragStartObservable: Observable<unknown>;
  50564. /** Fires an event when any of it's sub gizmos are released from dragging */
  50565. onDragEndObservable: Observable<unknown>;
  50566. private _meshAttached;
  50567. get attachedMesh(): Nullable<AbstractMesh>;
  50568. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50569. /**
  50570. * Creates a RotationGizmo
  50571. * @param gizmoLayer The utility layer the gizmo will be added to
  50572. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50573. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50574. */
  50575. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50576. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50577. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50578. /**
  50579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50580. */
  50581. set snapDistance(value: number);
  50582. get snapDistance(): number;
  50583. /**
  50584. * Ratio for the scale of the gizmo (Default: 1)
  50585. */
  50586. set scaleRatio(value: number);
  50587. get scaleRatio(): number;
  50588. /**
  50589. * Disposes of the gizmo
  50590. */
  50591. dispose(): void;
  50592. /**
  50593. * CustomMeshes are not supported by this gizmo
  50594. * @param mesh The mesh to replace the default mesh of the gizmo
  50595. */
  50596. setCustomMesh(mesh: Mesh): void;
  50597. }
  50598. }
  50599. declare module "babylonjs/Gizmos/gizmoManager" {
  50600. import { Observable } from "babylonjs/Misc/observable";
  50601. import { Nullable } from "babylonjs/types";
  50602. import { Scene, IDisposable } from "babylonjs/scene";
  50603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50604. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50605. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50606. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50607. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50608. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50609. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50610. /**
  50611. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50612. */
  50613. export class GizmoManager implements IDisposable {
  50614. private scene;
  50615. /**
  50616. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50617. */
  50618. gizmos: {
  50619. positionGizmo: Nullable<PositionGizmo>;
  50620. rotationGizmo: Nullable<RotationGizmo>;
  50621. scaleGizmo: Nullable<ScaleGizmo>;
  50622. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50623. };
  50624. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50625. clearGizmoOnEmptyPointerEvent: boolean;
  50626. /** Fires an event when the manager is attached to a mesh */
  50627. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50628. private _gizmosEnabled;
  50629. private _pointerObserver;
  50630. private _attachedMesh;
  50631. private _boundingBoxColor;
  50632. private _defaultUtilityLayer;
  50633. private _defaultKeepDepthUtilityLayer;
  50634. /**
  50635. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50636. */
  50637. boundingBoxDragBehavior: SixDofDragBehavior;
  50638. /**
  50639. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50640. */
  50641. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50642. /**
  50643. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50644. */
  50645. usePointerToAttachGizmos: boolean;
  50646. /**
  50647. * Utility layer that the bounding box gizmo belongs to
  50648. */
  50649. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50650. /**
  50651. * Utility layer that all gizmos besides bounding box belong to
  50652. */
  50653. get utilityLayer(): UtilityLayerRenderer;
  50654. /**
  50655. * Instatiates a gizmo manager
  50656. * @param scene the scene to overlay the gizmos on top of
  50657. */
  50658. constructor(scene: Scene);
  50659. /**
  50660. * Attaches a set of gizmos to the specified mesh
  50661. * @param mesh The mesh the gizmo's should be attached to
  50662. */
  50663. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50664. /**
  50665. * If the position gizmo is enabled
  50666. */
  50667. set positionGizmoEnabled(value: boolean);
  50668. get positionGizmoEnabled(): boolean;
  50669. /**
  50670. * If the rotation gizmo is enabled
  50671. */
  50672. set rotationGizmoEnabled(value: boolean);
  50673. get rotationGizmoEnabled(): boolean;
  50674. /**
  50675. * If the scale gizmo is enabled
  50676. */
  50677. set scaleGizmoEnabled(value: boolean);
  50678. get scaleGizmoEnabled(): boolean;
  50679. /**
  50680. * If the boundingBox gizmo is enabled
  50681. */
  50682. set boundingBoxGizmoEnabled(value: boolean);
  50683. get boundingBoxGizmoEnabled(): boolean;
  50684. /**
  50685. * Disposes of the gizmo manager
  50686. */
  50687. dispose(): void;
  50688. }
  50689. }
  50690. declare module "babylonjs/Lights/directionalLight" {
  50691. import { Camera } from "babylonjs/Cameras/camera";
  50692. import { Scene } from "babylonjs/scene";
  50693. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50695. import { Light } from "babylonjs/Lights/light";
  50696. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50697. import { Effect } from "babylonjs/Materials/effect";
  50698. /**
  50699. * A directional light is defined by a direction (what a surprise!).
  50700. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50701. * 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.
  50702. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50703. */
  50704. export class DirectionalLight extends ShadowLight {
  50705. private _shadowFrustumSize;
  50706. /**
  50707. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50708. */
  50709. get shadowFrustumSize(): number;
  50710. /**
  50711. * Specifies a fix frustum size for the shadow generation.
  50712. */
  50713. set shadowFrustumSize(value: number);
  50714. private _shadowOrthoScale;
  50715. /**
  50716. * Gets the shadow projection scale against the optimal computed one.
  50717. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50718. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50719. */
  50720. get shadowOrthoScale(): number;
  50721. /**
  50722. * Sets the shadow projection scale against the optimal computed one.
  50723. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50724. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50725. */
  50726. set shadowOrthoScale(value: number);
  50727. /**
  50728. * Automatically compute the projection matrix to best fit (including all the casters)
  50729. * on each frame.
  50730. */
  50731. autoUpdateExtends: boolean;
  50732. /**
  50733. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50734. * on each frame. autoUpdateExtends must be set to true for this to work
  50735. */
  50736. autoCalcShadowZBounds: boolean;
  50737. private _orthoLeft;
  50738. private _orthoRight;
  50739. private _orthoTop;
  50740. private _orthoBottom;
  50741. /**
  50742. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50743. * The directional light is emitted from everywhere in the given direction.
  50744. * It can cast shadows.
  50745. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50746. * @param name The friendly name of the light
  50747. * @param direction The direction of the light
  50748. * @param scene The scene the light belongs to
  50749. */
  50750. constructor(name: string, direction: Vector3, scene: Scene);
  50751. /**
  50752. * Returns the string "DirectionalLight".
  50753. * @return The class name
  50754. */
  50755. getClassName(): string;
  50756. /**
  50757. * Returns the integer 1.
  50758. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50759. */
  50760. getTypeID(): number;
  50761. /**
  50762. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50763. * Returns the DirectionalLight Shadow projection matrix.
  50764. */
  50765. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50766. /**
  50767. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50768. * Returns the DirectionalLight Shadow projection matrix.
  50769. */
  50770. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50771. /**
  50772. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50773. * Returns the DirectionalLight Shadow projection matrix.
  50774. */
  50775. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50776. protected _buildUniformLayout(): void;
  50777. /**
  50778. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50779. * @param effect The effect to update
  50780. * @param lightIndex The index of the light in the effect to update
  50781. * @returns The directional light
  50782. */
  50783. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50784. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50785. /**
  50786. * Gets the minZ used for shadow according to both the scene and the light.
  50787. *
  50788. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50789. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50790. * @param activeCamera The camera we are returning the min for
  50791. * @returns the depth min z
  50792. */
  50793. getDepthMinZ(activeCamera: Camera): number;
  50794. /**
  50795. * Gets the maxZ used for shadow according to both the scene and the light.
  50796. *
  50797. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50798. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50799. * @param activeCamera The camera we are returning the max for
  50800. * @returns the depth max z
  50801. */
  50802. getDepthMaxZ(activeCamera: Camera): number;
  50803. /**
  50804. * Prepares the list of defines specific to the light type.
  50805. * @param defines the list of defines
  50806. * @param lightIndex defines the index of the light for the effect
  50807. */
  50808. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50809. }
  50810. }
  50811. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50812. import { Mesh } from "babylonjs/Meshes/mesh";
  50813. /**
  50814. * Class containing static functions to help procedurally build meshes
  50815. */
  50816. export class HemisphereBuilder {
  50817. /**
  50818. * Creates a hemisphere mesh
  50819. * @param name defines the name of the mesh
  50820. * @param options defines the options used to create the mesh
  50821. * @param scene defines the hosting scene
  50822. * @returns the hemisphere mesh
  50823. */
  50824. static CreateHemisphere(name: string, options: {
  50825. segments?: number;
  50826. diameter?: number;
  50827. sideOrientation?: number;
  50828. }, scene: any): Mesh;
  50829. }
  50830. }
  50831. declare module "babylonjs/Lights/spotLight" {
  50832. import { Nullable } from "babylonjs/types";
  50833. import { Scene } from "babylonjs/scene";
  50834. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50836. import { Effect } from "babylonjs/Materials/effect";
  50837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50838. import { Light } from "babylonjs/Lights/light";
  50839. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50840. /**
  50841. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50842. * These values define a cone of light starting from the position, emitting toward the direction.
  50843. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50844. * and the exponent defines the speed of the decay of the light with distance (reach).
  50845. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50846. */
  50847. export class SpotLight extends ShadowLight {
  50848. private _angle;
  50849. private _innerAngle;
  50850. private _cosHalfAngle;
  50851. private _lightAngleScale;
  50852. private _lightAngleOffset;
  50853. /**
  50854. * Gets the cone angle of the spot light in Radians.
  50855. */
  50856. get angle(): number;
  50857. /**
  50858. * Sets the cone angle of the spot light in Radians.
  50859. */
  50860. set angle(value: number);
  50861. /**
  50862. * Only used in gltf falloff mode, this defines the angle where
  50863. * the directional falloff will start before cutting at angle which could be seen
  50864. * as outer angle.
  50865. */
  50866. get innerAngle(): number;
  50867. /**
  50868. * Only used in gltf falloff mode, this defines the angle where
  50869. * the directional falloff will start before cutting at angle which could be seen
  50870. * as outer angle.
  50871. */
  50872. set innerAngle(value: number);
  50873. private _shadowAngleScale;
  50874. /**
  50875. * Allows scaling the angle of the light for shadow generation only.
  50876. */
  50877. get shadowAngleScale(): number;
  50878. /**
  50879. * Allows scaling the angle of the light for shadow generation only.
  50880. */
  50881. set shadowAngleScale(value: number);
  50882. /**
  50883. * The light decay speed with the distance from the emission spot.
  50884. */
  50885. exponent: number;
  50886. private _projectionTextureMatrix;
  50887. /**
  50888. * Allows reading the projecton texture
  50889. */
  50890. get projectionTextureMatrix(): Matrix;
  50891. protected _projectionTextureLightNear: number;
  50892. /**
  50893. * Gets the near clip of the Spotlight for texture projection.
  50894. */
  50895. get projectionTextureLightNear(): number;
  50896. /**
  50897. * Sets the near clip of the Spotlight for texture projection.
  50898. */
  50899. set projectionTextureLightNear(value: number);
  50900. protected _projectionTextureLightFar: number;
  50901. /**
  50902. * Gets the far clip of the Spotlight for texture projection.
  50903. */
  50904. get projectionTextureLightFar(): number;
  50905. /**
  50906. * Sets the far clip of the Spotlight for texture projection.
  50907. */
  50908. set projectionTextureLightFar(value: number);
  50909. protected _projectionTextureUpDirection: Vector3;
  50910. /**
  50911. * Gets the Up vector of the Spotlight for texture projection.
  50912. */
  50913. get projectionTextureUpDirection(): Vector3;
  50914. /**
  50915. * Sets the Up vector of the Spotlight for texture projection.
  50916. */
  50917. set projectionTextureUpDirection(value: Vector3);
  50918. private _projectionTexture;
  50919. /**
  50920. * Gets the projection texture of the light.
  50921. */
  50922. get projectionTexture(): Nullable<BaseTexture>;
  50923. /**
  50924. * Sets the projection texture of the light.
  50925. */
  50926. set projectionTexture(value: Nullable<BaseTexture>);
  50927. private _projectionTextureViewLightDirty;
  50928. private _projectionTextureProjectionLightDirty;
  50929. private _projectionTextureDirty;
  50930. private _projectionTextureViewTargetVector;
  50931. private _projectionTextureViewLightMatrix;
  50932. private _projectionTextureProjectionLightMatrix;
  50933. private _projectionTextureScalingMatrix;
  50934. /**
  50935. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50936. * It can cast shadows.
  50937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50938. * @param name The light friendly name
  50939. * @param position The position of the spot light in the scene
  50940. * @param direction The direction of the light in the scene
  50941. * @param angle The cone angle of the light in Radians
  50942. * @param exponent The light decay speed with the distance from the emission spot
  50943. * @param scene The scene the lights belongs to
  50944. */
  50945. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50946. /**
  50947. * Returns the string "SpotLight".
  50948. * @returns the class name
  50949. */
  50950. getClassName(): string;
  50951. /**
  50952. * Returns the integer 2.
  50953. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50954. */
  50955. getTypeID(): number;
  50956. /**
  50957. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50958. */
  50959. protected _setDirection(value: Vector3): void;
  50960. /**
  50961. * Overrides the position setter to recompute the projection texture view light Matrix.
  50962. */
  50963. protected _setPosition(value: Vector3): void;
  50964. /**
  50965. * 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.
  50966. * Returns the SpotLight.
  50967. */
  50968. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50969. protected _computeProjectionTextureViewLightMatrix(): void;
  50970. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50971. /**
  50972. * Main function for light texture projection matrix computing.
  50973. */
  50974. protected _computeProjectionTextureMatrix(): void;
  50975. protected _buildUniformLayout(): void;
  50976. private _computeAngleValues;
  50977. /**
  50978. * Sets the passed Effect "effect" with the Light textures.
  50979. * @param effect The effect to update
  50980. * @param lightIndex The index of the light in the effect to update
  50981. * @returns The light
  50982. */
  50983. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50984. /**
  50985. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50986. * @param effect The effect to update
  50987. * @param lightIndex The index of the light in the effect to update
  50988. * @returns The spot light
  50989. */
  50990. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50991. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50992. /**
  50993. * Disposes the light and the associated resources.
  50994. */
  50995. dispose(): void;
  50996. /**
  50997. * Prepares the list of defines specific to the light type.
  50998. * @param defines the list of defines
  50999. * @param lightIndex defines the index of the light for the effect
  51000. */
  51001. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51002. }
  51003. }
  51004. declare module "babylonjs/Gizmos/lightGizmo" {
  51005. import { Nullable } from "babylonjs/types";
  51006. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51007. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51008. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51009. import { Light } from "babylonjs/Lights/light";
  51010. /**
  51011. * Gizmo that enables viewing a light
  51012. */
  51013. export class LightGizmo extends Gizmo {
  51014. private _lightMesh;
  51015. private _material;
  51016. private _cachedPosition;
  51017. private _cachedForward;
  51018. private _attachedMeshParent;
  51019. /**
  51020. * Creates a LightGizmo
  51021. * @param gizmoLayer The utility layer the gizmo will be added to
  51022. */
  51023. constructor(gizmoLayer?: UtilityLayerRenderer);
  51024. private _light;
  51025. /**
  51026. * The light that the gizmo is attached to
  51027. */
  51028. set light(light: Nullable<Light>);
  51029. get light(): Nullable<Light>;
  51030. /**
  51031. * Gets the material used to render the light gizmo
  51032. */
  51033. get material(): StandardMaterial;
  51034. /**
  51035. * @hidden
  51036. * Updates the gizmo to match the attached mesh's position/rotation
  51037. */
  51038. protected _update(): void;
  51039. private static _Scale;
  51040. /**
  51041. * Creates the lines for a light mesh
  51042. */
  51043. private static _CreateLightLines;
  51044. /**
  51045. * Disposes of the light gizmo
  51046. */
  51047. dispose(): void;
  51048. private static _CreateHemisphericLightMesh;
  51049. private static _CreatePointLightMesh;
  51050. private static _CreateSpotLightMesh;
  51051. private static _CreateDirectionalLightMesh;
  51052. }
  51053. }
  51054. declare module "babylonjs/Gizmos/index" {
  51055. export * from "babylonjs/Gizmos/axisDragGizmo";
  51056. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51057. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51058. export * from "babylonjs/Gizmos/gizmo";
  51059. export * from "babylonjs/Gizmos/gizmoManager";
  51060. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51061. export * from "babylonjs/Gizmos/positionGizmo";
  51062. export * from "babylonjs/Gizmos/rotationGizmo";
  51063. export * from "babylonjs/Gizmos/scaleGizmo";
  51064. export * from "babylonjs/Gizmos/lightGizmo";
  51065. export * from "babylonjs/Gizmos/planeDragGizmo";
  51066. }
  51067. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51068. /** @hidden */
  51069. export var backgroundFragmentDeclaration: {
  51070. name: string;
  51071. shader: string;
  51072. };
  51073. }
  51074. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51075. /** @hidden */
  51076. export var backgroundUboDeclaration: {
  51077. name: string;
  51078. shader: string;
  51079. };
  51080. }
  51081. declare module "babylonjs/Shaders/background.fragment" {
  51082. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51084. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51085. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51086. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51087. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51089. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51090. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51091. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51092. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51093. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51094. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51095. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51096. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51097. /** @hidden */
  51098. export var backgroundPixelShader: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51104. /** @hidden */
  51105. export var backgroundVertexDeclaration: {
  51106. name: string;
  51107. shader: string;
  51108. };
  51109. }
  51110. declare module "babylonjs/Shaders/background.vertex" {
  51111. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51114. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51115. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51117. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51118. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51119. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51120. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51121. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51122. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51123. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51124. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51125. /** @hidden */
  51126. export var backgroundVertexShader: {
  51127. name: string;
  51128. shader: string;
  51129. };
  51130. }
  51131. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51132. import { Nullable, int, float } from "babylonjs/types";
  51133. import { Scene } from "babylonjs/scene";
  51134. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51137. import { Mesh } from "babylonjs/Meshes/mesh";
  51138. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51139. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51140. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51142. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51143. import { Color3 } from "babylonjs/Maths/math.color";
  51144. import "babylonjs/Shaders/background.fragment";
  51145. import "babylonjs/Shaders/background.vertex";
  51146. /**
  51147. * Background material used to create an efficient environement around your scene.
  51148. */
  51149. export class BackgroundMaterial extends PushMaterial {
  51150. /**
  51151. * Standard reflectance value at parallel view angle.
  51152. */
  51153. static StandardReflectance0: number;
  51154. /**
  51155. * Standard reflectance value at grazing angle.
  51156. */
  51157. static StandardReflectance90: number;
  51158. protected _primaryColor: Color3;
  51159. /**
  51160. * Key light Color (multiply against the environement texture)
  51161. */
  51162. primaryColor: Color3;
  51163. protected __perceptualColor: Nullable<Color3>;
  51164. /**
  51165. * Experimental Internal Use Only.
  51166. *
  51167. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51168. * This acts as a helper to set the primary color to a more "human friendly" value.
  51169. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51170. * output color as close as possible from the chosen value.
  51171. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51172. * part of lighting setup.)
  51173. */
  51174. get _perceptualColor(): Nullable<Color3>;
  51175. set _perceptualColor(value: Nullable<Color3>);
  51176. protected _primaryColorShadowLevel: float;
  51177. /**
  51178. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51179. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51180. */
  51181. get primaryColorShadowLevel(): float;
  51182. set primaryColorShadowLevel(value: float);
  51183. protected _primaryColorHighlightLevel: float;
  51184. /**
  51185. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51186. * The primary color is used at the level chosen to define what the white area would look.
  51187. */
  51188. get primaryColorHighlightLevel(): float;
  51189. set primaryColorHighlightLevel(value: float);
  51190. protected _reflectionTexture: Nullable<BaseTexture>;
  51191. /**
  51192. * Reflection Texture used in the material.
  51193. * Should be author in a specific way for the best result (refer to the documentation).
  51194. */
  51195. reflectionTexture: Nullable<BaseTexture>;
  51196. protected _reflectionBlur: float;
  51197. /**
  51198. * Reflection Texture level of blur.
  51199. *
  51200. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51201. * texture twice.
  51202. */
  51203. reflectionBlur: float;
  51204. protected _diffuseTexture: Nullable<BaseTexture>;
  51205. /**
  51206. * Diffuse Texture used in the material.
  51207. * Should be author in a specific way for the best result (refer to the documentation).
  51208. */
  51209. diffuseTexture: Nullable<BaseTexture>;
  51210. protected _shadowLights: Nullable<IShadowLight[]>;
  51211. /**
  51212. * Specify the list of lights casting shadow on the material.
  51213. * All scene shadow lights will be included if null.
  51214. */
  51215. shadowLights: Nullable<IShadowLight[]>;
  51216. protected _shadowLevel: float;
  51217. /**
  51218. * Helps adjusting the shadow to a softer level if required.
  51219. * 0 means black shadows and 1 means no shadows.
  51220. */
  51221. shadowLevel: float;
  51222. protected _sceneCenter: Vector3;
  51223. /**
  51224. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51225. * It is usually zero but might be interesting to modify according to your setup.
  51226. */
  51227. sceneCenter: Vector3;
  51228. protected _opacityFresnel: boolean;
  51229. /**
  51230. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51231. * This helps ensuring a nice transition when the camera goes under the ground.
  51232. */
  51233. opacityFresnel: boolean;
  51234. protected _reflectionFresnel: boolean;
  51235. /**
  51236. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51237. * This helps adding a mirror texture on the ground.
  51238. */
  51239. reflectionFresnel: boolean;
  51240. protected _reflectionFalloffDistance: number;
  51241. /**
  51242. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51243. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51244. */
  51245. reflectionFalloffDistance: number;
  51246. protected _reflectionAmount: number;
  51247. /**
  51248. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51249. */
  51250. reflectionAmount: number;
  51251. protected _reflectionReflectance0: number;
  51252. /**
  51253. * This specifies the weight of the reflection at grazing angle.
  51254. */
  51255. reflectionReflectance0: number;
  51256. protected _reflectionReflectance90: number;
  51257. /**
  51258. * This specifies the weight of the reflection at a perpendicular point of view.
  51259. */
  51260. reflectionReflectance90: number;
  51261. /**
  51262. * Sets the reflection reflectance fresnel values according to the default standard
  51263. * empirically know to work well :-)
  51264. */
  51265. set reflectionStandardFresnelWeight(value: number);
  51266. protected _useRGBColor: boolean;
  51267. /**
  51268. * Helps to directly use the maps channels instead of their level.
  51269. */
  51270. useRGBColor: boolean;
  51271. protected _enableNoise: boolean;
  51272. /**
  51273. * This helps reducing the banding effect that could occur on the background.
  51274. */
  51275. enableNoise: boolean;
  51276. /**
  51277. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51278. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51279. * Recommended to be keep at 1.0 except for special cases.
  51280. */
  51281. get fovMultiplier(): number;
  51282. set fovMultiplier(value: number);
  51283. private _fovMultiplier;
  51284. /**
  51285. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51286. */
  51287. useEquirectangularFOV: boolean;
  51288. private _maxSimultaneousLights;
  51289. /**
  51290. * Number of Simultaneous lights allowed on the material.
  51291. */
  51292. maxSimultaneousLights: int;
  51293. /**
  51294. * Default configuration related to image processing available in the Background Material.
  51295. */
  51296. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51297. /**
  51298. * Keep track of the image processing observer to allow dispose and replace.
  51299. */
  51300. private _imageProcessingObserver;
  51301. /**
  51302. * Attaches a new image processing configuration to the PBR Material.
  51303. * @param configuration (if null the scene configuration will be use)
  51304. */
  51305. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51306. /**
  51307. * Gets the image processing configuration used either in this material.
  51308. */
  51309. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51310. /**
  51311. * Sets the Default image processing configuration used either in the this material.
  51312. *
  51313. * If sets to null, the scene one is in use.
  51314. */
  51315. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51316. /**
  51317. * Gets wether the color curves effect is enabled.
  51318. */
  51319. get cameraColorCurvesEnabled(): boolean;
  51320. /**
  51321. * Sets wether the color curves effect is enabled.
  51322. */
  51323. set cameraColorCurvesEnabled(value: boolean);
  51324. /**
  51325. * Gets wether the color grading effect is enabled.
  51326. */
  51327. get cameraColorGradingEnabled(): boolean;
  51328. /**
  51329. * Gets wether the color grading effect is enabled.
  51330. */
  51331. set cameraColorGradingEnabled(value: boolean);
  51332. /**
  51333. * Gets wether tonemapping is enabled or not.
  51334. */
  51335. get cameraToneMappingEnabled(): boolean;
  51336. /**
  51337. * Sets wether tonemapping is enabled or not
  51338. */
  51339. set cameraToneMappingEnabled(value: boolean);
  51340. /**
  51341. * The camera exposure used on this material.
  51342. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51343. * This corresponds to a photographic exposure.
  51344. */
  51345. get cameraExposure(): float;
  51346. /**
  51347. * The camera exposure used on this material.
  51348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51349. * This corresponds to a photographic exposure.
  51350. */
  51351. set cameraExposure(value: float);
  51352. /**
  51353. * Gets The camera contrast used on this material.
  51354. */
  51355. get cameraContrast(): float;
  51356. /**
  51357. * Sets The camera contrast used on this material.
  51358. */
  51359. set cameraContrast(value: float);
  51360. /**
  51361. * Gets the Color Grading 2D Lookup Texture.
  51362. */
  51363. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51364. /**
  51365. * Sets the Color Grading 2D Lookup Texture.
  51366. */
  51367. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51368. /**
  51369. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51370. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51371. * 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;
  51372. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51373. */
  51374. get cameraColorCurves(): Nullable<ColorCurves>;
  51375. /**
  51376. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51377. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51378. * 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;
  51379. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51380. */
  51381. set cameraColorCurves(value: Nullable<ColorCurves>);
  51382. /**
  51383. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51384. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51385. */
  51386. switchToBGR: boolean;
  51387. private _renderTargets;
  51388. private _reflectionControls;
  51389. private _white;
  51390. private _primaryShadowColor;
  51391. private _primaryHighlightColor;
  51392. /**
  51393. * Instantiates a Background Material in the given scene
  51394. * @param name The friendly name of the material
  51395. * @param scene The scene to add the material to
  51396. */
  51397. constructor(name: string, scene: Scene);
  51398. /**
  51399. * Gets a boolean indicating that current material needs to register RTT
  51400. */
  51401. get hasRenderTargetTextures(): boolean;
  51402. /**
  51403. * The entire material has been created in order to prevent overdraw.
  51404. * @returns false
  51405. */
  51406. needAlphaTesting(): boolean;
  51407. /**
  51408. * The entire material has been created in order to prevent overdraw.
  51409. * @returns true if blending is enable
  51410. */
  51411. needAlphaBlending(): boolean;
  51412. /**
  51413. * Checks wether the material is ready to be rendered for a given mesh.
  51414. * @param mesh The mesh to render
  51415. * @param subMesh The submesh to check against
  51416. * @param useInstances Specify wether or not the material is used with instances
  51417. * @returns true if all the dependencies are ready (Textures, Effects...)
  51418. */
  51419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51420. /**
  51421. * Compute the primary color according to the chosen perceptual color.
  51422. */
  51423. private _computePrimaryColorFromPerceptualColor;
  51424. /**
  51425. * Compute the highlights and shadow colors according to their chosen levels.
  51426. */
  51427. private _computePrimaryColors;
  51428. /**
  51429. * Build the uniform buffer used in the material.
  51430. */
  51431. buildUniformLayout(): void;
  51432. /**
  51433. * Unbind the material.
  51434. */
  51435. unbind(): void;
  51436. /**
  51437. * Bind only the world matrix to the material.
  51438. * @param world The world matrix to bind.
  51439. */
  51440. bindOnlyWorldMatrix(world: Matrix): void;
  51441. /**
  51442. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51443. * @param world The world matrix to bind.
  51444. * @param subMesh The submesh to bind for.
  51445. */
  51446. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51447. /**
  51448. * Checks to see if a texture is used in the material.
  51449. * @param texture - Base texture to use.
  51450. * @returns - Boolean specifying if a texture is used in the material.
  51451. */
  51452. hasTexture(texture: BaseTexture): boolean;
  51453. /**
  51454. * Dispose the material.
  51455. * @param forceDisposeEffect Force disposal of the associated effect.
  51456. * @param forceDisposeTextures Force disposal of the associated textures.
  51457. */
  51458. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51459. /**
  51460. * Clones the material.
  51461. * @param name The cloned name.
  51462. * @returns The cloned material.
  51463. */
  51464. clone(name: string): BackgroundMaterial;
  51465. /**
  51466. * Serializes the current material to its JSON representation.
  51467. * @returns The JSON representation.
  51468. */
  51469. serialize(): any;
  51470. /**
  51471. * Gets the class name of the material
  51472. * @returns "BackgroundMaterial"
  51473. */
  51474. getClassName(): string;
  51475. /**
  51476. * Parse a JSON input to create back a background material.
  51477. * @param source The JSON data to parse
  51478. * @param scene The scene to create the parsed material in
  51479. * @param rootUrl The root url of the assets the material depends upon
  51480. * @returns the instantiated BackgroundMaterial.
  51481. */
  51482. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51483. }
  51484. }
  51485. declare module "babylonjs/Helpers/environmentHelper" {
  51486. import { Observable } from "babylonjs/Misc/observable";
  51487. import { Nullable } from "babylonjs/types";
  51488. import { Scene } from "babylonjs/scene";
  51489. import { Vector3 } from "babylonjs/Maths/math.vector";
  51490. import { Color3 } from "babylonjs/Maths/math.color";
  51491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51492. import { Mesh } from "babylonjs/Meshes/mesh";
  51493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51494. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51495. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51496. import "babylonjs/Meshes/Builders/planeBuilder";
  51497. import "babylonjs/Meshes/Builders/boxBuilder";
  51498. /**
  51499. * Represents the different options available during the creation of
  51500. * a Environment helper.
  51501. *
  51502. * This can control the default ground, skybox and image processing setup of your scene.
  51503. */
  51504. export interface IEnvironmentHelperOptions {
  51505. /**
  51506. * Specifies whether or not to create a ground.
  51507. * True by default.
  51508. */
  51509. createGround: boolean;
  51510. /**
  51511. * Specifies the ground size.
  51512. * 15 by default.
  51513. */
  51514. groundSize: number;
  51515. /**
  51516. * The texture used on the ground for the main color.
  51517. * Comes from the BabylonJS CDN by default.
  51518. *
  51519. * Remarks: Can be either a texture or a url.
  51520. */
  51521. groundTexture: string | BaseTexture;
  51522. /**
  51523. * The color mixed in the ground texture by default.
  51524. * BabylonJS clearColor by default.
  51525. */
  51526. groundColor: Color3;
  51527. /**
  51528. * Specifies the ground opacity.
  51529. * 1 by default.
  51530. */
  51531. groundOpacity: number;
  51532. /**
  51533. * Enables the ground to receive shadows.
  51534. * True by default.
  51535. */
  51536. enableGroundShadow: boolean;
  51537. /**
  51538. * Helps preventing the shadow to be fully black on the ground.
  51539. * 0.5 by default.
  51540. */
  51541. groundShadowLevel: number;
  51542. /**
  51543. * Creates a mirror texture attach to the ground.
  51544. * false by default.
  51545. */
  51546. enableGroundMirror: boolean;
  51547. /**
  51548. * Specifies the ground mirror size ratio.
  51549. * 0.3 by default as the default kernel is 64.
  51550. */
  51551. groundMirrorSizeRatio: number;
  51552. /**
  51553. * Specifies the ground mirror blur kernel size.
  51554. * 64 by default.
  51555. */
  51556. groundMirrorBlurKernel: number;
  51557. /**
  51558. * Specifies the ground mirror visibility amount.
  51559. * 1 by default
  51560. */
  51561. groundMirrorAmount: number;
  51562. /**
  51563. * Specifies the ground mirror reflectance weight.
  51564. * This uses the standard weight of the background material to setup the fresnel effect
  51565. * of the mirror.
  51566. * 1 by default.
  51567. */
  51568. groundMirrorFresnelWeight: number;
  51569. /**
  51570. * Specifies the ground mirror Falloff distance.
  51571. * This can helps reducing the size of the reflection.
  51572. * 0 by Default.
  51573. */
  51574. groundMirrorFallOffDistance: number;
  51575. /**
  51576. * Specifies the ground mirror texture type.
  51577. * Unsigned Int by Default.
  51578. */
  51579. groundMirrorTextureType: number;
  51580. /**
  51581. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51582. * the shown objects.
  51583. */
  51584. groundYBias: number;
  51585. /**
  51586. * Specifies whether or not to create a skybox.
  51587. * True by default.
  51588. */
  51589. createSkybox: boolean;
  51590. /**
  51591. * Specifies the skybox size.
  51592. * 20 by default.
  51593. */
  51594. skyboxSize: number;
  51595. /**
  51596. * The texture used on the skybox for the main color.
  51597. * Comes from the BabylonJS CDN by default.
  51598. *
  51599. * Remarks: Can be either a texture or a url.
  51600. */
  51601. skyboxTexture: string | BaseTexture;
  51602. /**
  51603. * The color mixed in the skybox texture by default.
  51604. * BabylonJS clearColor by default.
  51605. */
  51606. skyboxColor: Color3;
  51607. /**
  51608. * The background rotation around the Y axis of the scene.
  51609. * This helps aligning the key lights of your scene with the background.
  51610. * 0 by default.
  51611. */
  51612. backgroundYRotation: number;
  51613. /**
  51614. * Compute automatically the size of the elements to best fit with the scene.
  51615. */
  51616. sizeAuto: boolean;
  51617. /**
  51618. * Default position of the rootMesh if autoSize is not true.
  51619. */
  51620. rootPosition: Vector3;
  51621. /**
  51622. * Sets up the image processing in the scene.
  51623. * true by default.
  51624. */
  51625. setupImageProcessing: boolean;
  51626. /**
  51627. * The texture used as your environment texture in the scene.
  51628. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51629. *
  51630. * Remarks: Can be either a texture or a url.
  51631. */
  51632. environmentTexture: string | BaseTexture;
  51633. /**
  51634. * The value of the exposure to apply to the scene.
  51635. * 0.6 by default if setupImageProcessing is true.
  51636. */
  51637. cameraExposure: number;
  51638. /**
  51639. * The value of the contrast to apply to the scene.
  51640. * 1.6 by default if setupImageProcessing is true.
  51641. */
  51642. cameraContrast: number;
  51643. /**
  51644. * Specifies whether or not tonemapping should be enabled in the scene.
  51645. * true by default if setupImageProcessing is true.
  51646. */
  51647. toneMappingEnabled: boolean;
  51648. }
  51649. /**
  51650. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51651. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51652. * It also helps with the default setup of your imageProcessing configuration.
  51653. */
  51654. export class EnvironmentHelper {
  51655. /**
  51656. * Default ground texture URL.
  51657. */
  51658. private static _groundTextureCDNUrl;
  51659. /**
  51660. * Default skybox texture URL.
  51661. */
  51662. private static _skyboxTextureCDNUrl;
  51663. /**
  51664. * Default environment texture URL.
  51665. */
  51666. private static _environmentTextureCDNUrl;
  51667. /**
  51668. * Creates the default options for the helper.
  51669. */
  51670. private static _getDefaultOptions;
  51671. private _rootMesh;
  51672. /**
  51673. * Gets the root mesh created by the helper.
  51674. */
  51675. get rootMesh(): Mesh;
  51676. private _skybox;
  51677. /**
  51678. * Gets the skybox created by the helper.
  51679. */
  51680. get skybox(): Nullable<Mesh>;
  51681. private _skyboxTexture;
  51682. /**
  51683. * Gets the skybox texture created by the helper.
  51684. */
  51685. get skyboxTexture(): Nullable<BaseTexture>;
  51686. private _skyboxMaterial;
  51687. /**
  51688. * Gets the skybox material created by the helper.
  51689. */
  51690. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51691. private _ground;
  51692. /**
  51693. * Gets the ground mesh created by the helper.
  51694. */
  51695. get ground(): Nullable<Mesh>;
  51696. private _groundTexture;
  51697. /**
  51698. * Gets the ground texture created by the helper.
  51699. */
  51700. get groundTexture(): Nullable<BaseTexture>;
  51701. private _groundMirror;
  51702. /**
  51703. * Gets the ground mirror created by the helper.
  51704. */
  51705. get groundMirror(): Nullable<MirrorTexture>;
  51706. /**
  51707. * Gets the ground mirror render list to helps pushing the meshes
  51708. * you wish in the ground reflection.
  51709. */
  51710. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51711. private _groundMaterial;
  51712. /**
  51713. * Gets the ground material created by the helper.
  51714. */
  51715. get groundMaterial(): Nullable<BackgroundMaterial>;
  51716. /**
  51717. * Stores the creation options.
  51718. */
  51719. private readonly _scene;
  51720. private _options;
  51721. /**
  51722. * This observable will be notified with any error during the creation of the environment,
  51723. * mainly texture creation errors.
  51724. */
  51725. onErrorObservable: Observable<{
  51726. message?: string;
  51727. exception?: any;
  51728. }>;
  51729. /**
  51730. * constructor
  51731. * @param options Defines the options we want to customize the helper
  51732. * @param scene The scene to add the material to
  51733. */
  51734. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51735. /**
  51736. * Updates the background according to the new options
  51737. * @param options
  51738. */
  51739. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51740. /**
  51741. * Sets the primary color of all the available elements.
  51742. * @param color the main color to affect to the ground and the background
  51743. */
  51744. setMainColor(color: Color3): void;
  51745. /**
  51746. * Setup the image processing according to the specified options.
  51747. */
  51748. private _setupImageProcessing;
  51749. /**
  51750. * Setup the environment texture according to the specified options.
  51751. */
  51752. private _setupEnvironmentTexture;
  51753. /**
  51754. * Setup the background according to the specified options.
  51755. */
  51756. private _setupBackground;
  51757. /**
  51758. * Get the scene sizes according to the setup.
  51759. */
  51760. private _getSceneSize;
  51761. /**
  51762. * Setup the ground according to the specified options.
  51763. */
  51764. private _setupGround;
  51765. /**
  51766. * Setup the ground material according to the specified options.
  51767. */
  51768. private _setupGroundMaterial;
  51769. /**
  51770. * Setup the ground diffuse texture according to the specified options.
  51771. */
  51772. private _setupGroundDiffuseTexture;
  51773. /**
  51774. * Setup the ground mirror texture according to the specified options.
  51775. */
  51776. private _setupGroundMirrorTexture;
  51777. /**
  51778. * Setup the ground to receive the mirror texture.
  51779. */
  51780. private _setupMirrorInGroundMaterial;
  51781. /**
  51782. * Setup the skybox according to the specified options.
  51783. */
  51784. private _setupSkybox;
  51785. /**
  51786. * Setup the skybox material according to the specified options.
  51787. */
  51788. private _setupSkyboxMaterial;
  51789. /**
  51790. * Setup the skybox reflection texture according to the specified options.
  51791. */
  51792. private _setupSkyboxReflectionTexture;
  51793. private _errorHandler;
  51794. /**
  51795. * Dispose all the elements created by the Helper.
  51796. */
  51797. dispose(): void;
  51798. }
  51799. }
  51800. declare module "babylonjs/Helpers/photoDome" {
  51801. import { Observable } from "babylonjs/Misc/observable";
  51802. import { Nullable } from "babylonjs/types";
  51803. import { Scene } from "babylonjs/scene";
  51804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51805. import { Mesh } from "babylonjs/Meshes/mesh";
  51806. import { Texture } from "babylonjs/Materials/Textures/texture";
  51807. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51808. import "babylonjs/Meshes/Builders/sphereBuilder";
  51809. /**
  51810. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51811. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51812. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51813. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51814. */
  51815. export class PhotoDome extends TransformNode {
  51816. /**
  51817. * Define the image as a Monoscopic panoramic 360 image.
  51818. */
  51819. static readonly MODE_MONOSCOPIC: number;
  51820. /**
  51821. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51822. */
  51823. static readonly MODE_TOPBOTTOM: number;
  51824. /**
  51825. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51826. */
  51827. static readonly MODE_SIDEBYSIDE: number;
  51828. private _useDirectMapping;
  51829. /**
  51830. * The texture being displayed on the sphere
  51831. */
  51832. protected _photoTexture: Texture;
  51833. /**
  51834. * Gets or sets the texture being displayed on the sphere
  51835. */
  51836. get photoTexture(): Texture;
  51837. set photoTexture(value: Texture);
  51838. /**
  51839. * Observable raised when an error occured while loading the 360 image
  51840. */
  51841. onLoadErrorObservable: Observable<string>;
  51842. /**
  51843. * The skybox material
  51844. */
  51845. protected _material: BackgroundMaterial;
  51846. /**
  51847. * The surface used for the skybox
  51848. */
  51849. protected _mesh: Mesh;
  51850. /**
  51851. * Gets the mesh used for the skybox.
  51852. */
  51853. get mesh(): Mesh;
  51854. /**
  51855. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51856. * Also see the options.resolution property.
  51857. */
  51858. get fovMultiplier(): number;
  51859. set fovMultiplier(value: number);
  51860. private _imageMode;
  51861. /**
  51862. * Gets or set the current video mode for the video. It can be:
  51863. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51864. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51865. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51866. */
  51867. get imageMode(): number;
  51868. set imageMode(value: number);
  51869. /**
  51870. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51871. * @param name Element's name, child elements will append suffixes for their own names.
  51872. * @param urlsOfPhoto defines the url of the photo to display
  51873. * @param options defines an object containing optional or exposed sub element properties
  51874. * @param onError defines a callback called when an error occured while loading the texture
  51875. */
  51876. constructor(name: string, urlOfPhoto: string, options: {
  51877. resolution?: number;
  51878. size?: number;
  51879. useDirectMapping?: boolean;
  51880. faceForward?: boolean;
  51881. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51882. private _onBeforeCameraRenderObserver;
  51883. private _changeImageMode;
  51884. /**
  51885. * Releases resources associated with this node.
  51886. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51887. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51888. */
  51889. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51890. }
  51891. }
  51892. declare module "babylonjs/Misc/rgbdTextureTools" {
  51893. import "babylonjs/Shaders/rgbdDecode.fragment";
  51894. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51895. import { Texture } from "babylonjs/Materials/Textures/texture";
  51896. /**
  51897. * Class used to host RGBD texture specific utilities
  51898. */
  51899. export class RGBDTextureTools {
  51900. /**
  51901. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51902. * @param texture the texture to expand.
  51903. */
  51904. static ExpandRGBDTexture(texture: Texture): void;
  51905. }
  51906. }
  51907. declare module "babylonjs/Misc/brdfTextureTools" {
  51908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51909. import { Scene } from "babylonjs/scene";
  51910. /**
  51911. * Class used to host texture specific utilities
  51912. */
  51913. export class BRDFTextureTools {
  51914. /**
  51915. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51916. * @param scene defines the hosting scene
  51917. * @returns the environment BRDF texture
  51918. */
  51919. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51920. private static _environmentBRDFBase64Texture;
  51921. }
  51922. }
  51923. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51924. import { Nullable } from "babylonjs/types";
  51925. import { Color3 } from "babylonjs/Maths/math.color";
  51926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51927. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51928. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51929. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51930. import { Engine } from "babylonjs/Engines/engine";
  51931. import { Scene } from "babylonjs/scene";
  51932. /**
  51933. * @hidden
  51934. */
  51935. export interface IMaterialClearCoatDefines {
  51936. CLEARCOAT: boolean;
  51937. CLEARCOAT_DEFAULTIOR: boolean;
  51938. CLEARCOAT_TEXTURE: boolean;
  51939. CLEARCOAT_TEXTUREDIRECTUV: number;
  51940. CLEARCOAT_BUMP: boolean;
  51941. CLEARCOAT_BUMPDIRECTUV: number;
  51942. CLEARCOAT_TINT: boolean;
  51943. CLEARCOAT_TINT_TEXTURE: boolean;
  51944. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51945. /** @hidden */
  51946. _areTexturesDirty: boolean;
  51947. }
  51948. /**
  51949. * Define the code related to the clear coat parameters of the pbr material.
  51950. */
  51951. export class PBRClearCoatConfiguration {
  51952. /**
  51953. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51954. * The default fits with a polyurethane material.
  51955. */
  51956. private static readonly _DefaultIndexOfRefraction;
  51957. private _isEnabled;
  51958. /**
  51959. * Defines if the clear coat is enabled in the material.
  51960. */
  51961. isEnabled: boolean;
  51962. /**
  51963. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51964. */
  51965. intensity: number;
  51966. /**
  51967. * Defines the clear coat layer roughness.
  51968. */
  51969. roughness: number;
  51970. private _indexOfRefraction;
  51971. /**
  51972. * Defines the index of refraction of the clear coat.
  51973. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51974. * The default fits with a polyurethane material.
  51975. * Changing the default value is more performance intensive.
  51976. */
  51977. indexOfRefraction: number;
  51978. private _texture;
  51979. /**
  51980. * Stores the clear coat values in a texture.
  51981. */
  51982. texture: Nullable<BaseTexture>;
  51983. private _bumpTexture;
  51984. /**
  51985. * Define the clear coat specific bump texture.
  51986. */
  51987. bumpTexture: Nullable<BaseTexture>;
  51988. private _isTintEnabled;
  51989. /**
  51990. * Defines if the clear coat tint is enabled in the material.
  51991. */
  51992. isTintEnabled: boolean;
  51993. /**
  51994. * Defines the clear coat tint of the material.
  51995. * This is only use if tint is enabled
  51996. */
  51997. tintColor: Color3;
  51998. /**
  51999. * Defines the distance at which the tint color should be found in the
  52000. * clear coat media.
  52001. * This is only use if tint is enabled
  52002. */
  52003. tintColorAtDistance: number;
  52004. /**
  52005. * Defines the clear coat layer thickness.
  52006. * This is only use if tint is enabled
  52007. */
  52008. tintThickness: number;
  52009. private _tintTexture;
  52010. /**
  52011. * Stores the clear tint values in a texture.
  52012. * rgb is tint
  52013. * a is a thickness factor
  52014. */
  52015. tintTexture: Nullable<BaseTexture>;
  52016. /** @hidden */
  52017. private _internalMarkAllSubMeshesAsTexturesDirty;
  52018. /** @hidden */
  52019. _markAllSubMeshesAsTexturesDirty(): void;
  52020. /**
  52021. * Instantiate a new istance of clear coat configuration.
  52022. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52023. */
  52024. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52025. /**
  52026. * Gets wehter the submesh is ready to be used or not.
  52027. * @param defines the list of "defines" to update.
  52028. * @param scene defines the scene the material belongs to.
  52029. * @param engine defines the engine the material belongs to.
  52030. * @param disableBumpMap defines wether the material disables bump or not.
  52031. * @returns - boolean indicating that the submesh is ready or not.
  52032. */
  52033. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52034. /**
  52035. * Checks to see if a texture is used in the material.
  52036. * @param defines the list of "defines" to update.
  52037. * @param scene defines the scene to the material belongs to.
  52038. */
  52039. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52040. /**
  52041. * Binds the material data.
  52042. * @param uniformBuffer defines the Uniform buffer to fill in.
  52043. * @param scene defines the scene the material belongs to.
  52044. * @param engine defines the engine the material belongs to.
  52045. * @param disableBumpMap defines wether the material disables bump or not.
  52046. * @param isFrozen defines wether the material is frozen or not.
  52047. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52048. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52049. */
  52050. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52051. /**
  52052. * Checks to see if a texture is used in the material.
  52053. * @param texture - Base texture to use.
  52054. * @returns - Boolean specifying if a texture is used in the material.
  52055. */
  52056. hasTexture(texture: BaseTexture): boolean;
  52057. /**
  52058. * Returns an array of the actively used textures.
  52059. * @param activeTextures Array of BaseTextures
  52060. */
  52061. getActiveTextures(activeTextures: BaseTexture[]): void;
  52062. /**
  52063. * Returns the animatable textures.
  52064. * @param animatables Array of animatable textures.
  52065. */
  52066. getAnimatables(animatables: IAnimatable[]): void;
  52067. /**
  52068. * Disposes the resources of the material.
  52069. * @param forceDisposeTextures - Forces the disposal of all textures.
  52070. */
  52071. dispose(forceDisposeTextures?: boolean): void;
  52072. /**
  52073. * Get the current class name of the texture useful for serialization or dynamic coding.
  52074. * @returns "PBRClearCoatConfiguration"
  52075. */
  52076. getClassName(): string;
  52077. /**
  52078. * Add fallbacks to the effect fallbacks list.
  52079. * @param defines defines the Base texture to use.
  52080. * @param fallbacks defines the current fallback list.
  52081. * @param currentRank defines the current fallback rank.
  52082. * @returns the new fallback rank.
  52083. */
  52084. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52085. /**
  52086. * Add the required uniforms to the current list.
  52087. * @param uniforms defines the current uniform list.
  52088. */
  52089. static AddUniforms(uniforms: string[]): void;
  52090. /**
  52091. * Add the required samplers to the current list.
  52092. * @param samplers defines the current sampler list.
  52093. */
  52094. static AddSamplers(samplers: string[]): void;
  52095. /**
  52096. * Add the required uniforms to the current buffer.
  52097. * @param uniformBuffer defines the current uniform buffer.
  52098. */
  52099. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52100. /**
  52101. * Makes a duplicate of the current configuration into another one.
  52102. * @param clearCoatConfiguration define the config where to copy the info
  52103. */
  52104. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52105. /**
  52106. * Serializes this clear coat configuration.
  52107. * @returns - An object with the serialized config.
  52108. */
  52109. serialize(): any;
  52110. /**
  52111. * Parses a anisotropy Configuration from a serialized object.
  52112. * @param source - Serialized object.
  52113. * @param scene Defines the scene we are parsing for
  52114. * @param rootUrl Defines the rootUrl to load from
  52115. */
  52116. parse(source: any, scene: Scene, rootUrl: string): void;
  52117. }
  52118. }
  52119. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52120. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52122. import { Vector2 } from "babylonjs/Maths/math.vector";
  52123. import { Scene } from "babylonjs/scene";
  52124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52125. import { Nullable } from "babylonjs/types";
  52126. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52127. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52128. /**
  52129. * @hidden
  52130. */
  52131. export interface IMaterialAnisotropicDefines {
  52132. ANISOTROPIC: boolean;
  52133. ANISOTROPIC_TEXTURE: boolean;
  52134. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52135. MAINUV1: boolean;
  52136. _areTexturesDirty: boolean;
  52137. _needUVs: boolean;
  52138. }
  52139. /**
  52140. * Define the code related to the anisotropic parameters of the pbr material.
  52141. */
  52142. export class PBRAnisotropicConfiguration {
  52143. private _isEnabled;
  52144. /**
  52145. * Defines if the anisotropy is enabled in the material.
  52146. */
  52147. isEnabled: boolean;
  52148. /**
  52149. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52150. */
  52151. intensity: number;
  52152. /**
  52153. * Defines if the effect is along the tangents, bitangents or in between.
  52154. * By default, the effect is "strectching" the highlights along the tangents.
  52155. */
  52156. direction: Vector2;
  52157. private _texture;
  52158. /**
  52159. * Stores the anisotropy values in a texture.
  52160. * rg is direction (like normal from -1 to 1)
  52161. * b is a intensity
  52162. */
  52163. texture: Nullable<BaseTexture>;
  52164. /** @hidden */
  52165. private _internalMarkAllSubMeshesAsTexturesDirty;
  52166. /** @hidden */
  52167. _markAllSubMeshesAsTexturesDirty(): void;
  52168. /**
  52169. * Instantiate a new istance of anisotropy configuration.
  52170. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52171. */
  52172. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52173. /**
  52174. * Specifies that the submesh is ready to be used.
  52175. * @param defines the list of "defines" to update.
  52176. * @param scene defines the scene the material belongs to.
  52177. * @returns - boolean indicating that the submesh is ready or not.
  52178. */
  52179. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52180. /**
  52181. * Checks to see if a texture is used in the material.
  52182. * @param defines the list of "defines" to update.
  52183. * @param mesh the mesh we are preparing the defines for.
  52184. * @param scene defines the scene the material belongs to.
  52185. */
  52186. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52187. /**
  52188. * Binds the material data.
  52189. * @param uniformBuffer defines the Uniform buffer to fill in.
  52190. * @param scene defines the scene the material belongs to.
  52191. * @param isFrozen defines wether the material is frozen or not.
  52192. */
  52193. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52194. /**
  52195. * Checks to see if a texture is used in the material.
  52196. * @param texture - Base texture to use.
  52197. * @returns - Boolean specifying if a texture is used in the material.
  52198. */
  52199. hasTexture(texture: BaseTexture): boolean;
  52200. /**
  52201. * Returns an array of the actively used textures.
  52202. * @param activeTextures Array of BaseTextures
  52203. */
  52204. getActiveTextures(activeTextures: BaseTexture[]): void;
  52205. /**
  52206. * Returns the animatable textures.
  52207. * @param animatables Array of animatable textures.
  52208. */
  52209. getAnimatables(animatables: IAnimatable[]): void;
  52210. /**
  52211. * Disposes the resources of the material.
  52212. * @param forceDisposeTextures - Forces the disposal of all textures.
  52213. */
  52214. dispose(forceDisposeTextures?: boolean): void;
  52215. /**
  52216. * Get the current class name of the texture useful for serialization or dynamic coding.
  52217. * @returns "PBRAnisotropicConfiguration"
  52218. */
  52219. getClassName(): string;
  52220. /**
  52221. * Add fallbacks to the effect fallbacks list.
  52222. * @param defines defines the Base texture to use.
  52223. * @param fallbacks defines the current fallback list.
  52224. * @param currentRank defines the current fallback rank.
  52225. * @returns the new fallback rank.
  52226. */
  52227. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52228. /**
  52229. * Add the required uniforms to the current list.
  52230. * @param uniforms defines the current uniform list.
  52231. */
  52232. static AddUniforms(uniforms: string[]): void;
  52233. /**
  52234. * Add the required uniforms to the current buffer.
  52235. * @param uniformBuffer defines the current uniform buffer.
  52236. */
  52237. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52238. /**
  52239. * Add the required samplers to the current list.
  52240. * @param samplers defines the current sampler list.
  52241. */
  52242. static AddSamplers(samplers: string[]): void;
  52243. /**
  52244. * Makes a duplicate of the current configuration into another one.
  52245. * @param anisotropicConfiguration define the config where to copy the info
  52246. */
  52247. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52248. /**
  52249. * Serializes this anisotropy configuration.
  52250. * @returns - An object with the serialized config.
  52251. */
  52252. serialize(): any;
  52253. /**
  52254. * Parses a anisotropy Configuration from a serialized object.
  52255. * @param source - Serialized object.
  52256. * @param scene Defines the scene we are parsing for
  52257. * @param rootUrl Defines the rootUrl to load from
  52258. */
  52259. parse(source: any, scene: Scene, rootUrl: string): void;
  52260. }
  52261. }
  52262. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52263. import { Scene } from "babylonjs/scene";
  52264. /**
  52265. * @hidden
  52266. */
  52267. export interface IMaterialBRDFDefines {
  52268. BRDF_V_HEIGHT_CORRELATED: boolean;
  52269. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52270. SPHERICAL_HARMONICS: boolean;
  52271. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52272. /** @hidden */
  52273. _areMiscDirty: boolean;
  52274. }
  52275. /**
  52276. * Define the code related to the BRDF parameters of the pbr material.
  52277. */
  52278. export class PBRBRDFConfiguration {
  52279. /**
  52280. * Default value used for the energy conservation.
  52281. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52282. */
  52283. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52284. /**
  52285. * Default value used for the Smith Visibility Height Correlated mode.
  52286. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52287. */
  52288. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52289. /**
  52290. * Default value used for the IBL diffuse part.
  52291. * This can help switching back to the polynomials mode globally which is a tiny bit
  52292. * less GPU intensive at the drawback of a lower quality.
  52293. */
  52294. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52295. /**
  52296. * Default value used for activating energy conservation for the specular workflow.
  52297. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52298. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52299. */
  52300. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52301. private _useEnergyConservation;
  52302. /**
  52303. * Defines if the material uses energy conservation.
  52304. */
  52305. useEnergyConservation: boolean;
  52306. private _useSmithVisibilityHeightCorrelated;
  52307. /**
  52308. * LEGACY Mode set to false
  52309. * Defines if the material uses height smith correlated visibility term.
  52310. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52311. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52312. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52313. * Not relying on height correlated will also disable energy conservation.
  52314. */
  52315. useSmithVisibilityHeightCorrelated: boolean;
  52316. private _useSphericalHarmonics;
  52317. /**
  52318. * LEGACY Mode set to false
  52319. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52320. * diffuse part of the IBL.
  52321. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52322. * to the ground truth.
  52323. */
  52324. useSphericalHarmonics: boolean;
  52325. private _useSpecularGlossinessInputEnergyConservation;
  52326. /**
  52327. * Defines if the material uses energy conservation, when the specular workflow is active.
  52328. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52329. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52330. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52331. */
  52332. useSpecularGlossinessInputEnergyConservation: boolean;
  52333. /** @hidden */
  52334. private _internalMarkAllSubMeshesAsMiscDirty;
  52335. /** @hidden */
  52336. _markAllSubMeshesAsMiscDirty(): void;
  52337. /**
  52338. * Instantiate a new istance of clear coat configuration.
  52339. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52340. */
  52341. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52342. /**
  52343. * Checks to see if a texture is used in the material.
  52344. * @param defines the list of "defines" to update.
  52345. */
  52346. prepareDefines(defines: IMaterialBRDFDefines): void;
  52347. /**
  52348. * Get the current class name of the texture useful for serialization or dynamic coding.
  52349. * @returns "PBRClearCoatConfiguration"
  52350. */
  52351. getClassName(): string;
  52352. /**
  52353. * Makes a duplicate of the current configuration into another one.
  52354. * @param brdfConfiguration define the config where to copy the info
  52355. */
  52356. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52357. /**
  52358. * Serializes this BRDF configuration.
  52359. * @returns - An object with the serialized config.
  52360. */
  52361. serialize(): any;
  52362. /**
  52363. * Parses a anisotropy Configuration from a serialized object.
  52364. * @param source - Serialized object.
  52365. * @param scene Defines the scene we are parsing for
  52366. * @param rootUrl Defines the rootUrl to load from
  52367. */
  52368. parse(source: any, scene: Scene, rootUrl: string): void;
  52369. }
  52370. }
  52371. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52372. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52373. import { Color3 } from "babylonjs/Maths/math.color";
  52374. import { Scene } from "babylonjs/scene";
  52375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52376. import { Nullable } from "babylonjs/types";
  52377. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52378. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52379. /**
  52380. * @hidden
  52381. */
  52382. export interface IMaterialSheenDefines {
  52383. SHEEN: boolean;
  52384. SHEEN_TEXTURE: boolean;
  52385. SHEEN_TEXTUREDIRECTUV: number;
  52386. SHEEN_LINKWITHALBEDO: boolean;
  52387. /** @hidden */
  52388. _areTexturesDirty: boolean;
  52389. }
  52390. /**
  52391. * Define the code related to the Sheen parameters of the pbr material.
  52392. */
  52393. export class PBRSheenConfiguration {
  52394. private _isEnabled;
  52395. /**
  52396. * Defines if the material uses sheen.
  52397. */
  52398. isEnabled: boolean;
  52399. private _linkSheenWithAlbedo;
  52400. /**
  52401. * Defines if the sheen is linked to the sheen color.
  52402. */
  52403. linkSheenWithAlbedo: boolean;
  52404. /**
  52405. * Defines the sheen intensity.
  52406. */
  52407. intensity: number;
  52408. /**
  52409. * Defines the sheen color.
  52410. */
  52411. color: Color3;
  52412. private _texture;
  52413. /**
  52414. * Stores the sheen tint values in a texture.
  52415. * rgb is tint
  52416. * a is a intensity
  52417. */
  52418. texture: Nullable<BaseTexture>;
  52419. /** @hidden */
  52420. private _internalMarkAllSubMeshesAsTexturesDirty;
  52421. /** @hidden */
  52422. _markAllSubMeshesAsTexturesDirty(): void;
  52423. /**
  52424. * Instantiate a new istance of clear coat configuration.
  52425. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52426. */
  52427. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52428. /**
  52429. * Specifies that the submesh is ready to be used.
  52430. * @param defines the list of "defines" to update.
  52431. * @param scene defines the scene the material belongs to.
  52432. * @returns - boolean indicating that the submesh is ready or not.
  52433. */
  52434. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52435. /**
  52436. * Checks to see if a texture is used in the material.
  52437. * @param defines the list of "defines" to update.
  52438. * @param scene defines the scene the material belongs to.
  52439. */
  52440. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52441. /**
  52442. * Binds the material data.
  52443. * @param uniformBuffer defines the Uniform buffer to fill in.
  52444. * @param scene defines the scene the material belongs to.
  52445. * @param isFrozen defines wether the material is frozen or not.
  52446. */
  52447. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52448. /**
  52449. * Checks to see if a texture is used in the material.
  52450. * @param texture - Base texture to use.
  52451. * @returns - Boolean specifying if a texture is used in the material.
  52452. */
  52453. hasTexture(texture: BaseTexture): boolean;
  52454. /**
  52455. * Returns an array of the actively used textures.
  52456. * @param activeTextures Array of BaseTextures
  52457. */
  52458. getActiveTextures(activeTextures: BaseTexture[]): void;
  52459. /**
  52460. * Returns the animatable textures.
  52461. * @param animatables Array of animatable textures.
  52462. */
  52463. getAnimatables(animatables: IAnimatable[]): void;
  52464. /**
  52465. * Disposes the resources of the material.
  52466. * @param forceDisposeTextures - Forces the disposal of all textures.
  52467. */
  52468. dispose(forceDisposeTextures?: boolean): void;
  52469. /**
  52470. * Get the current class name of the texture useful for serialization or dynamic coding.
  52471. * @returns "PBRSheenConfiguration"
  52472. */
  52473. getClassName(): string;
  52474. /**
  52475. * Add fallbacks to the effect fallbacks list.
  52476. * @param defines defines the Base texture to use.
  52477. * @param fallbacks defines the current fallback list.
  52478. * @param currentRank defines the current fallback rank.
  52479. * @returns the new fallback rank.
  52480. */
  52481. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52482. /**
  52483. * Add the required uniforms to the current list.
  52484. * @param uniforms defines the current uniform list.
  52485. */
  52486. static AddUniforms(uniforms: string[]): void;
  52487. /**
  52488. * Add the required uniforms to the current buffer.
  52489. * @param uniformBuffer defines the current uniform buffer.
  52490. */
  52491. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52492. /**
  52493. * Add the required samplers to the current list.
  52494. * @param samplers defines the current sampler list.
  52495. */
  52496. static AddSamplers(samplers: string[]): void;
  52497. /**
  52498. * Makes a duplicate of the current configuration into another one.
  52499. * @param sheenConfiguration define the config where to copy the info
  52500. */
  52501. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52502. /**
  52503. * Serializes this BRDF configuration.
  52504. * @returns - An object with the serialized config.
  52505. */
  52506. serialize(): any;
  52507. /**
  52508. * Parses a anisotropy Configuration from a serialized object.
  52509. * @param source - Serialized object.
  52510. * @param scene Defines the scene we are parsing for
  52511. * @param rootUrl Defines the rootUrl to load from
  52512. */
  52513. parse(source: any, scene: Scene, rootUrl: string): void;
  52514. }
  52515. }
  52516. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52517. import { Nullable } from "babylonjs/types";
  52518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52519. import { Color3 } from "babylonjs/Maths/math.color";
  52520. import { SmartArray } from "babylonjs/Misc/smartArray";
  52521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52523. import { Effect } from "babylonjs/Materials/effect";
  52524. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52525. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52526. import { Engine } from "babylonjs/Engines/engine";
  52527. import { Scene } from "babylonjs/scene";
  52528. /**
  52529. * @hidden
  52530. */
  52531. export interface IMaterialSubSurfaceDefines {
  52532. SUBSURFACE: boolean;
  52533. SS_REFRACTION: boolean;
  52534. SS_TRANSLUCENCY: boolean;
  52535. SS_SCATERRING: boolean;
  52536. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52537. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52538. SS_REFRACTIONMAP_3D: boolean;
  52539. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52540. SS_LODINREFRACTIONALPHA: boolean;
  52541. SS_GAMMAREFRACTION: boolean;
  52542. SS_RGBDREFRACTION: boolean;
  52543. SS_LINEARSPECULARREFRACTION: boolean;
  52544. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52545. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52546. /** @hidden */
  52547. _areTexturesDirty: boolean;
  52548. }
  52549. /**
  52550. * Define the code related to the sub surface parameters of the pbr material.
  52551. */
  52552. export class PBRSubSurfaceConfiguration {
  52553. private _isRefractionEnabled;
  52554. /**
  52555. * Defines if the refraction is enabled in the material.
  52556. */
  52557. isRefractionEnabled: boolean;
  52558. private _isTranslucencyEnabled;
  52559. /**
  52560. * Defines if the translucency is enabled in the material.
  52561. */
  52562. isTranslucencyEnabled: boolean;
  52563. private _isScatteringEnabled;
  52564. /**
  52565. * Defines the refraction intensity of the material.
  52566. * The refraction when enabled replaces the Diffuse part of the material.
  52567. * The intensity helps transitionning between diffuse and refraction.
  52568. */
  52569. refractionIntensity: number;
  52570. /**
  52571. * Defines the translucency intensity of the material.
  52572. * When translucency has been enabled, this defines how much of the "translucency"
  52573. * is addded to the diffuse part of the material.
  52574. */
  52575. translucencyIntensity: number;
  52576. /**
  52577. * Defines the scattering intensity of the material.
  52578. * When scattering has been enabled, this defines how much of the "scattered light"
  52579. * is addded to the diffuse part of the material.
  52580. */
  52581. scatteringIntensity: number;
  52582. private _thicknessTexture;
  52583. /**
  52584. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52585. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52586. * 0 would mean minimumThickness
  52587. * 1 would mean maximumThickness
  52588. * The other channels might be use as a mask to vary the different effects intensity.
  52589. */
  52590. thicknessTexture: Nullable<BaseTexture>;
  52591. private _refractionTexture;
  52592. /**
  52593. * Defines the texture to use for refraction.
  52594. */
  52595. refractionTexture: Nullable<BaseTexture>;
  52596. private _indexOfRefraction;
  52597. /**
  52598. * Defines the index of refraction used in the material.
  52599. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52600. */
  52601. indexOfRefraction: number;
  52602. private _invertRefractionY;
  52603. /**
  52604. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52605. */
  52606. invertRefractionY: boolean;
  52607. private _linkRefractionWithTransparency;
  52608. /**
  52609. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52610. * Materials half opaque for instance using refraction could benefit from this control.
  52611. */
  52612. linkRefractionWithTransparency: boolean;
  52613. /**
  52614. * Defines the minimum thickness stored in the thickness map.
  52615. * If no thickness map is defined, this value will be used to simulate thickness.
  52616. */
  52617. minimumThickness: number;
  52618. /**
  52619. * Defines the maximum thickness stored in the thickness map.
  52620. */
  52621. maximumThickness: number;
  52622. /**
  52623. * Defines the volume tint of the material.
  52624. * This is used for both translucency and scattering.
  52625. */
  52626. tintColor: Color3;
  52627. /**
  52628. * Defines the distance at which the tint color should be found in the media.
  52629. * This is used for refraction only.
  52630. */
  52631. tintColorAtDistance: number;
  52632. /**
  52633. * Defines how far each channel transmit through the media.
  52634. * It is defined as a color to simplify it selection.
  52635. */
  52636. diffusionDistance: Color3;
  52637. private _useMaskFromThicknessTexture;
  52638. /**
  52639. * Stores the intensity of the different subsurface effects in the thickness texture.
  52640. * * the green channel is the translucency intensity.
  52641. * * the blue channel is the scattering intensity.
  52642. * * the alpha channel is the refraction intensity.
  52643. */
  52644. useMaskFromThicknessTexture: boolean;
  52645. /** @hidden */
  52646. private _internalMarkAllSubMeshesAsTexturesDirty;
  52647. /** @hidden */
  52648. _markAllSubMeshesAsTexturesDirty(): void;
  52649. /**
  52650. * Instantiate a new istance of sub surface configuration.
  52651. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52652. */
  52653. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52654. /**
  52655. * Gets wehter the submesh is ready to be used or not.
  52656. * @param defines the list of "defines" to update.
  52657. * @param scene defines the scene the material belongs to.
  52658. * @returns - boolean indicating that the submesh is ready or not.
  52659. */
  52660. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52661. /**
  52662. * Checks to see if a texture is used in the material.
  52663. * @param defines the list of "defines" to update.
  52664. * @param scene defines the scene to the material belongs to.
  52665. */
  52666. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52667. /**
  52668. * Binds the material data.
  52669. * @param uniformBuffer defines the Uniform buffer to fill in.
  52670. * @param scene defines the scene the material belongs to.
  52671. * @param engine defines the engine the material belongs to.
  52672. * @param isFrozen defines wether the material is frozen or not.
  52673. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52674. */
  52675. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52676. /**
  52677. * Unbinds the material from the mesh.
  52678. * @param activeEffect defines the effect that should be unbound from.
  52679. * @returns true if unbound, otherwise false
  52680. */
  52681. unbind(activeEffect: Effect): boolean;
  52682. /**
  52683. * Returns the texture used for refraction or null if none is used.
  52684. * @param scene defines the scene the material belongs to.
  52685. * @returns - Refraction texture if present. If no refraction texture and refraction
  52686. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52687. */
  52688. private _getRefractionTexture;
  52689. /**
  52690. * Returns true if alpha blending should be disabled.
  52691. */
  52692. get disableAlphaBlending(): boolean;
  52693. /**
  52694. * Fills the list of render target textures.
  52695. * @param renderTargets the list of render targets to update
  52696. */
  52697. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52698. /**
  52699. * Checks to see if a texture is used in the material.
  52700. * @param texture - Base texture to use.
  52701. * @returns - Boolean specifying if a texture is used in the material.
  52702. */
  52703. hasTexture(texture: BaseTexture): boolean;
  52704. /**
  52705. * Gets a boolean indicating that current material needs to register RTT
  52706. * @returns true if this uses a render target otherwise false.
  52707. */
  52708. hasRenderTargetTextures(): boolean;
  52709. /**
  52710. * Returns an array of the actively used textures.
  52711. * @param activeTextures Array of BaseTextures
  52712. */
  52713. getActiveTextures(activeTextures: BaseTexture[]): void;
  52714. /**
  52715. * Returns the animatable textures.
  52716. * @param animatables Array of animatable textures.
  52717. */
  52718. getAnimatables(animatables: IAnimatable[]): void;
  52719. /**
  52720. * Disposes the resources of the material.
  52721. * @param forceDisposeTextures - Forces the disposal of all textures.
  52722. */
  52723. dispose(forceDisposeTextures?: boolean): void;
  52724. /**
  52725. * Get the current class name of the texture useful for serialization or dynamic coding.
  52726. * @returns "PBRSubSurfaceConfiguration"
  52727. */
  52728. getClassName(): string;
  52729. /**
  52730. * Add fallbacks to the effect fallbacks list.
  52731. * @param defines defines the Base texture to use.
  52732. * @param fallbacks defines the current fallback list.
  52733. * @param currentRank defines the current fallback rank.
  52734. * @returns the new fallback rank.
  52735. */
  52736. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52737. /**
  52738. * Add the required uniforms to the current list.
  52739. * @param uniforms defines the current uniform list.
  52740. */
  52741. static AddUniforms(uniforms: string[]): void;
  52742. /**
  52743. * Add the required samplers to the current list.
  52744. * @param samplers defines the current sampler list.
  52745. */
  52746. static AddSamplers(samplers: string[]): void;
  52747. /**
  52748. * Add the required uniforms to the current buffer.
  52749. * @param uniformBuffer defines the current uniform buffer.
  52750. */
  52751. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52752. /**
  52753. * Makes a duplicate of the current configuration into another one.
  52754. * @param configuration define the config where to copy the info
  52755. */
  52756. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52757. /**
  52758. * Serializes this Sub Surface configuration.
  52759. * @returns - An object with the serialized config.
  52760. */
  52761. serialize(): any;
  52762. /**
  52763. * Parses a anisotropy Configuration from a serialized object.
  52764. * @param source - Serialized object.
  52765. * @param scene Defines the scene we are parsing for
  52766. * @param rootUrl Defines the rootUrl to load from
  52767. */
  52768. parse(source: any, scene: Scene, rootUrl: string): void;
  52769. }
  52770. }
  52771. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52772. /** @hidden */
  52773. export var pbrFragmentDeclaration: {
  52774. name: string;
  52775. shader: string;
  52776. };
  52777. }
  52778. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52779. /** @hidden */
  52780. export var pbrUboDeclaration: {
  52781. name: string;
  52782. shader: string;
  52783. };
  52784. }
  52785. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52786. /** @hidden */
  52787. export var pbrFragmentExtraDeclaration: {
  52788. name: string;
  52789. shader: string;
  52790. };
  52791. }
  52792. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52793. /** @hidden */
  52794. export var pbrFragmentSamplersDeclaration: {
  52795. name: string;
  52796. shader: string;
  52797. };
  52798. }
  52799. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52800. /** @hidden */
  52801. export var pbrHelperFunctions: {
  52802. name: string;
  52803. shader: string;
  52804. };
  52805. }
  52806. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52807. /** @hidden */
  52808. export var harmonicsFunctions: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52814. /** @hidden */
  52815. export var pbrDirectLightingSetupFunctions: {
  52816. name: string;
  52817. shader: string;
  52818. };
  52819. }
  52820. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52821. /** @hidden */
  52822. export var pbrDirectLightingFalloffFunctions: {
  52823. name: string;
  52824. shader: string;
  52825. };
  52826. }
  52827. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52828. /** @hidden */
  52829. export var pbrBRDFFunctions: {
  52830. name: string;
  52831. shader: string;
  52832. };
  52833. }
  52834. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52835. /** @hidden */
  52836. export var pbrDirectLightingFunctions: {
  52837. name: string;
  52838. shader: string;
  52839. };
  52840. }
  52841. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52842. /** @hidden */
  52843. export var pbrIBLFunctions: {
  52844. name: string;
  52845. shader: string;
  52846. };
  52847. }
  52848. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52849. /** @hidden */
  52850. export var pbrDebug: {
  52851. name: string;
  52852. shader: string;
  52853. };
  52854. }
  52855. declare module "babylonjs/Shaders/pbr.fragment" {
  52856. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52858. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52859. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52860. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52861. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52862. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52863. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52864. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52865. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52866. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52869. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52870. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52871. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52872. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52873. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52874. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52875. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52876. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52877. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52879. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52880. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52881. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52882. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52883. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52884. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52885. /** @hidden */
  52886. export var pbrPixelShader: {
  52887. name: string;
  52888. shader: string;
  52889. };
  52890. }
  52891. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52892. /** @hidden */
  52893. export var pbrVertexDeclaration: {
  52894. name: string;
  52895. shader: string;
  52896. };
  52897. }
  52898. declare module "babylonjs/Shaders/pbr.vertex" {
  52899. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52902. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52905. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52908. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52909. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52912. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52914. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52915. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52916. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52917. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52918. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52919. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52920. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52921. /** @hidden */
  52922. export var pbrVertexShader: {
  52923. name: string;
  52924. shader: string;
  52925. };
  52926. }
  52927. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52928. import { Nullable } from "babylonjs/types";
  52929. import { Scene } from "babylonjs/scene";
  52930. import { Matrix } from "babylonjs/Maths/math.vector";
  52931. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52933. import { Mesh } from "babylonjs/Meshes/mesh";
  52934. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52935. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52936. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52937. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52938. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52939. import { Color3 } from "babylonjs/Maths/math.color";
  52940. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52941. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52942. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52943. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52945. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52946. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52947. import "babylonjs/Shaders/pbr.fragment";
  52948. import "babylonjs/Shaders/pbr.vertex";
  52949. /**
  52950. * Manages the defines for the PBR Material.
  52951. * @hidden
  52952. */
  52953. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52954. PBR: boolean;
  52955. MAINUV1: boolean;
  52956. MAINUV2: boolean;
  52957. UV1: boolean;
  52958. UV2: boolean;
  52959. ALBEDO: boolean;
  52960. GAMMAALBEDO: boolean;
  52961. ALBEDODIRECTUV: number;
  52962. VERTEXCOLOR: boolean;
  52963. AMBIENT: boolean;
  52964. AMBIENTDIRECTUV: number;
  52965. AMBIENTINGRAYSCALE: boolean;
  52966. OPACITY: boolean;
  52967. VERTEXALPHA: boolean;
  52968. OPACITYDIRECTUV: number;
  52969. OPACITYRGB: boolean;
  52970. ALPHATEST: boolean;
  52971. DEPTHPREPASS: boolean;
  52972. ALPHABLEND: boolean;
  52973. ALPHAFROMALBEDO: boolean;
  52974. ALPHATESTVALUE: string;
  52975. SPECULAROVERALPHA: boolean;
  52976. RADIANCEOVERALPHA: boolean;
  52977. ALPHAFRESNEL: boolean;
  52978. LINEARALPHAFRESNEL: boolean;
  52979. PREMULTIPLYALPHA: boolean;
  52980. EMISSIVE: boolean;
  52981. EMISSIVEDIRECTUV: number;
  52982. REFLECTIVITY: boolean;
  52983. REFLECTIVITYDIRECTUV: number;
  52984. SPECULARTERM: boolean;
  52985. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52986. MICROSURFACEAUTOMATIC: boolean;
  52987. LODBASEDMICROSFURACE: boolean;
  52988. MICROSURFACEMAP: boolean;
  52989. MICROSURFACEMAPDIRECTUV: number;
  52990. METALLICWORKFLOW: boolean;
  52991. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52992. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52993. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52994. AOSTOREINMETALMAPRED: boolean;
  52995. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52996. ENVIRONMENTBRDF: boolean;
  52997. ENVIRONMENTBRDF_RGBD: boolean;
  52998. NORMAL: boolean;
  52999. TANGENT: boolean;
  53000. BUMP: boolean;
  53001. BUMPDIRECTUV: number;
  53002. OBJECTSPACE_NORMALMAP: boolean;
  53003. PARALLAX: boolean;
  53004. PARALLAXOCCLUSION: boolean;
  53005. NORMALXYSCALE: boolean;
  53006. LIGHTMAP: boolean;
  53007. LIGHTMAPDIRECTUV: number;
  53008. USELIGHTMAPASSHADOWMAP: boolean;
  53009. GAMMALIGHTMAP: boolean;
  53010. RGBDLIGHTMAP: boolean;
  53011. REFLECTION: boolean;
  53012. REFLECTIONMAP_3D: boolean;
  53013. REFLECTIONMAP_SPHERICAL: boolean;
  53014. REFLECTIONMAP_PLANAR: boolean;
  53015. REFLECTIONMAP_CUBIC: boolean;
  53016. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53017. REFLECTIONMAP_PROJECTION: boolean;
  53018. REFLECTIONMAP_SKYBOX: boolean;
  53019. REFLECTIONMAP_EXPLICIT: boolean;
  53020. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53021. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53022. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53023. INVERTCUBICMAP: boolean;
  53024. USESPHERICALFROMREFLECTIONMAP: boolean;
  53025. USEIRRADIANCEMAP: boolean;
  53026. SPHERICAL_HARMONICS: boolean;
  53027. USESPHERICALINVERTEX: boolean;
  53028. REFLECTIONMAP_OPPOSITEZ: boolean;
  53029. LODINREFLECTIONALPHA: boolean;
  53030. GAMMAREFLECTION: boolean;
  53031. RGBDREFLECTION: boolean;
  53032. LINEARSPECULARREFLECTION: boolean;
  53033. RADIANCEOCCLUSION: boolean;
  53034. HORIZONOCCLUSION: boolean;
  53035. INSTANCES: boolean;
  53036. NUM_BONE_INFLUENCERS: number;
  53037. BonesPerMesh: number;
  53038. BONETEXTURE: boolean;
  53039. NONUNIFORMSCALING: boolean;
  53040. MORPHTARGETS: boolean;
  53041. MORPHTARGETS_NORMAL: boolean;
  53042. MORPHTARGETS_TANGENT: boolean;
  53043. MORPHTARGETS_UV: boolean;
  53044. NUM_MORPH_INFLUENCERS: number;
  53045. IMAGEPROCESSING: boolean;
  53046. VIGNETTE: boolean;
  53047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53048. VIGNETTEBLENDMODEOPAQUE: boolean;
  53049. TONEMAPPING: boolean;
  53050. TONEMAPPING_ACES: boolean;
  53051. CONTRAST: boolean;
  53052. COLORCURVES: boolean;
  53053. COLORGRADING: boolean;
  53054. COLORGRADING3D: boolean;
  53055. SAMPLER3DGREENDEPTH: boolean;
  53056. SAMPLER3DBGRMAP: boolean;
  53057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53058. EXPOSURE: boolean;
  53059. MULTIVIEW: boolean;
  53060. USEPHYSICALLIGHTFALLOFF: boolean;
  53061. USEGLTFLIGHTFALLOFF: boolean;
  53062. TWOSIDEDLIGHTING: boolean;
  53063. SHADOWFLOAT: boolean;
  53064. CLIPPLANE: boolean;
  53065. CLIPPLANE2: boolean;
  53066. CLIPPLANE3: boolean;
  53067. CLIPPLANE4: boolean;
  53068. CLIPPLANE5: boolean;
  53069. CLIPPLANE6: boolean;
  53070. POINTSIZE: boolean;
  53071. FOG: boolean;
  53072. LOGARITHMICDEPTH: boolean;
  53073. FORCENORMALFORWARD: boolean;
  53074. SPECULARAA: boolean;
  53075. CLEARCOAT: boolean;
  53076. CLEARCOAT_DEFAULTIOR: boolean;
  53077. CLEARCOAT_TEXTURE: boolean;
  53078. CLEARCOAT_TEXTUREDIRECTUV: number;
  53079. CLEARCOAT_BUMP: boolean;
  53080. CLEARCOAT_BUMPDIRECTUV: number;
  53081. CLEARCOAT_TINT: boolean;
  53082. CLEARCOAT_TINT_TEXTURE: boolean;
  53083. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53084. ANISOTROPIC: boolean;
  53085. ANISOTROPIC_TEXTURE: boolean;
  53086. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53087. BRDF_V_HEIGHT_CORRELATED: boolean;
  53088. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53089. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53090. SHEEN: boolean;
  53091. SHEEN_TEXTURE: boolean;
  53092. SHEEN_TEXTUREDIRECTUV: number;
  53093. SHEEN_LINKWITHALBEDO: boolean;
  53094. SUBSURFACE: boolean;
  53095. SS_REFRACTION: boolean;
  53096. SS_TRANSLUCENCY: boolean;
  53097. SS_SCATERRING: boolean;
  53098. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53099. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53100. SS_REFRACTIONMAP_3D: boolean;
  53101. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53102. SS_LODINREFRACTIONALPHA: boolean;
  53103. SS_GAMMAREFRACTION: boolean;
  53104. SS_RGBDREFRACTION: boolean;
  53105. SS_LINEARSPECULARREFRACTION: boolean;
  53106. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53107. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53108. UNLIT: boolean;
  53109. DEBUGMODE: number;
  53110. /**
  53111. * Initializes the PBR Material defines.
  53112. */
  53113. constructor();
  53114. /**
  53115. * Resets the PBR Material defines.
  53116. */
  53117. reset(): void;
  53118. }
  53119. /**
  53120. * The Physically based material base class of BJS.
  53121. *
  53122. * This offers the main features of a standard PBR material.
  53123. * For more information, please refer to the documentation :
  53124. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53125. */
  53126. export abstract class PBRBaseMaterial extends PushMaterial {
  53127. /**
  53128. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53129. */
  53130. static readonly PBRMATERIAL_OPAQUE: number;
  53131. /**
  53132. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53133. */
  53134. static readonly PBRMATERIAL_ALPHATEST: number;
  53135. /**
  53136. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53137. */
  53138. static readonly PBRMATERIAL_ALPHABLEND: number;
  53139. /**
  53140. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53141. * They are also discarded below the alpha cutoff threshold to improve performances.
  53142. */
  53143. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53144. /**
  53145. * Defines the default value of how much AO map is occluding the analytical lights
  53146. * (point spot...).
  53147. */
  53148. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53149. /**
  53150. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53151. */
  53152. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53153. /**
  53154. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53155. * to enhance interoperability with other engines.
  53156. */
  53157. static readonly LIGHTFALLOFF_GLTF: number;
  53158. /**
  53159. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53160. * to enhance interoperability with other materials.
  53161. */
  53162. static readonly LIGHTFALLOFF_STANDARD: number;
  53163. /**
  53164. * Intensity of the direct lights e.g. the four lights available in your scene.
  53165. * This impacts both the direct diffuse and specular highlights.
  53166. */
  53167. protected _directIntensity: number;
  53168. /**
  53169. * Intensity of the emissive part of the material.
  53170. * This helps controlling the emissive effect without modifying the emissive color.
  53171. */
  53172. protected _emissiveIntensity: number;
  53173. /**
  53174. * Intensity of the environment e.g. how much the environment will light the object
  53175. * either through harmonics for rough material or through the refelction for shiny ones.
  53176. */
  53177. protected _environmentIntensity: number;
  53178. /**
  53179. * This is a special control allowing the reduction of the specular highlights coming from the
  53180. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53181. */
  53182. protected _specularIntensity: number;
  53183. /**
  53184. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53185. */
  53186. private _lightingInfos;
  53187. /**
  53188. * Debug Control allowing disabling the bump map on this material.
  53189. */
  53190. protected _disableBumpMap: boolean;
  53191. /**
  53192. * AKA Diffuse Texture in standard nomenclature.
  53193. */
  53194. protected _albedoTexture: Nullable<BaseTexture>;
  53195. /**
  53196. * AKA Occlusion Texture in other nomenclature.
  53197. */
  53198. protected _ambientTexture: Nullable<BaseTexture>;
  53199. /**
  53200. * AKA Occlusion Texture Intensity in other nomenclature.
  53201. */
  53202. protected _ambientTextureStrength: number;
  53203. /**
  53204. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53205. * 1 means it completely occludes it
  53206. * 0 mean it has no impact
  53207. */
  53208. protected _ambientTextureImpactOnAnalyticalLights: number;
  53209. /**
  53210. * Stores the alpha values in a texture.
  53211. */
  53212. protected _opacityTexture: Nullable<BaseTexture>;
  53213. /**
  53214. * Stores the reflection values in a texture.
  53215. */
  53216. protected _reflectionTexture: Nullable<BaseTexture>;
  53217. /**
  53218. * Stores the emissive values in a texture.
  53219. */
  53220. protected _emissiveTexture: Nullable<BaseTexture>;
  53221. /**
  53222. * AKA Specular texture in other nomenclature.
  53223. */
  53224. protected _reflectivityTexture: Nullable<BaseTexture>;
  53225. /**
  53226. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53227. */
  53228. protected _metallicTexture: Nullable<BaseTexture>;
  53229. /**
  53230. * Specifies the metallic scalar of the metallic/roughness workflow.
  53231. * Can also be used to scale the metalness values of the metallic texture.
  53232. */
  53233. protected _metallic: Nullable<number>;
  53234. /**
  53235. * Specifies the roughness scalar of the metallic/roughness workflow.
  53236. * Can also be used to scale the roughness values of the metallic texture.
  53237. */
  53238. protected _roughness: Nullable<number>;
  53239. /**
  53240. * Specifies the an F0 factor to help configuring the material F0.
  53241. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53242. * to 0.5 the previously hard coded value stays the same.
  53243. * Can also be used to scale the F0 values of the metallic texture.
  53244. */
  53245. protected _metallicF0Factor: number;
  53246. /**
  53247. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53248. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53249. * your expectation as it multiplies with the texture data.
  53250. */
  53251. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53252. /**
  53253. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53254. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53255. */
  53256. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53257. /**
  53258. * Stores surface normal data used to displace a mesh in a texture.
  53259. */
  53260. protected _bumpTexture: Nullable<BaseTexture>;
  53261. /**
  53262. * Stores the pre-calculated light information of a mesh in a texture.
  53263. */
  53264. protected _lightmapTexture: Nullable<BaseTexture>;
  53265. /**
  53266. * The color of a material in ambient lighting.
  53267. */
  53268. protected _ambientColor: Color3;
  53269. /**
  53270. * AKA Diffuse Color in other nomenclature.
  53271. */
  53272. protected _albedoColor: Color3;
  53273. /**
  53274. * AKA Specular Color in other nomenclature.
  53275. */
  53276. protected _reflectivityColor: Color3;
  53277. /**
  53278. * The color applied when light is reflected from a material.
  53279. */
  53280. protected _reflectionColor: Color3;
  53281. /**
  53282. * The color applied when light is emitted from a material.
  53283. */
  53284. protected _emissiveColor: Color3;
  53285. /**
  53286. * AKA Glossiness in other nomenclature.
  53287. */
  53288. protected _microSurface: number;
  53289. /**
  53290. * Specifies that the material will use the light map as a show map.
  53291. */
  53292. protected _useLightmapAsShadowmap: boolean;
  53293. /**
  53294. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53295. * makes the reflect vector face the model (under horizon).
  53296. */
  53297. protected _useHorizonOcclusion: boolean;
  53298. /**
  53299. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53300. * too much the area relying on ambient texture to define their ambient occlusion.
  53301. */
  53302. protected _useRadianceOcclusion: boolean;
  53303. /**
  53304. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53305. */
  53306. protected _useAlphaFromAlbedoTexture: boolean;
  53307. /**
  53308. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53309. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53310. */
  53311. protected _useSpecularOverAlpha: boolean;
  53312. /**
  53313. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53314. */
  53315. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53316. /**
  53317. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53318. */
  53319. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53320. /**
  53321. * Specifies if the metallic texture contains the roughness information in its green channel.
  53322. */
  53323. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53324. /**
  53325. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53326. */
  53327. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53328. /**
  53329. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53330. */
  53331. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53332. /**
  53333. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53334. */
  53335. protected _useAmbientInGrayScale: boolean;
  53336. /**
  53337. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53338. * The material will try to infer what glossiness each pixel should be.
  53339. */
  53340. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53341. /**
  53342. * Defines the falloff type used in this material.
  53343. * It by default is Physical.
  53344. */
  53345. protected _lightFalloff: number;
  53346. /**
  53347. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53348. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53349. */
  53350. protected _useRadianceOverAlpha: boolean;
  53351. /**
  53352. * Allows using an object space normal map (instead of tangent space).
  53353. */
  53354. protected _useObjectSpaceNormalMap: boolean;
  53355. /**
  53356. * Allows using the bump map in parallax mode.
  53357. */
  53358. protected _useParallax: boolean;
  53359. /**
  53360. * Allows using the bump map in parallax occlusion mode.
  53361. */
  53362. protected _useParallaxOcclusion: boolean;
  53363. /**
  53364. * Controls the scale bias of the parallax mode.
  53365. */
  53366. protected _parallaxScaleBias: number;
  53367. /**
  53368. * If sets to true, disables all the lights affecting the material.
  53369. */
  53370. protected _disableLighting: boolean;
  53371. /**
  53372. * Number of Simultaneous lights allowed on the material.
  53373. */
  53374. protected _maxSimultaneousLights: number;
  53375. /**
  53376. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53377. */
  53378. protected _invertNormalMapX: boolean;
  53379. /**
  53380. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53381. */
  53382. protected _invertNormalMapY: boolean;
  53383. /**
  53384. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53385. */
  53386. protected _twoSidedLighting: boolean;
  53387. /**
  53388. * Defines the alpha limits in alpha test mode.
  53389. */
  53390. protected _alphaCutOff: number;
  53391. /**
  53392. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53393. */
  53394. protected _forceAlphaTest: boolean;
  53395. /**
  53396. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53397. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53398. */
  53399. protected _useAlphaFresnel: boolean;
  53400. /**
  53401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53402. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53403. */
  53404. protected _useLinearAlphaFresnel: boolean;
  53405. /**
  53406. * The transparency mode of the material.
  53407. */
  53408. protected _transparencyMode: Nullable<number>;
  53409. /**
  53410. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53411. * from cos thetav and roughness:
  53412. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53413. */
  53414. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53415. /**
  53416. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53417. */
  53418. protected _forceIrradianceInFragment: boolean;
  53419. /**
  53420. * Force normal to face away from face.
  53421. */
  53422. protected _forceNormalForward: boolean;
  53423. /**
  53424. * Enables specular anti aliasing in the PBR shader.
  53425. * It will both interacts on the Geometry for analytical and IBL lighting.
  53426. * It also prefilter the roughness map based on the bump values.
  53427. */
  53428. protected _enableSpecularAntiAliasing: boolean;
  53429. /**
  53430. * Default configuration related to image processing available in the PBR Material.
  53431. */
  53432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53433. /**
  53434. * Keep track of the image processing observer to allow dispose and replace.
  53435. */
  53436. private _imageProcessingObserver;
  53437. /**
  53438. * Attaches a new image processing configuration to the PBR Material.
  53439. * @param configuration
  53440. */
  53441. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53442. /**
  53443. * Stores the available render targets.
  53444. */
  53445. private _renderTargets;
  53446. /**
  53447. * Sets the global ambient color for the material used in lighting calculations.
  53448. */
  53449. private _globalAmbientColor;
  53450. /**
  53451. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53452. */
  53453. private _useLogarithmicDepth;
  53454. /**
  53455. * If set to true, no lighting calculations will be applied.
  53456. */
  53457. private _unlit;
  53458. private _debugMode;
  53459. /**
  53460. * @hidden
  53461. * This is reserved for the inspector.
  53462. * Defines the material debug mode.
  53463. * It helps seeing only some components of the material while troubleshooting.
  53464. */
  53465. debugMode: number;
  53466. /**
  53467. * @hidden
  53468. * This is reserved for the inspector.
  53469. * Specify from where on screen the debug mode should start.
  53470. * The value goes from -1 (full screen) to 1 (not visible)
  53471. * It helps with side by side comparison against the final render
  53472. * This defaults to -1
  53473. */
  53474. private debugLimit;
  53475. /**
  53476. * @hidden
  53477. * This is reserved for the inspector.
  53478. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53479. * You can use the factor to better multiply the final value.
  53480. */
  53481. private debugFactor;
  53482. /**
  53483. * Defines the clear coat layer parameters for the material.
  53484. */
  53485. readonly clearCoat: PBRClearCoatConfiguration;
  53486. /**
  53487. * Defines the anisotropic parameters for the material.
  53488. */
  53489. readonly anisotropy: PBRAnisotropicConfiguration;
  53490. /**
  53491. * Defines the BRDF parameters for the material.
  53492. */
  53493. readonly brdf: PBRBRDFConfiguration;
  53494. /**
  53495. * Defines the Sheen parameters for the material.
  53496. */
  53497. readonly sheen: PBRSheenConfiguration;
  53498. /**
  53499. * Defines the SubSurface parameters for the material.
  53500. */
  53501. readonly subSurface: PBRSubSurfaceConfiguration;
  53502. /**
  53503. * Custom callback helping to override the default shader used in the material.
  53504. */
  53505. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53506. protected _rebuildInParallel: boolean;
  53507. /**
  53508. * Instantiates a new PBRMaterial instance.
  53509. *
  53510. * @param name The material name
  53511. * @param scene The scene the material will be use in.
  53512. */
  53513. constructor(name: string, scene: Scene);
  53514. /**
  53515. * Gets a boolean indicating that current material needs to register RTT
  53516. */
  53517. get hasRenderTargetTextures(): boolean;
  53518. /**
  53519. * Gets the name of the material class.
  53520. */
  53521. getClassName(): string;
  53522. /**
  53523. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53524. */
  53525. get useLogarithmicDepth(): boolean;
  53526. /**
  53527. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53528. */
  53529. set useLogarithmicDepth(value: boolean);
  53530. /**
  53531. * Gets the current transparency mode.
  53532. */
  53533. get transparencyMode(): Nullable<number>;
  53534. /**
  53535. * Sets the transparency mode of the material.
  53536. *
  53537. * | Value | Type | Description |
  53538. * | ----- | ----------------------------------- | ----------- |
  53539. * | 0 | OPAQUE | |
  53540. * | 1 | ALPHATEST | |
  53541. * | 2 | ALPHABLEND | |
  53542. * | 3 | ALPHATESTANDBLEND | |
  53543. *
  53544. */
  53545. set transparencyMode(value: Nullable<number>);
  53546. /**
  53547. * Returns true if alpha blending should be disabled.
  53548. */
  53549. private get _disableAlphaBlending();
  53550. /**
  53551. * Specifies whether or not this material should be rendered in alpha blend mode.
  53552. */
  53553. needAlphaBlending(): boolean;
  53554. /**
  53555. * Specifies if the mesh will require alpha blending.
  53556. * @param mesh - BJS mesh.
  53557. */
  53558. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53559. /**
  53560. * Specifies whether or not this material should be rendered in alpha test mode.
  53561. */
  53562. needAlphaTesting(): boolean;
  53563. /**
  53564. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53565. */
  53566. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53567. /**
  53568. * Gets the texture used for the alpha test.
  53569. */
  53570. getAlphaTestTexture(): Nullable<BaseTexture>;
  53571. /**
  53572. * Specifies that the submesh is ready to be used.
  53573. * @param mesh - BJS mesh.
  53574. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53575. * @param useInstances - Specifies that instances should be used.
  53576. * @returns - boolean indicating that the submesh is ready or not.
  53577. */
  53578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53579. /**
  53580. * Specifies if the material uses metallic roughness workflow.
  53581. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53582. */
  53583. isMetallicWorkflow(): boolean;
  53584. private _prepareEffect;
  53585. private _prepareDefines;
  53586. /**
  53587. * Force shader compilation
  53588. */
  53589. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53590. /**
  53591. * Initializes the uniform buffer layout for the shader.
  53592. */
  53593. buildUniformLayout(): void;
  53594. /**
  53595. * Unbinds the material from the mesh
  53596. */
  53597. unbind(): void;
  53598. /**
  53599. * Binds the submesh data.
  53600. * @param world - The world matrix.
  53601. * @param mesh - The BJS mesh.
  53602. * @param subMesh - A submesh of the BJS mesh.
  53603. */
  53604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53605. /**
  53606. * Returns the animatable textures.
  53607. * @returns - Array of animatable textures.
  53608. */
  53609. getAnimatables(): IAnimatable[];
  53610. /**
  53611. * Returns the texture used for reflections.
  53612. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53613. */
  53614. private _getReflectionTexture;
  53615. /**
  53616. * Returns an array of the actively used textures.
  53617. * @returns - Array of BaseTextures
  53618. */
  53619. getActiveTextures(): BaseTexture[];
  53620. /**
  53621. * Checks to see if a texture is used in the material.
  53622. * @param texture - Base texture to use.
  53623. * @returns - Boolean specifying if a texture is used in the material.
  53624. */
  53625. hasTexture(texture: BaseTexture): boolean;
  53626. /**
  53627. * Disposes the resources of the material.
  53628. * @param forceDisposeEffect - Forces the disposal of effects.
  53629. * @param forceDisposeTextures - Forces the disposal of all textures.
  53630. */
  53631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53632. }
  53633. }
  53634. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53635. import { Nullable } from "babylonjs/types";
  53636. import { Scene } from "babylonjs/scene";
  53637. import { Color3 } from "babylonjs/Maths/math.color";
  53638. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53639. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53640. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53641. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53642. /**
  53643. * The Physically based material of BJS.
  53644. *
  53645. * This offers the main features of a standard PBR material.
  53646. * For more information, please refer to the documentation :
  53647. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53648. */
  53649. export class PBRMaterial extends PBRBaseMaterial {
  53650. /**
  53651. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53652. */
  53653. static readonly PBRMATERIAL_OPAQUE: number;
  53654. /**
  53655. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53656. */
  53657. static readonly PBRMATERIAL_ALPHATEST: number;
  53658. /**
  53659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53660. */
  53661. static readonly PBRMATERIAL_ALPHABLEND: number;
  53662. /**
  53663. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53664. * They are also discarded below the alpha cutoff threshold to improve performances.
  53665. */
  53666. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53667. /**
  53668. * Defines the default value of how much AO map is occluding the analytical lights
  53669. * (point spot...).
  53670. */
  53671. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53672. /**
  53673. * Intensity of the direct lights e.g. the four lights available in your scene.
  53674. * This impacts both the direct diffuse and specular highlights.
  53675. */
  53676. directIntensity: number;
  53677. /**
  53678. * Intensity of the emissive part of the material.
  53679. * This helps controlling the emissive effect without modifying the emissive color.
  53680. */
  53681. emissiveIntensity: number;
  53682. /**
  53683. * Intensity of the environment e.g. how much the environment will light the object
  53684. * either through harmonics for rough material or through the refelction for shiny ones.
  53685. */
  53686. environmentIntensity: number;
  53687. /**
  53688. * This is a special control allowing the reduction of the specular highlights coming from the
  53689. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53690. */
  53691. specularIntensity: number;
  53692. /**
  53693. * Debug Control allowing disabling the bump map on this material.
  53694. */
  53695. disableBumpMap: boolean;
  53696. /**
  53697. * AKA Diffuse Texture in standard nomenclature.
  53698. */
  53699. albedoTexture: BaseTexture;
  53700. /**
  53701. * AKA Occlusion Texture in other nomenclature.
  53702. */
  53703. ambientTexture: BaseTexture;
  53704. /**
  53705. * AKA Occlusion Texture Intensity in other nomenclature.
  53706. */
  53707. ambientTextureStrength: number;
  53708. /**
  53709. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53710. * 1 means it completely occludes it
  53711. * 0 mean it has no impact
  53712. */
  53713. ambientTextureImpactOnAnalyticalLights: number;
  53714. /**
  53715. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53716. */
  53717. opacityTexture: BaseTexture;
  53718. /**
  53719. * Stores the reflection values in a texture.
  53720. */
  53721. reflectionTexture: Nullable<BaseTexture>;
  53722. /**
  53723. * Stores the emissive values in a texture.
  53724. */
  53725. emissiveTexture: BaseTexture;
  53726. /**
  53727. * AKA Specular texture in other nomenclature.
  53728. */
  53729. reflectivityTexture: BaseTexture;
  53730. /**
  53731. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53732. */
  53733. metallicTexture: BaseTexture;
  53734. /**
  53735. * Specifies the metallic scalar of the metallic/roughness workflow.
  53736. * Can also be used to scale the metalness values of the metallic texture.
  53737. */
  53738. metallic: Nullable<number>;
  53739. /**
  53740. * Specifies the roughness scalar of the metallic/roughness workflow.
  53741. * Can also be used to scale the roughness values of the metallic texture.
  53742. */
  53743. roughness: Nullable<number>;
  53744. /**
  53745. * Specifies the an F0 factor to help configuring the material F0.
  53746. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53747. * to 0.5 the previously hard coded value stays the same.
  53748. * Can also be used to scale the F0 values of the metallic texture.
  53749. */
  53750. metallicF0Factor: number;
  53751. /**
  53752. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53753. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53754. * your expectation as it multiplies with the texture data.
  53755. */
  53756. useMetallicF0FactorFromMetallicTexture: boolean;
  53757. /**
  53758. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53759. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53760. */
  53761. microSurfaceTexture: BaseTexture;
  53762. /**
  53763. * Stores surface normal data used to displace a mesh in a texture.
  53764. */
  53765. bumpTexture: BaseTexture;
  53766. /**
  53767. * Stores the pre-calculated light information of a mesh in a texture.
  53768. */
  53769. lightmapTexture: BaseTexture;
  53770. /**
  53771. * Stores the refracted light information in a texture.
  53772. */
  53773. get refractionTexture(): Nullable<BaseTexture>;
  53774. set refractionTexture(value: Nullable<BaseTexture>);
  53775. /**
  53776. * The color of a material in ambient lighting.
  53777. */
  53778. ambientColor: Color3;
  53779. /**
  53780. * AKA Diffuse Color in other nomenclature.
  53781. */
  53782. albedoColor: Color3;
  53783. /**
  53784. * AKA Specular Color in other nomenclature.
  53785. */
  53786. reflectivityColor: Color3;
  53787. /**
  53788. * The color reflected from the material.
  53789. */
  53790. reflectionColor: Color3;
  53791. /**
  53792. * The color emitted from the material.
  53793. */
  53794. emissiveColor: Color3;
  53795. /**
  53796. * AKA Glossiness in other nomenclature.
  53797. */
  53798. microSurface: number;
  53799. /**
  53800. * source material index of refraction (IOR)' / 'destination material IOR.
  53801. */
  53802. get indexOfRefraction(): number;
  53803. set indexOfRefraction(value: number);
  53804. /**
  53805. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53806. */
  53807. get invertRefractionY(): boolean;
  53808. set invertRefractionY(value: boolean);
  53809. /**
  53810. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53811. * Materials half opaque for instance using refraction could benefit from this control.
  53812. */
  53813. get linkRefractionWithTransparency(): boolean;
  53814. set linkRefractionWithTransparency(value: boolean);
  53815. /**
  53816. * If true, the light map contains occlusion information instead of lighting info.
  53817. */
  53818. useLightmapAsShadowmap: boolean;
  53819. /**
  53820. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53821. */
  53822. useAlphaFromAlbedoTexture: boolean;
  53823. /**
  53824. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53825. */
  53826. forceAlphaTest: boolean;
  53827. /**
  53828. * Defines the alpha limits in alpha test mode.
  53829. */
  53830. alphaCutOff: number;
  53831. /**
  53832. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53833. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53834. */
  53835. useSpecularOverAlpha: boolean;
  53836. /**
  53837. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53838. */
  53839. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53840. /**
  53841. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53842. */
  53843. useRoughnessFromMetallicTextureAlpha: boolean;
  53844. /**
  53845. * Specifies if the metallic texture contains the roughness information in its green channel.
  53846. */
  53847. useRoughnessFromMetallicTextureGreen: boolean;
  53848. /**
  53849. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53850. */
  53851. useMetallnessFromMetallicTextureBlue: boolean;
  53852. /**
  53853. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53854. */
  53855. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53856. /**
  53857. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53858. */
  53859. useAmbientInGrayScale: boolean;
  53860. /**
  53861. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53862. * The material will try to infer what glossiness each pixel should be.
  53863. */
  53864. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53865. /**
  53866. * BJS is using an harcoded light falloff based on a manually sets up range.
  53867. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53868. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53869. */
  53870. get usePhysicalLightFalloff(): boolean;
  53871. /**
  53872. * BJS is using an harcoded light falloff based on a manually sets up range.
  53873. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53874. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53875. */
  53876. set usePhysicalLightFalloff(value: boolean);
  53877. /**
  53878. * In order to support the falloff compatibility with gltf, a special mode has been added
  53879. * to reproduce the gltf light falloff.
  53880. */
  53881. get useGLTFLightFalloff(): boolean;
  53882. /**
  53883. * In order to support the falloff compatibility with gltf, a special mode has been added
  53884. * to reproduce the gltf light falloff.
  53885. */
  53886. set useGLTFLightFalloff(value: boolean);
  53887. /**
  53888. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53889. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53890. */
  53891. useRadianceOverAlpha: boolean;
  53892. /**
  53893. * Allows using an object space normal map (instead of tangent space).
  53894. */
  53895. useObjectSpaceNormalMap: boolean;
  53896. /**
  53897. * Allows using the bump map in parallax mode.
  53898. */
  53899. useParallax: boolean;
  53900. /**
  53901. * Allows using the bump map in parallax occlusion mode.
  53902. */
  53903. useParallaxOcclusion: boolean;
  53904. /**
  53905. * Controls the scale bias of the parallax mode.
  53906. */
  53907. parallaxScaleBias: number;
  53908. /**
  53909. * If sets to true, disables all the lights affecting the material.
  53910. */
  53911. disableLighting: boolean;
  53912. /**
  53913. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53914. */
  53915. forceIrradianceInFragment: boolean;
  53916. /**
  53917. * Number of Simultaneous lights allowed on the material.
  53918. */
  53919. maxSimultaneousLights: number;
  53920. /**
  53921. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53922. */
  53923. invertNormalMapX: boolean;
  53924. /**
  53925. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53926. */
  53927. invertNormalMapY: boolean;
  53928. /**
  53929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53930. */
  53931. twoSidedLighting: boolean;
  53932. /**
  53933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53934. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53935. */
  53936. useAlphaFresnel: boolean;
  53937. /**
  53938. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53939. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53940. */
  53941. useLinearAlphaFresnel: boolean;
  53942. /**
  53943. * Let user defines the brdf lookup texture used for IBL.
  53944. * A default 8bit version is embedded but you could point at :
  53945. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53946. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53947. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53948. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53949. */
  53950. environmentBRDFTexture: Nullable<BaseTexture>;
  53951. /**
  53952. * Force normal to face away from face.
  53953. */
  53954. forceNormalForward: boolean;
  53955. /**
  53956. * Enables specular anti aliasing in the PBR shader.
  53957. * It will both interacts on the Geometry for analytical and IBL lighting.
  53958. * It also prefilter the roughness map based on the bump values.
  53959. */
  53960. enableSpecularAntiAliasing: boolean;
  53961. /**
  53962. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53963. * makes the reflect vector face the model (under horizon).
  53964. */
  53965. useHorizonOcclusion: boolean;
  53966. /**
  53967. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53968. * too much the area relying on ambient texture to define their ambient occlusion.
  53969. */
  53970. useRadianceOcclusion: boolean;
  53971. /**
  53972. * If set to true, no lighting calculations will be applied.
  53973. */
  53974. unlit: boolean;
  53975. /**
  53976. * Gets the image processing configuration used either in this material.
  53977. */
  53978. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53979. /**
  53980. * Sets the Default image processing configuration used either in the this material.
  53981. *
  53982. * If sets to null, the scene one is in use.
  53983. */
  53984. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53985. /**
  53986. * Gets wether the color curves effect is enabled.
  53987. */
  53988. get cameraColorCurvesEnabled(): boolean;
  53989. /**
  53990. * Sets wether the color curves effect is enabled.
  53991. */
  53992. set cameraColorCurvesEnabled(value: boolean);
  53993. /**
  53994. * Gets wether the color grading effect is enabled.
  53995. */
  53996. get cameraColorGradingEnabled(): boolean;
  53997. /**
  53998. * Gets wether the color grading effect is enabled.
  53999. */
  54000. set cameraColorGradingEnabled(value: boolean);
  54001. /**
  54002. * Gets wether tonemapping is enabled or not.
  54003. */
  54004. get cameraToneMappingEnabled(): boolean;
  54005. /**
  54006. * Sets wether tonemapping is enabled or not
  54007. */
  54008. set cameraToneMappingEnabled(value: boolean);
  54009. /**
  54010. * The camera exposure used on this material.
  54011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54012. * This corresponds to a photographic exposure.
  54013. */
  54014. get cameraExposure(): number;
  54015. /**
  54016. * The camera exposure used on this material.
  54017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54018. * This corresponds to a photographic exposure.
  54019. */
  54020. set cameraExposure(value: number);
  54021. /**
  54022. * Gets The camera contrast used on this material.
  54023. */
  54024. get cameraContrast(): number;
  54025. /**
  54026. * Sets The camera contrast used on this material.
  54027. */
  54028. set cameraContrast(value: number);
  54029. /**
  54030. * Gets the Color Grading 2D Lookup Texture.
  54031. */
  54032. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54033. /**
  54034. * Sets the Color Grading 2D Lookup Texture.
  54035. */
  54036. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54037. /**
  54038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54040. * 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;
  54041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54042. */
  54043. get cameraColorCurves(): Nullable<ColorCurves>;
  54044. /**
  54045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54047. * 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;
  54048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54049. */
  54050. set cameraColorCurves(value: Nullable<ColorCurves>);
  54051. /**
  54052. * Instantiates a new PBRMaterial instance.
  54053. *
  54054. * @param name The material name
  54055. * @param scene The scene the material will be use in.
  54056. */
  54057. constructor(name: string, scene: Scene);
  54058. /**
  54059. * Returns the name of this material class.
  54060. */
  54061. getClassName(): string;
  54062. /**
  54063. * Makes a duplicate of the current material.
  54064. * @param name - name to use for the new material.
  54065. */
  54066. clone(name: string): PBRMaterial;
  54067. /**
  54068. * Serializes this PBR Material.
  54069. * @returns - An object with the serialized material.
  54070. */
  54071. serialize(): any;
  54072. /**
  54073. * Parses a PBR Material from a serialized object.
  54074. * @param source - Serialized object.
  54075. * @param scene - BJS scene instance.
  54076. * @param rootUrl - url for the scene object
  54077. * @returns - PBRMaterial
  54078. */
  54079. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54080. }
  54081. }
  54082. declare module "babylonjs/Misc/dds" {
  54083. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54085. import { Nullable } from "babylonjs/types";
  54086. import { Scene } from "babylonjs/scene";
  54087. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54088. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54089. /**
  54090. * Direct draw surface info
  54091. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54092. */
  54093. export interface DDSInfo {
  54094. /**
  54095. * Width of the texture
  54096. */
  54097. width: number;
  54098. /**
  54099. * Width of the texture
  54100. */
  54101. height: number;
  54102. /**
  54103. * Number of Mipmaps for the texture
  54104. * @see https://en.wikipedia.org/wiki/Mipmap
  54105. */
  54106. mipmapCount: number;
  54107. /**
  54108. * If the textures format is a known fourCC format
  54109. * @see https://www.fourcc.org/
  54110. */
  54111. isFourCC: boolean;
  54112. /**
  54113. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54114. */
  54115. isRGB: boolean;
  54116. /**
  54117. * If the texture is a lumincance format
  54118. */
  54119. isLuminance: boolean;
  54120. /**
  54121. * If this is a cube texture
  54122. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54123. */
  54124. isCube: boolean;
  54125. /**
  54126. * If the texture is a compressed format eg. FOURCC_DXT1
  54127. */
  54128. isCompressed: boolean;
  54129. /**
  54130. * The dxgiFormat of the texture
  54131. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54132. */
  54133. dxgiFormat: number;
  54134. /**
  54135. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54136. */
  54137. textureType: number;
  54138. /**
  54139. * Sphericle polynomial created for the dds texture
  54140. */
  54141. sphericalPolynomial?: SphericalPolynomial;
  54142. }
  54143. /**
  54144. * Class used to provide DDS decompression tools
  54145. */
  54146. export class DDSTools {
  54147. /**
  54148. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54149. */
  54150. static StoreLODInAlphaChannel: boolean;
  54151. /**
  54152. * Gets DDS information from an array buffer
  54153. * @param data defines the array buffer view to read data from
  54154. * @returns the DDS information
  54155. */
  54156. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54157. private static _FloatView;
  54158. private static _Int32View;
  54159. private static _ToHalfFloat;
  54160. private static _FromHalfFloat;
  54161. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54162. private static _GetHalfFloatRGBAArrayBuffer;
  54163. private static _GetFloatRGBAArrayBuffer;
  54164. private static _GetFloatAsUIntRGBAArrayBuffer;
  54165. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54166. private static _GetRGBAArrayBuffer;
  54167. private static _ExtractLongWordOrder;
  54168. private static _GetRGBArrayBuffer;
  54169. private static _GetLuminanceArrayBuffer;
  54170. /**
  54171. * Uploads DDS Levels to a Babylon Texture
  54172. * @hidden
  54173. */
  54174. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54175. }
  54176. module "babylonjs/Engines/thinEngine" {
  54177. interface ThinEngine {
  54178. /**
  54179. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54180. * @param rootUrl defines the url where the file to load is located
  54181. * @param scene defines the current scene
  54182. * @param lodScale defines scale to apply to the mip map selection
  54183. * @param lodOffset defines offset to apply to the mip map selection
  54184. * @param onLoad defines an optional callback raised when the texture is loaded
  54185. * @param onError defines an optional callback raised if there is an issue to load the texture
  54186. * @param format defines the format of the data
  54187. * @param forcedExtension defines the extension to use to pick the right loader
  54188. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54189. * @returns the cube texture as an InternalTexture
  54190. */
  54191. 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;
  54192. }
  54193. }
  54194. }
  54195. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54196. import { Nullable } from "babylonjs/types";
  54197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54198. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54199. /**
  54200. * Implementation of the DDS Texture Loader.
  54201. * @hidden
  54202. */
  54203. export class _DDSTextureLoader implements IInternalTextureLoader {
  54204. /**
  54205. * Defines wether the loader supports cascade loading the different faces.
  54206. */
  54207. readonly supportCascades: boolean;
  54208. /**
  54209. * This returns if the loader support the current file information.
  54210. * @param extension defines the file extension of the file being loaded
  54211. * @returns true if the loader can load the specified file
  54212. */
  54213. canLoad(extension: string): boolean;
  54214. /**
  54215. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54216. * @param data contains the texture data
  54217. * @param texture defines the BabylonJS internal texture
  54218. * @param createPolynomials will be true if polynomials have been requested
  54219. * @param onLoad defines the callback to trigger once the texture is ready
  54220. * @param onError defines the callback to trigger in case of error
  54221. */
  54222. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54223. /**
  54224. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54225. * @param data contains the texture data
  54226. * @param texture defines the BabylonJS internal texture
  54227. * @param callback defines the method to call once ready to upload
  54228. */
  54229. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54230. }
  54231. }
  54232. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54233. import { Nullable } from "babylonjs/types";
  54234. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54235. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54236. /**
  54237. * Implementation of the ENV Texture Loader.
  54238. * @hidden
  54239. */
  54240. export class _ENVTextureLoader implements IInternalTextureLoader {
  54241. /**
  54242. * Defines wether the loader supports cascade loading the different faces.
  54243. */
  54244. readonly supportCascades: boolean;
  54245. /**
  54246. * This returns if the loader support the current file information.
  54247. * @param extension defines the file extension of the file being loaded
  54248. * @returns true if the loader can load the specified file
  54249. */
  54250. canLoad(extension: string): boolean;
  54251. /**
  54252. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54253. * @param data contains the texture data
  54254. * @param texture defines the BabylonJS internal texture
  54255. * @param createPolynomials will be true if polynomials have been requested
  54256. * @param onLoad defines the callback to trigger once the texture is ready
  54257. * @param onError defines the callback to trigger in case of error
  54258. */
  54259. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54260. /**
  54261. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54262. * @param data contains the texture data
  54263. * @param texture defines the BabylonJS internal texture
  54264. * @param callback defines the method to call once ready to upload
  54265. */
  54266. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54267. }
  54268. }
  54269. declare module "babylonjs/Misc/khronosTextureContainer" {
  54270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54271. /**
  54272. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54273. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54274. */
  54275. export class KhronosTextureContainer {
  54276. /** contents of the KTX container file */
  54277. data: ArrayBufferView;
  54278. private static HEADER_LEN;
  54279. private static COMPRESSED_2D;
  54280. private static COMPRESSED_3D;
  54281. private static TEX_2D;
  54282. private static TEX_3D;
  54283. /**
  54284. * Gets the openGL type
  54285. */
  54286. glType: number;
  54287. /**
  54288. * Gets the openGL type size
  54289. */
  54290. glTypeSize: number;
  54291. /**
  54292. * Gets the openGL format
  54293. */
  54294. glFormat: number;
  54295. /**
  54296. * Gets the openGL internal format
  54297. */
  54298. glInternalFormat: number;
  54299. /**
  54300. * Gets the base internal format
  54301. */
  54302. glBaseInternalFormat: number;
  54303. /**
  54304. * Gets image width in pixel
  54305. */
  54306. pixelWidth: number;
  54307. /**
  54308. * Gets image height in pixel
  54309. */
  54310. pixelHeight: number;
  54311. /**
  54312. * Gets image depth in pixels
  54313. */
  54314. pixelDepth: number;
  54315. /**
  54316. * Gets the number of array elements
  54317. */
  54318. numberOfArrayElements: number;
  54319. /**
  54320. * Gets the number of faces
  54321. */
  54322. numberOfFaces: number;
  54323. /**
  54324. * Gets the number of mipmap levels
  54325. */
  54326. numberOfMipmapLevels: number;
  54327. /**
  54328. * Gets the bytes of key value data
  54329. */
  54330. bytesOfKeyValueData: number;
  54331. /**
  54332. * Gets the load type
  54333. */
  54334. loadType: number;
  54335. /**
  54336. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54337. */
  54338. isInvalid: boolean;
  54339. /**
  54340. * Creates a new KhronosTextureContainer
  54341. * @param data contents of the KTX container file
  54342. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54343. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54344. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54345. */
  54346. constructor(
  54347. /** contents of the KTX container file */
  54348. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54349. /**
  54350. * Uploads KTX content to a Babylon Texture.
  54351. * It is assumed that the texture has already been created & is currently bound
  54352. * @hidden
  54353. */
  54354. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54355. private _upload2DCompressedLevels;
  54356. /**
  54357. * Checks if the given data starts with a KTX file identifier.
  54358. * @param data the data to check
  54359. * @returns true if the data is a KTX file or false otherwise
  54360. */
  54361. static IsValid(data: ArrayBufferView): boolean;
  54362. }
  54363. }
  54364. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54367. /**
  54368. * Class for loading KTX2 files
  54369. * !!! Experimental Extension Subject to Changes !!!
  54370. * @hidden
  54371. */
  54372. export class KhronosTextureContainer2 {
  54373. private static _ModulePromise;
  54374. private static _TranscodeFormat;
  54375. constructor(engine: ThinEngine);
  54376. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54377. private _determineTranscodeFormat;
  54378. /**
  54379. * Checks if the given data starts with a KTX2 file identifier.
  54380. * @param data the data to check
  54381. * @returns true if the data is a KTX2 file or false otherwise
  54382. */
  54383. static IsValid(data: ArrayBufferView): boolean;
  54384. }
  54385. }
  54386. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54387. import { Nullable } from "babylonjs/types";
  54388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54389. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54390. /**
  54391. * Implementation of the KTX Texture Loader.
  54392. * @hidden
  54393. */
  54394. export class _KTXTextureLoader implements IInternalTextureLoader {
  54395. /**
  54396. * Defines wether the loader supports cascade loading the different faces.
  54397. */
  54398. readonly supportCascades: boolean;
  54399. /**
  54400. * This returns if the loader support the current file information.
  54401. * @param extension defines the file extension of the file being loaded
  54402. * @returns true if the loader can load the specified file
  54403. */
  54404. canLoad(extension: string): boolean;
  54405. /**
  54406. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54407. * @param data contains the texture data
  54408. * @param texture defines the BabylonJS internal texture
  54409. * @param createPolynomials will be true if polynomials have been requested
  54410. * @param onLoad defines the callback to trigger once the texture is ready
  54411. * @param onError defines the callback to trigger in case of error
  54412. */
  54413. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54414. /**
  54415. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54416. * @param data contains the texture data
  54417. * @param texture defines the BabylonJS internal texture
  54418. * @param callback defines the method to call once ready to upload
  54419. */
  54420. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54421. }
  54422. }
  54423. declare module "babylonjs/Helpers/sceneHelpers" {
  54424. import { Nullable } from "babylonjs/types";
  54425. import { Mesh } from "babylonjs/Meshes/mesh";
  54426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54427. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54428. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54429. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54430. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54431. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54432. import "babylonjs/Meshes/Builders/boxBuilder";
  54433. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54434. /** @hidden */
  54435. export var _forceSceneHelpersToBundle: boolean;
  54436. module "babylonjs/scene" {
  54437. interface Scene {
  54438. /**
  54439. * Creates a default light for the scene.
  54440. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54441. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54442. */
  54443. createDefaultLight(replace?: boolean): void;
  54444. /**
  54445. * Creates a default camera for the scene.
  54446. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54447. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54448. * @param replace has default false, when true replaces the active camera in the scene
  54449. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54450. */
  54451. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54452. /**
  54453. * Creates a default camera and a default light.
  54454. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54455. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54456. * @param replace has the default false, when true replaces the active camera/light in the scene
  54457. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54458. */
  54459. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54460. /**
  54461. * Creates a new sky box
  54462. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54463. * @param environmentTexture defines the texture to use as environment texture
  54464. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54465. * @param scale defines the overall scale of the skybox
  54466. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54467. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54468. * @returns a new mesh holding the sky box
  54469. */
  54470. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54471. /**
  54472. * Creates a new environment
  54473. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54474. * @param options defines the options you can use to configure the environment
  54475. * @returns the new EnvironmentHelper
  54476. */
  54477. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54478. /**
  54479. * Creates a new VREXperienceHelper
  54480. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54481. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54482. * @returns a new VREXperienceHelper
  54483. */
  54484. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54485. /**
  54486. * Creates a new WebXRDefaultExperience
  54487. * @see http://doc.babylonjs.com/how_to/webxr
  54488. * @param options experience options
  54489. * @returns a promise for a new WebXRDefaultExperience
  54490. */
  54491. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54492. }
  54493. }
  54494. }
  54495. declare module "babylonjs/Helpers/videoDome" {
  54496. import { Scene } from "babylonjs/scene";
  54497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54498. import { Mesh } from "babylonjs/Meshes/mesh";
  54499. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54500. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54501. import "babylonjs/Meshes/Builders/sphereBuilder";
  54502. /**
  54503. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54504. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54505. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54506. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54507. */
  54508. export class VideoDome extends TransformNode {
  54509. /**
  54510. * Define the video source as a Monoscopic panoramic 360 video.
  54511. */
  54512. static readonly MODE_MONOSCOPIC: number;
  54513. /**
  54514. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54515. */
  54516. static readonly MODE_TOPBOTTOM: number;
  54517. /**
  54518. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54519. */
  54520. static readonly MODE_SIDEBYSIDE: number;
  54521. private _halfDome;
  54522. private _useDirectMapping;
  54523. /**
  54524. * The video texture being displayed on the sphere
  54525. */
  54526. protected _videoTexture: VideoTexture;
  54527. /**
  54528. * Gets the video texture being displayed on the sphere
  54529. */
  54530. get videoTexture(): VideoTexture;
  54531. /**
  54532. * The skybox material
  54533. */
  54534. protected _material: BackgroundMaterial;
  54535. /**
  54536. * The surface used for the skybox
  54537. */
  54538. protected _mesh: Mesh;
  54539. /**
  54540. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54541. */
  54542. private _halfDomeMask;
  54543. /**
  54544. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54545. * Also see the options.resolution property.
  54546. */
  54547. get fovMultiplier(): number;
  54548. set fovMultiplier(value: number);
  54549. private _videoMode;
  54550. /**
  54551. * Gets or set the current video mode for the video. It can be:
  54552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54555. */
  54556. get videoMode(): number;
  54557. set videoMode(value: number);
  54558. /**
  54559. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54560. *
  54561. */
  54562. get halfDome(): boolean;
  54563. /**
  54564. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54565. */
  54566. set halfDome(enabled: boolean);
  54567. /**
  54568. * Oberserver used in Stereoscopic VR Mode.
  54569. */
  54570. private _onBeforeCameraRenderObserver;
  54571. /**
  54572. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54573. * @param name Element's name, child elements will append suffixes for their own names.
  54574. * @param urlsOrVideo defines the url(s) or the video element to use
  54575. * @param options An object containing optional or exposed sub element properties
  54576. */
  54577. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54578. resolution?: number;
  54579. clickToPlay?: boolean;
  54580. autoPlay?: boolean;
  54581. loop?: boolean;
  54582. size?: number;
  54583. poster?: string;
  54584. faceForward?: boolean;
  54585. useDirectMapping?: boolean;
  54586. halfDomeMode?: boolean;
  54587. }, scene: Scene);
  54588. private _changeVideoMode;
  54589. /**
  54590. * Releases resources associated with this node.
  54591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54593. */
  54594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54595. }
  54596. }
  54597. declare module "babylonjs/Helpers/index" {
  54598. export * from "babylonjs/Helpers/environmentHelper";
  54599. export * from "babylonjs/Helpers/photoDome";
  54600. export * from "babylonjs/Helpers/sceneHelpers";
  54601. export * from "babylonjs/Helpers/videoDome";
  54602. }
  54603. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54604. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54605. import { IDisposable } from "babylonjs/scene";
  54606. import { Engine } from "babylonjs/Engines/engine";
  54607. /**
  54608. * This class can be used to get instrumentation data from a Babylon engine
  54609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54610. */
  54611. export class EngineInstrumentation implements IDisposable {
  54612. /**
  54613. * Define the instrumented engine.
  54614. */
  54615. engine: Engine;
  54616. private _captureGPUFrameTime;
  54617. private _gpuFrameTimeToken;
  54618. private _gpuFrameTime;
  54619. private _captureShaderCompilationTime;
  54620. private _shaderCompilationTime;
  54621. private _onBeginFrameObserver;
  54622. private _onEndFrameObserver;
  54623. private _onBeforeShaderCompilationObserver;
  54624. private _onAfterShaderCompilationObserver;
  54625. /**
  54626. * Gets the perf counter used for GPU frame time
  54627. */
  54628. get gpuFrameTimeCounter(): PerfCounter;
  54629. /**
  54630. * Gets the GPU frame time capture status
  54631. */
  54632. get captureGPUFrameTime(): boolean;
  54633. /**
  54634. * Enable or disable the GPU frame time capture
  54635. */
  54636. set captureGPUFrameTime(value: boolean);
  54637. /**
  54638. * Gets the perf counter used for shader compilation time
  54639. */
  54640. get shaderCompilationTimeCounter(): PerfCounter;
  54641. /**
  54642. * Gets the shader compilation time capture status
  54643. */
  54644. get captureShaderCompilationTime(): boolean;
  54645. /**
  54646. * Enable or disable the shader compilation time capture
  54647. */
  54648. set captureShaderCompilationTime(value: boolean);
  54649. /**
  54650. * Instantiates a new engine instrumentation.
  54651. * This class can be used to get instrumentation data from a Babylon engine
  54652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54653. * @param engine Defines the engine to instrument
  54654. */
  54655. constructor(
  54656. /**
  54657. * Define the instrumented engine.
  54658. */
  54659. engine: Engine);
  54660. /**
  54661. * Dispose and release associated resources.
  54662. */
  54663. dispose(): void;
  54664. }
  54665. }
  54666. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54667. import { Scene, IDisposable } from "babylonjs/scene";
  54668. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54669. /**
  54670. * This class can be used to get instrumentation data from a Babylon engine
  54671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54672. */
  54673. export class SceneInstrumentation implements IDisposable {
  54674. /**
  54675. * Defines the scene to instrument
  54676. */
  54677. scene: Scene;
  54678. private _captureActiveMeshesEvaluationTime;
  54679. private _activeMeshesEvaluationTime;
  54680. private _captureRenderTargetsRenderTime;
  54681. private _renderTargetsRenderTime;
  54682. private _captureFrameTime;
  54683. private _frameTime;
  54684. private _captureRenderTime;
  54685. private _renderTime;
  54686. private _captureInterFrameTime;
  54687. private _interFrameTime;
  54688. private _captureParticlesRenderTime;
  54689. private _particlesRenderTime;
  54690. private _captureSpritesRenderTime;
  54691. private _spritesRenderTime;
  54692. private _capturePhysicsTime;
  54693. private _physicsTime;
  54694. private _captureAnimationsTime;
  54695. private _animationsTime;
  54696. private _captureCameraRenderTime;
  54697. private _cameraRenderTime;
  54698. private _onBeforeActiveMeshesEvaluationObserver;
  54699. private _onAfterActiveMeshesEvaluationObserver;
  54700. private _onBeforeRenderTargetsRenderObserver;
  54701. private _onAfterRenderTargetsRenderObserver;
  54702. private _onAfterRenderObserver;
  54703. private _onBeforeDrawPhaseObserver;
  54704. private _onAfterDrawPhaseObserver;
  54705. private _onBeforeAnimationsObserver;
  54706. private _onBeforeParticlesRenderingObserver;
  54707. private _onAfterParticlesRenderingObserver;
  54708. private _onBeforeSpritesRenderingObserver;
  54709. private _onAfterSpritesRenderingObserver;
  54710. private _onBeforePhysicsObserver;
  54711. private _onAfterPhysicsObserver;
  54712. private _onAfterAnimationsObserver;
  54713. private _onBeforeCameraRenderObserver;
  54714. private _onAfterCameraRenderObserver;
  54715. /**
  54716. * Gets the perf counter used for active meshes evaluation time
  54717. */
  54718. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54719. /**
  54720. * Gets the active meshes evaluation time capture status
  54721. */
  54722. get captureActiveMeshesEvaluationTime(): boolean;
  54723. /**
  54724. * Enable or disable the active meshes evaluation time capture
  54725. */
  54726. set captureActiveMeshesEvaluationTime(value: boolean);
  54727. /**
  54728. * Gets the perf counter used for render targets render time
  54729. */
  54730. get renderTargetsRenderTimeCounter(): PerfCounter;
  54731. /**
  54732. * Gets the render targets render time capture status
  54733. */
  54734. get captureRenderTargetsRenderTime(): boolean;
  54735. /**
  54736. * Enable or disable the render targets render time capture
  54737. */
  54738. set captureRenderTargetsRenderTime(value: boolean);
  54739. /**
  54740. * Gets the perf counter used for particles render time
  54741. */
  54742. get particlesRenderTimeCounter(): PerfCounter;
  54743. /**
  54744. * Gets the particles render time capture status
  54745. */
  54746. get captureParticlesRenderTime(): boolean;
  54747. /**
  54748. * Enable or disable the particles render time capture
  54749. */
  54750. set captureParticlesRenderTime(value: boolean);
  54751. /**
  54752. * Gets the perf counter used for sprites render time
  54753. */
  54754. get spritesRenderTimeCounter(): PerfCounter;
  54755. /**
  54756. * Gets the sprites render time capture status
  54757. */
  54758. get captureSpritesRenderTime(): boolean;
  54759. /**
  54760. * Enable or disable the sprites render time capture
  54761. */
  54762. set captureSpritesRenderTime(value: boolean);
  54763. /**
  54764. * Gets the perf counter used for physics time
  54765. */
  54766. get physicsTimeCounter(): PerfCounter;
  54767. /**
  54768. * Gets the physics time capture status
  54769. */
  54770. get capturePhysicsTime(): boolean;
  54771. /**
  54772. * Enable or disable the physics time capture
  54773. */
  54774. set capturePhysicsTime(value: boolean);
  54775. /**
  54776. * Gets the perf counter used for animations time
  54777. */
  54778. get animationsTimeCounter(): PerfCounter;
  54779. /**
  54780. * Gets the animations time capture status
  54781. */
  54782. get captureAnimationsTime(): boolean;
  54783. /**
  54784. * Enable or disable the animations time capture
  54785. */
  54786. set captureAnimationsTime(value: boolean);
  54787. /**
  54788. * Gets the perf counter used for frame time capture
  54789. */
  54790. get frameTimeCounter(): PerfCounter;
  54791. /**
  54792. * Gets the frame time capture status
  54793. */
  54794. get captureFrameTime(): boolean;
  54795. /**
  54796. * Enable or disable the frame time capture
  54797. */
  54798. set captureFrameTime(value: boolean);
  54799. /**
  54800. * Gets the perf counter used for inter-frames time capture
  54801. */
  54802. get interFrameTimeCounter(): PerfCounter;
  54803. /**
  54804. * Gets the inter-frames time capture status
  54805. */
  54806. get captureInterFrameTime(): boolean;
  54807. /**
  54808. * Enable or disable the inter-frames time capture
  54809. */
  54810. set captureInterFrameTime(value: boolean);
  54811. /**
  54812. * Gets the perf counter used for render time capture
  54813. */
  54814. get renderTimeCounter(): PerfCounter;
  54815. /**
  54816. * Gets the render time capture status
  54817. */
  54818. get captureRenderTime(): boolean;
  54819. /**
  54820. * Enable or disable the render time capture
  54821. */
  54822. set captureRenderTime(value: boolean);
  54823. /**
  54824. * Gets the perf counter used for camera render time capture
  54825. */
  54826. get cameraRenderTimeCounter(): PerfCounter;
  54827. /**
  54828. * Gets the camera render time capture status
  54829. */
  54830. get captureCameraRenderTime(): boolean;
  54831. /**
  54832. * Enable or disable the camera render time capture
  54833. */
  54834. set captureCameraRenderTime(value: boolean);
  54835. /**
  54836. * Gets the perf counter used for draw calls
  54837. */
  54838. get drawCallsCounter(): PerfCounter;
  54839. /**
  54840. * Instantiates a new scene instrumentation.
  54841. * This class can be used to get instrumentation data from a Babylon engine
  54842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54843. * @param scene Defines the scene to instrument
  54844. */
  54845. constructor(
  54846. /**
  54847. * Defines the scene to instrument
  54848. */
  54849. scene: Scene);
  54850. /**
  54851. * Dispose and release associated resources.
  54852. */
  54853. dispose(): void;
  54854. }
  54855. }
  54856. declare module "babylonjs/Instrumentation/index" {
  54857. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54858. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54859. export * from "babylonjs/Instrumentation/timeToken";
  54860. }
  54861. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54862. /** @hidden */
  54863. export var glowMapGenerationPixelShader: {
  54864. name: string;
  54865. shader: string;
  54866. };
  54867. }
  54868. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54869. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54870. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54871. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54872. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54873. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54874. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54875. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54876. /** @hidden */
  54877. export var glowMapGenerationVertexShader: {
  54878. name: string;
  54879. shader: string;
  54880. };
  54881. }
  54882. declare module "babylonjs/Layers/effectLayer" {
  54883. import { Observable } from "babylonjs/Misc/observable";
  54884. import { Nullable } from "babylonjs/types";
  54885. import { Camera } from "babylonjs/Cameras/camera";
  54886. import { Scene } from "babylonjs/scene";
  54887. import { ISize } from "babylonjs/Maths/math.size";
  54888. import { Color4 } from "babylonjs/Maths/math.color";
  54889. import { Engine } from "babylonjs/Engines/engine";
  54890. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54892. import { Mesh } from "babylonjs/Meshes/mesh";
  54893. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54896. import { Effect } from "babylonjs/Materials/effect";
  54897. import { Material } from "babylonjs/Materials/material";
  54898. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54899. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54900. /**
  54901. * Effect layer options. This helps customizing the behaviour
  54902. * of the effect layer.
  54903. */
  54904. export interface IEffectLayerOptions {
  54905. /**
  54906. * Multiplication factor apply to the canvas size to compute the render target size
  54907. * used to generated the objects (the smaller the faster).
  54908. */
  54909. mainTextureRatio: number;
  54910. /**
  54911. * Enforces a fixed size texture to ensure effect stability across devices.
  54912. */
  54913. mainTextureFixedSize?: number;
  54914. /**
  54915. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54916. */
  54917. alphaBlendingMode: number;
  54918. /**
  54919. * The camera attached to the layer.
  54920. */
  54921. camera: Nullable<Camera>;
  54922. /**
  54923. * The rendering group to draw the layer in.
  54924. */
  54925. renderingGroupId: number;
  54926. }
  54927. /**
  54928. * The effect layer Helps adding post process effect blended with the main pass.
  54929. *
  54930. * This can be for instance use to generate glow or higlight effects on the scene.
  54931. *
  54932. * The effect layer class can not be used directly and is intented to inherited from to be
  54933. * customized per effects.
  54934. */
  54935. export abstract class EffectLayer {
  54936. private _vertexBuffers;
  54937. private _indexBuffer;
  54938. private _cachedDefines;
  54939. private _effectLayerMapGenerationEffect;
  54940. private _effectLayerOptions;
  54941. private _mergeEffect;
  54942. protected _scene: Scene;
  54943. protected _engine: Engine;
  54944. protected _maxSize: number;
  54945. protected _mainTextureDesiredSize: ISize;
  54946. protected _mainTexture: RenderTargetTexture;
  54947. protected _shouldRender: boolean;
  54948. protected _postProcesses: PostProcess[];
  54949. protected _textures: BaseTexture[];
  54950. protected _emissiveTextureAndColor: {
  54951. texture: Nullable<BaseTexture>;
  54952. color: Color4;
  54953. };
  54954. /**
  54955. * The name of the layer
  54956. */
  54957. name: string;
  54958. /**
  54959. * The clear color of the texture used to generate the glow map.
  54960. */
  54961. neutralColor: Color4;
  54962. /**
  54963. * Specifies whether the highlight layer is enabled or not.
  54964. */
  54965. isEnabled: boolean;
  54966. /**
  54967. * Gets the camera attached to the layer.
  54968. */
  54969. get camera(): Nullable<Camera>;
  54970. /**
  54971. * Gets the rendering group id the layer should render in.
  54972. */
  54973. get renderingGroupId(): number;
  54974. set renderingGroupId(renderingGroupId: number);
  54975. /**
  54976. * An event triggered when the effect layer has been disposed.
  54977. */
  54978. onDisposeObservable: Observable<EffectLayer>;
  54979. /**
  54980. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54981. */
  54982. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54983. /**
  54984. * An event triggered when the generated texture is being merged in the scene.
  54985. */
  54986. onBeforeComposeObservable: Observable<EffectLayer>;
  54987. /**
  54988. * An event triggered when the mesh is rendered into the effect render target.
  54989. */
  54990. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54991. /**
  54992. * An event triggered after the mesh has been rendered into the effect render target.
  54993. */
  54994. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54995. /**
  54996. * An event triggered when the generated texture has been merged in the scene.
  54997. */
  54998. onAfterComposeObservable: Observable<EffectLayer>;
  54999. /**
  55000. * An event triggered when the efffect layer changes its size.
  55001. */
  55002. onSizeChangedObservable: Observable<EffectLayer>;
  55003. /** @hidden */
  55004. static _SceneComponentInitialization: (scene: Scene) => void;
  55005. /**
  55006. * Instantiates a new effect Layer and references it in the scene.
  55007. * @param name The name of the layer
  55008. * @param scene The scene to use the layer in
  55009. */
  55010. constructor(
  55011. /** The Friendly of the effect in the scene */
  55012. name: string, scene: Scene);
  55013. /**
  55014. * Get the effect name of the layer.
  55015. * @return The effect name
  55016. */
  55017. abstract getEffectName(): string;
  55018. /**
  55019. * Checks for the readiness of the element composing the layer.
  55020. * @param subMesh the mesh to check for
  55021. * @param useInstances specify whether or not to use instances to render the mesh
  55022. * @return true if ready otherwise, false
  55023. */
  55024. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55025. /**
  55026. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55027. * @returns true if the effect requires stencil during the main canvas render pass.
  55028. */
  55029. abstract needStencil(): boolean;
  55030. /**
  55031. * Create the merge effect. This is the shader use to blit the information back
  55032. * to the main canvas at the end of the scene rendering.
  55033. * @returns The effect containing the shader used to merge the effect on the main canvas
  55034. */
  55035. protected abstract _createMergeEffect(): Effect;
  55036. /**
  55037. * Creates the render target textures and post processes used in the effect layer.
  55038. */
  55039. protected abstract _createTextureAndPostProcesses(): void;
  55040. /**
  55041. * Implementation specific of rendering the generating effect on the main canvas.
  55042. * @param effect The effect used to render through
  55043. */
  55044. protected abstract _internalRender(effect: Effect): void;
  55045. /**
  55046. * Sets the required values for both the emissive texture and and the main color.
  55047. */
  55048. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55049. /**
  55050. * Free any resources and references associated to a mesh.
  55051. * Internal use
  55052. * @param mesh The mesh to free.
  55053. */
  55054. abstract _disposeMesh(mesh: Mesh): void;
  55055. /**
  55056. * Serializes this layer (Glow or Highlight for example)
  55057. * @returns a serialized layer object
  55058. */
  55059. abstract serialize?(): any;
  55060. /**
  55061. * Initializes the effect layer with the required options.
  55062. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55063. */
  55064. protected _init(options: Partial<IEffectLayerOptions>): void;
  55065. /**
  55066. * Generates the index buffer of the full screen quad blending to the main canvas.
  55067. */
  55068. private _generateIndexBuffer;
  55069. /**
  55070. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55071. */
  55072. private _generateVertexBuffer;
  55073. /**
  55074. * Sets the main texture desired size which is the closest power of two
  55075. * of the engine canvas size.
  55076. */
  55077. private _setMainTextureSize;
  55078. /**
  55079. * Creates the main texture for the effect layer.
  55080. */
  55081. protected _createMainTexture(): void;
  55082. /**
  55083. * Adds specific effects defines.
  55084. * @param defines The defines to add specifics to.
  55085. */
  55086. protected _addCustomEffectDefines(defines: string[]): void;
  55087. /**
  55088. * Checks for the readiness of the element composing the layer.
  55089. * @param subMesh the mesh to check for
  55090. * @param useInstances specify whether or not to use instances to render the mesh
  55091. * @param emissiveTexture the associated emissive texture used to generate the glow
  55092. * @return true if ready otherwise, false
  55093. */
  55094. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55095. /**
  55096. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55097. */
  55098. render(): void;
  55099. /**
  55100. * Determine if a given mesh will be used in the current effect.
  55101. * @param mesh mesh to test
  55102. * @returns true if the mesh will be used
  55103. */
  55104. hasMesh(mesh: AbstractMesh): boolean;
  55105. /**
  55106. * Returns true if the layer contains information to display, otherwise false.
  55107. * @returns true if the glow layer should be rendered
  55108. */
  55109. shouldRender(): boolean;
  55110. /**
  55111. * Returns true if the mesh should render, otherwise false.
  55112. * @param mesh The mesh to render
  55113. * @returns true if it should render otherwise false
  55114. */
  55115. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55116. /**
  55117. * Returns true if the mesh can be rendered, otherwise false.
  55118. * @param mesh The mesh to render
  55119. * @param material The material used on the mesh
  55120. * @returns true if it can be rendered otherwise false
  55121. */
  55122. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55123. /**
  55124. * Returns true if the mesh should render, otherwise false.
  55125. * @param mesh The mesh to render
  55126. * @returns true if it should render otherwise false
  55127. */
  55128. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55129. /**
  55130. * Renders the submesh passed in parameter to the generation map.
  55131. */
  55132. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55133. /**
  55134. * Defines whether the current material of the mesh should be use to render the effect.
  55135. * @param mesh defines the current mesh to render
  55136. */
  55137. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55138. /**
  55139. * Rebuild the required buffers.
  55140. * @hidden Internal use only.
  55141. */
  55142. _rebuild(): void;
  55143. /**
  55144. * Dispose only the render target textures and post process.
  55145. */
  55146. private _disposeTextureAndPostProcesses;
  55147. /**
  55148. * Dispose the highlight layer and free resources.
  55149. */
  55150. dispose(): void;
  55151. /**
  55152. * Gets the class name of the effect layer
  55153. * @returns the string with the class name of the effect layer
  55154. */
  55155. getClassName(): string;
  55156. /**
  55157. * Creates an effect layer from parsed effect layer data
  55158. * @param parsedEffectLayer defines effect layer data
  55159. * @param scene defines the current scene
  55160. * @param rootUrl defines the root URL containing the effect layer information
  55161. * @returns a parsed effect Layer
  55162. */
  55163. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55164. }
  55165. }
  55166. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55167. import { Scene } from "babylonjs/scene";
  55168. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55169. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55170. import { AbstractScene } from "babylonjs/abstractScene";
  55171. module "babylonjs/abstractScene" {
  55172. interface AbstractScene {
  55173. /**
  55174. * The list of effect layers (highlights/glow) added to the scene
  55175. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55176. * @see http://doc.babylonjs.com/how_to/glow_layer
  55177. */
  55178. effectLayers: Array<EffectLayer>;
  55179. /**
  55180. * Removes the given effect layer from this scene.
  55181. * @param toRemove defines the effect layer to remove
  55182. * @returns the index of the removed effect layer
  55183. */
  55184. removeEffectLayer(toRemove: EffectLayer): number;
  55185. /**
  55186. * Adds the given effect layer to this scene
  55187. * @param newEffectLayer defines the effect layer to add
  55188. */
  55189. addEffectLayer(newEffectLayer: EffectLayer): void;
  55190. }
  55191. }
  55192. /**
  55193. * Defines the layer scene component responsible to manage any effect layers
  55194. * in a given scene.
  55195. */
  55196. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55197. /**
  55198. * The component name helpfull to identify the component in the list of scene components.
  55199. */
  55200. readonly name: string;
  55201. /**
  55202. * The scene the component belongs to.
  55203. */
  55204. scene: Scene;
  55205. private _engine;
  55206. private _renderEffects;
  55207. private _needStencil;
  55208. private _previousStencilState;
  55209. /**
  55210. * Creates a new instance of the component for the given scene
  55211. * @param scene Defines the scene to register the component in
  55212. */
  55213. constructor(scene: Scene);
  55214. /**
  55215. * Registers the component in a given scene
  55216. */
  55217. register(): void;
  55218. /**
  55219. * Rebuilds the elements related to this component in case of
  55220. * context lost for instance.
  55221. */
  55222. rebuild(): void;
  55223. /**
  55224. * Serializes the component data to the specified json object
  55225. * @param serializationObject The object to serialize to
  55226. */
  55227. serialize(serializationObject: any): void;
  55228. /**
  55229. * Adds all the elements from the container to the scene
  55230. * @param container the container holding the elements
  55231. */
  55232. addFromContainer(container: AbstractScene): void;
  55233. /**
  55234. * Removes all the elements in the container from the scene
  55235. * @param container contains the elements to remove
  55236. * @param dispose if the removed element should be disposed (default: false)
  55237. */
  55238. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55239. /**
  55240. * Disposes the component and the associated ressources.
  55241. */
  55242. dispose(): void;
  55243. private _isReadyForMesh;
  55244. private _renderMainTexture;
  55245. private _setStencil;
  55246. private _setStencilBack;
  55247. private _draw;
  55248. private _drawCamera;
  55249. private _drawRenderingGroup;
  55250. }
  55251. }
  55252. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55253. /** @hidden */
  55254. export var glowMapMergePixelShader: {
  55255. name: string;
  55256. shader: string;
  55257. };
  55258. }
  55259. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55260. /** @hidden */
  55261. export var glowMapMergeVertexShader: {
  55262. name: string;
  55263. shader: string;
  55264. };
  55265. }
  55266. declare module "babylonjs/Layers/glowLayer" {
  55267. import { Nullable } from "babylonjs/types";
  55268. import { Camera } from "babylonjs/Cameras/camera";
  55269. import { Scene } from "babylonjs/scene";
  55270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55272. import { Mesh } from "babylonjs/Meshes/mesh";
  55273. import { Texture } from "babylonjs/Materials/Textures/texture";
  55274. import { Effect } from "babylonjs/Materials/effect";
  55275. import { Material } from "babylonjs/Materials/material";
  55276. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55277. import { Color4 } from "babylonjs/Maths/math.color";
  55278. import "babylonjs/Shaders/glowMapMerge.fragment";
  55279. import "babylonjs/Shaders/glowMapMerge.vertex";
  55280. import "babylonjs/Layers/effectLayerSceneComponent";
  55281. module "babylonjs/abstractScene" {
  55282. interface AbstractScene {
  55283. /**
  55284. * Return a the first highlight layer of the scene with a given name.
  55285. * @param name The name of the highlight layer to look for.
  55286. * @return The highlight layer if found otherwise null.
  55287. */
  55288. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55289. }
  55290. }
  55291. /**
  55292. * Glow layer options. This helps customizing the behaviour
  55293. * of the glow layer.
  55294. */
  55295. export interface IGlowLayerOptions {
  55296. /**
  55297. * Multiplication factor apply to the canvas size to compute the render target size
  55298. * used to generated the glowing objects (the smaller the faster).
  55299. */
  55300. mainTextureRatio: number;
  55301. /**
  55302. * Enforces a fixed size texture to ensure resize independant blur.
  55303. */
  55304. mainTextureFixedSize?: number;
  55305. /**
  55306. * How big is the kernel of the blur texture.
  55307. */
  55308. blurKernelSize: number;
  55309. /**
  55310. * The camera attached to the layer.
  55311. */
  55312. camera: Nullable<Camera>;
  55313. /**
  55314. * Enable MSAA by chosing the number of samples.
  55315. */
  55316. mainTextureSamples?: number;
  55317. /**
  55318. * The rendering group to draw the layer in.
  55319. */
  55320. renderingGroupId: number;
  55321. }
  55322. /**
  55323. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55324. *
  55325. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55326. *
  55327. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55328. */
  55329. export class GlowLayer extends EffectLayer {
  55330. /**
  55331. * Effect Name of the layer.
  55332. */
  55333. static readonly EffectName: string;
  55334. /**
  55335. * The default blur kernel size used for the glow.
  55336. */
  55337. static DefaultBlurKernelSize: number;
  55338. /**
  55339. * The default texture size ratio used for the glow.
  55340. */
  55341. static DefaultTextureRatio: number;
  55342. /**
  55343. * Sets the kernel size of the blur.
  55344. */
  55345. set blurKernelSize(value: number);
  55346. /**
  55347. * Gets the kernel size of the blur.
  55348. */
  55349. get blurKernelSize(): number;
  55350. /**
  55351. * Sets the glow intensity.
  55352. */
  55353. set intensity(value: number);
  55354. /**
  55355. * Gets the glow intensity.
  55356. */
  55357. get intensity(): number;
  55358. private _options;
  55359. private _intensity;
  55360. private _horizontalBlurPostprocess1;
  55361. private _verticalBlurPostprocess1;
  55362. private _horizontalBlurPostprocess2;
  55363. private _verticalBlurPostprocess2;
  55364. private _blurTexture1;
  55365. private _blurTexture2;
  55366. private _postProcesses1;
  55367. private _postProcesses2;
  55368. private _includedOnlyMeshes;
  55369. private _excludedMeshes;
  55370. private _meshesUsingTheirOwnMaterials;
  55371. /**
  55372. * Callback used to let the user override the color selection on a per mesh basis
  55373. */
  55374. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55375. /**
  55376. * Callback used to let the user override the texture selection on a per mesh basis
  55377. */
  55378. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55379. /**
  55380. * Instantiates a new glow Layer and references it to the scene.
  55381. * @param name The name of the layer
  55382. * @param scene The scene to use the layer in
  55383. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55384. */
  55385. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55386. /**
  55387. * Get the effect name of the layer.
  55388. * @return The effect name
  55389. */
  55390. getEffectName(): string;
  55391. /**
  55392. * Create the merge effect. This is the shader use to blit the information back
  55393. * to the main canvas at the end of the scene rendering.
  55394. */
  55395. protected _createMergeEffect(): Effect;
  55396. /**
  55397. * Creates the render target textures and post processes used in the glow layer.
  55398. */
  55399. protected _createTextureAndPostProcesses(): void;
  55400. /**
  55401. * Checks for the readiness of the element composing the layer.
  55402. * @param subMesh the mesh to check for
  55403. * @param useInstances specify wether or not to use instances to render the mesh
  55404. * @param emissiveTexture the associated emissive texture used to generate the glow
  55405. * @return true if ready otherwise, false
  55406. */
  55407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55408. /**
  55409. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55410. */
  55411. needStencil(): boolean;
  55412. /**
  55413. * Returns true if the mesh can be rendered, otherwise false.
  55414. * @param mesh The mesh to render
  55415. * @param material The material used on the mesh
  55416. * @returns true if it can be rendered otherwise false
  55417. */
  55418. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55419. /**
  55420. * Implementation specific of rendering the generating effect on the main canvas.
  55421. * @param effect The effect used to render through
  55422. */
  55423. protected _internalRender(effect: Effect): void;
  55424. /**
  55425. * Sets the required values for both the emissive texture and and the main color.
  55426. */
  55427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55428. /**
  55429. * Returns true if the mesh should render, otherwise false.
  55430. * @param mesh The mesh to render
  55431. * @returns true if it should render otherwise false
  55432. */
  55433. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55434. /**
  55435. * Adds specific effects defines.
  55436. * @param defines The defines to add specifics to.
  55437. */
  55438. protected _addCustomEffectDefines(defines: string[]): void;
  55439. /**
  55440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55441. * @param mesh The mesh to exclude from the glow layer
  55442. */
  55443. addExcludedMesh(mesh: Mesh): void;
  55444. /**
  55445. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55446. * @param mesh The mesh to remove
  55447. */
  55448. removeExcludedMesh(mesh: Mesh): void;
  55449. /**
  55450. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55451. * @param mesh The mesh to include in the glow layer
  55452. */
  55453. addIncludedOnlyMesh(mesh: Mesh): void;
  55454. /**
  55455. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55456. * @param mesh The mesh to remove
  55457. */
  55458. removeIncludedOnlyMesh(mesh: Mesh): void;
  55459. /**
  55460. * Determine if a given mesh will be used in the glow layer
  55461. * @param mesh The mesh to test
  55462. * @returns true if the mesh will be highlighted by the current glow layer
  55463. */
  55464. hasMesh(mesh: AbstractMesh): boolean;
  55465. /**
  55466. * Defines whether the current material of the mesh should be use to render the effect.
  55467. * @param mesh defines the current mesh to render
  55468. */
  55469. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55470. /**
  55471. * Add a mesh to be rendered through its own material and not with emissive only.
  55472. * @param mesh The mesh for which we need to use its material
  55473. */
  55474. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55475. /**
  55476. * Remove a mesh from being rendered through its own material and not with emissive only.
  55477. * @param mesh The mesh for which we need to not use its material
  55478. */
  55479. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55480. /**
  55481. * Free any resources and references associated to a mesh.
  55482. * Internal use
  55483. * @param mesh The mesh to free.
  55484. * @hidden
  55485. */
  55486. _disposeMesh(mesh: Mesh): void;
  55487. /**
  55488. * Gets the class name of the effect layer
  55489. * @returns the string with the class name of the effect layer
  55490. */
  55491. getClassName(): string;
  55492. /**
  55493. * Serializes this glow layer
  55494. * @returns a serialized glow layer object
  55495. */
  55496. serialize(): any;
  55497. /**
  55498. * Creates a Glow Layer from parsed glow layer data
  55499. * @param parsedGlowLayer defines glow layer data
  55500. * @param scene defines the current scene
  55501. * @param rootUrl defines the root URL containing the glow layer information
  55502. * @returns a parsed Glow Layer
  55503. */
  55504. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55505. }
  55506. }
  55507. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55508. /** @hidden */
  55509. export var glowBlurPostProcessPixelShader: {
  55510. name: string;
  55511. shader: string;
  55512. };
  55513. }
  55514. declare module "babylonjs/Layers/highlightLayer" {
  55515. import { Observable } from "babylonjs/Misc/observable";
  55516. import { Nullable } from "babylonjs/types";
  55517. import { Camera } from "babylonjs/Cameras/camera";
  55518. import { Scene } from "babylonjs/scene";
  55519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55521. import { Mesh } from "babylonjs/Meshes/mesh";
  55522. import { Effect } from "babylonjs/Materials/effect";
  55523. import { Material } from "babylonjs/Materials/material";
  55524. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55526. import "babylonjs/Shaders/glowMapMerge.fragment";
  55527. import "babylonjs/Shaders/glowMapMerge.vertex";
  55528. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55529. module "babylonjs/abstractScene" {
  55530. interface AbstractScene {
  55531. /**
  55532. * Return a the first highlight layer of the scene with a given name.
  55533. * @param name The name of the highlight layer to look for.
  55534. * @return The highlight layer if found otherwise null.
  55535. */
  55536. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55537. }
  55538. }
  55539. /**
  55540. * Highlight layer options. This helps customizing the behaviour
  55541. * of the highlight layer.
  55542. */
  55543. export interface IHighlightLayerOptions {
  55544. /**
  55545. * Multiplication factor apply to the canvas size to compute the render target size
  55546. * used to generated the glowing objects (the smaller the faster).
  55547. */
  55548. mainTextureRatio: number;
  55549. /**
  55550. * Enforces a fixed size texture to ensure resize independant blur.
  55551. */
  55552. mainTextureFixedSize?: number;
  55553. /**
  55554. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55555. * of the picture to blur (the smaller the faster).
  55556. */
  55557. blurTextureSizeRatio: number;
  55558. /**
  55559. * How big in texel of the blur texture is the vertical blur.
  55560. */
  55561. blurVerticalSize: number;
  55562. /**
  55563. * How big in texel of the blur texture is the horizontal blur.
  55564. */
  55565. blurHorizontalSize: number;
  55566. /**
  55567. * Alpha blending mode used to apply the blur. Default is combine.
  55568. */
  55569. alphaBlendingMode: number;
  55570. /**
  55571. * The camera attached to the layer.
  55572. */
  55573. camera: Nullable<Camera>;
  55574. /**
  55575. * Should we display highlight as a solid stroke?
  55576. */
  55577. isStroke?: boolean;
  55578. /**
  55579. * The rendering group to draw the layer in.
  55580. */
  55581. renderingGroupId: number;
  55582. }
  55583. /**
  55584. * The highlight layer Helps adding a glow effect around a mesh.
  55585. *
  55586. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55587. * glowy meshes to your scene.
  55588. *
  55589. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55590. */
  55591. export class HighlightLayer extends EffectLayer {
  55592. name: string;
  55593. /**
  55594. * Effect Name of the highlight layer.
  55595. */
  55596. static readonly EffectName: string;
  55597. /**
  55598. * The neutral color used during the preparation of the glow effect.
  55599. * This is black by default as the blend operation is a blend operation.
  55600. */
  55601. static NeutralColor: Color4;
  55602. /**
  55603. * Stencil value used for glowing meshes.
  55604. */
  55605. static GlowingMeshStencilReference: number;
  55606. /**
  55607. * Stencil value used for the other meshes in the scene.
  55608. */
  55609. static NormalMeshStencilReference: number;
  55610. /**
  55611. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55612. */
  55613. innerGlow: boolean;
  55614. /**
  55615. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55616. */
  55617. outerGlow: boolean;
  55618. /**
  55619. * Specifies the horizontal size of the blur.
  55620. */
  55621. set blurHorizontalSize(value: number);
  55622. /**
  55623. * Specifies the vertical size of the blur.
  55624. */
  55625. set blurVerticalSize(value: number);
  55626. /**
  55627. * Gets the horizontal size of the blur.
  55628. */
  55629. get blurHorizontalSize(): number;
  55630. /**
  55631. * Gets the vertical size of the blur.
  55632. */
  55633. get blurVerticalSize(): number;
  55634. /**
  55635. * An event triggered when the highlight layer is being blurred.
  55636. */
  55637. onBeforeBlurObservable: Observable<HighlightLayer>;
  55638. /**
  55639. * An event triggered when the highlight layer has been blurred.
  55640. */
  55641. onAfterBlurObservable: Observable<HighlightLayer>;
  55642. private _instanceGlowingMeshStencilReference;
  55643. private _options;
  55644. private _downSamplePostprocess;
  55645. private _horizontalBlurPostprocess;
  55646. private _verticalBlurPostprocess;
  55647. private _blurTexture;
  55648. private _meshes;
  55649. private _excludedMeshes;
  55650. /**
  55651. * Instantiates a new highlight Layer and references it to the scene..
  55652. * @param name The name of the layer
  55653. * @param scene The scene to use the layer in
  55654. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55655. */
  55656. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55657. /**
  55658. * Get the effect name of the layer.
  55659. * @return The effect name
  55660. */
  55661. getEffectName(): string;
  55662. /**
  55663. * Create the merge effect. This is the shader use to blit the information back
  55664. * to the main canvas at the end of the scene rendering.
  55665. */
  55666. protected _createMergeEffect(): Effect;
  55667. /**
  55668. * Creates the render target textures and post processes used in the highlight layer.
  55669. */
  55670. protected _createTextureAndPostProcesses(): void;
  55671. /**
  55672. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55673. */
  55674. needStencil(): boolean;
  55675. /**
  55676. * Checks for the readiness of the element composing the layer.
  55677. * @param subMesh the mesh to check for
  55678. * @param useInstances specify wether or not to use instances to render the mesh
  55679. * @param emissiveTexture the associated emissive texture used to generate the glow
  55680. * @return true if ready otherwise, false
  55681. */
  55682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55683. /**
  55684. * Implementation specific of rendering the generating effect on the main canvas.
  55685. * @param effect The effect used to render through
  55686. */
  55687. protected _internalRender(effect: Effect): void;
  55688. /**
  55689. * Returns true if the layer contains information to display, otherwise false.
  55690. */
  55691. shouldRender(): boolean;
  55692. /**
  55693. * Returns true if the mesh should render, otherwise false.
  55694. * @param mesh The mesh to render
  55695. * @returns true if it should render otherwise false
  55696. */
  55697. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55698. /**
  55699. * Sets the required values for both the emissive texture and and the main color.
  55700. */
  55701. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55702. /**
  55703. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55704. * @param mesh The mesh to exclude from the highlight layer
  55705. */
  55706. addExcludedMesh(mesh: Mesh): void;
  55707. /**
  55708. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55709. * @param mesh The mesh to highlight
  55710. */
  55711. removeExcludedMesh(mesh: Mesh): void;
  55712. /**
  55713. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55714. * @param mesh mesh to test
  55715. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55716. */
  55717. hasMesh(mesh: AbstractMesh): boolean;
  55718. /**
  55719. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55720. * @param mesh The mesh to highlight
  55721. * @param color The color of the highlight
  55722. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55723. */
  55724. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55725. /**
  55726. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55727. * @param mesh The mesh to highlight
  55728. */
  55729. removeMesh(mesh: Mesh): void;
  55730. /**
  55731. * Remove all the meshes currently referenced in the highlight layer
  55732. */
  55733. removeAllMeshes(): void;
  55734. /**
  55735. * Force the stencil to the normal expected value for none glowing parts
  55736. */
  55737. private _defaultStencilReference;
  55738. /**
  55739. * Free any resources and references associated to a mesh.
  55740. * Internal use
  55741. * @param mesh The mesh to free.
  55742. * @hidden
  55743. */
  55744. _disposeMesh(mesh: Mesh): void;
  55745. /**
  55746. * Dispose the highlight layer and free resources.
  55747. */
  55748. dispose(): void;
  55749. /**
  55750. * Gets the class name of the effect layer
  55751. * @returns the string with the class name of the effect layer
  55752. */
  55753. getClassName(): string;
  55754. /**
  55755. * Serializes this Highlight layer
  55756. * @returns a serialized Highlight layer object
  55757. */
  55758. serialize(): any;
  55759. /**
  55760. * Creates a Highlight layer from parsed Highlight layer data
  55761. * @param parsedHightlightLayer defines the Highlight layer data
  55762. * @param scene defines the current scene
  55763. * @param rootUrl defines the root URL containing the Highlight layer information
  55764. * @returns a parsed Highlight layer
  55765. */
  55766. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55767. }
  55768. }
  55769. declare module "babylonjs/Layers/layerSceneComponent" {
  55770. import { Scene } from "babylonjs/scene";
  55771. import { ISceneComponent } from "babylonjs/sceneComponent";
  55772. import { Layer } from "babylonjs/Layers/layer";
  55773. import { AbstractScene } from "babylonjs/abstractScene";
  55774. module "babylonjs/abstractScene" {
  55775. interface AbstractScene {
  55776. /**
  55777. * The list of layers (background and foreground) of the scene
  55778. */
  55779. layers: Array<Layer>;
  55780. }
  55781. }
  55782. /**
  55783. * Defines the layer scene component responsible to manage any layers
  55784. * in a given scene.
  55785. */
  55786. export class LayerSceneComponent implements ISceneComponent {
  55787. /**
  55788. * The component name helpfull to identify the component in the list of scene components.
  55789. */
  55790. readonly name: string;
  55791. /**
  55792. * The scene the component belongs to.
  55793. */
  55794. scene: Scene;
  55795. private _engine;
  55796. /**
  55797. * Creates a new instance of the component for the given scene
  55798. * @param scene Defines the scene to register the component in
  55799. */
  55800. constructor(scene: Scene);
  55801. /**
  55802. * Registers the component in a given scene
  55803. */
  55804. register(): void;
  55805. /**
  55806. * Rebuilds the elements related to this component in case of
  55807. * context lost for instance.
  55808. */
  55809. rebuild(): void;
  55810. /**
  55811. * Disposes the component and the associated ressources.
  55812. */
  55813. dispose(): void;
  55814. private _draw;
  55815. private _drawCameraPredicate;
  55816. private _drawCameraBackground;
  55817. private _drawCameraForeground;
  55818. private _drawRenderTargetPredicate;
  55819. private _drawRenderTargetBackground;
  55820. private _drawRenderTargetForeground;
  55821. /**
  55822. * Adds all the elements from the container to the scene
  55823. * @param container the container holding the elements
  55824. */
  55825. addFromContainer(container: AbstractScene): void;
  55826. /**
  55827. * Removes all the elements in the container from the scene
  55828. * @param container contains the elements to remove
  55829. * @param dispose if the removed element should be disposed (default: false)
  55830. */
  55831. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55832. }
  55833. }
  55834. declare module "babylonjs/Shaders/layer.fragment" {
  55835. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55836. /** @hidden */
  55837. export var layerPixelShader: {
  55838. name: string;
  55839. shader: string;
  55840. };
  55841. }
  55842. declare module "babylonjs/Shaders/layer.vertex" {
  55843. /** @hidden */
  55844. export var layerVertexShader: {
  55845. name: string;
  55846. shader: string;
  55847. };
  55848. }
  55849. declare module "babylonjs/Layers/layer" {
  55850. import { Observable } from "babylonjs/Misc/observable";
  55851. import { Nullable } from "babylonjs/types";
  55852. import { Scene } from "babylonjs/scene";
  55853. import { Vector2 } from "babylonjs/Maths/math.vector";
  55854. import { Color4 } from "babylonjs/Maths/math.color";
  55855. import { Texture } from "babylonjs/Materials/Textures/texture";
  55856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55857. import "babylonjs/Shaders/layer.fragment";
  55858. import "babylonjs/Shaders/layer.vertex";
  55859. /**
  55860. * This represents a full screen 2d layer.
  55861. * This can be useful to display a picture in the background of your scene for instance.
  55862. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55863. */
  55864. export class Layer {
  55865. /**
  55866. * Define the name of the layer.
  55867. */
  55868. name: string;
  55869. /**
  55870. * Define the texture the layer should display.
  55871. */
  55872. texture: Nullable<Texture>;
  55873. /**
  55874. * Is the layer in background or foreground.
  55875. */
  55876. isBackground: boolean;
  55877. /**
  55878. * Define the color of the layer (instead of texture).
  55879. */
  55880. color: Color4;
  55881. /**
  55882. * Define the scale of the layer in order to zoom in out of the texture.
  55883. */
  55884. scale: Vector2;
  55885. /**
  55886. * Define an offset for the layer in order to shift the texture.
  55887. */
  55888. offset: Vector2;
  55889. /**
  55890. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55891. */
  55892. alphaBlendingMode: number;
  55893. /**
  55894. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55895. * Alpha test will not mix with the background color in case of transparency.
  55896. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55897. */
  55898. alphaTest: boolean;
  55899. /**
  55900. * Define a mask to restrict the layer to only some of the scene cameras.
  55901. */
  55902. layerMask: number;
  55903. /**
  55904. * Define the list of render target the layer is visible into.
  55905. */
  55906. renderTargetTextures: RenderTargetTexture[];
  55907. /**
  55908. * Define if the layer is only used in renderTarget or if it also
  55909. * renders in the main frame buffer of the canvas.
  55910. */
  55911. renderOnlyInRenderTargetTextures: boolean;
  55912. private _scene;
  55913. private _vertexBuffers;
  55914. private _indexBuffer;
  55915. private _effect;
  55916. private _previousDefines;
  55917. /**
  55918. * An event triggered when the layer is disposed.
  55919. */
  55920. onDisposeObservable: Observable<Layer>;
  55921. private _onDisposeObserver;
  55922. /**
  55923. * Back compatibility with callback before the onDisposeObservable existed.
  55924. * The set callback will be triggered when the layer has been disposed.
  55925. */
  55926. set onDispose(callback: () => void);
  55927. /**
  55928. * An event triggered before rendering the scene
  55929. */
  55930. onBeforeRenderObservable: Observable<Layer>;
  55931. private _onBeforeRenderObserver;
  55932. /**
  55933. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55934. * The set callback will be triggered just before rendering the layer.
  55935. */
  55936. set onBeforeRender(callback: () => void);
  55937. /**
  55938. * An event triggered after rendering the scene
  55939. */
  55940. onAfterRenderObservable: Observable<Layer>;
  55941. private _onAfterRenderObserver;
  55942. /**
  55943. * Back compatibility with callback before the onAfterRenderObservable existed.
  55944. * The set callback will be triggered just after rendering the layer.
  55945. */
  55946. set onAfterRender(callback: () => void);
  55947. /**
  55948. * Instantiates a new layer.
  55949. * This represents a full screen 2d layer.
  55950. * This can be useful to display a picture in the background of your scene for instance.
  55951. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55952. * @param name Define the name of the layer in the scene
  55953. * @param imgUrl Define the url of the texture to display in the layer
  55954. * @param scene Define the scene the layer belongs to
  55955. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55956. * @param color Defines a color for the layer
  55957. */
  55958. constructor(
  55959. /**
  55960. * Define the name of the layer.
  55961. */
  55962. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55963. private _createIndexBuffer;
  55964. /** @hidden */
  55965. _rebuild(): void;
  55966. /**
  55967. * Renders the layer in the scene.
  55968. */
  55969. render(): void;
  55970. /**
  55971. * Disposes and releases the associated ressources.
  55972. */
  55973. dispose(): void;
  55974. }
  55975. }
  55976. declare module "babylonjs/Layers/index" {
  55977. export * from "babylonjs/Layers/effectLayer";
  55978. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55979. export * from "babylonjs/Layers/glowLayer";
  55980. export * from "babylonjs/Layers/highlightLayer";
  55981. export * from "babylonjs/Layers/layer";
  55982. export * from "babylonjs/Layers/layerSceneComponent";
  55983. }
  55984. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55985. /** @hidden */
  55986. export var lensFlarePixelShader: {
  55987. name: string;
  55988. shader: string;
  55989. };
  55990. }
  55991. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55992. /** @hidden */
  55993. export var lensFlareVertexShader: {
  55994. name: string;
  55995. shader: string;
  55996. };
  55997. }
  55998. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55999. import { Scene } from "babylonjs/scene";
  56000. import { Vector3 } from "babylonjs/Maths/math.vector";
  56001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56002. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56003. import "babylonjs/Shaders/lensFlare.fragment";
  56004. import "babylonjs/Shaders/lensFlare.vertex";
  56005. import { Viewport } from "babylonjs/Maths/math.viewport";
  56006. /**
  56007. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56008. * It is usually composed of several `lensFlare`.
  56009. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56010. */
  56011. export class LensFlareSystem {
  56012. /**
  56013. * Define the name of the lens flare system
  56014. */
  56015. name: string;
  56016. /**
  56017. * List of lens flares used in this system.
  56018. */
  56019. lensFlares: LensFlare[];
  56020. /**
  56021. * Define a limit from the border the lens flare can be visible.
  56022. */
  56023. borderLimit: number;
  56024. /**
  56025. * Define a viewport border we do not want to see the lens flare in.
  56026. */
  56027. viewportBorder: number;
  56028. /**
  56029. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56030. */
  56031. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56032. /**
  56033. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56034. */
  56035. layerMask: number;
  56036. /**
  56037. * Define the id of the lens flare system in the scene.
  56038. * (equal to name by default)
  56039. */
  56040. id: string;
  56041. private _scene;
  56042. private _emitter;
  56043. private _vertexBuffers;
  56044. private _indexBuffer;
  56045. private _effect;
  56046. private _positionX;
  56047. private _positionY;
  56048. private _isEnabled;
  56049. /** @hidden */
  56050. static _SceneComponentInitialization: (scene: Scene) => void;
  56051. /**
  56052. * Instantiates a lens flare system.
  56053. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56054. * It is usually composed of several `lensFlare`.
  56055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56056. * @param name Define the name of the lens flare system in the scene
  56057. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56058. * @param scene Define the scene the lens flare system belongs to
  56059. */
  56060. constructor(
  56061. /**
  56062. * Define the name of the lens flare system
  56063. */
  56064. name: string, emitter: any, scene: Scene);
  56065. /**
  56066. * Define if the lens flare system is enabled.
  56067. */
  56068. get isEnabled(): boolean;
  56069. set isEnabled(value: boolean);
  56070. /**
  56071. * Get the scene the effects belongs to.
  56072. * @returns the scene holding the lens flare system
  56073. */
  56074. getScene(): Scene;
  56075. /**
  56076. * Get the emitter of the lens flare system.
  56077. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56078. * @returns the emitter of the lens flare system
  56079. */
  56080. getEmitter(): any;
  56081. /**
  56082. * Set the emitter of the lens flare system.
  56083. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56084. * @param newEmitter Define the new emitter of the system
  56085. */
  56086. setEmitter(newEmitter: any): void;
  56087. /**
  56088. * Get the lens flare system emitter position.
  56089. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56090. * @returns the position
  56091. */
  56092. getEmitterPosition(): Vector3;
  56093. /**
  56094. * @hidden
  56095. */
  56096. computeEffectivePosition(globalViewport: Viewport): boolean;
  56097. /** @hidden */
  56098. _isVisible(): boolean;
  56099. /**
  56100. * @hidden
  56101. */
  56102. render(): boolean;
  56103. /**
  56104. * Dispose and release the lens flare with its associated resources.
  56105. */
  56106. dispose(): void;
  56107. /**
  56108. * Parse a lens flare system from a JSON repressentation
  56109. * @param parsedLensFlareSystem Define the JSON to parse
  56110. * @param scene Define the scene the parsed system should be instantiated in
  56111. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56112. * @returns the parsed system
  56113. */
  56114. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56115. /**
  56116. * Serialize the current Lens Flare System into a JSON representation.
  56117. * @returns the serialized JSON
  56118. */
  56119. serialize(): any;
  56120. }
  56121. }
  56122. declare module "babylonjs/LensFlares/lensFlare" {
  56123. import { Nullable } from "babylonjs/types";
  56124. import { Color3 } from "babylonjs/Maths/math.color";
  56125. import { Texture } from "babylonjs/Materials/Textures/texture";
  56126. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56127. /**
  56128. * This represents one of the lens effect in a `lensFlareSystem`.
  56129. * It controls one of the indiviual texture used in the effect.
  56130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56131. */
  56132. export class LensFlare {
  56133. /**
  56134. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56135. */
  56136. size: number;
  56137. /**
  56138. * 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.
  56139. */
  56140. position: number;
  56141. /**
  56142. * Define the lens color.
  56143. */
  56144. color: Color3;
  56145. /**
  56146. * Define the lens texture.
  56147. */
  56148. texture: Nullable<Texture>;
  56149. /**
  56150. * Define the alpha mode to render this particular lens.
  56151. */
  56152. alphaMode: number;
  56153. private _system;
  56154. /**
  56155. * Creates a new Lens Flare.
  56156. * This represents one of the lens effect in a `lensFlareSystem`.
  56157. * It controls one of the indiviual texture used in the effect.
  56158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56159. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56160. * @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.
  56161. * @param color Define the lens color
  56162. * @param imgUrl Define the lens texture url
  56163. * @param system Define the `lensFlareSystem` this flare is part of
  56164. * @returns The newly created Lens Flare
  56165. */
  56166. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56167. /**
  56168. * Instantiates a new Lens Flare.
  56169. * This represents one of the lens effect in a `lensFlareSystem`.
  56170. * It controls one of the indiviual texture used in the effect.
  56171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56172. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56173. * @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.
  56174. * @param color Define the lens color
  56175. * @param imgUrl Define the lens texture url
  56176. * @param system Define the `lensFlareSystem` this flare is part of
  56177. */
  56178. constructor(
  56179. /**
  56180. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56181. */
  56182. size: number,
  56183. /**
  56184. * 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.
  56185. */
  56186. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56187. /**
  56188. * Dispose and release the lens flare with its associated resources.
  56189. */
  56190. dispose(): void;
  56191. }
  56192. }
  56193. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56194. import { Nullable } from "babylonjs/types";
  56195. import { Scene } from "babylonjs/scene";
  56196. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56197. import { AbstractScene } from "babylonjs/abstractScene";
  56198. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56199. module "babylonjs/abstractScene" {
  56200. interface AbstractScene {
  56201. /**
  56202. * The list of lens flare system added to the scene
  56203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56204. */
  56205. lensFlareSystems: Array<LensFlareSystem>;
  56206. /**
  56207. * Removes the given lens flare system from this scene.
  56208. * @param toRemove The lens flare system to remove
  56209. * @returns The index of the removed lens flare system
  56210. */
  56211. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56212. /**
  56213. * Adds the given lens flare system to this scene
  56214. * @param newLensFlareSystem The lens flare system to add
  56215. */
  56216. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56217. /**
  56218. * Gets a lens flare system using its name
  56219. * @param name defines the name to look for
  56220. * @returns the lens flare system or null if not found
  56221. */
  56222. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56223. /**
  56224. * Gets a lens flare system using its id
  56225. * @param id defines the id to look for
  56226. * @returns the lens flare system or null if not found
  56227. */
  56228. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56229. }
  56230. }
  56231. /**
  56232. * Defines the lens flare scene component responsible to manage any lens flares
  56233. * in a given scene.
  56234. */
  56235. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56236. /**
  56237. * The component name helpfull to identify the component in the list of scene components.
  56238. */
  56239. readonly name: string;
  56240. /**
  56241. * The scene the component belongs to.
  56242. */
  56243. scene: Scene;
  56244. /**
  56245. * Creates a new instance of the component for the given scene
  56246. * @param scene Defines the scene to register the component in
  56247. */
  56248. constructor(scene: Scene);
  56249. /**
  56250. * Registers the component in a given scene
  56251. */
  56252. register(): void;
  56253. /**
  56254. * Rebuilds the elements related to this component in case of
  56255. * context lost for instance.
  56256. */
  56257. rebuild(): void;
  56258. /**
  56259. * Adds all the elements from the container to the scene
  56260. * @param container the container holding the elements
  56261. */
  56262. addFromContainer(container: AbstractScene): void;
  56263. /**
  56264. * Removes all the elements in the container from the scene
  56265. * @param container contains the elements to remove
  56266. * @param dispose if the removed element should be disposed (default: false)
  56267. */
  56268. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56269. /**
  56270. * Serializes the component data to the specified json object
  56271. * @param serializationObject The object to serialize to
  56272. */
  56273. serialize(serializationObject: any): void;
  56274. /**
  56275. * Disposes the component and the associated ressources.
  56276. */
  56277. dispose(): void;
  56278. private _draw;
  56279. }
  56280. }
  56281. declare module "babylonjs/LensFlares/index" {
  56282. export * from "babylonjs/LensFlares/lensFlare";
  56283. export * from "babylonjs/LensFlares/lensFlareSystem";
  56284. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56285. }
  56286. declare module "babylonjs/Shaders/depth.fragment" {
  56287. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56288. /** @hidden */
  56289. export var depthPixelShader: {
  56290. name: string;
  56291. shader: string;
  56292. };
  56293. }
  56294. declare module "babylonjs/Shaders/depth.vertex" {
  56295. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56298. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56299. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56300. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56301. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56302. /** @hidden */
  56303. export var depthVertexShader: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module "babylonjs/Rendering/depthRenderer" {
  56309. import { Nullable } from "babylonjs/types";
  56310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56311. import { Scene } from "babylonjs/scene";
  56312. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56313. import { Camera } from "babylonjs/Cameras/camera";
  56314. import "babylonjs/Shaders/depth.fragment";
  56315. import "babylonjs/Shaders/depth.vertex";
  56316. /**
  56317. * This represents a depth renderer in Babylon.
  56318. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56319. */
  56320. export class DepthRenderer {
  56321. private _scene;
  56322. private _depthMap;
  56323. private _effect;
  56324. private readonly _storeNonLinearDepth;
  56325. private readonly _clearColor;
  56326. /** Get if the depth renderer is using packed depth or not */
  56327. readonly isPacked: boolean;
  56328. private _cachedDefines;
  56329. private _camera;
  56330. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56331. enabled: boolean;
  56332. /**
  56333. * Specifiess that the depth renderer will only be used within
  56334. * the camera it is created for.
  56335. * This can help forcing its rendering during the camera processing.
  56336. */
  56337. useOnlyInActiveCamera: boolean;
  56338. /** @hidden */
  56339. static _SceneComponentInitialization: (scene: Scene) => void;
  56340. /**
  56341. * Instantiates a depth renderer
  56342. * @param scene The scene the renderer belongs to
  56343. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56344. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56345. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56346. */
  56347. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56348. /**
  56349. * Creates the depth rendering effect and checks if the effect is ready.
  56350. * @param subMesh The submesh to be used to render the depth map of
  56351. * @param useInstances If multiple world instances should be used
  56352. * @returns if the depth renderer is ready to render the depth map
  56353. */
  56354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56355. /**
  56356. * Gets the texture which the depth map will be written to.
  56357. * @returns The depth map texture
  56358. */
  56359. getDepthMap(): RenderTargetTexture;
  56360. /**
  56361. * Disposes of the depth renderer.
  56362. */
  56363. dispose(): void;
  56364. }
  56365. }
  56366. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56367. /** @hidden */
  56368. export var minmaxReduxPixelShader: {
  56369. name: string;
  56370. shader: string;
  56371. };
  56372. }
  56373. declare module "babylonjs/Misc/minMaxReducer" {
  56374. import { Nullable } from "babylonjs/types";
  56375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56376. import { Camera } from "babylonjs/Cameras/camera";
  56377. import { Observer } from "babylonjs/Misc/observable";
  56378. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56379. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56380. import { Observable } from "babylonjs/Misc/observable";
  56381. import "babylonjs/Shaders/minmaxRedux.fragment";
  56382. /**
  56383. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56384. * and maximum values from all values of the texture.
  56385. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56386. * The source values are read from the red channel of the texture.
  56387. */
  56388. export class MinMaxReducer {
  56389. /**
  56390. * Observable triggered when the computation has been performed
  56391. */
  56392. onAfterReductionPerformed: Observable<{
  56393. min: number;
  56394. max: number;
  56395. }>;
  56396. protected _camera: Camera;
  56397. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56398. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56399. protected _postProcessManager: PostProcessManager;
  56400. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56401. protected _forceFullscreenViewport: boolean;
  56402. /**
  56403. * Creates a min/max reducer
  56404. * @param camera The camera to use for the post processes
  56405. */
  56406. constructor(camera: Camera);
  56407. /**
  56408. * Gets the texture used to read the values from.
  56409. */
  56410. get sourceTexture(): Nullable<RenderTargetTexture>;
  56411. /**
  56412. * Sets the source texture to read the values from.
  56413. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56414. * because in such textures '1' value must not be taken into account to compute the maximum
  56415. * as this value is used to clear the texture.
  56416. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56417. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56418. * @param depthRedux Indicates if the texture is a depth texture or not
  56419. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56420. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56421. */
  56422. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56423. /**
  56424. * Defines the refresh rate of the computation.
  56425. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56426. */
  56427. get refreshRate(): number;
  56428. set refreshRate(value: number);
  56429. protected _activated: boolean;
  56430. /**
  56431. * Gets the activation status of the reducer
  56432. */
  56433. get activated(): boolean;
  56434. /**
  56435. * Activates the reduction computation.
  56436. * When activated, the observers registered in onAfterReductionPerformed are
  56437. * called after the compuation is performed
  56438. */
  56439. activate(): void;
  56440. /**
  56441. * Deactivates the reduction computation.
  56442. */
  56443. deactivate(): void;
  56444. /**
  56445. * Disposes the min/max reducer
  56446. * @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.
  56447. */
  56448. dispose(disposeAll?: boolean): void;
  56449. }
  56450. }
  56451. declare module "babylonjs/Misc/depthReducer" {
  56452. import { Nullable } from "babylonjs/types";
  56453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56454. import { Camera } from "babylonjs/Cameras/camera";
  56455. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56456. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56457. /**
  56458. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56459. */
  56460. export class DepthReducer extends MinMaxReducer {
  56461. private _depthRenderer;
  56462. private _depthRendererId;
  56463. /**
  56464. * Gets the depth renderer used for the computation.
  56465. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56466. */
  56467. get depthRenderer(): Nullable<DepthRenderer>;
  56468. /**
  56469. * Creates a depth reducer
  56470. * @param camera The camera used to render the depth texture
  56471. */
  56472. constructor(camera: Camera);
  56473. /**
  56474. * Sets the depth renderer to use to generate the depth map
  56475. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56476. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56477. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56478. */
  56479. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56480. /** @hidden */
  56481. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56482. /**
  56483. * Activates the reduction computation.
  56484. * When activated, the observers registered in onAfterReductionPerformed are
  56485. * called after the compuation is performed
  56486. */
  56487. activate(): void;
  56488. /**
  56489. * Deactivates the reduction computation.
  56490. */
  56491. deactivate(): void;
  56492. /**
  56493. * Disposes the depth reducer
  56494. * @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.
  56495. */
  56496. dispose(disposeAll?: boolean): void;
  56497. }
  56498. }
  56499. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56500. import { Nullable } from "babylonjs/types";
  56501. import { Scene } from "babylonjs/scene";
  56502. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56503. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56504. import { Effect } from "babylonjs/Materials/effect";
  56505. import "babylonjs/Shaders/shadowMap.fragment";
  56506. import "babylonjs/Shaders/shadowMap.vertex";
  56507. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56508. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56509. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56510. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56511. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56512. /**
  56513. * A CSM implementation allowing casting shadows on large scenes.
  56514. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56515. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56516. */
  56517. export class CascadedShadowGenerator extends ShadowGenerator {
  56518. private static readonly frustumCornersNDCSpace;
  56519. /**
  56520. * Name of the CSM class
  56521. */
  56522. static CLASSNAME: string;
  56523. /**
  56524. * Defines the default number of cascades used by the CSM.
  56525. */
  56526. static readonly DEFAULT_CASCADES_COUNT: number;
  56527. /**
  56528. * Defines the minimum number of cascades used by the CSM.
  56529. */
  56530. static readonly MIN_CASCADES_COUNT: number;
  56531. /**
  56532. * Defines the maximum number of cascades used by the CSM.
  56533. */
  56534. static readonly MAX_CASCADES_COUNT: number;
  56535. protected _validateFilter(filter: number): number;
  56536. /**
  56537. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56538. */
  56539. penumbraDarkness: number;
  56540. private _numCascades;
  56541. /**
  56542. * Gets or set the number of cascades used by the CSM.
  56543. */
  56544. get numCascades(): number;
  56545. set numCascades(value: number);
  56546. /**
  56547. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56548. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56549. */
  56550. stabilizeCascades: boolean;
  56551. private _freezeShadowCastersBoundingInfo;
  56552. private _freezeShadowCastersBoundingInfoObservable;
  56553. /**
  56554. * Enables or disables the shadow casters bounding info computation.
  56555. * If your shadow casters don't move, you can disable this feature.
  56556. * If it is enabled, the bounding box computation is done every frame.
  56557. */
  56558. get freezeShadowCastersBoundingInfo(): boolean;
  56559. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56560. private _scbiMin;
  56561. private _scbiMax;
  56562. protected _computeShadowCastersBoundingInfo(): void;
  56563. protected _shadowCastersBoundingInfo: BoundingInfo;
  56564. /**
  56565. * Gets or sets the shadow casters bounding info.
  56566. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56567. * so that the system won't overwrite the bounds you provide
  56568. */
  56569. get shadowCastersBoundingInfo(): BoundingInfo;
  56570. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56571. protected _breaksAreDirty: boolean;
  56572. protected _minDistance: number;
  56573. protected _maxDistance: number;
  56574. /**
  56575. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56576. *
  56577. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56578. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56579. * @param min minimal distance for the breaks (default to 0.)
  56580. * @param max maximal distance for the breaks (default to 1.)
  56581. */
  56582. setMinMaxDistance(min: number, max: number): void;
  56583. /** Gets the minimal distance used in the cascade break computation */
  56584. get minDistance(): number;
  56585. /** Gets the maximal distance used in the cascade break computation */
  56586. get maxDistance(): number;
  56587. /**
  56588. * Gets the class name of that object
  56589. * @returns "CascadedShadowGenerator"
  56590. */
  56591. getClassName(): string;
  56592. private _cascadeMinExtents;
  56593. private _cascadeMaxExtents;
  56594. /**
  56595. * Gets a cascade minimum extents
  56596. * @param cascadeIndex index of the cascade
  56597. * @returns the minimum cascade extents
  56598. */
  56599. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56600. /**
  56601. * Gets a cascade maximum extents
  56602. * @param cascadeIndex index of the cascade
  56603. * @returns the maximum cascade extents
  56604. */
  56605. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56606. private _cascades;
  56607. private _currentLayer;
  56608. private _viewSpaceFrustumsZ;
  56609. private _viewMatrices;
  56610. private _projectionMatrices;
  56611. private _transformMatrices;
  56612. private _transformMatricesAsArray;
  56613. private _frustumLengths;
  56614. private _lightSizeUVCorrection;
  56615. private _depthCorrection;
  56616. private _frustumCornersWorldSpace;
  56617. private _frustumCenter;
  56618. private _shadowCameraPos;
  56619. private _shadowMaxZ;
  56620. /**
  56621. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56622. * It defaults to camera.maxZ
  56623. */
  56624. get shadowMaxZ(): number;
  56625. /**
  56626. * Sets the shadow max z distance.
  56627. */
  56628. set shadowMaxZ(value: number);
  56629. protected _debug: boolean;
  56630. /**
  56631. * Gets or sets the debug flag.
  56632. * When enabled, the cascades are materialized by different colors on the screen.
  56633. */
  56634. get debug(): boolean;
  56635. set debug(dbg: boolean);
  56636. private _depthClamp;
  56637. /**
  56638. * Gets or sets the depth clamping value.
  56639. *
  56640. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56641. * to account for the shadow casters far away.
  56642. *
  56643. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56644. */
  56645. get depthClamp(): boolean;
  56646. set depthClamp(value: boolean);
  56647. private _cascadeBlendPercentage;
  56648. /**
  56649. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56650. * It defaults to 0.1 (10% blending).
  56651. */
  56652. get cascadeBlendPercentage(): number;
  56653. set cascadeBlendPercentage(value: number);
  56654. private _lambda;
  56655. /**
  56656. * Gets or set the lambda parameter.
  56657. * This parameter is used to split the camera frustum and create the cascades.
  56658. * 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.
  56659. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56660. */
  56661. get lambda(): number;
  56662. set lambda(value: number);
  56663. /**
  56664. * Gets the view matrix corresponding to a given cascade
  56665. * @param cascadeNum cascade to retrieve the view matrix from
  56666. * @returns the cascade view matrix
  56667. */
  56668. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56669. /**
  56670. * Gets the projection matrix corresponding to a given cascade
  56671. * @param cascadeNum cascade to retrieve the projection matrix from
  56672. * @returns the cascade projection matrix
  56673. */
  56674. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56675. /**
  56676. * Gets the transformation matrix corresponding to a given cascade
  56677. * @param cascadeNum cascade to retrieve the transformation matrix from
  56678. * @returns the cascade transformation matrix
  56679. */
  56680. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56681. private _depthRenderer;
  56682. /**
  56683. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56684. *
  56685. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56686. *
  56687. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56688. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56689. * @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
  56690. */
  56691. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56692. private _depthReducer;
  56693. private _autoCalcDepthBounds;
  56694. /**
  56695. * Gets or sets the autoCalcDepthBounds property.
  56696. *
  56697. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56698. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56699. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56700. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56701. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56702. */
  56703. get autoCalcDepthBounds(): boolean;
  56704. set autoCalcDepthBounds(value: boolean);
  56705. /**
  56706. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56707. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56708. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56709. * for setting the refresh rate on the renderer yourself!
  56710. */
  56711. get autoCalcDepthBoundsRefreshRate(): number;
  56712. set autoCalcDepthBoundsRefreshRate(value: number);
  56713. /**
  56714. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56715. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56716. * you change the camera near/far planes!
  56717. */
  56718. splitFrustum(): void;
  56719. private _splitFrustum;
  56720. private _computeMatrices;
  56721. private _computeFrustumInWorldSpace;
  56722. private _computeCascadeFrustum;
  56723. /** @hidden */
  56724. static _SceneComponentInitialization: (scene: Scene) => void;
  56725. /**
  56726. * Creates a Cascaded Shadow Generator object.
  56727. * A ShadowGenerator is the required tool to use the shadows.
  56728. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56729. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56730. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56731. * @param light The directional light object generating the shadows.
  56732. * @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.
  56733. */
  56734. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56735. protected _initializeGenerator(): void;
  56736. protected _createTargetRenderTexture(): void;
  56737. protected _initializeShadowMap(): void;
  56738. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56739. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56740. /**
  56741. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56742. * @param defines Defines of the material we want to update
  56743. * @param lightIndex Index of the light in the enabled light list of the material
  56744. */
  56745. prepareDefines(defines: any, lightIndex: number): void;
  56746. /**
  56747. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56748. * defined in the generator but impacting the effect).
  56749. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56750. * @param effect The effect we are binfing the information for
  56751. */
  56752. bindShadowLight(lightIndex: string, effect: Effect): void;
  56753. /**
  56754. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56755. * (eq to view projection * shadow projection matrices)
  56756. * @returns The transform matrix used to create the shadow map
  56757. */
  56758. getTransformMatrix(): Matrix;
  56759. /**
  56760. * Disposes the ShadowGenerator.
  56761. * Returns nothing.
  56762. */
  56763. dispose(): void;
  56764. /**
  56765. * Serializes the shadow generator setup to a json object.
  56766. * @returns The serialized JSON object
  56767. */
  56768. serialize(): any;
  56769. /**
  56770. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56771. * @param parsedShadowGenerator The JSON object to parse
  56772. * @param scene The scene to create the shadow map for
  56773. * @returns The parsed shadow generator
  56774. */
  56775. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56776. }
  56777. }
  56778. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56779. import { Scene } from "babylonjs/scene";
  56780. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56781. import { AbstractScene } from "babylonjs/abstractScene";
  56782. /**
  56783. * Defines the shadow generator component responsible to manage any shadow generators
  56784. * in a given scene.
  56785. */
  56786. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56787. /**
  56788. * The component name helpfull to identify the component in the list of scene components.
  56789. */
  56790. readonly name: string;
  56791. /**
  56792. * The scene the component belongs to.
  56793. */
  56794. scene: Scene;
  56795. /**
  56796. * Creates a new instance of the component for the given scene
  56797. * @param scene Defines the scene to register the component in
  56798. */
  56799. constructor(scene: Scene);
  56800. /**
  56801. * Registers the component in a given scene
  56802. */
  56803. register(): void;
  56804. /**
  56805. * Rebuilds the elements related to this component in case of
  56806. * context lost for instance.
  56807. */
  56808. rebuild(): void;
  56809. /**
  56810. * Serializes the component data to the specified json object
  56811. * @param serializationObject The object to serialize to
  56812. */
  56813. serialize(serializationObject: any): void;
  56814. /**
  56815. * Adds all the elements from the container to the scene
  56816. * @param container the container holding the elements
  56817. */
  56818. addFromContainer(container: AbstractScene): void;
  56819. /**
  56820. * Removes all the elements in the container from the scene
  56821. * @param container contains the elements to remove
  56822. * @param dispose if the removed element should be disposed (default: false)
  56823. */
  56824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56825. /**
  56826. * Rebuilds the elements related to this component in case of
  56827. * context lost for instance.
  56828. */
  56829. dispose(): void;
  56830. private _gatherRenderTargets;
  56831. }
  56832. }
  56833. declare module "babylonjs/Lights/Shadows/index" {
  56834. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56835. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56836. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56837. }
  56838. declare module "babylonjs/Lights/pointLight" {
  56839. import { Scene } from "babylonjs/scene";
  56840. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56842. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56843. import { Effect } from "babylonjs/Materials/effect";
  56844. /**
  56845. * A point light is a light defined by an unique point in world space.
  56846. * The light is emitted in every direction from this point.
  56847. * A good example of a point light is a standard light bulb.
  56848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56849. */
  56850. export class PointLight extends ShadowLight {
  56851. private _shadowAngle;
  56852. /**
  56853. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56854. * This specifies what angle the shadow will use to be created.
  56855. *
  56856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56857. */
  56858. get shadowAngle(): number;
  56859. /**
  56860. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56861. * This specifies what angle the shadow will use to be created.
  56862. *
  56863. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56864. */
  56865. set shadowAngle(value: number);
  56866. /**
  56867. * Gets the direction if it has been set.
  56868. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56869. */
  56870. get direction(): Vector3;
  56871. /**
  56872. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56873. */
  56874. set direction(value: Vector3);
  56875. /**
  56876. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56877. * A PointLight emits the light in every direction.
  56878. * It can cast shadows.
  56879. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56880. * ```javascript
  56881. * var pointLight = new PointLight("pl", camera.position, scene);
  56882. * ```
  56883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56884. * @param name The light friendly name
  56885. * @param position The position of the point light in the scene
  56886. * @param scene The scene the lights belongs to
  56887. */
  56888. constructor(name: string, position: Vector3, scene: Scene);
  56889. /**
  56890. * Returns the string "PointLight"
  56891. * @returns the class name
  56892. */
  56893. getClassName(): string;
  56894. /**
  56895. * Returns the integer 0.
  56896. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56897. */
  56898. getTypeID(): number;
  56899. /**
  56900. * Specifies wether or not the shadowmap should be a cube texture.
  56901. * @returns true if the shadowmap needs to be a cube texture.
  56902. */
  56903. needCube(): boolean;
  56904. /**
  56905. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56908. */
  56909. getShadowDirection(faceIndex?: number): Vector3;
  56910. /**
  56911. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56912. * - fov = PI / 2
  56913. * - aspect ratio : 1.0
  56914. * - z-near and far equal to the active camera minZ and maxZ.
  56915. * Returns the PointLight.
  56916. */
  56917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56918. protected _buildUniformLayout(): void;
  56919. /**
  56920. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56921. * @param effect The effect to update
  56922. * @param lightIndex The index of the light in the effect to update
  56923. * @returns The point light
  56924. */
  56925. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56926. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56927. /**
  56928. * Prepares the list of defines specific to the light type.
  56929. * @param defines the list of defines
  56930. * @param lightIndex defines the index of the light for the effect
  56931. */
  56932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56933. }
  56934. }
  56935. declare module "babylonjs/Lights/index" {
  56936. export * from "babylonjs/Lights/light";
  56937. export * from "babylonjs/Lights/shadowLight";
  56938. export * from "babylonjs/Lights/Shadows/index";
  56939. export * from "babylonjs/Lights/directionalLight";
  56940. export * from "babylonjs/Lights/hemisphericLight";
  56941. export * from "babylonjs/Lights/pointLight";
  56942. export * from "babylonjs/Lights/spotLight";
  56943. }
  56944. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56945. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56946. /**
  56947. * Header information of HDR texture files.
  56948. */
  56949. export interface HDRInfo {
  56950. /**
  56951. * The height of the texture in pixels.
  56952. */
  56953. height: number;
  56954. /**
  56955. * The width of the texture in pixels.
  56956. */
  56957. width: number;
  56958. /**
  56959. * The index of the beginning of the data in the binary file.
  56960. */
  56961. dataPosition: number;
  56962. }
  56963. /**
  56964. * This groups tools to convert HDR texture to native colors array.
  56965. */
  56966. export class HDRTools {
  56967. private static Ldexp;
  56968. private static Rgbe2float;
  56969. private static readStringLine;
  56970. /**
  56971. * Reads header information from an RGBE texture stored in a native array.
  56972. * More information on this format are available here:
  56973. * https://en.wikipedia.org/wiki/RGBE_image_format
  56974. *
  56975. * @param uint8array The binary file stored in native array.
  56976. * @return The header information.
  56977. */
  56978. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56979. /**
  56980. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56981. * This RGBE texture needs to store the information as a panorama.
  56982. *
  56983. * More information on this format are available here:
  56984. * https://en.wikipedia.org/wiki/RGBE_image_format
  56985. *
  56986. * @param buffer The binary file stored in an array buffer.
  56987. * @param size The expected size of the extracted cubemap.
  56988. * @return The Cube Map information.
  56989. */
  56990. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56991. /**
  56992. * Returns the pixels data extracted from an RGBE texture.
  56993. * This pixels will be stored left to right up to down in the R G B order in one array.
  56994. *
  56995. * More information on this format are available here:
  56996. * https://en.wikipedia.org/wiki/RGBE_image_format
  56997. *
  56998. * @param uint8array The binary file stored in an array buffer.
  56999. * @param hdrInfo The header information of the file.
  57000. * @return The pixels data in RGB right to left up to down order.
  57001. */
  57002. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57003. private static RGBE_ReadPixels_RLE;
  57004. }
  57005. }
  57006. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57007. import { Nullable } from "babylonjs/types";
  57008. import { Scene } from "babylonjs/scene";
  57009. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57011. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57012. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57013. /**
  57014. * This represents a texture coming from an HDR input.
  57015. *
  57016. * The only supported format is currently panorama picture stored in RGBE format.
  57017. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57018. */
  57019. export class HDRCubeTexture extends BaseTexture {
  57020. private static _facesMapping;
  57021. private _generateHarmonics;
  57022. private _noMipmap;
  57023. private _textureMatrix;
  57024. private _size;
  57025. private _onLoad;
  57026. private _onError;
  57027. /**
  57028. * The texture URL.
  57029. */
  57030. url: string;
  57031. /**
  57032. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57033. */
  57034. coordinatesMode: number;
  57035. protected _isBlocking: boolean;
  57036. /**
  57037. * Sets wether or not the texture is blocking during loading.
  57038. */
  57039. set isBlocking(value: boolean);
  57040. /**
  57041. * Gets wether or not the texture is blocking during loading.
  57042. */
  57043. get isBlocking(): boolean;
  57044. protected _rotationY: number;
  57045. /**
  57046. * Sets texture matrix rotation angle around Y axis in radians.
  57047. */
  57048. set rotationY(value: number);
  57049. /**
  57050. * Gets texture matrix rotation angle around Y axis radians.
  57051. */
  57052. get rotationY(): number;
  57053. /**
  57054. * Gets or sets the center of the bounding box associated with the cube texture
  57055. * It must define where the camera used to render the texture was set
  57056. */
  57057. boundingBoxPosition: Vector3;
  57058. private _boundingBoxSize;
  57059. /**
  57060. * Gets or sets the size of the bounding box associated with the cube texture
  57061. * When defined, the cubemap will switch to local mode
  57062. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57063. * @example https://www.babylonjs-playground.com/#RNASML
  57064. */
  57065. set boundingBoxSize(value: Vector3);
  57066. get boundingBoxSize(): Vector3;
  57067. /**
  57068. * Instantiates an HDRTexture from the following parameters.
  57069. *
  57070. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57071. * @param scene The scene the texture will be used in
  57072. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57073. * @param noMipmap Forces to not generate the mipmap if true
  57074. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57075. * @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)
  57076. * @param reserved Reserved flag for internal use.
  57077. */
  57078. 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>);
  57079. /**
  57080. * Get the current class name of the texture useful for serialization or dynamic coding.
  57081. * @returns "HDRCubeTexture"
  57082. */
  57083. getClassName(): string;
  57084. /**
  57085. * Occurs when the file is raw .hdr file.
  57086. */
  57087. private loadTexture;
  57088. clone(): HDRCubeTexture;
  57089. delayLoad(): void;
  57090. /**
  57091. * Get the texture reflection matrix used to rotate/transform the reflection.
  57092. * @returns the reflection matrix
  57093. */
  57094. getReflectionTextureMatrix(): Matrix;
  57095. /**
  57096. * Set the texture reflection matrix used to rotate/transform the reflection.
  57097. * @param value Define the reflection matrix to set
  57098. */
  57099. setReflectionTextureMatrix(value: Matrix): void;
  57100. /**
  57101. * Parses a JSON representation of an HDR Texture in order to create the texture
  57102. * @param parsedTexture Define the JSON representation
  57103. * @param scene Define the scene the texture should be created in
  57104. * @param rootUrl Define the root url in case we need to load relative dependencies
  57105. * @returns the newly created texture after parsing
  57106. */
  57107. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57108. serialize(): any;
  57109. }
  57110. }
  57111. declare module "babylonjs/Physics/physicsEngine" {
  57112. import { Nullable } from "babylonjs/types";
  57113. import { Vector3 } from "babylonjs/Maths/math.vector";
  57114. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57115. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57116. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57117. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57118. /**
  57119. * Class used to control physics engine
  57120. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57121. */
  57122. export class PhysicsEngine implements IPhysicsEngine {
  57123. private _physicsPlugin;
  57124. /**
  57125. * Global value used to control the smallest number supported by the simulation
  57126. */
  57127. static Epsilon: number;
  57128. private _impostors;
  57129. private _joints;
  57130. private _subTimeStep;
  57131. /**
  57132. * Gets the gravity vector used by the simulation
  57133. */
  57134. gravity: Vector3;
  57135. /**
  57136. * Factory used to create the default physics plugin.
  57137. * @returns The default physics plugin
  57138. */
  57139. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57140. /**
  57141. * Creates a new Physics Engine
  57142. * @param gravity defines the gravity vector used by the simulation
  57143. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57144. */
  57145. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57146. /**
  57147. * Sets the gravity vector used by the simulation
  57148. * @param gravity defines the gravity vector to use
  57149. */
  57150. setGravity(gravity: Vector3): void;
  57151. /**
  57152. * Set the time step of the physics engine.
  57153. * Default is 1/60.
  57154. * To slow it down, enter 1/600 for example.
  57155. * To speed it up, 1/30
  57156. * @param newTimeStep defines the new timestep to apply to this world.
  57157. */
  57158. setTimeStep(newTimeStep?: number): void;
  57159. /**
  57160. * Get the time step of the physics engine.
  57161. * @returns the current time step
  57162. */
  57163. getTimeStep(): number;
  57164. /**
  57165. * Set the sub time step of the physics engine.
  57166. * Default is 0 meaning there is no sub steps
  57167. * To increase physics resolution precision, set a small value (like 1 ms)
  57168. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57169. */
  57170. setSubTimeStep(subTimeStep?: number): void;
  57171. /**
  57172. * Get the sub time step of the physics engine.
  57173. * @returns the current sub time step
  57174. */
  57175. getSubTimeStep(): number;
  57176. /**
  57177. * Release all resources
  57178. */
  57179. dispose(): void;
  57180. /**
  57181. * Gets the name of the current physics plugin
  57182. * @returns the name of the plugin
  57183. */
  57184. getPhysicsPluginName(): string;
  57185. /**
  57186. * Adding a new impostor for the impostor tracking.
  57187. * This will be done by the impostor itself.
  57188. * @param impostor the impostor to add
  57189. */
  57190. addImpostor(impostor: PhysicsImpostor): void;
  57191. /**
  57192. * Remove an impostor from the engine.
  57193. * This impostor and its mesh will not longer be updated by the physics engine.
  57194. * @param impostor the impostor to remove
  57195. */
  57196. removeImpostor(impostor: PhysicsImpostor): void;
  57197. /**
  57198. * Add a joint to the physics engine
  57199. * @param mainImpostor defines the main impostor to which the joint is added.
  57200. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57201. * @param joint defines the joint that will connect both impostors.
  57202. */
  57203. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57204. /**
  57205. * Removes a joint from the simulation
  57206. * @param mainImpostor defines the impostor used with the joint
  57207. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57208. * @param joint defines the joint to remove
  57209. */
  57210. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57211. /**
  57212. * Called by the scene. No need to call it.
  57213. * @param delta defines the timespam between frames
  57214. */
  57215. _step(delta: number): void;
  57216. /**
  57217. * Gets the current plugin used to run the simulation
  57218. * @returns current plugin
  57219. */
  57220. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57221. /**
  57222. * Gets the list of physic impostors
  57223. * @returns an array of PhysicsImpostor
  57224. */
  57225. getImpostors(): Array<PhysicsImpostor>;
  57226. /**
  57227. * Gets the impostor for a physics enabled object
  57228. * @param object defines the object impersonated by the impostor
  57229. * @returns the PhysicsImpostor or null if not found
  57230. */
  57231. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57232. /**
  57233. * Gets the impostor for a physics body object
  57234. * @param body defines physics body used by the impostor
  57235. * @returns the PhysicsImpostor or null if not found
  57236. */
  57237. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57238. /**
  57239. * Does a raycast in the physics world
  57240. * @param from when should the ray start?
  57241. * @param to when should the ray end?
  57242. * @returns PhysicsRaycastResult
  57243. */
  57244. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57245. }
  57246. }
  57247. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57248. import { Nullable } from "babylonjs/types";
  57249. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57251. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57252. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57253. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57254. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57255. /** @hidden */
  57256. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57257. private _useDeltaForWorldStep;
  57258. world: any;
  57259. name: string;
  57260. private _physicsMaterials;
  57261. private _fixedTimeStep;
  57262. private _cannonRaycastResult;
  57263. private _raycastResult;
  57264. private _physicsBodysToRemoveAfterStep;
  57265. BJSCANNON: any;
  57266. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57267. setGravity(gravity: Vector3): void;
  57268. setTimeStep(timeStep: number): void;
  57269. getTimeStep(): number;
  57270. executeStep(delta: number): void;
  57271. private _removeMarkedPhysicsBodiesFromWorld;
  57272. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57273. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57274. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57275. private _processChildMeshes;
  57276. removePhysicsBody(impostor: PhysicsImpostor): void;
  57277. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57278. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57279. private _addMaterial;
  57280. private _checkWithEpsilon;
  57281. private _createShape;
  57282. private _createHeightmap;
  57283. private _minus90X;
  57284. private _plus90X;
  57285. private _tmpPosition;
  57286. private _tmpDeltaPosition;
  57287. private _tmpUnityRotation;
  57288. private _updatePhysicsBodyTransformation;
  57289. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57291. isSupported(): boolean;
  57292. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57293. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57294. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57295. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57296. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57297. getBodyMass(impostor: PhysicsImpostor): number;
  57298. getBodyFriction(impostor: PhysicsImpostor): number;
  57299. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57300. getBodyRestitution(impostor: PhysicsImpostor): number;
  57301. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57302. sleepBody(impostor: PhysicsImpostor): void;
  57303. wakeUpBody(impostor: PhysicsImpostor): void;
  57304. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57305. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57306. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57307. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57308. getRadius(impostor: PhysicsImpostor): number;
  57309. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57310. dispose(): void;
  57311. private _extendNamespace;
  57312. /**
  57313. * Does a raycast in the physics world
  57314. * @param from when should the ray start?
  57315. * @param to when should the ray end?
  57316. * @returns PhysicsRaycastResult
  57317. */
  57318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57319. }
  57320. }
  57321. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57322. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57323. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57324. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57326. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57327. import { Nullable } from "babylonjs/types";
  57328. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57329. /** @hidden */
  57330. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57331. world: any;
  57332. name: string;
  57333. BJSOIMO: any;
  57334. private _raycastResult;
  57335. constructor(iterations?: number, oimoInjection?: any);
  57336. setGravity(gravity: Vector3): void;
  57337. setTimeStep(timeStep: number): void;
  57338. getTimeStep(): number;
  57339. private _tmpImpostorsArray;
  57340. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57341. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57342. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57343. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57344. private _tmpPositionVector;
  57345. removePhysicsBody(impostor: PhysicsImpostor): void;
  57346. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57347. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57348. isSupported(): boolean;
  57349. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57350. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57352. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57355. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57356. getBodyMass(impostor: PhysicsImpostor): number;
  57357. getBodyFriction(impostor: PhysicsImpostor): number;
  57358. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57359. getBodyRestitution(impostor: PhysicsImpostor): number;
  57360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57361. sleepBody(impostor: PhysicsImpostor): void;
  57362. wakeUpBody(impostor: PhysicsImpostor): void;
  57363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57364. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57367. getRadius(impostor: PhysicsImpostor): number;
  57368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57369. dispose(): void;
  57370. /**
  57371. * Does a raycast in the physics world
  57372. * @param from when should the ray start?
  57373. * @param to when should the ray end?
  57374. * @returns PhysicsRaycastResult
  57375. */
  57376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57377. }
  57378. }
  57379. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57380. import { Nullable } from "babylonjs/types";
  57381. import { Scene } from "babylonjs/scene";
  57382. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57383. import { Color4 } from "babylonjs/Maths/math.color";
  57384. import { Mesh } from "babylonjs/Meshes/mesh";
  57385. /**
  57386. * Class containing static functions to help procedurally build meshes
  57387. */
  57388. export class RibbonBuilder {
  57389. /**
  57390. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57391. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57392. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57393. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57394. * * 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
  57395. * * 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
  57396. * * 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
  57397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57400. * * 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
  57401. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57402. * * 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
  57403. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57405. * @param name defines the name of the mesh
  57406. * @param options defines the options used to create the mesh
  57407. * @param scene defines the hosting scene
  57408. * @returns the ribbon mesh
  57409. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57411. */
  57412. static CreateRibbon(name: string, options: {
  57413. pathArray: Vector3[][];
  57414. closeArray?: boolean;
  57415. closePath?: boolean;
  57416. offset?: number;
  57417. updatable?: boolean;
  57418. sideOrientation?: number;
  57419. frontUVs?: Vector4;
  57420. backUVs?: Vector4;
  57421. instance?: Mesh;
  57422. invertUV?: boolean;
  57423. uvs?: Vector2[];
  57424. colors?: Color4[];
  57425. }, scene?: Nullable<Scene>): Mesh;
  57426. }
  57427. }
  57428. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57429. import { Nullable } from "babylonjs/types";
  57430. import { Scene } from "babylonjs/scene";
  57431. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57432. import { Mesh } from "babylonjs/Meshes/mesh";
  57433. /**
  57434. * Class containing static functions to help procedurally build meshes
  57435. */
  57436. export class ShapeBuilder {
  57437. /**
  57438. * 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.
  57439. * * 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.
  57440. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57441. * * 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.
  57442. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57443. * * 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
  57444. * * 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
  57445. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57450. * @param name defines the name of the mesh
  57451. * @param options defines the options used to create the mesh
  57452. * @param scene defines the hosting scene
  57453. * @returns the extruded shape mesh
  57454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57456. */
  57457. static ExtrudeShape(name: string, options: {
  57458. shape: Vector3[];
  57459. path: Vector3[];
  57460. scale?: number;
  57461. rotation?: number;
  57462. cap?: number;
  57463. updatable?: boolean;
  57464. sideOrientation?: number;
  57465. frontUVs?: Vector4;
  57466. backUVs?: Vector4;
  57467. instance?: Mesh;
  57468. invertUV?: boolean;
  57469. }, scene?: Nullable<Scene>): Mesh;
  57470. /**
  57471. * Creates an custom extruded shape mesh.
  57472. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57473. * * 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.
  57474. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57475. * * 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
  57476. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57477. * * 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
  57478. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57479. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57480. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57481. * * 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
  57482. * * 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
  57483. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57488. * @param name defines the name of the mesh
  57489. * @param options defines the options used to create the mesh
  57490. * @param scene defines the hosting scene
  57491. * @returns the custom extruded shape mesh
  57492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57495. */
  57496. static ExtrudeShapeCustom(name: string, options: {
  57497. shape: Vector3[];
  57498. path: Vector3[];
  57499. scaleFunction?: any;
  57500. rotationFunction?: any;
  57501. ribbonCloseArray?: boolean;
  57502. ribbonClosePath?: boolean;
  57503. cap?: number;
  57504. updatable?: boolean;
  57505. sideOrientation?: number;
  57506. frontUVs?: Vector4;
  57507. backUVs?: Vector4;
  57508. instance?: Mesh;
  57509. invertUV?: boolean;
  57510. }, scene?: Nullable<Scene>): Mesh;
  57511. private static _ExtrudeShapeGeneric;
  57512. }
  57513. }
  57514. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57515. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57516. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57517. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57518. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57519. import { Nullable } from "babylonjs/types";
  57520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57521. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57522. /**
  57523. * AmmoJS Physics plugin
  57524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57525. * @see https://github.com/kripken/ammo.js/
  57526. */
  57527. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57528. private _useDeltaForWorldStep;
  57529. /**
  57530. * Reference to the Ammo library
  57531. */
  57532. bjsAMMO: any;
  57533. /**
  57534. * Created ammoJS world which physics bodies are added to
  57535. */
  57536. world: any;
  57537. /**
  57538. * Name of the plugin
  57539. */
  57540. name: string;
  57541. private _timeStep;
  57542. private _fixedTimeStep;
  57543. private _maxSteps;
  57544. private _tmpQuaternion;
  57545. private _tmpAmmoTransform;
  57546. private _tmpAmmoQuaternion;
  57547. private _tmpAmmoConcreteContactResultCallback;
  57548. private _collisionConfiguration;
  57549. private _dispatcher;
  57550. private _overlappingPairCache;
  57551. private _solver;
  57552. private _softBodySolver;
  57553. private _tmpAmmoVectorA;
  57554. private _tmpAmmoVectorB;
  57555. private _tmpAmmoVectorC;
  57556. private _tmpAmmoVectorD;
  57557. private _tmpContactCallbackResult;
  57558. private _tmpAmmoVectorRCA;
  57559. private _tmpAmmoVectorRCB;
  57560. private _raycastResult;
  57561. private static readonly DISABLE_COLLISION_FLAG;
  57562. private static readonly KINEMATIC_FLAG;
  57563. private static readonly DISABLE_DEACTIVATION_FLAG;
  57564. /**
  57565. * Initializes the ammoJS plugin
  57566. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57567. * @param ammoInjection can be used to inject your own ammo reference
  57568. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57569. */
  57570. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57571. /**
  57572. * Sets the gravity of the physics world (m/(s^2))
  57573. * @param gravity Gravity to set
  57574. */
  57575. setGravity(gravity: Vector3): void;
  57576. /**
  57577. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57578. * @param timeStep timestep to use in seconds
  57579. */
  57580. setTimeStep(timeStep: number): void;
  57581. /**
  57582. * 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)
  57583. * @param fixedTimeStep fixedTimeStep to use in seconds
  57584. */
  57585. setFixedTimeStep(fixedTimeStep: number): void;
  57586. /**
  57587. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57588. * @param maxSteps the maximum number of steps by the physics engine per frame
  57589. */
  57590. setMaxSteps(maxSteps: number): void;
  57591. /**
  57592. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57593. * @returns the current timestep in seconds
  57594. */
  57595. getTimeStep(): number;
  57596. /**
  57597. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57598. */
  57599. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57600. private _isImpostorInContact;
  57601. private _isImpostorPairInContact;
  57602. private _stepSimulation;
  57603. /**
  57604. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57605. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57606. * After the step the babylon meshes are set to the position of the physics imposters
  57607. * @param delta amount of time to step forward
  57608. * @param impostors array of imposters to update before/after the step
  57609. */
  57610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57611. /**
  57612. * Update babylon mesh to match physics world object
  57613. * @param impostor imposter to match
  57614. */
  57615. private _afterSoftStep;
  57616. /**
  57617. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57618. * @param impostor imposter to match
  57619. */
  57620. private _ropeStep;
  57621. /**
  57622. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57623. * @param impostor imposter to match
  57624. */
  57625. private _softbodyOrClothStep;
  57626. private _tmpVector;
  57627. private _tmpMatrix;
  57628. /**
  57629. * Applies an impulse on the imposter
  57630. * @param impostor imposter to apply impulse to
  57631. * @param force amount of force to be applied to the imposter
  57632. * @param contactPoint the location to apply the impulse on the imposter
  57633. */
  57634. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57635. /**
  57636. * Applies a force on the imposter
  57637. * @param impostor imposter to apply force
  57638. * @param force amount of force to be applied to the imposter
  57639. * @param contactPoint the location to apply the force on the imposter
  57640. */
  57641. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57642. /**
  57643. * Creates a physics body using the plugin
  57644. * @param impostor the imposter to create the physics body on
  57645. */
  57646. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57647. /**
  57648. * Removes the physics body from the imposter and disposes of the body's memory
  57649. * @param impostor imposter to remove the physics body from
  57650. */
  57651. removePhysicsBody(impostor: PhysicsImpostor): void;
  57652. /**
  57653. * Generates a joint
  57654. * @param impostorJoint the imposter joint to create the joint with
  57655. */
  57656. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57657. /**
  57658. * Removes a joint
  57659. * @param impostorJoint the imposter joint to remove the joint from
  57660. */
  57661. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57662. private _addMeshVerts;
  57663. /**
  57664. * Initialise the soft body vertices to match its object's (mesh) vertices
  57665. * Softbody vertices (nodes) are in world space and to match this
  57666. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57667. * @param impostor to create the softbody for
  57668. */
  57669. private _softVertexData;
  57670. /**
  57671. * Create an impostor's soft body
  57672. * @param impostor to create the softbody for
  57673. */
  57674. private _createSoftbody;
  57675. /**
  57676. * Create cloth for an impostor
  57677. * @param impostor to create the softbody for
  57678. */
  57679. private _createCloth;
  57680. /**
  57681. * Create rope for an impostor
  57682. * @param impostor to create the softbody for
  57683. */
  57684. private _createRope;
  57685. /**
  57686. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57687. * @param impostor to create the custom physics shape for
  57688. */
  57689. private _createCustom;
  57690. private _addHullVerts;
  57691. private _createShape;
  57692. /**
  57693. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57694. * @param impostor imposter containing the physics body and babylon object
  57695. */
  57696. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57697. /**
  57698. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57699. * @param impostor imposter containing the physics body and babylon object
  57700. * @param newPosition new position
  57701. * @param newRotation new rotation
  57702. */
  57703. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57704. /**
  57705. * If this plugin is supported
  57706. * @returns true if its supported
  57707. */
  57708. isSupported(): boolean;
  57709. /**
  57710. * Sets the linear velocity of the physics body
  57711. * @param impostor imposter to set the velocity on
  57712. * @param velocity velocity to set
  57713. */
  57714. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57715. /**
  57716. * Sets the angular velocity of the physics body
  57717. * @param impostor imposter to set the velocity on
  57718. * @param velocity velocity to set
  57719. */
  57720. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57721. /**
  57722. * gets the linear velocity
  57723. * @param impostor imposter to get linear velocity from
  57724. * @returns linear velocity
  57725. */
  57726. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57727. /**
  57728. * gets the angular velocity
  57729. * @param impostor imposter to get angular velocity from
  57730. * @returns angular velocity
  57731. */
  57732. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57733. /**
  57734. * Sets the mass of physics body
  57735. * @param impostor imposter to set the mass on
  57736. * @param mass mass to set
  57737. */
  57738. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57739. /**
  57740. * Gets the mass of the physics body
  57741. * @param impostor imposter to get the mass from
  57742. * @returns mass
  57743. */
  57744. getBodyMass(impostor: PhysicsImpostor): number;
  57745. /**
  57746. * Gets friction of the impostor
  57747. * @param impostor impostor to get friction from
  57748. * @returns friction value
  57749. */
  57750. getBodyFriction(impostor: PhysicsImpostor): number;
  57751. /**
  57752. * Sets friction of the impostor
  57753. * @param impostor impostor to set friction on
  57754. * @param friction friction value
  57755. */
  57756. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57757. /**
  57758. * Gets restitution of the impostor
  57759. * @param impostor impostor to get restitution from
  57760. * @returns restitution value
  57761. */
  57762. getBodyRestitution(impostor: PhysicsImpostor): number;
  57763. /**
  57764. * Sets resitution of the impostor
  57765. * @param impostor impostor to set resitution on
  57766. * @param restitution resitution value
  57767. */
  57768. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57769. /**
  57770. * Gets pressure inside the impostor
  57771. * @param impostor impostor to get pressure from
  57772. * @returns pressure value
  57773. */
  57774. getBodyPressure(impostor: PhysicsImpostor): number;
  57775. /**
  57776. * Sets pressure inside a soft body impostor
  57777. * Cloth and rope must remain 0 pressure
  57778. * @param impostor impostor to set pressure on
  57779. * @param pressure pressure value
  57780. */
  57781. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57782. /**
  57783. * Gets stiffness of the impostor
  57784. * @param impostor impostor to get stiffness from
  57785. * @returns pressure value
  57786. */
  57787. getBodyStiffness(impostor: PhysicsImpostor): number;
  57788. /**
  57789. * Sets stiffness of the impostor
  57790. * @param impostor impostor to set stiffness on
  57791. * @param stiffness stiffness value from 0 to 1
  57792. */
  57793. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57794. /**
  57795. * Gets velocityIterations of the impostor
  57796. * @param impostor impostor to get velocity iterations from
  57797. * @returns velocityIterations value
  57798. */
  57799. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57800. /**
  57801. * Sets velocityIterations of the impostor
  57802. * @param impostor impostor to set velocity iterations on
  57803. * @param velocityIterations velocityIterations value
  57804. */
  57805. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57806. /**
  57807. * Gets positionIterations of the impostor
  57808. * @param impostor impostor to get position iterations from
  57809. * @returns positionIterations value
  57810. */
  57811. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57812. /**
  57813. * Sets positionIterations of the impostor
  57814. * @param impostor impostor to set position on
  57815. * @param positionIterations positionIterations value
  57816. */
  57817. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57818. /**
  57819. * Append an anchor to a cloth object
  57820. * @param impostor is the cloth impostor to add anchor to
  57821. * @param otherImpostor is the rigid impostor to anchor to
  57822. * @param width ratio across width from 0 to 1
  57823. * @param height ratio up height from 0 to 1
  57824. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57825. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57826. */
  57827. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57828. /**
  57829. * Append an hook to a rope object
  57830. * @param impostor is the rope impostor to add hook to
  57831. * @param otherImpostor is the rigid impostor to hook to
  57832. * @param length ratio along the rope from 0 to 1
  57833. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57834. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57835. */
  57836. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57837. /**
  57838. * Sleeps the physics body and stops it from being active
  57839. * @param impostor impostor to sleep
  57840. */
  57841. sleepBody(impostor: PhysicsImpostor): void;
  57842. /**
  57843. * Activates the physics body
  57844. * @param impostor impostor to activate
  57845. */
  57846. wakeUpBody(impostor: PhysicsImpostor): void;
  57847. /**
  57848. * Updates the distance parameters of the joint
  57849. * @param joint joint to update
  57850. * @param maxDistance maximum distance of the joint
  57851. * @param minDistance minimum distance of the joint
  57852. */
  57853. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57854. /**
  57855. * Sets a motor on the joint
  57856. * @param joint joint to set motor on
  57857. * @param speed speed of the motor
  57858. * @param maxForce maximum force of the motor
  57859. * @param motorIndex index of the motor
  57860. */
  57861. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57862. /**
  57863. * Sets the motors limit
  57864. * @param joint joint to set limit on
  57865. * @param upperLimit upper limit
  57866. * @param lowerLimit lower limit
  57867. */
  57868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57869. /**
  57870. * Syncs the position and rotation of a mesh with the impostor
  57871. * @param mesh mesh to sync
  57872. * @param impostor impostor to update the mesh with
  57873. */
  57874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57875. /**
  57876. * Gets the radius of the impostor
  57877. * @param impostor impostor to get radius from
  57878. * @returns the radius
  57879. */
  57880. getRadius(impostor: PhysicsImpostor): number;
  57881. /**
  57882. * Gets the box size of the impostor
  57883. * @param impostor impostor to get box size from
  57884. * @param result the resulting box size
  57885. */
  57886. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57887. /**
  57888. * Disposes of the impostor
  57889. */
  57890. dispose(): void;
  57891. /**
  57892. * Does a raycast in the physics world
  57893. * @param from when should the ray start?
  57894. * @param to when should the ray end?
  57895. * @returns PhysicsRaycastResult
  57896. */
  57897. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57898. }
  57899. }
  57900. declare module "babylonjs/Probes/reflectionProbe" {
  57901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57902. import { Vector3 } from "babylonjs/Maths/math.vector";
  57903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57904. import { Nullable } from "babylonjs/types";
  57905. import { Scene } from "babylonjs/scene";
  57906. module "babylonjs/abstractScene" {
  57907. interface AbstractScene {
  57908. /**
  57909. * The list of reflection probes added to the scene
  57910. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57911. */
  57912. reflectionProbes: Array<ReflectionProbe>;
  57913. /**
  57914. * Removes the given reflection probe from this scene.
  57915. * @param toRemove The reflection probe to remove
  57916. * @returns The index of the removed reflection probe
  57917. */
  57918. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57919. /**
  57920. * Adds the given reflection probe to this scene.
  57921. * @param newReflectionProbe The reflection probe to add
  57922. */
  57923. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57924. }
  57925. }
  57926. /**
  57927. * Class used to generate realtime reflection / refraction cube textures
  57928. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57929. */
  57930. export class ReflectionProbe {
  57931. /** defines the name of the probe */
  57932. name: string;
  57933. private _scene;
  57934. private _renderTargetTexture;
  57935. private _projectionMatrix;
  57936. private _viewMatrix;
  57937. private _target;
  57938. private _add;
  57939. private _attachedMesh;
  57940. private _invertYAxis;
  57941. /** Gets or sets probe position (center of the cube map) */
  57942. position: Vector3;
  57943. /**
  57944. * Creates a new reflection probe
  57945. * @param name defines the name of the probe
  57946. * @param size defines the texture resolution (for each face)
  57947. * @param scene defines the hosting scene
  57948. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57949. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57950. */
  57951. constructor(
  57952. /** defines the name of the probe */
  57953. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57954. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57955. get samples(): number;
  57956. set samples(value: number);
  57957. /** Gets or sets the refresh rate to use (on every frame by default) */
  57958. get refreshRate(): number;
  57959. set refreshRate(value: number);
  57960. /**
  57961. * Gets the hosting scene
  57962. * @returns a Scene
  57963. */
  57964. getScene(): Scene;
  57965. /** Gets the internal CubeTexture used to render to */
  57966. get cubeTexture(): RenderTargetTexture;
  57967. /** Gets the list of meshes to render */
  57968. get renderList(): Nullable<AbstractMesh[]>;
  57969. /**
  57970. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57971. * @param mesh defines the mesh to attach to
  57972. */
  57973. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57974. /**
  57975. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57976. * @param renderingGroupId The rendering group id corresponding to its index
  57977. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57978. */
  57979. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57980. /**
  57981. * Clean all associated resources
  57982. */
  57983. dispose(): void;
  57984. /**
  57985. * Converts the reflection probe information to a readable string for debug purpose.
  57986. * @param fullDetails Supports for multiple levels of logging within scene loading
  57987. * @returns the human readable reflection probe info
  57988. */
  57989. toString(fullDetails?: boolean): string;
  57990. /**
  57991. * Get the class name of the relfection probe.
  57992. * @returns "ReflectionProbe"
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57997. * @returns The JSON representation of the texture
  57998. */
  57999. serialize(): any;
  58000. /**
  58001. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58002. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58003. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58004. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58005. * @returns The parsed reflection probe if successful
  58006. */
  58007. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58008. }
  58009. }
  58010. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58011. /** @hidden */
  58012. export var _BabylonLoaderRegistered: boolean;
  58013. /**
  58014. * Helps setting up some configuration for the babylon file loader.
  58015. */
  58016. export class BabylonFileLoaderConfiguration {
  58017. /**
  58018. * The loader does not allow injecting custom physix engine into the plugins.
  58019. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58020. * So you could set this variable to your engine import to make it work.
  58021. */
  58022. static LoaderInjectedPhysicsEngine: any;
  58023. }
  58024. }
  58025. declare module "babylonjs/Loading/Plugins/index" {
  58026. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58027. }
  58028. declare module "babylonjs/Loading/index" {
  58029. export * from "babylonjs/Loading/loadingScreen";
  58030. export * from "babylonjs/Loading/Plugins/index";
  58031. export * from "babylonjs/Loading/sceneLoader";
  58032. export * from "babylonjs/Loading/sceneLoaderFlags";
  58033. }
  58034. declare module "babylonjs/Materials/Background/index" {
  58035. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58036. }
  58037. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58038. import { Scene } from "babylonjs/scene";
  58039. import { Color3 } from "babylonjs/Maths/math.color";
  58040. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58042. /**
  58043. * The Physically based simple base material of BJS.
  58044. *
  58045. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58046. * It is used as the base class for both the specGloss and metalRough conventions.
  58047. */
  58048. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58049. /**
  58050. * Number of Simultaneous lights allowed on the material.
  58051. */
  58052. maxSimultaneousLights: number;
  58053. /**
  58054. * If sets to true, disables all the lights affecting the material.
  58055. */
  58056. disableLighting: boolean;
  58057. /**
  58058. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58059. */
  58060. environmentTexture: BaseTexture;
  58061. /**
  58062. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58063. */
  58064. invertNormalMapX: boolean;
  58065. /**
  58066. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58067. */
  58068. invertNormalMapY: boolean;
  58069. /**
  58070. * Normal map used in the model.
  58071. */
  58072. normalTexture: BaseTexture;
  58073. /**
  58074. * Emissivie color used to self-illuminate the model.
  58075. */
  58076. emissiveColor: Color3;
  58077. /**
  58078. * Emissivie texture used to self-illuminate the model.
  58079. */
  58080. emissiveTexture: BaseTexture;
  58081. /**
  58082. * Occlusion Channel Strenght.
  58083. */
  58084. occlusionStrength: number;
  58085. /**
  58086. * Occlusion Texture of the material (adding extra occlusion effects).
  58087. */
  58088. occlusionTexture: BaseTexture;
  58089. /**
  58090. * Defines the alpha limits in alpha test mode.
  58091. */
  58092. alphaCutOff: number;
  58093. /**
  58094. * Gets the current double sided mode.
  58095. */
  58096. get doubleSided(): boolean;
  58097. /**
  58098. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58099. */
  58100. set doubleSided(value: boolean);
  58101. /**
  58102. * Stores the pre-calculated light information of a mesh in a texture.
  58103. */
  58104. lightmapTexture: BaseTexture;
  58105. /**
  58106. * If true, the light map contains occlusion information instead of lighting info.
  58107. */
  58108. useLightmapAsShadowmap: boolean;
  58109. /**
  58110. * Instantiates a new PBRMaterial instance.
  58111. *
  58112. * @param name The material name
  58113. * @param scene The scene the material will be use in.
  58114. */
  58115. constructor(name: string, scene: Scene);
  58116. getClassName(): string;
  58117. }
  58118. }
  58119. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58120. import { Scene } from "babylonjs/scene";
  58121. import { Color3 } from "babylonjs/Maths/math.color";
  58122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58123. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58124. /**
  58125. * The PBR material of BJS following the metal roughness convention.
  58126. *
  58127. * This fits to the PBR convention in the GLTF definition:
  58128. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58129. */
  58130. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58131. /**
  58132. * The base color has two different interpretations depending on the value of metalness.
  58133. * When the material is a metal, the base color is the specific measured reflectance value
  58134. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58135. * of the material.
  58136. */
  58137. baseColor: Color3;
  58138. /**
  58139. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58140. * well as opacity information in the alpha channel.
  58141. */
  58142. baseTexture: BaseTexture;
  58143. /**
  58144. * Specifies the metallic scalar value of the material.
  58145. * Can also be used to scale the metalness values of the metallic texture.
  58146. */
  58147. metallic: number;
  58148. /**
  58149. * Specifies the roughness scalar value of the material.
  58150. * Can also be used to scale the roughness values of the metallic texture.
  58151. */
  58152. roughness: number;
  58153. /**
  58154. * Texture containing both the metallic value in the B channel and the
  58155. * roughness value in the G channel to keep better precision.
  58156. */
  58157. metallicRoughnessTexture: BaseTexture;
  58158. /**
  58159. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58160. *
  58161. * @param name The material name
  58162. * @param scene The scene the material will be use in.
  58163. */
  58164. constructor(name: string, scene: Scene);
  58165. /**
  58166. * Return the currrent class name of the material.
  58167. */
  58168. getClassName(): string;
  58169. /**
  58170. * Makes a duplicate of the current material.
  58171. * @param name - name to use for the new material.
  58172. */
  58173. clone(name: string): PBRMetallicRoughnessMaterial;
  58174. /**
  58175. * Serialize the material to a parsable JSON object.
  58176. */
  58177. serialize(): any;
  58178. /**
  58179. * Parses a JSON object correponding to the serialize function.
  58180. */
  58181. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58182. }
  58183. }
  58184. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58185. import { Scene } from "babylonjs/scene";
  58186. import { Color3 } from "babylonjs/Maths/math.color";
  58187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58188. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58189. /**
  58190. * The PBR material of BJS following the specular glossiness convention.
  58191. *
  58192. * This fits to the PBR convention in the GLTF definition:
  58193. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58194. */
  58195. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58196. /**
  58197. * Specifies the diffuse color of the material.
  58198. */
  58199. diffuseColor: Color3;
  58200. /**
  58201. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58202. * channel.
  58203. */
  58204. diffuseTexture: BaseTexture;
  58205. /**
  58206. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58207. */
  58208. specularColor: Color3;
  58209. /**
  58210. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58211. */
  58212. glossiness: number;
  58213. /**
  58214. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58215. */
  58216. specularGlossinessTexture: BaseTexture;
  58217. /**
  58218. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58219. *
  58220. * @param name The material name
  58221. * @param scene The scene the material will be use in.
  58222. */
  58223. constructor(name: string, scene: Scene);
  58224. /**
  58225. * Return the currrent class name of the material.
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Makes a duplicate of the current material.
  58230. * @param name - name to use for the new material.
  58231. */
  58232. clone(name: string): PBRSpecularGlossinessMaterial;
  58233. /**
  58234. * Serialize the material to a parsable JSON object.
  58235. */
  58236. serialize(): any;
  58237. /**
  58238. * Parses a JSON object correponding to the serialize function.
  58239. */
  58240. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58241. }
  58242. }
  58243. declare module "babylonjs/Materials/PBR/index" {
  58244. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58245. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58246. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58247. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58248. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58249. }
  58250. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58251. import { Nullable } from "babylonjs/types";
  58252. import { Scene } from "babylonjs/scene";
  58253. import { Matrix } from "babylonjs/Maths/math.vector";
  58254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58255. /**
  58256. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58257. * It can help converting any input color in a desired output one. This can then be used to create effects
  58258. * from sepia, black and white to sixties or futuristic rendering...
  58259. *
  58260. * The only supported format is currently 3dl.
  58261. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58262. */
  58263. export class ColorGradingTexture extends BaseTexture {
  58264. /**
  58265. * The current texture matrix. (will always be identity in color grading texture)
  58266. */
  58267. private _textureMatrix;
  58268. /**
  58269. * The texture URL.
  58270. */
  58271. url: string;
  58272. /**
  58273. * Empty line regex stored for GC.
  58274. */
  58275. private static _noneEmptyLineRegex;
  58276. private _engine;
  58277. /**
  58278. * Instantiates a ColorGradingTexture from the following parameters.
  58279. *
  58280. * @param url The location of the color gradind data (currently only supporting 3dl)
  58281. * @param scene The scene the texture will be used in
  58282. */
  58283. constructor(url: string, scene: Scene);
  58284. /**
  58285. * Returns the texture matrix used in most of the material.
  58286. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58287. */
  58288. getTextureMatrix(): Matrix;
  58289. /**
  58290. * Occurs when the file being loaded is a .3dl LUT file.
  58291. */
  58292. private load3dlTexture;
  58293. /**
  58294. * Starts the loading process of the texture.
  58295. */
  58296. private loadTexture;
  58297. /**
  58298. * Clones the color gradind texture.
  58299. */
  58300. clone(): ColorGradingTexture;
  58301. /**
  58302. * Called during delayed load for textures.
  58303. */
  58304. delayLoad(): void;
  58305. /**
  58306. * Parses a color grading texture serialized by Babylon.
  58307. * @param parsedTexture The texture information being parsedTexture
  58308. * @param scene The scene to load the texture in
  58309. * @param rootUrl The root url of the data assets to load
  58310. * @return A color gradind texture
  58311. */
  58312. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58313. /**
  58314. * Serializes the LUT texture to json format.
  58315. */
  58316. serialize(): any;
  58317. }
  58318. }
  58319. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58321. import { Scene } from "babylonjs/scene";
  58322. import { Nullable } from "babylonjs/types";
  58323. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58324. /**
  58325. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58326. */
  58327. export class EquiRectangularCubeTexture extends BaseTexture {
  58328. /** The six faces of the cube. */
  58329. private static _FacesMapping;
  58330. private _noMipmap;
  58331. private _onLoad;
  58332. private _onError;
  58333. /** The size of the cubemap. */
  58334. private _size;
  58335. /** The buffer of the image. */
  58336. private _buffer;
  58337. /** The width of the input image. */
  58338. private _width;
  58339. /** The height of the input image. */
  58340. private _height;
  58341. /** The URL to the image. */
  58342. url: string;
  58343. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58344. coordinatesMode: number;
  58345. /**
  58346. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58347. * @param url The location of the image
  58348. * @param scene The scene the texture will be used in
  58349. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58350. * @param noMipmap Forces to not generate the mipmap if true
  58351. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58352. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58353. * @param onLoad — defines a callback called when texture is loaded
  58354. * @param onError — defines a callback called if there is an error
  58355. */
  58356. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58357. /**
  58358. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58359. */
  58360. private loadImage;
  58361. /**
  58362. * Convert the image buffer into a cubemap and create a CubeTexture.
  58363. */
  58364. private loadTexture;
  58365. /**
  58366. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58367. * @param buffer The ArrayBuffer that should be converted.
  58368. * @returns The buffer as Float32Array.
  58369. */
  58370. private getFloat32ArrayFromArrayBuffer;
  58371. /**
  58372. * Get the current class name of the texture useful for serialization or dynamic coding.
  58373. * @returns "EquiRectangularCubeTexture"
  58374. */
  58375. getClassName(): string;
  58376. /**
  58377. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58378. * @returns A clone of the current EquiRectangularCubeTexture.
  58379. */
  58380. clone(): EquiRectangularCubeTexture;
  58381. }
  58382. }
  58383. declare module "babylonjs/Misc/tga" {
  58384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58385. /**
  58386. * Based on jsTGALoader - Javascript loader for TGA file
  58387. * By Vincent Thibault
  58388. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58389. */
  58390. export class TGATools {
  58391. private static _TYPE_INDEXED;
  58392. private static _TYPE_RGB;
  58393. private static _TYPE_GREY;
  58394. private static _TYPE_RLE_INDEXED;
  58395. private static _TYPE_RLE_RGB;
  58396. private static _TYPE_RLE_GREY;
  58397. private static _ORIGIN_MASK;
  58398. private static _ORIGIN_SHIFT;
  58399. private static _ORIGIN_BL;
  58400. private static _ORIGIN_BR;
  58401. private static _ORIGIN_UL;
  58402. private static _ORIGIN_UR;
  58403. /**
  58404. * Gets the header of a TGA file
  58405. * @param data defines the TGA data
  58406. * @returns the header
  58407. */
  58408. static GetTGAHeader(data: Uint8Array): any;
  58409. /**
  58410. * Uploads TGA content to a Babylon Texture
  58411. * @hidden
  58412. */
  58413. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58414. /** @hidden */
  58415. 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;
  58416. /** @hidden */
  58417. 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;
  58418. /** @hidden */
  58419. 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;
  58420. /** @hidden */
  58421. 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;
  58422. /** @hidden */
  58423. 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;
  58424. /** @hidden */
  58425. 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;
  58426. }
  58427. }
  58428. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58429. import { Nullable } from "babylonjs/types";
  58430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58431. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58432. /**
  58433. * Implementation of the TGA Texture Loader.
  58434. * @hidden
  58435. */
  58436. export class _TGATextureLoader implements IInternalTextureLoader {
  58437. /**
  58438. * Defines wether the loader supports cascade loading the different faces.
  58439. */
  58440. readonly supportCascades: boolean;
  58441. /**
  58442. * This returns if the loader support the current file information.
  58443. * @param extension defines the file extension of the file being loaded
  58444. * @returns true if the loader can load the specified file
  58445. */
  58446. canLoad(extension: string): boolean;
  58447. /**
  58448. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58449. * @param data contains the texture data
  58450. * @param texture defines the BabylonJS internal texture
  58451. * @param createPolynomials will be true if polynomials have been requested
  58452. * @param onLoad defines the callback to trigger once the texture is ready
  58453. * @param onError defines the callback to trigger in case of error
  58454. */
  58455. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58456. /**
  58457. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58458. * @param data contains the texture data
  58459. * @param texture defines the BabylonJS internal texture
  58460. * @param callback defines the method to call once ready to upload
  58461. */
  58462. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58463. }
  58464. }
  58465. declare module "babylonjs/Misc/basis" {
  58466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58467. /**
  58468. * Info about the .basis files
  58469. */
  58470. class BasisFileInfo {
  58471. /**
  58472. * If the file has alpha
  58473. */
  58474. hasAlpha: boolean;
  58475. /**
  58476. * Info about each image of the basis file
  58477. */
  58478. images: Array<{
  58479. levels: Array<{
  58480. width: number;
  58481. height: number;
  58482. transcodedPixels: ArrayBufferView;
  58483. }>;
  58484. }>;
  58485. }
  58486. /**
  58487. * Result of transcoding a basis file
  58488. */
  58489. class TranscodeResult {
  58490. /**
  58491. * Info about the .basis file
  58492. */
  58493. fileInfo: BasisFileInfo;
  58494. /**
  58495. * Format to use when loading the file
  58496. */
  58497. format: number;
  58498. }
  58499. /**
  58500. * Configuration options for the Basis transcoder
  58501. */
  58502. export class BasisTranscodeConfiguration {
  58503. /**
  58504. * Supported compression formats used to determine the supported output format of the transcoder
  58505. */
  58506. supportedCompressionFormats?: {
  58507. /**
  58508. * etc1 compression format
  58509. */
  58510. etc1?: boolean;
  58511. /**
  58512. * s3tc compression format
  58513. */
  58514. s3tc?: boolean;
  58515. /**
  58516. * pvrtc compression format
  58517. */
  58518. pvrtc?: boolean;
  58519. /**
  58520. * etc2 compression format
  58521. */
  58522. etc2?: boolean;
  58523. };
  58524. /**
  58525. * If mipmap levels should be loaded for transcoded images (Default: true)
  58526. */
  58527. loadMipmapLevels?: boolean;
  58528. /**
  58529. * Index of a single image to load (Default: all images)
  58530. */
  58531. loadSingleImage?: number;
  58532. }
  58533. /**
  58534. * Used to load .Basis files
  58535. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58536. */
  58537. export class BasisTools {
  58538. private static _IgnoreSupportedFormats;
  58539. /**
  58540. * URL to use when loading the basis transcoder
  58541. */
  58542. static JSModuleURL: string;
  58543. /**
  58544. * URL to use when loading the wasm module for the transcoder
  58545. */
  58546. static WasmModuleURL: string;
  58547. /**
  58548. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58549. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58550. * @returns internal format corresponding to the Basis format
  58551. */
  58552. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58553. private static _WorkerPromise;
  58554. private static _Worker;
  58555. private static _actionId;
  58556. private static _CreateWorkerAsync;
  58557. /**
  58558. * Transcodes a loaded image file to compressed pixel data
  58559. * @param data image data to transcode
  58560. * @param config configuration options for the transcoding
  58561. * @returns a promise resulting in the transcoded image
  58562. */
  58563. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58564. /**
  58565. * Loads a texture from the transcode result
  58566. * @param texture texture load to
  58567. * @param transcodeResult the result of transcoding the basis file to load from
  58568. */
  58569. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58570. }
  58571. }
  58572. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58573. import { Nullable } from "babylonjs/types";
  58574. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58575. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58576. /**
  58577. * Loader for .basis file format
  58578. */
  58579. export class _BasisTextureLoader implements IInternalTextureLoader {
  58580. /**
  58581. * Defines whether the loader supports cascade loading the different faces.
  58582. */
  58583. readonly supportCascades: boolean;
  58584. /**
  58585. * This returns if the loader support the current file information.
  58586. * @param extension defines the file extension of the file being loaded
  58587. * @returns true if the loader can load the specified file
  58588. */
  58589. canLoad(extension: string): boolean;
  58590. /**
  58591. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58592. * @param data contains the texture data
  58593. * @param texture defines the BabylonJS internal texture
  58594. * @param createPolynomials will be true if polynomials have been requested
  58595. * @param onLoad defines the callback to trigger once the texture is ready
  58596. * @param onError defines the callback to trigger in case of error
  58597. */
  58598. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58599. /**
  58600. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58601. * @param data contains the texture data
  58602. * @param texture defines the BabylonJS internal texture
  58603. * @param callback defines the method to call once ready to upload
  58604. */
  58605. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58606. }
  58607. }
  58608. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58609. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58610. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58611. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58612. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58613. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58614. }
  58615. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58616. import { Scene } from "babylonjs/scene";
  58617. import { Texture } from "babylonjs/Materials/Textures/texture";
  58618. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58619. /**
  58620. * 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.
  58621. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58622. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58623. */
  58624. export class CustomProceduralTexture extends ProceduralTexture {
  58625. private _animate;
  58626. private _time;
  58627. private _config;
  58628. private _texturePath;
  58629. /**
  58630. * Instantiates a new Custom Procedural Texture.
  58631. * 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.
  58632. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58633. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58634. * @param name Define the name of the texture
  58635. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58636. * @param size Define the size of the texture to create
  58637. * @param scene Define the scene the texture belongs to
  58638. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58639. * @param generateMipMaps Define if the texture should creates mip maps or not
  58640. */
  58641. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58642. private _loadJson;
  58643. /**
  58644. * Is the texture ready to be used ? (rendered at least once)
  58645. * @returns true if ready, otherwise, false.
  58646. */
  58647. isReady(): boolean;
  58648. /**
  58649. * Render the texture to its associated render target.
  58650. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58651. */
  58652. render(useCameraPostProcess?: boolean): void;
  58653. /**
  58654. * Update the list of dependant textures samplers in the shader.
  58655. */
  58656. updateTextures(): void;
  58657. /**
  58658. * Update the uniform values of the procedural texture in the shader.
  58659. */
  58660. updateShaderUniforms(): void;
  58661. /**
  58662. * Define if the texture animates or not.
  58663. */
  58664. get animate(): boolean;
  58665. set animate(value: boolean);
  58666. }
  58667. }
  58668. declare module "babylonjs/Shaders/noise.fragment" {
  58669. /** @hidden */
  58670. export var noisePixelShader: {
  58671. name: string;
  58672. shader: string;
  58673. };
  58674. }
  58675. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58676. import { Nullable } from "babylonjs/types";
  58677. import { Scene } from "babylonjs/scene";
  58678. import { Texture } from "babylonjs/Materials/Textures/texture";
  58679. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58680. import "babylonjs/Shaders/noise.fragment";
  58681. /**
  58682. * Class used to generate noise procedural textures
  58683. */
  58684. export class NoiseProceduralTexture extends ProceduralTexture {
  58685. private _time;
  58686. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58687. brightness: number;
  58688. /** Defines the number of octaves to process */
  58689. octaves: number;
  58690. /** Defines the level of persistence (0.8 by default) */
  58691. persistence: number;
  58692. /** Gets or sets animation speed factor (default is 1) */
  58693. animationSpeedFactor: number;
  58694. /**
  58695. * Creates a new NoiseProceduralTexture
  58696. * @param name defines the name fo the texture
  58697. * @param size defines the size of the texture (default is 256)
  58698. * @param scene defines the hosting scene
  58699. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58700. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58701. */
  58702. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58703. private _updateShaderUniforms;
  58704. protected _getDefines(): string;
  58705. /** Generate the current state of the procedural texture */
  58706. render(useCameraPostProcess?: boolean): void;
  58707. /**
  58708. * Serializes this noise procedural texture
  58709. * @returns a serialized noise procedural texture object
  58710. */
  58711. serialize(): any;
  58712. /**
  58713. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58714. * @param parsedTexture defines parsed texture data
  58715. * @param scene defines the current scene
  58716. * @param rootUrl defines the root URL containing noise procedural texture information
  58717. * @returns a parsed NoiseProceduralTexture
  58718. */
  58719. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58720. }
  58721. }
  58722. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58723. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58724. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58725. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58726. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58727. }
  58728. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58729. import { Nullable } from "babylonjs/types";
  58730. import { Scene } from "babylonjs/scene";
  58731. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58733. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58734. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58735. /**
  58736. * Raw cube texture where the raw buffers are passed in
  58737. */
  58738. export class RawCubeTexture extends CubeTexture {
  58739. /**
  58740. * Creates a cube texture where the raw buffers are passed in.
  58741. * @param scene defines the scene the texture is attached to
  58742. * @param data defines the array of data to use to create each face
  58743. * @param size defines the size of the textures
  58744. * @param format defines the format of the data
  58745. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58746. * @param generateMipMaps defines if the engine should generate the mip levels
  58747. * @param invertY defines if data must be stored with Y axis inverted
  58748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58749. * @param compression defines the compression used (null by default)
  58750. */
  58751. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58752. /**
  58753. * Updates the raw cube texture.
  58754. * @param data defines the data to store
  58755. * @param format defines the data format
  58756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58757. * @param invertY defines if data must be stored with Y axis inverted
  58758. * @param compression defines the compression used (null by default)
  58759. * @param level defines which level of the texture to update
  58760. */
  58761. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58762. /**
  58763. * Updates a raw cube texture with RGBD encoded data.
  58764. * @param data defines the array of data [mipmap][face] to use to create each face
  58765. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58766. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58767. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58768. * @returns a promsie that resolves when the operation is complete
  58769. */
  58770. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58771. /**
  58772. * Clones the raw cube texture.
  58773. * @return a new cube texture
  58774. */
  58775. clone(): CubeTexture;
  58776. /** @hidden */
  58777. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58778. }
  58779. }
  58780. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58781. import { Scene } from "babylonjs/scene";
  58782. import { Texture } from "babylonjs/Materials/Textures/texture";
  58783. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58784. /**
  58785. * Class used to store 3D textures containing user data
  58786. */
  58787. export class RawTexture3D extends Texture {
  58788. /** Gets or sets the texture format to use */
  58789. format: number;
  58790. private _engine;
  58791. /**
  58792. * Create a new RawTexture3D
  58793. * @param data defines the data of the texture
  58794. * @param width defines the width of the texture
  58795. * @param height defines the height of the texture
  58796. * @param depth defines the depth of the texture
  58797. * @param format defines the texture format to use
  58798. * @param scene defines the hosting scene
  58799. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58800. * @param invertY defines if texture must be stored with Y axis inverted
  58801. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58802. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58803. */
  58804. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58805. /** Gets or sets the texture format to use */
  58806. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58807. /**
  58808. * Update the texture with new data
  58809. * @param data defines the data to store in the texture
  58810. */
  58811. update(data: ArrayBufferView): void;
  58812. }
  58813. }
  58814. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58815. import { Scene } from "babylonjs/scene";
  58816. import { Texture } from "babylonjs/Materials/Textures/texture";
  58817. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58818. /**
  58819. * Class used to store 2D array textures containing user data
  58820. */
  58821. export class RawTexture2DArray extends Texture {
  58822. /** Gets or sets the texture format to use */
  58823. format: number;
  58824. private _engine;
  58825. /**
  58826. * Create a new RawTexture2DArray
  58827. * @param data defines the data of the texture
  58828. * @param width defines the width of the texture
  58829. * @param height defines the height of the texture
  58830. * @param depth defines the number of layers of the texture
  58831. * @param format defines the texture format to use
  58832. * @param scene defines the hosting scene
  58833. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58834. * @param invertY defines if texture must be stored with Y axis inverted
  58835. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58836. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58837. */
  58838. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58839. /** Gets or sets the texture format to use */
  58840. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58841. /**
  58842. * Update the texture with new data
  58843. * @param data defines the data to store in the texture
  58844. */
  58845. update(data: ArrayBufferView): void;
  58846. }
  58847. }
  58848. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58849. import { Scene } from "babylonjs/scene";
  58850. import { Plane } from "babylonjs/Maths/math.plane";
  58851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58852. /**
  58853. * Creates a refraction texture used by refraction channel of the standard material.
  58854. * It is like a mirror but to see through a material.
  58855. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58856. */
  58857. export class RefractionTexture extends RenderTargetTexture {
  58858. /**
  58859. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58860. * 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.
  58861. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58862. */
  58863. refractionPlane: Plane;
  58864. /**
  58865. * Define how deep under the surface we should see.
  58866. */
  58867. depth: number;
  58868. /**
  58869. * Creates a refraction texture used by refraction channel of the standard material.
  58870. * It is like a mirror but to see through a material.
  58871. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58872. * @param name Define the texture name
  58873. * @param size Define the size of the underlying texture
  58874. * @param scene Define the scene the refraction belongs to
  58875. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58876. */
  58877. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58878. /**
  58879. * Clone the refraction texture.
  58880. * @returns the cloned texture
  58881. */
  58882. clone(): RefractionTexture;
  58883. /**
  58884. * Serialize the texture to a JSON representation you could use in Parse later on
  58885. * @returns the serialized JSON representation
  58886. */
  58887. serialize(): any;
  58888. }
  58889. }
  58890. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58891. import { Nullable } from "babylonjs/types";
  58892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58893. import { Matrix } from "babylonjs/Maths/math.vector";
  58894. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58895. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58896. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58897. import { Scene } from "babylonjs/scene";
  58898. /**
  58899. * Defines the options related to the creation of an HtmlElementTexture
  58900. */
  58901. export interface IHtmlElementTextureOptions {
  58902. /**
  58903. * Defines wether mip maps should be created or not.
  58904. */
  58905. generateMipMaps?: boolean;
  58906. /**
  58907. * Defines the sampling mode of the texture.
  58908. */
  58909. samplingMode?: number;
  58910. /**
  58911. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58912. */
  58913. engine: Nullable<ThinEngine>;
  58914. /**
  58915. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58916. */
  58917. scene: Nullable<Scene>;
  58918. }
  58919. /**
  58920. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58921. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58922. * is automatically managed.
  58923. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58924. * in your application.
  58925. *
  58926. * As the update is not automatic, you need to call them manually.
  58927. */
  58928. export class HtmlElementTexture extends BaseTexture {
  58929. /**
  58930. * The texture URL.
  58931. */
  58932. element: HTMLVideoElement | HTMLCanvasElement;
  58933. private static readonly DefaultOptions;
  58934. private _textureMatrix;
  58935. private _engine;
  58936. private _isVideo;
  58937. private _generateMipMaps;
  58938. private _samplingMode;
  58939. /**
  58940. * Instantiates a HtmlElementTexture from the following parameters.
  58941. *
  58942. * @param name Defines the name of the texture
  58943. * @param element Defines the video or canvas the texture is filled with
  58944. * @param options Defines the other none mandatory texture creation options
  58945. */
  58946. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58947. private _createInternalTexture;
  58948. /**
  58949. * Returns the texture matrix used in most of the material.
  58950. */
  58951. getTextureMatrix(): Matrix;
  58952. /**
  58953. * Updates the content of the texture.
  58954. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58955. */
  58956. update(invertY?: Nullable<boolean>): void;
  58957. }
  58958. }
  58959. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58960. import { Vector2 } from "babylonjs/Maths/math.vector";
  58961. /**
  58962. * Defines the basic options interface of a TexturePacker Frame
  58963. */
  58964. export interface ITexturePackerFrame {
  58965. /**
  58966. * The frame ID
  58967. */
  58968. id: number;
  58969. /**
  58970. * The frames Scale
  58971. */
  58972. scale: Vector2;
  58973. /**
  58974. * The Frames offset
  58975. */
  58976. offset: Vector2;
  58977. }
  58978. /**
  58979. * This is a support class for frame Data on texture packer sets.
  58980. */
  58981. export class TexturePackerFrame implements ITexturePackerFrame {
  58982. /**
  58983. * The frame ID
  58984. */
  58985. id: number;
  58986. /**
  58987. * The frames Scale
  58988. */
  58989. scale: Vector2;
  58990. /**
  58991. * The Frames offset
  58992. */
  58993. offset: Vector2;
  58994. /**
  58995. * Initializes a texture package frame.
  58996. * @param id The numerical frame identifier
  58997. * @param scale Scalar Vector2 for UV frame
  58998. * @param offset Vector2 for the frame position in UV units.
  58999. * @returns TexturePackerFrame
  59000. */
  59001. constructor(id: number, scale: Vector2, offset: Vector2);
  59002. }
  59003. }
  59004. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59006. import { Scene } from "babylonjs/scene";
  59007. import { Nullable } from "babylonjs/types";
  59008. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59009. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59010. /**
  59011. * Defines the basic options interface of a TexturePacker
  59012. */
  59013. export interface ITexturePackerOptions {
  59014. /**
  59015. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59016. */
  59017. map?: string[];
  59018. /**
  59019. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59020. */
  59021. uvsIn?: string;
  59022. /**
  59023. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59024. */
  59025. uvsOut?: string;
  59026. /**
  59027. * number representing the layout style. Defaults to LAYOUT_STRIP
  59028. */
  59029. layout?: number;
  59030. /**
  59031. * number of columns if using custom column count layout(2). This defaults to 4.
  59032. */
  59033. colnum?: number;
  59034. /**
  59035. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59036. */
  59037. updateInputMeshes?: boolean;
  59038. /**
  59039. * boolean flag to dispose all the source textures. Defaults to true.
  59040. */
  59041. disposeSources?: boolean;
  59042. /**
  59043. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59044. */
  59045. fillBlanks?: boolean;
  59046. /**
  59047. * string value representing the context fill style color. Defaults to 'black'.
  59048. */
  59049. customFillColor?: string;
  59050. /**
  59051. * Width and Height Value of each Frame in the TexturePacker Sets
  59052. */
  59053. frameSize?: number;
  59054. /**
  59055. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59056. */
  59057. paddingRatio?: number;
  59058. /**
  59059. * Number that declares the fill method for the padding gutter.
  59060. */
  59061. paddingMode?: number;
  59062. /**
  59063. * If in SUBUV_COLOR padding mode what color to use.
  59064. */
  59065. paddingColor?: Color3 | Color4;
  59066. }
  59067. /**
  59068. * Defines the basic interface of a TexturePacker JSON File
  59069. */
  59070. export interface ITexturePackerJSON {
  59071. /**
  59072. * The frame ID
  59073. */
  59074. name: string;
  59075. /**
  59076. * The base64 channel data
  59077. */
  59078. sets: any;
  59079. /**
  59080. * The options of the Packer
  59081. */
  59082. options: ITexturePackerOptions;
  59083. /**
  59084. * The frame data of the Packer
  59085. */
  59086. frames: Array<number>;
  59087. }
  59088. /**
  59089. * This is a support class that generates a series of packed texture sets.
  59090. * @see https://doc.babylonjs.com/babylon101/materials
  59091. */
  59092. export class TexturePacker {
  59093. /** Packer Layout Constant 0 */
  59094. static readonly LAYOUT_STRIP: number;
  59095. /** Packer Layout Constant 1 */
  59096. static readonly LAYOUT_POWER2: number;
  59097. /** Packer Layout Constant 2 */
  59098. static readonly LAYOUT_COLNUM: number;
  59099. /** Packer Layout Constant 0 */
  59100. static readonly SUBUV_WRAP: number;
  59101. /** Packer Layout Constant 1 */
  59102. static readonly SUBUV_EXTEND: number;
  59103. /** Packer Layout Constant 2 */
  59104. static readonly SUBUV_COLOR: number;
  59105. /** The Name of the Texture Package */
  59106. name: string;
  59107. /** The scene scope of the TexturePacker */
  59108. scene: Scene;
  59109. /** The Meshes to target */
  59110. meshes: AbstractMesh[];
  59111. /** Arguments passed with the Constructor */
  59112. options: ITexturePackerOptions;
  59113. /** The promise that is started upon initialization */
  59114. promise: Nullable<Promise<TexturePacker | string>>;
  59115. /** The Container object for the channel sets that are generated */
  59116. sets: object;
  59117. /** The Container array for the frames that are generated */
  59118. frames: TexturePackerFrame[];
  59119. /** The expected number of textures the system is parsing. */
  59120. private _expecting;
  59121. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59122. private _paddingValue;
  59123. /**
  59124. * Initializes a texture package series from an array of meshes or a single mesh.
  59125. * @param name The name of the package
  59126. * @param meshes The target meshes to compose the package from
  59127. * @param options The arguments that texture packer should follow while building.
  59128. * @param scene The scene which the textures are scoped to.
  59129. * @returns TexturePacker
  59130. */
  59131. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59132. /**
  59133. * Starts the package process
  59134. * @param resolve The promises resolution function
  59135. * @returns TexturePacker
  59136. */
  59137. private _createFrames;
  59138. /**
  59139. * Calculates the Size of the Channel Sets
  59140. * @returns Vector2
  59141. */
  59142. private _calculateSize;
  59143. /**
  59144. * Calculates the UV data for the frames.
  59145. * @param baseSize the base frameSize
  59146. * @param padding the base frame padding
  59147. * @param dtSize size of the Dynamic Texture for that channel
  59148. * @param dtUnits is 1/dtSize
  59149. * @param update flag to update the input meshes
  59150. */
  59151. private _calculateMeshUVFrames;
  59152. /**
  59153. * Calculates the frames Offset.
  59154. * @param index of the frame
  59155. * @returns Vector2
  59156. */
  59157. private _getFrameOffset;
  59158. /**
  59159. * Updates a Mesh to the frame data
  59160. * @param mesh that is the target
  59161. * @param frameID or the frame index
  59162. */
  59163. private _updateMeshUV;
  59164. /**
  59165. * Updates a Meshes materials to use the texture packer channels
  59166. * @param m is the mesh to target
  59167. * @param force all channels on the packer to be set.
  59168. */
  59169. private _updateTextureReferences;
  59170. /**
  59171. * Public method to set a Mesh to a frame
  59172. * @param m that is the target
  59173. * @param frameID or the frame index
  59174. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59175. */
  59176. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59177. /**
  59178. * Starts the async promise to compile the texture packer.
  59179. * @returns Promise<void>
  59180. */
  59181. processAsync(): Promise<void>;
  59182. /**
  59183. * Disposes all textures associated with this packer
  59184. */
  59185. dispose(): void;
  59186. /**
  59187. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59188. * @param imageType is the image type to use.
  59189. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59190. */
  59191. download(imageType?: string, quality?: number): void;
  59192. /**
  59193. * Public method to load a texturePacker JSON file.
  59194. * @param data of the JSON file in string format.
  59195. */
  59196. updateFromJSON(data: string): void;
  59197. }
  59198. }
  59199. declare module "babylonjs/Materials/Textures/Packer/index" {
  59200. export * from "babylonjs/Materials/Textures/Packer/packer";
  59201. export * from "babylonjs/Materials/Textures/Packer/frame";
  59202. }
  59203. declare module "babylonjs/Materials/Textures/index" {
  59204. export * from "babylonjs/Materials/Textures/baseTexture";
  59205. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59206. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59207. export * from "babylonjs/Materials/Textures/cubeTexture";
  59208. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59209. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59210. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59211. export * from "babylonjs/Materials/Textures/internalTexture";
  59212. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59213. export * from "babylonjs/Materials/Textures/Loaders/index";
  59214. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59215. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59216. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59217. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59218. export * from "babylonjs/Materials/Textures/rawTexture";
  59219. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59220. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59221. export * from "babylonjs/Materials/Textures/refractionTexture";
  59222. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59223. export * from "babylonjs/Materials/Textures/texture";
  59224. export * from "babylonjs/Materials/Textures/videoTexture";
  59225. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59226. export * from "babylonjs/Materials/Textures/Packer/index";
  59227. }
  59228. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59229. /**
  59230. * Enum used to define the target of a block
  59231. */
  59232. export enum NodeMaterialBlockTargets {
  59233. /** Vertex shader */
  59234. Vertex = 1,
  59235. /** Fragment shader */
  59236. Fragment = 2,
  59237. /** Neutral */
  59238. Neutral = 4,
  59239. /** Vertex and Fragment */
  59240. VertexAndFragment = 3
  59241. }
  59242. }
  59243. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59244. /**
  59245. * Defines the kind of connection point for node based material
  59246. */
  59247. export enum NodeMaterialBlockConnectionPointTypes {
  59248. /** Float */
  59249. Float = 1,
  59250. /** Int */
  59251. Int = 2,
  59252. /** Vector2 */
  59253. Vector2 = 4,
  59254. /** Vector3 */
  59255. Vector3 = 8,
  59256. /** Vector4 */
  59257. Vector4 = 16,
  59258. /** Color3 */
  59259. Color3 = 32,
  59260. /** Color4 */
  59261. Color4 = 64,
  59262. /** Matrix */
  59263. Matrix = 128,
  59264. /** Detect type based on connection */
  59265. AutoDetect = 1024,
  59266. /** Output type that will be defined by input type */
  59267. BasedOnInput = 2048
  59268. }
  59269. }
  59270. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59271. /**
  59272. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59273. */
  59274. export enum NodeMaterialBlockConnectionPointMode {
  59275. /** Value is an uniform */
  59276. Uniform = 0,
  59277. /** Value is a mesh attribute */
  59278. Attribute = 1,
  59279. /** Value is a varying between vertex and fragment shaders */
  59280. Varying = 2,
  59281. /** Mode is undefined */
  59282. Undefined = 3
  59283. }
  59284. }
  59285. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59286. /**
  59287. * Enum used to define system values e.g. values automatically provided by the system
  59288. */
  59289. export enum NodeMaterialSystemValues {
  59290. /** World */
  59291. World = 1,
  59292. /** View */
  59293. View = 2,
  59294. /** Projection */
  59295. Projection = 3,
  59296. /** ViewProjection */
  59297. ViewProjection = 4,
  59298. /** WorldView */
  59299. WorldView = 5,
  59300. /** WorldViewProjection */
  59301. WorldViewProjection = 6,
  59302. /** CameraPosition */
  59303. CameraPosition = 7,
  59304. /** Fog Color */
  59305. FogColor = 8,
  59306. /** Delta time */
  59307. DeltaTime = 9
  59308. }
  59309. }
  59310. declare module "babylonjs/Materials/Node/Enums/index" {
  59311. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59312. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59313. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59314. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59315. }
  59316. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59318. /**
  59319. * Root class for all node material optimizers
  59320. */
  59321. export class NodeMaterialOptimizer {
  59322. /**
  59323. * Function used to optimize a NodeMaterial graph
  59324. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59325. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59326. */
  59327. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59328. }
  59329. }
  59330. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59334. import { Scene } from "babylonjs/scene";
  59335. /**
  59336. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59337. */
  59338. export class TransformBlock extends NodeMaterialBlock {
  59339. /**
  59340. * Defines the value to use to complement W value to transform it to a Vector4
  59341. */
  59342. complementW: number;
  59343. /**
  59344. * Defines the value to use to complement z value to transform it to a Vector4
  59345. */
  59346. complementZ: number;
  59347. /**
  59348. * Creates a new TransformBlock
  59349. * @param name defines the block name
  59350. */
  59351. constructor(name: string);
  59352. /**
  59353. * Gets the current class name
  59354. * @returns the class name
  59355. */
  59356. getClassName(): string;
  59357. /**
  59358. * Gets the vector input
  59359. */
  59360. get vector(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the output component
  59363. */
  59364. get output(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the matrix transform input
  59367. */
  59368. get transform(): NodeMaterialConnectionPoint;
  59369. protected _buildBlock(state: NodeMaterialBuildState): this;
  59370. serialize(): any;
  59371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59372. protected _dumpPropertiesCode(): string;
  59373. }
  59374. }
  59375. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59379. /**
  59380. * Block used to output the vertex position
  59381. */
  59382. export class VertexOutputBlock extends NodeMaterialBlock {
  59383. /**
  59384. * Creates a new VertexOutputBlock
  59385. * @param name defines the block name
  59386. */
  59387. constructor(name: string);
  59388. /**
  59389. * Gets the current class name
  59390. * @returns the class name
  59391. */
  59392. getClassName(): string;
  59393. /**
  59394. * Gets the vector input component
  59395. */
  59396. get vector(): NodeMaterialConnectionPoint;
  59397. protected _buildBlock(state: NodeMaterialBuildState): this;
  59398. }
  59399. }
  59400. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59404. /**
  59405. * Block used to output the final color
  59406. */
  59407. export class FragmentOutputBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Create a new FragmentOutputBlock
  59410. * @param name defines the block name
  59411. */
  59412. constructor(name: string);
  59413. /**
  59414. * Gets the current class name
  59415. * @returns the class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Gets the rgba input component
  59420. */
  59421. get rgba(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the rgb input component
  59424. */
  59425. get rgb(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the a input component
  59428. */
  59429. get a(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59439. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59440. import { Effect } from "babylonjs/Materials/effect";
  59441. import { Mesh } from "babylonjs/Meshes/mesh";
  59442. import { Nullable } from "babylonjs/types";
  59443. import { Scene } from "babylonjs/scene";
  59444. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59445. /**
  59446. * Block used to read a reflection texture from a sampler
  59447. */
  59448. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59449. private _define3DName;
  59450. private _defineCubicName;
  59451. private _defineExplicitName;
  59452. private _defineProjectionName;
  59453. private _defineLocalCubicName;
  59454. private _defineSphericalName;
  59455. private _definePlanarName;
  59456. private _defineEquirectangularName;
  59457. private _defineMirroredEquirectangularFixedName;
  59458. private _defineEquirectangularFixedName;
  59459. private _defineSkyboxName;
  59460. private _cubeSamplerName;
  59461. private _2DSamplerName;
  59462. private _positionUVWName;
  59463. private _directionWName;
  59464. private _reflectionCoordsName;
  59465. private _reflection2DCoordsName;
  59466. private _reflectionColorName;
  59467. private _reflectionMatrixName;
  59468. /**
  59469. * Gets or sets the texture associated with the node
  59470. */
  59471. texture: Nullable<BaseTexture>;
  59472. /**
  59473. * Create a new TextureBlock
  59474. * @param name defines the block name
  59475. */
  59476. constructor(name: string);
  59477. /**
  59478. * Gets the current class name
  59479. * @returns the class name
  59480. */
  59481. getClassName(): string;
  59482. /**
  59483. * Gets the world position input component
  59484. */
  59485. get position(): NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the world position input component
  59488. */
  59489. get worldPosition(): NodeMaterialConnectionPoint;
  59490. /**
  59491. * Gets the world normal input component
  59492. */
  59493. get worldNormal(): NodeMaterialConnectionPoint;
  59494. /**
  59495. * Gets the world input component
  59496. */
  59497. get world(): NodeMaterialConnectionPoint;
  59498. /**
  59499. * Gets the camera (or eye) position component
  59500. */
  59501. get cameraPosition(): NodeMaterialConnectionPoint;
  59502. /**
  59503. * Gets the view input component
  59504. */
  59505. get view(): NodeMaterialConnectionPoint;
  59506. /**
  59507. * Gets the rgb output component
  59508. */
  59509. get rgb(): NodeMaterialConnectionPoint;
  59510. /**
  59511. * Gets the r output component
  59512. */
  59513. get r(): NodeMaterialConnectionPoint;
  59514. /**
  59515. * Gets the g output component
  59516. */
  59517. get g(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the b output component
  59520. */
  59521. get b(): NodeMaterialConnectionPoint;
  59522. autoConfigure(material: NodeMaterial): void;
  59523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59524. isReady(): boolean;
  59525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59526. private _injectVertexCode;
  59527. private _writeOutput;
  59528. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59529. protected _dumpPropertiesCode(): string;
  59530. serialize(): any;
  59531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59532. }
  59533. }
  59534. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59536. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59537. import { Scene } from "babylonjs/scene";
  59538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59539. import { Matrix } from "babylonjs/Maths/math.vector";
  59540. import { Mesh } from "babylonjs/Meshes/mesh";
  59541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59542. import { Observable } from "babylonjs/Misc/observable";
  59543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59544. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59545. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59546. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59547. import { Nullable } from "babylonjs/types";
  59548. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59549. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59550. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59551. /**
  59552. * Interface used to configure the node material editor
  59553. */
  59554. export interface INodeMaterialEditorOptions {
  59555. /** Define the URl to load node editor script */
  59556. editorURL?: string;
  59557. }
  59558. /** @hidden */
  59559. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59560. NORMAL: boolean;
  59561. TANGENT: boolean;
  59562. UV1: boolean;
  59563. /** BONES */
  59564. NUM_BONE_INFLUENCERS: number;
  59565. BonesPerMesh: number;
  59566. BONETEXTURE: boolean;
  59567. /** MORPH TARGETS */
  59568. MORPHTARGETS: boolean;
  59569. MORPHTARGETS_NORMAL: boolean;
  59570. MORPHTARGETS_TANGENT: boolean;
  59571. MORPHTARGETS_UV: boolean;
  59572. NUM_MORPH_INFLUENCERS: number;
  59573. /** IMAGE PROCESSING */
  59574. IMAGEPROCESSING: boolean;
  59575. VIGNETTE: boolean;
  59576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59577. VIGNETTEBLENDMODEOPAQUE: boolean;
  59578. TONEMAPPING: boolean;
  59579. TONEMAPPING_ACES: boolean;
  59580. CONTRAST: boolean;
  59581. EXPOSURE: boolean;
  59582. COLORCURVES: boolean;
  59583. COLORGRADING: boolean;
  59584. COLORGRADING3D: boolean;
  59585. SAMPLER3DGREENDEPTH: boolean;
  59586. SAMPLER3DBGRMAP: boolean;
  59587. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59588. /** MISC. */
  59589. BUMPDIRECTUV: number;
  59590. constructor();
  59591. setValue(name: string, value: boolean): void;
  59592. }
  59593. /**
  59594. * Class used to configure NodeMaterial
  59595. */
  59596. export interface INodeMaterialOptions {
  59597. /**
  59598. * Defines if blocks should emit comments
  59599. */
  59600. emitComments: boolean;
  59601. }
  59602. /**
  59603. * Class used to create a node based material built by assembling shader blocks
  59604. */
  59605. export class NodeMaterial extends PushMaterial {
  59606. private static _BuildIdGenerator;
  59607. private _options;
  59608. private _vertexCompilationState;
  59609. private _fragmentCompilationState;
  59610. private _sharedData;
  59611. private _buildId;
  59612. private _buildWasSuccessful;
  59613. private _cachedWorldViewMatrix;
  59614. private _cachedWorldViewProjectionMatrix;
  59615. private _optimizers;
  59616. private _animationFrame;
  59617. /** Define the Url to load node editor script */
  59618. static EditorURL: string;
  59619. /** Define the Url to load snippets */
  59620. static SnippetUrl: string;
  59621. private BJSNODEMATERIALEDITOR;
  59622. /** Get the inspector from bundle or global */
  59623. private _getGlobalNodeMaterialEditor;
  59624. /**
  59625. * Gets or sets data used by visual editor
  59626. * @see https://nme.babylonjs.com
  59627. */
  59628. editorData: any;
  59629. /**
  59630. * 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)
  59631. */
  59632. ignoreAlpha: boolean;
  59633. /**
  59634. * Defines the maximum number of lights that can be used in the material
  59635. */
  59636. maxSimultaneousLights: number;
  59637. /**
  59638. * Observable raised when the material is built
  59639. */
  59640. onBuildObservable: Observable<NodeMaterial>;
  59641. /**
  59642. * Gets or sets the root nodes of the material vertex shader
  59643. */
  59644. _vertexOutputNodes: NodeMaterialBlock[];
  59645. /**
  59646. * Gets or sets the root nodes of the material fragment (pixel) shader
  59647. */
  59648. _fragmentOutputNodes: NodeMaterialBlock[];
  59649. /** Gets or sets options to control the node material overall behavior */
  59650. get options(): INodeMaterialOptions;
  59651. set options(options: INodeMaterialOptions);
  59652. /**
  59653. * Default configuration related to image processing available in the standard Material.
  59654. */
  59655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59656. /**
  59657. * Gets the image processing configuration used either in this material.
  59658. */
  59659. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59660. /**
  59661. * Sets the Default image processing configuration used either in the this material.
  59662. *
  59663. * If sets to null, the scene one is in use.
  59664. */
  59665. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59666. /**
  59667. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59668. */
  59669. attachedBlocks: NodeMaterialBlock[];
  59670. /**
  59671. * Create a new node based material
  59672. * @param name defines the material name
  59673. * @param scene defines the hosting scene
  59674. * @param options defines creation option
  59675. */
  59676. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59677. /**
  59678. * Gets the current class name of the material e.g. "NodeMaterial"
  59679. * @returns the class name
  59680. */
  59681. getClassName(): string;
  59682. /**
  59683. * Keep track of the image processing observer to allow dispose and replace.
  59684. */
  59685. private _imageProcessingObserver;
  59686. /**
  59687. * Attaches a new image processing configuration to the Standard Material.
  59688. * @param configuration
  59689. */
  59690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59691. /**
  59692. * Get a block by its name
  59693. * @param name defines the name of the block to retrieve
  59694. * @returns the required block or null if not found
  59695. */
  59696. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59697. /**
  59698. * Get a block by its name
  59699. * @param predicate defines the predicate used to find the good candidate
  59700. * @returns the required block or null if not found
  59701. */
  59702. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59703. /**
  59704. * Get an input block by its name
  59705. * @param predicate defines the predicate used to find the good candidate
  59706. * @returns the required input block or null if not found
  59707. */
  59708. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59709. /**
  59710. * Gets the list of input blocks attached to this material
  59711. * @returns an array of InputBlocks
  59712. */
  59713. getInputBlocks(): InputBlock[];
  59714. /**
  59715. * Adds a new optimizer to the list of optimizers
  59716. * @param optimizer defines the optimizers to add
  59717. * @returns the current material
  59718. */
  59719. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59720. /**
  59721. * Remove an optimizer from the list of optimizers
  59722. * @param optimizer defines the optimizers to remove
  59723. * @returns the current material
  59724. */
  59725. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59726. /**
  59727. * Add a new block to the list of output nodes
  59728. * @param node defines the node to add
  59729. * @returns the current material
  59730. */
  59731. addOutputNode(node: NodeMaterialBlock): this;
  59732. /**
  59733. * Remove a block from the list of root nodes
  59734. * @param node defines the node to remove
  59735. * @returns the current material
  59736. */
  59737. removeOutputNode(node: NodeMaterialBlock): this;
  59738. private _addVertexOutputNode;
  59739. private _removeVertexOutputNode;
  59740. private _addFragmentOutputNode;
  59741. private _removeFragmentOutputNode;
  59742. /**
  59743. * Specifies if the material will require alpha blending
  59744. * @returns a boolean specifying if alpha blending is needed
  59745. */
  59746. needAlphaBlending(): boolean;
  59747. /**
  59748. * Specifies if this material should be rendered in alpha test mode
  59749. * @returns a boolean specifying if an alpha test is needed.
  59750. */
  59751. needAlphaTesting(): boolean;
  59752. private _initializeBlock;
  59753. private _resetDualBlocks;
  59754. /**
  59755. * Remove a block from the current node material
  59756. * @param block defines the block to remove
  59757. */
  59758. removeBlock(block: NodeMaterialBlock): void;
  59759. /**
  59760. * Build the material and generates the inner effect
  59761. * @param verbose defines if the build should log activity
  59762. */
  59763. build(verbose?: boolean): void;
  59764. /**
  59765. * Runs an otpimization phase to try to improve the shader code
  59766. */
  59767. optimize(): void;
  59768. private _prepareDefinesForAttributes;
  59769. /**
  59770. * Get if the submesh is ready to be used and all its information available.
  59771. * Child classes can use it to update shaders
  59772. * @param mesh defines the mesh to check
  59773. * @param subMesh defines which submesh to check
  59774. * @param useInstances specifies that instances should be used
  59775. * @returns a boolean indicating that the submesh is ready or not
  59776. */
  59777. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59778. /**
  59779. * Get a string representing the shaders built by the current node graph
  59780. */
  59781. get compiledShaders(): string;
  59782. /**
  59783. * Binds the world matrix to the material
  59784. * @param world defines the world transformation matrix
  59785. */
  59786. bindOnlyWorldMatrix(world: Matrix): void;
  59787. /**
  59788. * Binds the submesh to this material by preparing the effect and shader to draw
  59789. * @param world defines the world transformation matrix
  59790. * @param mesh defines the mesh containing the submesh
  59791. * @param subMesh defines the submesh to bind the material to
  59792. */
  59793. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59794. /**
  59795. * Gets the active textures from the material
  59796. * @returns an array of textures
  59797. */
  59798. getActiveTextures(): BaseTexture[];
  59799. /**
  59800. * Gets the list of texture blocks
  59801. * @returns an array of texture blocks
  59802. */
  59803. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59804. /**
  59805. * Specifies if the material uses a texture
  59806. * @param texture defines the texture to check against the material
  59807. * @returns a boolean specifying if the material uses the texture
  59808. */
  59809. hasTexture(texture: BaseTexture): boolean;
  59810. /**
  59811. * Disposes the material
  59812. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59813. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59814. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59815. */
  59816. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59817. /** Creates the node editor window. */
  59818. private _createNodeEditor;
  59819. /**
  59820. * Launch the node material editor
  59821. * @param config Define the configuration of the editor
  59822. * @return a promise fulfilled when the node editor is visible
  59823. */
  59824. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59825. /**
  59826. * Clear the current material
  59827. */
  59828. clear(): void;
  59829. /**
  59830. * Clear the current material and set it to a default state
  59831. */
  59832. setToDefault(): void;
  59833. /**
  59834. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59835. * @param url defines the url to load from
  59836. * @returns a promise that will fullfil when the material is fully loaded
  59837. */
  59838. loadAsync(url: string): Promise<void>;
  59839. private _gatherBlocks;
  59840. /**
  59841. * Generate a string containing the code declaration required to create an equivalent of this material
  59842. * @returns a string
  59843. */
  59844. generateCode(): string;
  59845. /**
  59846. * Serializes this material in a JSON representation
  59847. * @returns the serialized material object
  59848. */
  59849. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59850. private _restoreConnections;
  59851. /**
  59852. * Clear the current graph and load a new one from a serialization object
  59853. * @param source defines the JSON representation of the material
  59854. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59855. */
  59856. loadFromSerialization(source: any, rootUrl?: string): void;
  59857. /**
  59858. * Creates a node material from parsed material data
  59859. * @param source defines the JSON representation of the material
  59860. * @param scene defines the hosting scene
  59861. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59862. * @returns a new node material
  59863. */
  59864. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59865. /**
  59866. * Creates a node material from a snippet saved in a remote file
  59867. * @param name defines the name of the material to create
  59868. * @param url defines the url to load from
  59869. * @param scene defines the hosting scene
  59870. * @returns a promise that will resolve to the new node material
  59871. */
  59872. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59873. /**
  59874. * Creates a node material from a snippet saved by the node material editor
  59875. * @param snippetId defines the snippet to load
  59876. * @param scene defines the hosting scene
  59877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59878. * @returns a promise that will resolve to the new node material
  59879. */
  59880. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59881. /**
  59882. * Creates a new node material set to default basic configuration
  59883. * @param name defines the name of the material
  59884. * @param scene defines the hosting scene
  59885. * @returns a new NodeMaterial
  59886. */
  59887. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59888. }
  59889. }
  59890. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59893. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59896. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59897. import { Effect } from "babylonjs/Materials/effect";
  59898. import { Mesh } from "babylonjs/Meshes/mesh";
  59899. import { Nullable } from "babylonjs/types";
  59900. import { Texture } from "babylonjs/Materials/Textures/texture";
  59901. import { Scene } from "babylonjs/scene";
  59902. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59903. /**
  59904. * Block used to read a texture from a sampler
  59905. */
  59906. export class TextureBlock extends NodeMaterialBlock {
  59907. private _defineName;
  59908. private _linearDefineName;
  59909. private _tempTextureRead;
  59910. private _samplerName;
  59911. private _transformedUVName;
  59912. private _textureTransformName;
  59913. private _textureInfoName;
  59914. private _mainUVName;
  59915. private _mainUVDefineName;
  59916. /**
  59917. * Gets or sets the texture associated with the node
  59918. */
  59919. texture: Nullable<Texture>;
  59920. /**
  59921. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59922. */
  59923. convertToGammaSpace: boolean;
  59924. /**
  59925. * Create a new TextureBlock
  59926. * @param name defines the block name
  59927. */
  59928. constructor(name: string);
  59929. /**
  59930. * Gets the current class name
  59931. * @returns the class name
  59932. */
  59933. getClassName(): string;
  59934. /**
  59935. * Gets the uv input component
  59936. */
  59937. get uv(): NodeMaterialConnectionPoint;
  59938. /**
  59939. * Gets the rgba output component
  59940. */
  59941. get rgba(): NodeMaterialConnectionPoint;
  59942. /**
  59943. * Gets the rgb output component
  59944. */
  59945. get rgb(): NodeMaterialConnectionPoint;
  59946. /**
  59947. * Gets the r output component
  59948. */
  59949. get r(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the g output component
  59952. */
  59953. get g(): NodeMaterialConnectionPoint;
  59954. /**
  59955. * Gets the b output component
  59956. */
  59957. get b(): NodeMaterialConnectionPoint;
  59958. /**
  59959. * Gets the a output component
  59960. */
  59961. get a(): NodeMaterialConnectionPoint;
  59962. get target(): NodeMaterialBlockTargets;
  59963. autoConfigure(material: NodeMaterial): void;
  59964. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59966. isReady(): boolean;
  59967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59968. private get _isMixed();
  59969. private _injectVertexCode;
  59970. private _writeTextureRead;
  59971. private _writeOutput;
  59972. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59973. protected _dumpPropertiesCode(): string;
  59974. serialize(): any;
  59975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59976. }
  59977. }
  59978. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59981. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59982. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59983. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59984. import { Scene } from "babylonjs/scene";
  59985. /**
  59986. * Class used to store shared data between 2 NodeMaterialBuildState
  59987. */
  59988. export class NodeMaterialBuildStateSharedData {
  59989. /**
  59990. * Gets the list of emitted varyings
  59991. */
  59992. temps: string[];
  59993. /**
  59994. * Gets the list of emitted varyings
  59995. */
  59996. varyings: string[];
  59997. /**
  59998. * Gets the varying declaration string
  59999. */
  60000. varyingDeclaration: string;
  60001. /**
  60002. * Input blocks
  60003. */
  60004. inputBlocks: InputBlock[];
  60005. /**
  60006. * Input blocks
  60007. */
  60008. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60009. /**
  60010. * Bindable blocks (Blocks that need to set data to the effect)
  60011. */
  60012. bindableBlocks: NodeMaterialBlock[];
  60013. /**
  60014. * List of blocks that can provide a compilation fallback
  60015. */
  60016. blocksWithFallbacks: NodeMaterialBlock[];
  60017. /**
  60018. * List of blocks that can provide a define update
  60019. */
  60020. blocksWithDefines: NodeMaterialBlock[];
  60021. /**
  60022. * List of blocks that can provide a repeatable content
  60023. */
  60024. repeatableContentBlocks: NodeMaterialBlock[];
  60025. /**
  60026. * List of blocks that can provide a dynamic list of uniforms
  60027. */
  60028. dynamicUniformBlocks: NodeMaterialBlock[];
  60029. /**
  60030. * List of blocks that can block the isReady function for the material
  60031. */
  60032. blockingBlocks: NodeMaterialBlock[];
  60033. /**
  60034. * Gets the list of animated inputs
  60035. */
  60036. animatedInputs: InputBlock[];
  60037. /**
  60038. * Build Id used to avoid multiple recompilations
  60039. */
  60040. buildId: number;
  60041. /** List of emitted variables */
  60042. variableNames: {
  60043. [key: string]: number;
  60044. };
  60045. /** List of emitted defines */
  60046. defineNames: {
  60047. [key: string]: number;
  60048. };
  60049. /** Should emit comments? */
  60050. emitComments: boolean;
  60051. /** Emit build activity */
  60052. verbose: boolean;
  60053. /** Gets or sets the hosting scene */
  60054. scene: Scene;
  60055. /**
  60056. * Gets the compilation hints emitted at compilation time
  60057. */
  60058. hints: {
  60059. needWorldViewMatrix: boolean;
  60060. needWorldViewProjectionMatrix: boolean;
  60061. needAlphaBlending: boolean;
  60062. needAlphaTesting: boolean;
  60063. };
  60064. /**
  60065. * List of compilation checks
  60066. */
  60067. checks: {
  60068. emitVertex: boolean;
  60069. emitFragment: boolean;
  60070. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60071. };
  60072. /** Creates a new shared data */
  60073. constructor();
  60074. /**
  60075. * Emits console errors and exceptions if there is a failing check
  60076. */
  60077. emitErrors(): void;
  60078. }
  60079. }
  60080. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60081. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60082. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60083. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60084. /**
  60085. * Class used to store node based material build state
  60086. */
  60087. export class NodeMaterialBuildState {
  60088. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60089. supportUniformBuffers: boolean;
  60090. /**
  60091. * Gets the list of emitted attributes
  60092. */
  60093. attributes: string[];
  60094. /**
  60095. * Gets the list of emitted uniforms
  60096. */
  60097. uniforms: string[];
  60098. /**
  60099. * Gets the list of emitted constants
  60100. */
  60101. constants: string[];
  60102. /**
  60103. * Gets the list of emitted samplers
  60104. */
  60105. samplers: string[];
  60106. /**
  60107. * Gets the list of emitted functions
  60108. */
  60109. functions: {
  60110. [key: string]: string;
  60111. };
  60112. /**
  60113. * Gets the list of emitted extensions
  60114. */
  60115. extensions: {
  60116. [key: string]: string;
  60117. };
  60118. /**
  60119. * Gets the target of the compilation state
  60120. */
  60121. target: NodeMaterialBlockTargets;
  60122. /**
  60123. * Gets the list of emitted counters
  60124. */
  60125. counters: {
  60126. [key: string]: number;
  60127. };
  60128. /**
  60129. * Shared data between multiple NodeMaterialBuildState instances
  60130. */
  60131. sharedData: NodeMaterialBuildStateSharedData;
  60132. /** @hidden */
  60133. _vertexState: NodeMaterialBuildState;
  60134. /** @hidden */
  60135. _attributeDeclaration: string;
  60136. /** @hidden */
  60137. _uniformDeclaration: string;
  60138. /** @hidden */
  60139. _constantDeclaration: string;
  60140. /** @hidden */
  60141. _samplerDeclaration: string;
  60142. /** @hidden */
  60143. _varyingTransfer: string;
  60144. private _repeatableContentAnchorIndex;
  60145. /** @hidden */
  60146. _builtCompilationString: string;
  60147. /**
  60148. * Gets the emitted compilation strings
  60149. */
  60150. compilationString: string;
  60151. /**
  60152. * Finalize the compilation strings
  60153. * @param state defines the current compilation state
  60154. */
  60155. finalize(state: NodeMaterialBuildState): void;
  60156. /** @hidden */
  60157. get _repeatableContentAnchor(): string;
  60158. /** @hidden */
  60159. _getFreeVariableName(prefix: string): string;
  60160. /** @hidden */
  60161. _getFreeDefineName(prefix: string): string;
  60162. /** @hidden */
  60163. _excludeVariableName(name: string): void;
  60164. /** @hidden */
  60165. _emit2DSampler(name: string): void;
  60166. /** @hidden */
  60167. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60168. /** @hidden */
  60169. _emitExtension(name: string, extension: string): void;
  60170. /** @hidden */
  60171. _emitFunction(name: string, code: string, comments: string): void;
  60172. /** @hidden */
  60173. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60174. replaceStrings?: {
  60175. search: RegExp;
  60176. replace: string;
  60177. }[];
  60178. repeatKey?: string;
  60179. }): string;
  60180. /** @hidden */
  60181. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60182. repeatKey?: string;
  60183. removeAttributes?: boolean;
  60184. removeUniforms?: boolean;
  60185. removeVaryings?: boolean;
  60186. removeIfDef?: boolean;
  60187. replaceStrings?: {
  60188. search: RegExp;
  60189. replace: string;
  60190. }[];
  60191. }, storeKey?: string): void;
  60192. /** @hidden */
  60193. _registerTempVariable(name: string): boolean;
  60194. /** @hidden */
  60195. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60196. /** @hidden */
  60197. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60198. /** @hidden */
  60199. _emitFloat(value: number): string;
  60200. }
  60201. }
  60202. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60203. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60205. import { Nullable } from "babylonjs/types";
  60206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60207. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60208. import { Effect } from "babylonjs/Materials/effect";
  60209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60210. import { Mesh } from "babylonjs/Meshes/mesh";
  60211. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60212. import { Scene } from "babylonjs/scene";
  60213. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60214. /**
  60215. * Defines a block that can be used inside a node based material
  60216. */
  60217. export class NodeMaterialBlock {
  60218. private _buildId;
  60219. private _buildTarget;
  60220. private _target;
  60221. private _isFinalMerger;
  60222. private _isInput;
  60223. protected _isUnique: boolean;
  60224. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60225. inputsAreExclusive: boolean;
  60226. /** @hidden */
  60227. _codeVariableName: string;
  60228. /** @hidden */
  60229. _inputs: NodeMaterialConnectionPoint[];
  60230. /** @hidden */
  60231. _outputs: NodeMaterialConnectionPoint[];
  60232. /** @hidden */
  60233. _preparationId: number;
  60234. /**
  60235. * Gets or sets the name of the block
  60236. */
  60237. name: string;
  60238. /**
  60239. * Gets or sets the unique id of the node
  60240. */
  60241. uniqueId: number;
  60242. /**
  60243. * Gets or sets the comments associated with this block
  60244. */
  60245. comments: string;
  60246. /**
  60247. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60248. */
  60249. get isUnique(): boolean;
  60250. /**
  60251. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60252. */
  60253. get isFinalMerger(): boolean;
  60254. /**
  60255. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60256. */
  60257. get isInput(): boolean;
  60258. /**
  60259. * Gets or sets the build Id
  60260. */
  60261. get buildId(): number;
  60262. set buildId(value: number);
  60263. /**
  60264. * Gets or sets the target of the block
  60265. */
  60266. get target(): NodeMaterialBlockTargets;
  60267. set target(value: NodeMaterialBlockTargets);
  60268. /**
  60269. * Gets the list of input points
  60270. */
  60271. get inputs(): NodeMaterialConnectionPoint[];
  60272. /** Gets the list of output points */
  60273. get outputs(): NodeMaterialConnectionPoint[];
  60274. /**
  60275. * Find an input by its name
  60276. * @param name defines the name of the input to look for
  60277. * @returns the input or null if not found
  60278. */
  60279. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60280. /**
  60281. * Find an output by its name
  60282. * @param name defines the name of the outputto look for
  60283. * @returns the output or null if not found
  60284. */
  60285. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60286. /**
  60287. * Creates a new NodeMaterialBlock
  60288. * @param name defines the block name
  60289. * @param target defines the target of that block (Vertex by default)
  60290. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60291. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60292. */
  60293. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60294. /**
  60295. * Initialize the block and prepare the context for build
  60296. * @param state defines the state that will be used for the build
  60297. */
  60298. initialize(state: NodeMaterialBuildState): void;
  60299. /**
  60300. * Bind data to effect. Will only be called for blocks with isBindable === true
  60301. * @param effect defines the effect to bind data to
  60302. * @param nodeMaterial defines the hosting NodeMaterial
  60303. * @param mesh defines the mesh that will be rendered
  60304. */
  60305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60306. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60307. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60308. protected _writeFloat(value: number): string;
  60309. /**
  60310. * Gets the current class name e.g. "NodeMaterialBlock"
  60311. * @returns the class name
  60312. */
  60313. getClassName(): string;
  60314. /**
  60315. * Register a new input. Must be called inside a block constructor
  60316. * @param name defines the connection point name
  60317. * @param type defines the connection point type
  60318. * @param isOptional defines a boolean indicating that this input can be omitted
  60319. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60320. * @returns the current block
  60321. */
  60322. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60323. /**
  60324. * Register a new output. Must be called inside a block constructor
  60325. * @param name defines the connection point name
  60326. * @param type defines the connection point type
  60327. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60328. * @returns the current block
  60329. */
  60330. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60331. /**
  60332. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60333. * @param forOutput defines an optional connection point to check compatibility with
  60334. * @returns the first available input or null
  60335. */
  60336. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60337. /**
  60338. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60339. * @param forBlock defines an optional block to check compatibility with
  60340. * @returns the first available input or null
  60341. */
  60342. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60343. /**
  60344. * Gets the sibling of the given output
  60345. * @param current defines the current output
  60346. * @returns the next output in the list or null
  60347. */
  60348. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60349. /**
  60350. * Connect current block with another block
  60351. * @param other defines the block to connect with
  60352. * @param options define the various options to help pick the right connections
  60353. * @returns the current block
  60354. */
  60355. connectTo(other: NodeMaterialBlock, options?: {
  60356. input?: string;
  60357. output?: string;
  60358. outputSwizzle?: string;
  60359. }): this | undefined;
  60360. protected _buildBlock(state: NodeMaterialBuildState): void;
  60361. /**
  60362. * Add uniforms, samplers and uniform buffers at compilation time
  60363. * @param state defines the state to update
  60364. * @param nodeMaterial defines the node material requesting the update
  60365. * @param defines defines the material defines to update
  60366. * @param uniformBuffers defines the list of uniform buffer names
  60367. */
  60368. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60369. /**
  60370. * Add potential fallbacks if shader compilation fails
  60371. * @param mesh defines the mesh to be rendered
  60372. * @param fallbacks defines the current prioritized list of fallbacks
  60373. */
  60374. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60375. /**
  60376. * Initialize defines for shader compilation
  60377. * @param mesh defines the mesh to be rendered
  60378. * @param nodeMaterial defines the node material requesting the update
  60379. * @param defines defines the material defines to update
  60380. * @param useInstances specifies that instances should be used
  60381. */
  60382. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60383. /**
  60384. * Update defines for shader compilation
  60385. * @param mesh defines the mesh to be rendered
  60386. * @param nodeMaterial defines the node material requesting the update
  60387. * @param defines defines the material defines to update
  60388. * @param useInstances specifies that instances should be used
  60389. */
  60390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60391. /**
  60392. * Lets the block try to connect some inputs automatically
  60393. * @param material defines the hosting NodeMaterial
  60394. */
  60395. autoConfigure(material: NodeMaterial): void;
  60396. /**
  60397. * Function called when a block is declared as repeatable content generator
  60398. * @param vertexShaderState defines the current compilation state for the vertex shader
  60399. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60400. * @param mesh defines the mesh to be rendered
  60401. * @param defines defines the material defines to update
  60402. */
  60403. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60404. /**
  60405. * Checks if the block is ready
  60406. * @param mesh defines the mesh to be rendered
  60407. * @param nodeMaterial defines the node material requesting the update
  60408. * @param defines defines the material defines to update
  60409. * @param useInstances specifies that instances should be used
  60410. * @returns true if the block is ready
  60411. */
  60412. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60413. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60414. private _processBuild;
  60415. /**
  60416. * Compile the current node and generate the shader code
  60417. * @param state defines the current compilation state (uniforms, samplers, current string)
  60418. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60419. * @returns true if already built
  60420. */
  60421. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60422. protected _inputRename(name: string): string;
  60423. protected _outputRename(name: string): string;
  60424. protected _dumpPropertiesCode(): string;
  60425. /** @hidden */
  60426. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60427. /** @hidden */
  60428. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60429. /**
  60430. * Clone the current block to a new identical block
  60431. * @param scene defines the hosting scene
  60432. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60433. * @returns a copy of the current block
  60434. */
  60435. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60436. /**
  60437. * Serializes this block in a JSON representation
  60438. * @returns the serialized block object
  60439. */
  60440. serialize(): any;
  60441. /** @hidden */
  60442. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60443. /**
  60444. * Release resources
  60445. */
  60446. dispose(): void;
  60447. }
  60448. }
  60449. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60450. /**
  60451. * Enum defining the type of animations supported by InputBlock
  60452. */
  60453. export enum AnimatedInputBlockTypes {
  60454. /** No animation */
  60455. None = 0,
  60456. /** Time based animation. Will only work for floats */
  60457. Time = 1
  60458. }
  60459. }
  60460. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60462. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60463. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60464. import { Nullable } from "babylonjs/types";
  60465. import { Effect } from "babylonjs/Materials/effect";
  60466. import { Matrix } from "babylonjs/Maths/math.vector";
  60467. import { Scene } from "babylonjs/scene";
  60468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60470. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60471. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60472. /**
  60473. * Block used to expose an input value
  60474. */
  60475. export class InputBlock extends NodeMaterialBlock {
  60476. private _mode;
  60477. private _associatedVariableName;
  60478. private _storedValue;
  60479. private _valueCallback;
  60480. private _type;
  60481. private _animationType;
  60482. /** Gets or set a value used to limit the range of float values */
  60483. min: number;
  60484. /** Gets or set a value used to limit the range of float values */
  60485. max: number;
  60486. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60487. isBoolean: boolean;
  60488. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60489. matrixMode: number;
  60490. /** @hidden */
  60491. _systemValue: Nullable<NodeMaterialSystemValues>;
  60492. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60493. visibleInInspector: boolean;
  60494. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60495. isConstant: boolean;
  60496. /** Gets or sets the group to use to display this block in the Inspector */
  60497. groupInInspector: string;
  60498. /**
  60499. * Gets or sets the connection point type (default is float)
  60500. */
  60501. get type(): NodeMaterialBlockConnectionPointTypes;
  60502. /**
  60503. * Creates a new InputBlock
  60504. * @param name defines the block name
  60505. * @param target defines the target of that block (Vertex by default)
  60506. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60507. */
  60508. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60509. /**
  60510. * Gets the output component
  60511. */
  60512. get output(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Set the source of this connection point to a vertex attribute
  60515. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60516. * @returns the current connection point
  60517. */
  60518. setAsAttribute(attributeName?: string): InputBlock;
  60519. /**
  60520. * Set the source of this connection point to a system value
  60521. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60522. * @returns the current connection point
  60523. */
  60524. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60525. /**
  60526. * Gets or sets the value of that point.
  60527. * Please note that this value will be ignored if valueCallback is defined
  60528. */
  60529. get value(): any;
  60530. set value(value: any);
  60531. /**
  60532. * Gets or sets a callback used to get the value of that point.
  60533. * Please note that setting this value will force the connection point to ignore the value property
  60534. */
  60535. get valueCallback(): () => any;
  60536. set valueCallback(value: () => any);
  60537. /**
  60538. * Gets or sets the associated variable name in the shader
  60539. */
  60540. get associatedVariableName(): string;
  60541. set associatedVariableName(value: string);
  60542. /** Gets or sets the type of animation applied to the input */
  60543. get animationType(): AnimatedInputBlockTypes;
  60544. set animationType(value: AnimatedInputBlockTypes);
  60545. /**
  60546. * Gets a boolean indicating that this connection point not defined yet
  60547. */
  60548. get isUndefined(): boolean;
  60549. /**
  60550. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60551. * In this case the connection point name must be the name of the uniform to use.
  60552. * Can only be set on inputs
  60553. */
  60554. get isUniform(): boolean;
  60555. set isUniform(value: boolean);
  60556. /**
  60557. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60558. * In this case the connection point name must be the name of the attribute to use
  60559. * Can only be set on inputs
  60560. */
  60561. get isAttribute(): boolean;
  60562. set isAttribute(value: boolean);
  60563. /**
  60564. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60565. * Can only be set on exit points
  60566. */
  60567. get isVarying(): boolean;
  60568. set isVarying(value: boolean);
  60569. /**
  60570. * Gets a boolean indicating that the current connection point is a system value
  60571. */
  60572. get isSystemValue(): boolean;
  60573. /**
  60574. * Gets or sets the current well known value or null if not defined as a system value
  60575. */
  60576. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60577. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60578. /**
  60579. * Gets the current class name
  60580. * @returns the class name
  60581. */
  60582. getClassName(): string;
  60583. /**
  60584. * Animate the input if animationType !== None
  60585. * @param scene defines the rendering scene
  60586. */
  60587. animate(scene: Scene): void;
  60588. private _emitDefine;
  60589. initialize(state: NodeMaterialBuildState): void;
  60590. /**
  60591. * Set the input block to its default value (based on its type)
  60592. */
  60593. setDefaultValue(): void;
  60594. private _emitConstant;
  60595. private _emit;
  60596. /** @hidden */
  60597. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60598. /** @hidden */
  60599. _transmit(effect: Effect, scene: Scene): void;
  60600. protected _buildBlock(state: NodeMaterialBuildState): void;
  60601. protected _dumpPropertiesCode(): string;
  60602. serialize(): any;
  60603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60604. }
  60605. }
  60606. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60607. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60608. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60609. import { Nullable } from "babylonjs/types";
  60610. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60611. import { Observable } from "babylonjs/Misc/observable";
  60612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60613. /**
  60614. * Enum used to define the compatibility state between two connection points
  60615. */
  60616. export enum NodeMaterialConnectionPointCompatibilityStates {
  60617. /** Points are compatibles */
  60618. Compatible = 0,
  60619. /** Points are incompatible because of their types */
  60620. TypeIncompatible = 1,
  60621. /** Points are incompatible because of their targets (vertex vs fragment) */
  60622. TargetIncompatible = 2
  60623. }
  60624. /**
  60625. * Defines the direction of a connection point
  60626. */
  60627. export enum NodeMaterialConnectionPointDirection {
  60628. /** Input */
  60629. Input = 0,
  60630. /** Output */
  60631. Output = 1
  60632. }
  60633. /**
  60634. * Defines a connection point for a block
  60635. */
  60636. export class NodeMaterialConnectionPoint {
  60637. /** @hidden */
  60638. _ownerBlock: NodeMaterialBlock;
  60639. /** @hidden */
  60640. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60641. private _endpoints;
  60642. private _associatedVariableName;
  60643. private _direction;
  60644. /** @hidden */
  60645. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60646. /** @hidden */
  60647. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60648. private _type;
  60649. /** @hidden */
  60650. _enforceAssociatedVariableName: boolean;
  60651. /** Gets the direction of the point */
  60652. get direction(): NodeMaterialConnectionPointDirection;
  60653. /**
  60654. * Gets or sets the additional types supported by this connection point
  60655. */
  60656. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60657. /**
  60658. * Gets or sets the additional types excluded by this connection point
  60659. */
  60660. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60661. /**
  60662. * Observable triggered when this point is connected
  60663. */
  60664. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60665. /**
  60666. * Gets or sets the associated variable name in the shader
  60667. */
  60668. get associatedVariableName(): string;
  60669. set associatedVariableName(value: string);
  60670. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60671. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60672. /**
  60673. * Gets or sets the connection point type (default is float)
  60674. */
  60675. get type(): NodeMaterialBlockConnectionPointTypes;
  60676. set type(value: NodeMaterialBlockConnectionPointTypes);
  60677. /**
  60678. * Gets or sets the connection point name
  60679. */
  60680. name: string;
  60681. /**
  60682. * Gets or sets a boolean indicating that this connection point can be omitted
  60683. */
  60684. isOptional: boolean;
  60685. /**
  60686. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60687. */
  60688. define: string;
  60689. /** @hidden */
  60690. _prioritizeVertex: boolean;
  60691. private _target;
  60692. /** Gets or sets the target of that connection point */
  60693. get target(): NodeMaterialBlockTargets;
  60694. set target(value: NodeMaterialBlockTargets);
  60695. /**
  60696. * Gets a boolean indicating that the current point is connected
  60697. */
  60698. get isConnected(): boolean;
  60699. /**
  60700. * Gets a boolean indicating that the current point is connected to an input block
  60701. */
  60702. get isConnectedToInputBlock(): boolean;
  60703. /**
  60704. * Gets a the connected input block (if any)
  60705. */
  60706. get connectInputBlock(): Nullable<InputBlock>;
  60707. /** Get the other side of the connection (if any) */
  60708. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60709. /** Get the block that owns this connection point */
  60710. get ownerBlock(): NodeMaterialBlock;
  60711. /** Get the block connected on the other side of this connection (if any) */
  60712. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60713. /** Get the block connected on the endpoints of this connection (if any) */
  60714. get connectedBlocks(): Array<NodeMaterialBlock>;
  60715. /** Gets the list of connected endpoints */
  60716. get endpoints(): NodeMaterialConnectionPoint[];
  60717. /** Gets a boolean indicating if that output point is connected to at least one input */
  60718. get hasEndpoints(): boolean;
  60719. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60720. get isConnectedInVertexShader(): boolean;
  60721. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60722. get isConnectedInFragmentShader(): boolean;
  60723. /**
  60724. * Creates a new connection point
  60725. * @param name defines the connection point name
  60726. * @param ownerBlock defines the block hosting this connection point
  60727. * @param direction defines the direction of the connection point
  60728. */
  60729. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60730. /**
  60731. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60732. * @returns the class name
  60733. */
  60734. getClassName(): string;
  60735. /**
  60736. * Gets a boolean indicating if the current point can be connected to another point
  60737. * @param connectionPoint defines the other connection point
  60738. * @returns a boolean
  60739. */
  60740. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60741. /**
  60742. * Gets a number indicating if the current point can be connected to another point
  60743. * @param connectionPoint defines the other connection point
  60744. * @returns a number defining the compatibility state
  60745. */
  60746. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60747. /**
  60748. * Connect this point to another connection point
  60749. * @param connectionPoint defines the other connection point
  60750. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60751. * @returns the current connection point
  60752. */
  60753. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Disconnect this point from one of his endpoint
  60756. * @param endpoint defines the other connection point
  60757. * @returns the current connection point
  60758. */
  60759. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60760. /**
  60761. * Serializes this point in a JSON representation
  60762. * @returns the serialized point object
  60763. */
  60764. serialize(): any;
  60765. /**
  60766. * Release resources
  60767. */
  60768. dispose(): void;
  60769. }
  60770. }
  60771. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60775. import { Mesh } from "babylonjs/Meshes/mesh";
  60776. import { Effect } from "babylonjs/Materials/effect";
  60777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60778. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60779. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60780. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60781. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60782. /**
  60783. * Block used to add support for vertex skinning (bones)
  60784. */
  60785. export class BonesBlock extends NodeMaterialBlock {
  60786. /**
  60787. * Creates a new BonesBlock
  60788. * @param name defines the block name
  60789. */
  60790. constructor(name: string);
  60791. /**
  60792. * Initialize the block and prepare the context for build
  60793. * @param state defines the state that will be used for the build
  60794. */
  60795. initialize(state: NodeMaterialBuildState): void;
  60796. /**
  60797. * Gets the current class name
  60798. * @returns the class name
  60799. */
  60800. getClassName(): string;
  60801. /**
  60802. * Gets the matrix indices input component
  60803. */
  60804. get matricesIndices(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the matrix weights input component
  60807. */
  60808. get matricesWeights(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the extra matrix indices input component
  60811. */
  60812. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60813. /**
  60814. * Gets the extra matrix weights input component
  60815. */
  60816. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60817. /**
  60818. * Gets the world input component
  60819. */
  60820. get world(): NodeMaterialConnectionPoint;
  60821. /**
  60822. * Gets the output component
  60823. */
  60824. get output(): NodeMaterialConnectionPoint;
  60825. autoConfigure(material: NodeMaterial): void;
  60826. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60829. protected _buildBlock(state: NodeMaterialBuildState): this;
  60830. }
  60831. }
  60832. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60837. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60838. /**
  60839. * Block used to add support for instances
  60840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60841. */
  60842. export class InstancesBlock extends NodeMaterialBlock {
  60843. /**
  60844. * Creates a new InstancesBlock
  60845. * @param name defines the block name
  60846. */
  60847. constructor(name: string);
  60848. /**
  60849. * Gets the current class name
  60850. * @returns the class name
  60851. */
  60852. getClassName(): string;
  60853. /**
  60854. * Gets the first world row input component
  60855. */
  60856. get world0(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the second world row input component
  60859. */
  60860. get world1(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the third world row input component
  60863. */
  60864. get world2(): NodeMaterialConnectionPoint;
  60865. /**
  60866. * Gets the forth world row input component
  60867. */
  60868. get world3(): NodeMaterialConnectionPoint;
  60869. /**
  60870. * Gets the world input component
  60871. */
  60872. get world(): NodeMaterialConnectionPoint;
  60873. /**
  60874. * Gets the output component
  60875. */
  60876. get output(): NodeMaterialConnectionPoint;
  60877. /**
  60878. * Gets the isntanceID component
  60879. */
  60880. get instanceID(): NodeMaterialConnectionPoint;
  60881. autoConfigure(material: NodeMaterial): void;
  60882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60883. protected _buildBlock(state: NodeMaterialBuildState): this;
  60884. }
  60885. }
  60886. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60891. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60892. import { Effect } from "babylonjs/Materials/effect";
  60893. import { Mesh } from "babylonjs/Meshes/mesh";
  60894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60896. /**
  60897. * Block used to add morph targets support to vertex shader
  60898. */
  60899. export class MorphTargetsBlock extends NodeMaterialBlock {
  60900. private _repeatableContentAnchor;
  60901. /**
  60902. * Create a new MorphTargetsBlock
  60903. * @param name defines the block name
  60904. */
  60905. constructor(name: string);
  60906. /**
  60907. * Gets the current class name
  60908. * @returns the class name
  60909. */
  60910. getClassName(): string;
  60911. /**
  60912. * Gets the position input component
  60913. */
  60914. get position(): NodeMaterialConnectionPoint;
  60915. /**
  60916. * Gets the normal input component
  60917. */
  60918. get normal(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the tangent input component
  60921. */
  60922. get tangent(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the tangent input component
  60925. */
  60926. get uv(): NodeMaterialConnectionPoint;
  60927. /**
  60928. * Gets the position output component
  60929. */
  60930. get positionOutput(): NodeMaterialConnectionPoint;
  60931. /**
  60932. * Gets the normal output component
  60933. */
  60934. get normalOutput(): NodeMaterialConnectionPoint;
  60935. /**
  60936. * Gets the tangent output component
  60937. */
  60938. get tangentOutput(): NodeMaterialConnectionPoint;
  60939. /**
  60940. * Gets the tangent output component
  60941. */
  60942. get uvOutput(): NodeMaterialConnectionPoint;
  60943. initialize(state: NodeMaterialBuildState): void;
  60944. autoConfigure(material: NodeMaterial): void;
  60945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60947. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60948. protected _buildBlock(state: NodeMaterialBuildState): this;
  60949. }
  60950. }
  60951. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60955. import { Nullable } from "babylonjs/types";
  60956. import { Scene } from "babylonjs/scene";
  60957. import { Effect } from "babylonjs/Materials/effect";
  60958. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60959. import { Mesh } from "babylonjs/Meshes/mesh";
  60960. import { Light } from "babylonjs/Lights/light";
  60961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60962. /**
  60963. * Block used to get data information from a light
  60964. */
  60965. export class LightInformationBlock extends NodeMaterialBlock {
  60966. private _lightDataUniformName;
  60967. private _lightColorUniformName;
  60968. private _lightTypeDefineName;
  60969. /**
  60970. * Gets or sets the light associated with this block
  60971. */
  60972. light: Nullable<Light>;
  60973. /**
  60974. * Creates a new LightInformationBlock
  60975. * @param name defines the block name
  60976. */
  60977. constructor(name: string);
  60978. /**
  60979. * Gets the current class name
  60980. * @returns the class name
  60981. */
  60982. getClassName(): string;
  60983. /**
  60984. * Gets the world position input component
  60985. */
  60986. get worldPosition(): NodeMaterialConnectionPoint;
  60987. /**
  60988. * Gets the direction output component
  60989. */
  60990. get direction(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the direction output component
  60993. */
  60994. get color(): NodeMaterialConnectionPoint;
  60995. /**
  60996. * Gets the direction output component
  60997. */
  60998. get intensity(): NodeMaterialConnectionPoint;
  60999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61001. protected _buildBlock(state: NodeMaterialBuildState): this;
  61002. serialize(): any;
  61003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61004. }
  61005. }
  61006. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61007. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61008. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61009. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61010. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61011. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61012. }
  61013. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61018. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61019. import { Effect } from "babylonjs/Materials/effect";
  61020. import { Mesh } from "babylonjs/Meshes/mesh";
  61021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61022. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61023. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61024. /**
  61025. * Block used to add image processing support to fragment shader
  61026. */
  61027. export class ImageProcessingBlock extends NodeMaterialBlock {
  61028. /**
  61029. * Create a new ImageProcessingBlock
  61030. * @param name defines the block name
  61031. */
  61032. constructor(name: string);
  61033. /**
  61034. * Gets the current class name
  61035. * @returns the class name
  61036. */
  61037. getClassName(): string;
  61038. /**
  61039. * Gets the color input component
  61040. */
  61041. get color(): NodeMaterialConnectionPoint;
  61042. /**
  61043. * Gets the output component
  61044. */
  61045. get output(): NodeMaterialConnectionPoint;
  61046. /**
  61047. * Initialize the block and prepare the context for build
  61048. * @param state defines the state that will be used for the build
  61049. */
  61050. initialize(state: NodeMaterialBuildState): void;
  61051. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61054. protected _buildBlock(state: NodeMaterialBuildState): this;
  61055. }
  61056. }
  61057. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61061. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61063. import { Effect } from "babylonjs/Materials/effect";
  61064. import { Mesh } from "babylonjs/Meshes/mesh";
  61065. import { Scene } from "babylonjs/scene";
  61066. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61067. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61068. /**
  61069. * Block used to pertub normals based on a normal map
  61070. */
  61071. export class PerturbNormalBlock extends NodeMaterialBlock {
  61072. private _tangentSpaceParameterName;
  61073. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61074. invertX: boolean;
  61075. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61076. invertY: boolean;
  61077. /**
  61078. * Create a new PerturbNormalBlock
  61079. * @param name defines the block name
  61080. */
  61081. constructor(name: string);
  61082. /**
  61083. * Gets the current class name
  61084. * @returns the class name
  61085. */
  61086. getClassName(): string;
  61087. /**
  61088. * Gets the world position input component
  61089. */
  61090. get worldPosition(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the world normal input component
  61093. */
  61094. get worldNormal(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the world tangent input component
  61097. */
  61098. get worldTangent(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the uv input component
  61101. */
  61102. get uv(): NodeMaterialConnectionPoint;
  61103. /**
  61104. * Gets the normal map color input component
  61105. */
  61106. get normalMapColor(): NodeMaterialConnectionPoint;
  61107. /**
  61108. * Gets the strength input component
  61109. */
  61110. get strength(): NodeMaterialConnectionPoint;
  61111. /**
  61112. * Gets the output component
  61113. */
  61114. get output(): NodeMaterialConnectionPoint;
  61115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61117. autoConfigure(material: NodeMaterial): void;
  61118. protected _buildBlock(state: NodeMaterialBuildState): this;
  61119. protected _dumpPropertiesCode(): string;
  61120. serialize(): any;
  61121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61122. }
  61123. }
  61124. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61128. /**
  61129. * Block used to discard a pixel if a value is smaller than a cutoff
  61130. */
  61131. export class DiscardBlock extends NodeMaterialBlock {
  61132. /**
  61133. * Create a new DiscardBlock
  61134. * @param name defines the block name
  61135. */
  61136. constructor(name: string);
  61137. /**
  61138. * Gets the current class name
  61139. * @returns the class name
  61140. */
  61141. getClassName(): string;
  61142. /**
  61143. * Gets the color input component
  61144. */
  61145. get value(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the cutoff input component
  61148. */
  61149. get cutoff(): NodeMaterialConnectionPoint;
  61150. protected _buildBlock(state: NodeMaterialBuildState): this;
  61151. }
  61152. }
  61153. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61157. /**
  61158. * Block used to test if the fragment shader is front facing
  61159. */
  61160. export class FrontFacingBlock extends NodeMaterialBlock {
  61161. /**
  61162. * Creates a new FrontFacingBlock
  61163. * @param name defines the block name
  61164. */
  61165. constructor(name: string);
  61166. /**
  61167. * Gets the current class name
  61168. * @returns the class name
  61169. */
  61170. getClassName(): string;
  61171. /**
  61172. * Gets the output component
  61173. */
  61174. get output(): NodeMaterialConnectionPoint;
  61175. protected _buildBlock(state: NodeMaterialBuildState): this;
  61176. }
  61177. }
  61178. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61182. /**
  61183. * Block used to get the derivative value on x and y of a given input
  61184. */
  61185. export class DerivativeBlock extends NodeMaterialBlock {
  61186. /**
  61187. * Create a new DerivativeBlock
  61188. * @param name defines the block name
  61189. */
  61190. constructor(name: string);
  61191. /**
  61192. * Gets the current class name
  61193. * @returns the class name
  61194. */
  61195. getClassName(): string;
  61196. /**
  61197. * Gets the input component
  61198. */
  61199. get input(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the derivative output on x
  61202. */
  61203. get dx(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the derivative output on y
  61206. */
  61207. get dy(): NodeMaterialConnectionPoint;
  61208. protected _buildBlock(state: NodeMaterialBuildState): this;
  61209. }
  61210. }
  61211. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61212. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61213. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61214. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61215. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61216. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61217. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61218. }
  61219. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61222. import { Mesh } from "babylonjs/Meshes/mesh";
  61223. import { Effect } from "babylonjs/Materials/effect";
  61224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61226. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61227. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61228. /**
  61229. * Block used to add support for scene fog
  61230. */
  61231. export class FogBlock extends NodeMaterialBlock {
  61232. private _fogDistanceName;
  61233. private _fogParameters;
  61234. /**
  61235. * Create a new FogBlock
  61236. * @param name defines the block name
  61237. */
  61238. constructor(name: string);
  61239. /**
  61240. * Gets the current class name
  61241. * @returns the class name
  61242. */
  61243. getClassName(): string;
  61244. /**
  61245. * Gets the world position input component
  61246. */
  61247. get worldPosition(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the view input component
  61250. */
  61251. get view(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the color input component
  61254. */
  61255. get input(): NodeMaterialConnectionPoint;
  61256. /**
  61257. * Gets the fog color input component
  61258. */
  61259. get fogColor(): NodeMaterialConnectionPoint;
  61260. /**
  61261. * Gets the output component
  61262. */
  61263. get output(): NodeMaterialConnectionPoint;
  61264. autoConfigure(material: NodeMaterial): void;
  61265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61267. protected _buildBlock(state: NodeMaterialBuildState): this;
  61268. }
  61269. }
  61270. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61275. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61276. import { Effect } from "babylonjs/Materials/effect";
  61277. import { Mesh } from "babylonjs/Meshes/mesh";
  61278. import { Light } from "babylonjs/Lights/light";
  61279. import { Nullable } from "babylonjs/types";
  61280. import { Scene } from "babylonjs/scene";
  61281. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61282. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61283. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61285. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61286. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61287. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61288. /**
  61289. * Block used to add light in the fragment shader
  61290. */
  61291. export class LightBlock extends NodeMaterialBlock {
  61292. private _lightId;
  61293. /**
  61294. * Gets or sets the light associated with this block
  61295. */
  61296. light: Nullable<Light>;
  61297. /**
  61298. * Create a new LightBlock
  61299. * @param name defines the block name
  61300. */
  61301. constructor(name: string);
  61302. /**
  61303. * Gets the current class name
  61304. * @returns the class name
  61305. */
  61306. getClassName(): string;
  61307. /**
  61308. * Gets the world position input component
  61309. */
  61310. get worldPosition(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the world normal input component
  61313. */
  61314. get worldNormal(): NodeMaterialConnectionPoint;
  61315. /**
  61316. * Gets the camera (or eye) position component
  61317. */
  61318. get cameraPosition(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the glossiness component
  61321. */
  61322. get glossiness(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the glossinness power component
  61325. */
  61326. get glossPower(): NodeMaterialConnectionPoint;
  61327. /**
  61328. * Gets the diffuse color component
  61329. */
  61330. get diffuseColor(): NodeMaterialConnectionPoint;
  61331. /**
  61332. * Gets the specular color component
  61333. */
  61334. get specularColor(): NodeMaterialConnectionPoint;
  61335. /**
  61336. * Gets the diffuse output component
  61337. */
  61338. get diffuseOutput(): NodeMaterialConnectionPoint;
  61339. /**
  61340. * Gets the specular output component
  61341. */
  61342. get specularOutput(): NodeMaterialConnectionPoint;
  61343. /**
  61344. * Gets the shadow output component
  61345. */
  61346. get shadow(): NodeMaterialConnectionPoint;
  61347. autoConfigure(material: NodeMaterial): void;
  61348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61349. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61351. private _injectVertexCode;
  61352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61353. serialize(): any;
  61354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61355. }
  61356. }
  61357. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61358. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61359. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61360. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61361. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61362. }
  61363. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61364. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61365. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61366. }
  61367. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61371. /**
  61372. * Block used to multiply 2 values
  61373. */
  61374. export class MultiplyBlock extends NodeMaterialBlock {
  61375. /**
  61376. * Creates a new MultiplyBlock
  61377. * @param name defines the block name
  61378. */
  61379. constructor(name: string);
  61380. /**
  61381. * Gets the current class name
  61382. * @returns the class name
  61383. */
  61384. getClassName(): string;
  61385. /**
  61386. * Gets the left operand input component
  61387. */
  61388. get left(): NodeMaterialConnectionPoint;
  61389. /**
  61390. * Gets the right operand input component
  61391. */
  61392. get right(): NodeMaterialConnectionPoint;
  61393. /**
  61394. * Gets the output component
  61395. */
  61396. get output(): NodeMaterialConnectionPoint;
  61397. protected _buildBlock(state: NodeMaterialBuildState): this;
  61398. }
  61399. }
  61400. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61404. /**
  61405. * Block used to add 2 vectors
  61406. */
  61407. export class AddBlock extends NodeMaterialBlock {
  61408. /**
  61409. * Creates a new AddBlock
  61410. * @param name defines the block name
  61411. */
  61412. constructor(name: string);
  61413. /**
  61414. * Gets the current class name
  61415. * @returns the class name
  61416. */
  61417. getClassName(): string;
  61418. /**
  61419. * Gets the left operand input component
  61420. */
  61421. get left(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the right operand input component
  61424. */
  61425. get right(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the output component
  61428. */
  61429. get output(): NodeMaterialConnectionPoint;
  61430. protected _buildBlock(state: NodeMaterialBuildState): this;
  61431. }
  61432. }
  61433. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61437. /**
  61438. * Block used to scale a vector by a float
  61439. */
  61440. export class ScaleBlock extends NodeMaterialBlock {
  61441. /**
  61442. * Creates a new ScaleBlock
  61443. * @param name defines the block name
  61444. */
  61445. constructor(name: string);
  61446. /**
  61447. * Gets the current class name
  61448. * @returns the class name
  61449. */
  61450. getClassName(): string;
  61451. /**
  61452. * Gets the input component
  61453. */
  61454. get input(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the factor input component
  61457. */
  61458. get factor(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the output component
  61461. */
  61462. get output(): NodeMaterialConnectionPoint;
  61463. protected _buildBlock(state: NodeMaterialBuildState): this;
  61464. }
  61465. }
  61466. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61470. import { Scene } from "babylonjs/scene";
  61471. /**
  61472. * Block used to clamp a float
  61473. */
  61474. export class ClampBlock extends NodeMaterialBlock {
  61475. /** Gets or sets the minimum range */
  61476. minimum: number;
  61477. /** Gets or sets the maximum range */
  61478. maximum: number;
  61479. /**
  61480. * Creates a new ClampBlock
  61481. * @param name defines the block name
  61482. */
  61483. constructor(name: string);
  61484. /**
  61485. * Gets the current class name
  61486. * @returns the class name
  61487. */
  61488. getClassName(): string;
  61489. /**
  61490. * Gets the value input component
  61491. */
  61492. get value(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the output component
  61495. */
  61496. get output(): NodeMaterialConnectionPoint;
  61497. protected _buildBlock(state: NodeMaterialBuildState): this;
  61498. protected _dumpPropertiesCode(): string;
  61499. serialize(): any;
  61500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61501. }
  61502. }
  61503. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61507. /**
  61508. * Block used to apply a cross product between 2 vectors
  61509. */
  61510. export class CrossBlock extends NodeMaterialBlock {
  61511. /**
  61512. * Creates a new CrossBlock
  61513. * @param name defines the block name
  61514. */
  61515. constructor(name: string);
  61516. /**
  61517. * Gets the current class name
  61518. * @returns the class name
  61519. */
  61520. getClassName(): string;
  61521. /**
  61522. * Gets the left operand input component
  61523. */
  61524. get left(): NodeMaterialConnectionPoint;
  61525. /**
  61526. * Gets the right operand input component
  61527. */
  61528. get right(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the output component
  61531. */
  61532. get output(): NodeMaterialConnectionPoint;
  61533. protected _buildBlock(state: NodeMaterialBuildState): this;
  61534. }
  61535. }
  61536. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61540. /**
  61541. * Block used to apply a dot product between 2 vectors
  61542. */
  61543. export class DotBlock extends NodeMaterialBlock {
  61544. /**
  61545. * Creates a new DotBlock
  61546. * @param name defines the block name
  61547. */
  61548. constructor(name: string);
  61549. /**
  61550. * Gets the current class name
  61551. * @returns the class name
  61552. */
  61553. getClassName(): string;
  61554. /**
  61555. * Gets the left operand input component
  61556. */
  61557. get left(): NodeMaterialConnectionPoint;
  61558. /**
  61559. * Gets the right operand input component
  61560. */
  61561. get right(): NodeMaterialConnectionPoint;
  61562. /**
  61563. * Gets the output component
  61564. */
  61565. get output(): NodeMaterialConnectionPoint;
  61566. protected _buildBlock(state: NodeMaterialBuildState): this;
  61567. }
  61568. }
  61569. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61573. import { Vector2 } from "babylonjs/Maths/math.vector";
  61574. import { Scene } from "babylonjs/scene";
  61575. /**
  61576. * Block used to remap a float from a range to a new one
  61577. */
  61578. export class RemapBlock extends NodeMaterialBlock {
  61579. /**
  61580. * Gets or sets the source range
  61581. */
  61582. sourceRange: Vector2;
  61583. /**
  61584. * Gets or sets the target range
  61585. */
  61586. targetRange: Vector2;
  61587. /**
  61588. * Creates a new RemapBlock
  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 input component
  61599. */
  61600. get input(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the source min input component
  61603. */
  61604. get sourceMin(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the source max input component
  61607. */
  61608. get sourceMax(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the target min input component
  61611. */
  61612. get targetMin(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the target max input component
  61615. */
  61616. get targetMax(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the output component
  61619. */
  61620. get output(): NodeMaterialConnectionPoint;
  61621. protected _buildBlock(state: NodeMaterialBuildState): this;
  61622. protected _dumpPropertiesCode(): string;
  61623. serialize(): any;
  61624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61625. }
  61626. }
  61627. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61631. /**
  61632. * Block used to normalize a vector
  61633. */
  61634. export class NormalizeBlock extends NodeMaterialBlock {
  61635. /**
  61636. * Creates a new NormalizeBlock
  61637. * @param name defines the block name
  61638. */
  61639. constructor(name: string);
  61640. /**
  61641. * Gets the current class name
  61642. * @returns the class name
  61643. */
  61644. getClassName(): string;
  61645. /**
  61646. * Gets the input component
  61647. */
  61648. get input(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the output component
  61651. */
  61652. get output(): NodeMaterialConnectionPoint;
  61653. protected _buildBlock(state: NodeMaterialBuildState): this;
  61654. }
  61655. }
  61656. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61660. import { Scene } from "babylonjs/scene";
  61661. /**
  61662. * Operations supported by the Trigonometry block
  61663. */
  61664. export enum TrigonometryBlockOperations {
  61665. /** Cos */
  61666. Cos = 0,
  61667. /** Sin */
  61668. Sin = 1,
  61669. /** Abs */
  61670. Abs = 2,
  61671. /** Exp */
  61672. Exp = 3,
  61673. /** Exp2 */
  61674. Exp2 = 4,
  61675. /** Round */
  61676. Round = 5,
  61677. /** Floor */
  61678. Floor = 6,
  61679. /** Ceiling */
  61680. Ceiling = 7,
  61681. /** Square root */
  61682. Sqrt = 8,
  61683. /** Log */
  61684. Log = 9,
  61685. /** Tangent */
  61686. Tan = 10,
  61687. /** Arc tangent */
  61688. ArcTan = 11,
  61689. /** Arc cosinus */
  61690. ArcCos = 12,
  61691. /** Arc sinus */
  61692. ArcSin = 13,
  61693. /** Fraction */
  61694. Fract = 14,
  61695. /** Sign */
  61696. Sign = 15,
  61697. /** To radians (from degrees) */
  61698. Radians = 16,
  61699. /** To degrees (from radians) */
  61700. Degrees = 17
  61701. }
  61702. /**
  61703. * Block used to apply trigonometry operation to floats
  61704. */
  61705. export class TrigonometryBlock extends NodeMaterialBlock {
  61706. /**
  61707. * Gets or sets the operation applied by the block
  61708. */
  61709. operation: TrigonometryBlockOperations;
  61710. /**
  61711. * Creates a new TrigonometryBlock
  61712. * @param name defines the block name
  61713. */
  61714. constructor(name: string);
  61715. /**
  61716. * Gets the current class name
  61717. * @returns the class name
  61718. */
  61719. getClassName(): string;
  61720. /**
  61721. * Gets the input component
  61722. */
  61723. get input(): NodeMaterialConnectionPoint;
  61724. /**
  61725. * Gets the output component
  61726. */
  61727. get output(): NodeMaterialConnectionPoint;
  61728. protected _buildBlock(state: NodeMaterialBuildState): this;
  61729. serialize(): any;
  61730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61731. protected _dumpPropertiesCode(): string;
  61732. }
  61733. }
  61734. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61738. /**
  61739. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61740. */
  61741. export class ColorMergerBlock extends NodeMaterialBlock {
  61742. /**
  61743. * Create a new ColorMergerBlock
  61744. * @param name defines the block name
  61745. */
  61746. constructor(name: string);
  61747. /**
  61748. * Gets the current class name
  61749. * @returns the class name
  61750. */
  61751. getClassName(): string;
  61752. /**
  61753. * Gets the rgb component (input)
  61754. */
  61755. get rgbIn(): NodeMaterialConnectionPoint;
  61756. /**
  61757. * Gets the r component (input)
  61758. */
  61759. get r(): NodeMaterialConnectionPoint;
  61760. /**
  61761. * Gets the g component (input)
  61762. */
  61763. get g(): NodeMaterialConnectionPoint;
  61764. /**
  61765. * Gets the b component (input)
  61766. */
  61767. get b(): NodeMaterialConnectionPoint;
  61768. /**
  61769. * Gets the a component (input)
  61770. */
  61771. get a(): NodeMaterialConnectionPoint;
  61772. /**
  61773. * Gets the rgba component (output)
  61774. */
  61775. get rgba(): NodeMaterialConnectionPoint;
  61776. /**
  61777. * Gets the rgb component (output)
  61778. */
  61779. get rgbOut(): NodeMaterialConnectionPoint;
  61780. /**
  61781. * Gets the rgb component (output)
  61782. * @deprecated Please use rgbOut instead.
  61783. */
  61784. get rgb(): NodeMaterialConnectionPoint;
  61785. protected _buildBlock(state: NodeMaterialBuildState): this;
  61786. }
  61787. }
  61788. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61792. /**
  61793. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61794. */
  61795. export class VectorMergerBlock extends NodeMaterialBlock {
  61796. /**
  61797. * Create a new VectorMergerBlock
  61798. * @param name defines the block name
  61799. */
  61800. constructor(name: string);
  61801. /**
  61802. * Gets the current class name
  61803. * @returns the class name
  61804. */
  61805. getClassName(): string;
  61806. /**
  61807. * Gets the xyz component (input)
  61808. */
  61809. get xyzIn(): NodeMaterialConnectionPoint;
  61810. /**
  61811. * Gets the xy component (input)
  61812. */
  61813. get xyIn(): NodeMaterialConnectionPoint;
  61814. /**
  61815. * Gets the x component (input)
  61816. */
  61817. get x(): NodeMaterialConnectionPoint;
  61818. /**
  61819. * Gets the y component (input)
  61820. */
  61821. get y(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the z component (input)
  61824. */
  61825. get z(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the w component (input)
  61828. */
  61829. get w(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the xyzw component (output)
  61832. */
  61833. get xyzw(): NodeMaterialConnectionPoint;
  61834. /**
  61835. * Gets the xyz component (output)
  61836. */
  61837. get xyzOut(): NodeMaterialConnectionPoint;
  61838. /**
  61839. * Gets the xy component (output)
  61840. */
  61841. get xyOut(): NodeMaterialConnectionPoint;
  61842. /**
  61843. * Gets the xy component (output)
  61844. * @deprecated Please use xyOut instead.
  61845. */
  61846. get xy(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the xyz component (output)
  61849. * @deprecated Please use xyzOut instead.
  61850. */
  61851. get xyz(): NodeMaterialConnectionPoint;
  61852. protected _buildBlock(state: NodeMaterialBuildState): this;
  61853. }
  61854. }
  61855. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61859. /**
  61860. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61861. */
  61862. export class ColorSplitterBlock extends NodeMaterialBlock {
  61863. /**
  61864. * Create a new ColorSplitterBlock
  61865. * @param name defines the block name
  61866. */
  61867. constructor(name: string);
  61868. /**
  61869. * Gets the current class name
  61870. * @returns the class name
  61871. */
  61872. getClassName(): string;
  61873. /**
  61874. * Gets the rgba component (input)
  61875. */
  61876. get rgba(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the rgb component (input)
  61879. */
  61880. get rgbIn(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the rgb component (output)
  61883. */
  61884. get rgbOut(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the r component (output)
  61887. */
  61888. get r(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the g component (output)
  61891. */
  61892. get g(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the b component (output)
  61895. */
  61896. get b(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the a component (output)
  61899. */
  61900. get a(): NodeMaterialConnectionPoint;
  61901. protected _inputRename(name: string): string;
  61902. protected _outputRename(name: string): string;
  61903. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61904. }
  61905. }
  61906. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61910. /**
  61911. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61912. */
  61913. export class VectorSplitterBlock extends NodeMaterialBlock {
  61914. /**
  61915. * Create a new VectorSplitterBlock
  61916. * @param name defines the block name
  61917. */
  61918. constructor(name: string);
  61919. /**
  61920. * Gets the current class name
  61921. * @returns the class name
  61922. */
  61923. getClassName(): string;
  61924. /**
  61925. * Gets the xyzw component (input)
  61926. */
  61927. get xyzw(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the xyz component (input)
  61930. */
  61931. get xyzIn(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the xy component (input)
  61934. */
  61935. get xyIn(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the xyz component (output)
  61938. */
  61939. get xyzOut(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the xy component (output)
  61942. */
  61943. get xyOut(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the x component (output)
  61946. */
  61947. get x(): NodeMaterialConnectionPoint;
  61948. /**
  61949. * Gets the y component (output)
  61950. */
  61951. get y(): NodeMaterialConnectionPoint;
  61952. /**
  61953. * Gets the z component (output)
  61954. */
  61955. get z(): NodeMaterialConnectionPoint;
  61956. /**
  61957. * Gets the w component (output)
  61958. */
  61959. get w(): NodeMaterialConnectionPoint;
  61960. protected _inputRename(name: string): string;
  61961. protected _outputRename(name: string): string;
  61962. protected _buildBlock(state: NodeMaterialBuildState): this;
  61963. }
  61964. }
  61965. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61969. /**
  61970. * Block used to lerp between 2 values
  61971. */
  61972. export class LerpBlock extends NodeMaterialBlock {
  61973. /**
  61974. * Creates a new LerpBlock
  61975. * @param name defines the block name
  61976. */
  61977. constructor(name: string);
  61978. /**
  61979. * Gets the current class name
  61980. * @returns the class name
  61981. */
  61982. getClassName(): string;
  61983. /**
  61984. * Gets the left operand input component
  61985. */
  61986. get left(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the right operand input component
  61989. */
  61990. get right(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the gradient operand input component
  61993. */
  61994. get gradient(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the output component
  61997. */
  61998. get output(): NodeMaterialConnectionPoint;
  61999. protected _buildBlock(state: NodeMaterialBuildState): this;
  62000. }
  62001. }
  62002. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62006. /**
  62007. * Block used to divide 2 vectors
  62008. */
  62009. export class DivideBlock extends NodeMaterialBlock {
  62010. /**
  62011. * Creates a new DivideBlock
  62012. * @param name defines the block name
  62013. */
  62014. constructor(name: string);
  62015. /**
  62016. * Gets the current class name
  62017. * @returns the class name
  62018. */
  62019. getClassName(): string;
  62020. /**
  62021. * Gets the left operand input component
  62022. */
  62023. get left(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the right operand input component
  62026. */
  62027. get right(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the output component
  62030. */
  62031. get output(): NodeMaterialConnectionPoint;
  62032. protected _buildBlock(state: NodeMaterialBuildState): this;
  62033. }
  62034. }
  62035. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62039. /**
  62040. * Block used to subtract 2 vectors
  62041. */
  62042. export class SubtractBlock extends NodeMaterialBlock {
  62043. /**
  62044. * Creates a new SubtractBlock
  62045. * @param name defines the block name
  62046. */
  62047. constructor(name: string);
  62048. /**
  62049. * Gets the current class name
  62050. * @returns the class name
  62051. */
  62052. getClassName(): string;
  62053. /**
  62054. * Gets the left operand input component
  62055. */
  62056. get left(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the right operand input component
  62059. */
  62060. get right(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the output component
  62063. */
  62064. get output(): NodeMaterialConnectionPoint;
  62065. protected _buildBlock(state: NodeMaterialBuildState): this;
  62066. }
  62067. }
  62068. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62072. /**
  62073. * Block used to step a value
  62074. */
  62075. export class StepBlock extends NodeMaterialBlock {
  62076. /**
  62077. * Creates a new StepBlock
  62078. * @param name defines the block name
  62079. */
  62080. constructor(name: string);
  62081. /**
  62082. * Gets the current class name
  62083. * @returns the class name
  62084. */
  62085. getClassName(): string;
  62086. /**
  62087. * Gets the value operand input component
  62088. */
  62089. get value(): NodeMaterialConnectionPoint;
  62090. /**
  62091. * Gets the edge operand input component
  62092. */
  62093. get edge(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the output component
  62096. */
  62097. get output(): NodeMaterialConnectionPoint;
  62098. protected _buildBlock(state: NodeMaterialBuildState): this;
  62099. }
  62100. }
  62101. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62105. /**
  62106. * Block used to get the opposite (1 - x) of a value
  62107. */
  62108. export class OneMinusBlock extends NodeMaterialBlock {
  62109. /**
  62110. * Creates a new OneMinusBlock
  62111. * @param name defines the block name
  62112. */
  62113. constructor(name: string);
  62114. /**
  62115. * Gets the current class name
  62116. * @returns the class name
  62117. */
  62118. getClassName(): string;
  62119. /**
  62120. * Gets the input component
  62121. */
  62122. get input(): NodeMaterialConnectionPoint;
  62123. /**
  62124. * Gets the output component
  62125. */
  62126. get output(): NodeMaterialConnectionPoint;
  62127. protected _buildBlock(state: NodeMaterialBuildState): this;
  62128. }
  62129. }
  62130. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62134. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62135. /**
  62136. * Block used to get the view direction
  62137. */
  62138. export class ViewDirectionBlock extends NodeMaterialBlock {
  62139. /**
  62140. * Creates a new ViewDirectionBlock
  62141. * @param name defines the block name
  62142. */
  62143. constructor(name: string);
  62144. /**
  62145. * Gets the current class name
  62146. * @returns the class name
  62147. */
  62148. getClassName(): string;
  62149. /**
  62150. * Gets the world position component
  62151. */
  62152. get worldPosition(): NodeMaterialConnectionPoint;
  62153. /**
  62154. * Gets the camera position component
  62155. */
  62156. get cameraPosition(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the output component
  62159. */
  62160. get output(): NodeMaterialConnectionPoint;
  62161. autoConfigure(material: NodeMaterial): void;
  62162. protected _buildBlock(state: NodeMaterialBuildState): this;
  62163. }
  62164. }
  62165. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62169. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62170. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62171. /**
  62172. * Block used to compute fresnel value
  62173. */
  62174. export class FresnelBlock extends NodeMaterialBlock {
  62175. /**
  62176. * Create a new FresnelBlock
  62177. * @param name defines the block name
  62178. */
  62179. constructor(name: string);
  62180. /**
  62181. * Gets the current class name
  62182. * @returns the class name
  62183. */
  62184. getClassName(): string;
  62185. /**
  62186. * Gets the world normal input component
  62187. */
  62188. get worldNormal(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the view direction input component
  62191. */
  62192. get viewDirection(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the bias input component
  62195. */
  62196. get bias(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the camera (or eye) position component
  62199. */
  62200. get power(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the fresnel output component
  62203. */
  62204. get fresnel(): NodeMaterialConnectionPoint;
  62205. autoConfigure(material: NodeMaterial): void;
  62206. protected _buildBlock(state: NodeMaterialBuildState): this;
  62207. }
  62208. }
  62209. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62213. /**
  62214. * Block used to get the max of 2 values
  62215. */
  62216. export class MaxBlock extends NodeMaterialBlock {
  62217. /**
  62218. * Creates a new MaxBlock
  62219. * @param name defines the block name
  62220. */
  62221. constructor(name: string);
  62222. /**
  62223. * Gets the current class name
  62224. * @returns the class name
  62225. */
  62226. getClassName(): string;
  62227. /**
  62228. * Gets the left operand input component
  62229. */
  62230. get left(): NodeMaterialConnectionPoint;
  62231. /**
  62232. * Gets the right operand input component
  62233. */
  62234. get right(): 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/minBlock" {
  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 get the min of 2 values
  62248. */
  62249. export class MinBlock extends NodeMaterialBlock {
  62250. /**
  62251. * Creates a new MinBlock
  62252. * @param name defines the block name
  62253. */
  62254. constructor(name: string);
  62255. /**
  62256. * Gets the current class name
  62257. * @returns the class name
  62258. */
  62259. getClassName(): string;
  62260. /**
  62261. * Gets the left operand input component
  62262. */
  62263. get left(): NodeMaterialConnectionPoint;
  62264. /**
  62265. * Gets the right operand input component
  62266. */
  62267. get right(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the output component
  62270. */
  62271. get output(): NodeMaterialConnectionPoint;
  62272. protected _buildBlock(state: NodeMaterialBuildState): this;
  62273. }
  62274. }
  62275. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62277. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62279. /**
  62280. * Block used to get the distance between 2 values
  62281. */
  62282. export class DistanceBlock extends NodeMaterialBlock {
  62283. /**
  62284. * Creates a new DistanceBlock
  62285. * @param name defines the block name
  62286. */
  62287. constructor(name: string);
  62288. /**
  62289. * Gets the current class name
  62290. * @returns the class name
  62291. */
  62292. getClassName(): string;
  62293. /**
  62294. * Gets the left operand input component
  62295. */
  62296. get left(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the right operand input component
  62299. */
  62300. get right(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the output component
  62303. */
  62304. get output(): NodeMaterialConnectionPoint;
  62305. protected _buildBlock(state: NodeMaterialBuildState): this;
  62306. }
  62307. }
  62308. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62310. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62311. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62312. /**
  62313. * Block used to get the length of a vector
  62314. */
  62315. export class LengthBlock extends NodeMaterialBlock {
  62316. /**
  62317. * Creates a new LengthBlock
  62318. * @param name defines the block name
  62319. */
  62320. constructor(name: string);
  62321. /**
  62322. * Gets the current class name
  62323. * @returns the class name
  62324. */
  62325. getClassName(): string;
  62326. /**
  62327. * Gets the value input component
  62328. */
  62329. get value(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the output component
  62332. */
  62333. get output(): NodeMaterialConnectionPoint;
  62334. protected _buildBlock(state: NodeMaterialBuildState): this;
  62335. }
  62336. }
  62337. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62341. /**
  62342. * Block used to get negative version of a value (i.e. x * -1)
  62343. */
  62344. export class NegateBlock extends NodeMaterialBlock {
  62345. /**
  62346. * Creates a new NegateBlock
  62347. * @param name defines the block name
  62348. */
  62349. constructor(name: string);
  62350. /**
  62351. * Gets the current class name
  62352. * @returns the class name
  62353. */
  62354. getClassName(): string;
  62355. /**
  62356. * Gets the value input component
  62357. */
  62358. get value(): NodeMaterialConnectionPoint;
  62359. /**
  62360. * Gets the output component
  62361. */
  62362. get output(): NodeMaterialConnectionPoint;
  62363. protected _buildBlock(state: NodeMaterialBuildState): this;
  62364. }
  62365. }
  62366. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62370. /**
  62371. * Block used to get the value of the first parameter raised to the power of the second
  62372. */
  62373. export class PowBlock extends NodeMaterialBlock {
  62374. /**
  62375. * Creates a new PowBlock
  62376. * @param name defines the block name
  62377. */
  62378. constructor(name: string);
  62379. /**
  62380. * Gets the current class name
  62381. * @returns the class name
  62382. */
  62383. getClassName(): string;
  62384. /**
  62385. * Gets the value operand input component
  62386. */
  62387. get value(): NodeMaterialConnectionPoint;
  62388. /**
  62389. * Gets the power operand input component
  62390. */
  62391. get power(): NodeMaterialConnectionPoint;
  62392. /**
  62393. * Gets the output component
  62394. */
  62395. get output(): NodeMaterialConnectionPoint;
  62396. protected _buildBlock(state: NodeMaterialBuildState): this;
  62397. }
  62398. }
  62399. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62403. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62404. /**
  62405. * Block used to get a random number
  62406. */
  62407. export class RandomNumberBlock extends NodeMaterialBlock {
  62408. /**
  62409. * Creates a new RandomNumberBlock
  62410. * @param name defines the block name
  62411. */
  62412. constructor(name: string);
  62413. /**
  62414. * Gets the current class name
  62415. * @returns the class name
  62416. */
  62417. getClassName(): string;
  62418. /**
  62419. * Gets the seed input component
  62420. */
  62421. get seed(): NodeMaterialConnectionPoint;
  62422. /**
  62423. * Gets the output component
  62424. */
  62425. get output(): NodeMaterialConnectionPoint;
  62426. protected _buildBlock(state: NodeMaterialBuildState): this;
  62427. }
  62428. }
  62429. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62433. /**
  62434. * Block used to compute arc tangent of 2 values
  62435. */
  62436. export class ArcTan2Block extends NodeMaterialBlock {
  62437. /**
  62438. * Creates a new ArcTan2Block
  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 x operand input component
  62449. */
  62450. get x(): NodeMaterialConnectionPoint;
  62451. /**
  62452. * Gets the y operand input component
  62453. */
  62454. get y(): NodeMaterialConnectionPoint;
  62455. /**
  62456. * Gets the output component
  62457. */
  62458. get output(): NodeMaterialConnectionPoint;
  62459. protected _buildBlock(state: NodeMaterialBuildState): this;
  62460. }
  62461. }
  62462. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62466. /**
  62467. * Block used to smooth step a value
  62468. */
  62469. export class SmoothStepBlock extends NodeMaterialBlock {
  62470. /**
  62471. * Creates a new SmoothStepBlock
  62472. * @param name defines the block name
  62473. */
  62474. constructor(name: string);
  62475. /**
  62476. * Gets the current class name
  62477. * @returns the class name
  62478. */
  62479. getClassName(): string;
  62480. /**
  62481. * Gets the value operand input component
  62482. */
  62483. get value(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the first edge operand input component
  62486. */
  62487. get edge0(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the second edge operand input component
  62490. */
  62491. get edge1(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the output component
  62494. */
  62495. get output(): NodeMaterialConnectionPoint;
  62496. protected _buildBlock(state: NodeMaterialBuildState): this;
  62497. }
  62498. }
  62499. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62503. /**
  62504. * Block used to get the reciprocal (1 / x) of a value
  62505. */
  62506. export class ReciprocalBlock extends NodeMaterialBlock {
  62507. /**
  62508. * Creates a new ReciprocalBlock
  62509. * @param name defines the block name
  62510. */
  62511. constructor(name: string);
  62512. /**
  62513. * Gets the current class name
  62514. * @returns the class name
  62515. */
  62516. getClassName(): string;
  62517. /**
  62518. * Gets the input component
  62519. */
  62520. get input(): NodeMaterialConnectionPoint;
  62521. /**
  62522. * Gets the output component
  62523. */
  62524. get output(): NodeMaterialConnectionPoint;
  62525. protected _buildBlock(state: NodeMaterialBuildState): this;
  62526. }
  62527. }
  62528. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62532. /**
  62533. * Block used to replace a color by another one
  62534. */
  62535. export class ReplaceColorBlock extends NodeMaterialBlock {
  62536. /**
  62537. * Creates a new ReplaceColorBlock
  62538. * @param name defines the block name
  62539. */
  62540. constructor(name: string);
  62541. /**
  62542. * Gets the current class name
  62543. * @returns the class name
  62544. */
  62545. getClassName(): string;
  62546. /**
  62547. * Gets the value input component
  62548. */
  62549. get value(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the reference input component
  62552. */
  62553. get reference(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the distance input component
  62556. */
  62557. get distance(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the replacement input component
  62560. */
  62561. get replacement(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the output component
  62564. */
  62565. get output(): NodeMaterialConnectionPoint;
  62566. protected _buildBlock(state: NodeMaterialBuildState): this;
  62567. }
  62568. }
  62569. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62573. /**
  62574. * Block used to posterize a value
  62575. * @see https://en.wikipedia.org/wiki/Posterization
  62576. */
  62577. export class PosterizeBlock extends NodeMaterialBlock {
  62578. /**
  62579. * Creates a new PosterizeBlock
  62580. * @param name defines the block name
  62581. */
  62582. constructor(name: string);
  62583. /**
  62584. * Gets the current class name
  62585. * @returns the class name
  62586. */
  62587. getClassName(): string;
  62588. /**
  62589. * Gets the value input component
  62590. */
  62591. get value(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the steps input component
  62594. */
  62595. get steps(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the output component
  62598. */
  62599. get output(): NodeMaterialConnectionPoint;
  62600. protected _buildBlock(state: NodeMaterialBuildState): this;
  62601. }
  62602. }
  62603. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62607. import { Scene } from "babylonjs/scene";
  62608. /**
  62609. * Operations supported by the Wave block
  62610. */
  62611. export enum WaveBlockKind {
  62612. /** SawTooth */
  62613. SawTooth = 0,
  62614. /** Square */
  62615. Square = 1,
  62616. /** Triangle */
  62617. Triangle = 2
  62618. }
  62619. /**
  62620. * Block used to apply wave operation to floats
  62621. */
  62622. export class WaveBlock extends NodeMaterialBlock {
  62623. /**
  62624. * Gets or sets the kibnd of wave to be applied by the block
  62625. */
  62626. kind: WaveBlockKind;
  62627. /**
  62628. * Creates a new WaveBlock
  62629. * @param name defines the block name
  62630. */
  62631. constructor(name: string);
  62632. /**
  62633. * Gets the current class name
  62634. * @returns the class name
  62635. */
  62636. getClassName(): string;
  62637. /**
  62638. * Gets the input component
  62639. */
  62640. get input(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the output component
  62643. */
  62644. get output(): NodeMaterialConnectionPoint;
  62645. protected _buildBlock(state: NodeMaterialBuildState): this;
  62646. serialize(): any;
  62647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62648. }
  62649. }
  62650. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62653. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62654. import { Color3 } from "babylonjs/Maths/math.color";
  62655. import { Scene } from "babylonjs/scene";
  62656. /**
  62657. * Class used to store a color step for the GradientBlock
  62658. */
  62659. export class GradientBlockColorStep {
  62660. /**
  62661. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62662. */
  62663. step: number;
  62664. /**
  62665. * Gets or sets the color associated with this step
  62666. */
  62667. color: Color3;
  62668. /**
  62669. * Creates a new GradientBlockColorStep
  62670. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62671. * @param color defines the color associated with this step
  62672. */
  62673. constructor(
  62674. /**
  62675. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62676. */
  62677. step: number,
  62678. /**
  62679. * Gets or sets the color associated with this step
  62680. */
  62681. color: Color3);
  62682. }
  62683. /**
  62684. * Block used to return a color from a gradient based on an input value between 0 and 1
  62685. */
  62686. export class GradientBlock extends NodeMaterialBlock {
  62687. /**
  62688. * Gets or sets the list of color steps
  62689. */
  62690. colorSteps: GradientBlockColorStep[];
  62691. /**
  62692. * Creates a new GradientBlock
  62693. * @param name defines the block name
  62694. */
  62695. constructor(name: string);
  62696. /**
  62697. * Gets the current class name
  62698. * @returns the class name
  62699. */
  62700. getClassName(): string;
  62701. /**
  62702. * Gets the gradient input component
  62703. */
  62704. get gradient(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the output component
  62707. */
  62708. get output(): NodeMaterialConnectionPoint;
  62709. private _writeColorConstant;
  62710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62711. serialize(): any;
  62712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62713. protected _dumpPropertiesCode(): string;
  62714. }
  62715. }
  62716. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62720. /**
  62721. * Block used to normalize lerp between 2 values
  62722. */
  62723. export class NLerpBlock extends NodeMaterialBlock {
  62724. /**
  62725. * Creates a new NLerpBlock
  62726. * @param name defines the block name
  62727. */
  62728. constructor(name: string);
  62729. /**
  62730. * Gets the current class name
  62731. * @returns the class name
  62732. */
  62733. getClassName(): string;
  62734. /**
  62735. * Gets the left operand input component
  62736. */
  62737. get left(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the right operand input component
  62740. */
  62741. get right(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the gradient operand input component
  62744. */
  62745. get gradient(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the output component
  62748. */
  62749. get output(): NodeMaterialConnectionPoint;
  62750. protected _buildBlock(state: NodeMaterialBuildState): this;
  62751. }
  62752. }
  62753. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62757. import { Scene } from "babylonjs/scene";
  62758. /**
  62759. * block used to Generate a Worley Noise 3D Noise Pattern
  62760. */
  62761. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62762. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62763. manhattanDistance: boolean;
  62764. /**
  62765. * Creates a new WorleyNoise3DBlock
  62766. * @param name defines the block name
  62767. */
  62768. constructor(name: string);
  62769. /**
  62770. * Gets the current class name
  62771. * @returns the class name
  62772. */
  62773. getClassName(): string;
  62774. /**
  62775. * Gets the seed input component
  62776. */
  62777. get seed(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the jitter input component
  62780. */
  62781. get jitter(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the output component
  62784. */
  62785. get output(): NodeMaterialConnectionPoint;
  62786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62787. /**
  62788. * Exposes the properties to the UI?
  62789. */
  62790. protected _dumpPropertiesCode(): string;
  62791. /**
  62792. * Exposes the properties to the Seralize?
  62793. */
  62794. serialize(): any;
  62795. /**
  62796. * Exposes the properties to the deseralize?
  62797. */
  62798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62799. }
  62800. }
  62801. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62805. /**
  62806. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62807. */
  62808. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62809. /**
  62810. * Creates a new SimplexPerlin3DBlock
  62811. * @param name defines the block name
  62812. */
  62813. constructor(name: string);
  62814. /**
  62815. * Gets the current class name
  62816. * @returns the class name
  62817. */
  62818. getClassName(): string;
  62819. /**
  62820. * Gets the seed operand input component
  62821. */
  62822. get seed(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the output component
  62825. */
  62826. get output(): NodeMaterialConnectionPoint;
  62827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62828. }
  62829. }
  62830. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62834. /**
  62835. * Block used to blend normals
  62836. */
  62837. export class NormalBlendBlock extends NodeMaterialBlock {
  62838. /**
  62839. * Creates a new NormalBlendBlock
  62840. * @param name defines the block name
  62841. */
  62842. constructor(name: string);
  62843. /**
  62844. * Gets the current class name
  62845. * @returns the class name
  62846. */
  62847. getClassName(): string;
  62848. /**
  62849. * Gets the first input component
  62850. */
  62851. get normalMap0(): NodeMaterialConnectionPoint;
  62852. /**
  62853. * Gets the second input component
  62854. */
  62855. get normalMap1(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the output component
  62858. */
  62859. get output(): NodeMaterialConnectionPoint;
  62860. protected _buildBlock(state: NodeMaterialBuildState): this;
  62861. }
  62862. }
  62863. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62867. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62868. /**
  62869. * Block used to rotate a 2d vector by a given angle
  62870. */
  62871. export class Rotate2dBlock extends NodeMaterialBlock {
  62872. /**
  62873. * Creates a new Rotate2dBlock
  62874. * @param name defines the block name
  62875. */
  62876. constructor(name: string);
  62877. /**
  62878. * Gets the current class name
  62879. * @returns the class name
  62880. */
  62881. getClassName(): string;
  62882. /**
  62883. * Gets the input vector
  62884. */
  62885. get input(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the input angle
  62888. */
  62889. get angle(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the output component
  62892. */
  62893. get output(): NodeMaterialConnectionPoint;
  62894. autoConfigure(material: NodeMaterial): void;
  62895. protected _buildBlock(state: NodeMaterialBuildState): this;
  62896. }
  62897. }
  62898. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62902. /**
  62903. * Block used to get the reflected vector from a direction and a normal
  62904. */
  62905. export class ReflectBlock extends NodeMaterialBlock {
  62906. /**
  62907. * Creates a new ReflectBlock
  62908. * @param name defines the block name
  62909. */
  62910. constructor(name: string);
  62911. /**
  62912. * Gets the current class name
  62913. * @returns the class name
  62914. */
  62915. getClassName(): string;
  62916. /**
  62917. * Gets the incident component
  62918. */
  62919. get incident(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the normal component
  62922. */
  62923. get normal(): NodeMaterialConnectionPoint;
  62924. /**
  62925. * Gets the output component
  62926. */
  62927. get output(): NodeMaterialConnectionPoint;
  62928. protected _buildBlock(state: NodeMaterialBuildState): this;
  62929. }
  62930. }
  62931. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62935. /**
  62936. * Block used to get the refracted vector from a direction and a normal
  62937. */
  62938. export class RefractBlock extends NodeMaterialBlock {
  62939. /**
  62940. * Creates a new RefractBlock
  62941. * @param name defines the block name
  62942. */
  62943. constructor(name: string);
  62944. /**
  62945. * Gets the current class name
  62946. * @returns the class name
  62947. */
  62948. getClassName(): string;
  62949. /**
  62950. * Gets the incident component
  62951. */
  62952. get incident(): NodeMaterialConnectionPoint;
  62953. /**
  62954. * Gets the normal component
  62955. */
  62956. get normal(): NodeMaterialConnectionPoint;
  62957. /**
  62958. * Gets the index of refraction component
  62959. */
  62960. get ior(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the output component
  62963. */
  62964. get output(): NodeMaterialConnectionPoint;
  62965. protected _buildBlock(state: NodeMaterialBuildState): this;
  62966. }
  62967. }
  62968. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62972. /**
  62973. * Block used to desaturate a color
  62974. */
  62975. export class DesaturateBlock extends NodeMaterialBlock {
  62976. /**
  62977. * Creates a new DesaturateBlock
  62978. * @param name defines the block name
  62979. */
  62980. constructor(name: string);
  62981. /**
  62982. * Gets the current class name
  62983. * @returns the class name
  62984. */
  62985. getClassName(): string;
  62986. /**
  62987. * Gets the color operand input component
  62988. */
  62989. get color(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the level operand input component
  62992. */
  62993. get level(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the output component
  62996. */
  62997. get output(): NodeMaterialConnectionPoint;
  62998. protected _buildBlock(state: NodeMaterialBuildState): this;
  62999. }
  63000. }
  63001. declare module "babylonjs/Materials/Node/Blocks/index" {
  63002. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63003. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63004. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63005. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63006. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63007. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63008. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63009. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63010. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63011. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63012. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63013. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63014. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63015. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63016. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63017. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63018. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63019. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63020. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63021. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63022. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63023. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63024. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63025. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63026. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63027. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63028. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63029. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63030. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63031. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63032. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63033. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63034. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63035. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63036. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63037. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63038. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63039. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63040. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63041. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63042. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63043. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63048. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63049. }
  63050. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63051. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63052. }
  63053. declare module "babylonjs/Materials/Node/index" {
  63054. export * from "babylonjs/Materials/Node/Enums/index";
  63055. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63056. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63057. export * from "babylonjs/Materials/Node/nodeMaterial";
  63058. export * from "babylonjs/Materials/Node/Blocks/index";
  63059. export * from "babylonjs/Materials/Node/Optimizers/index";
  63060. }
  63061. declare module "babylonjs/Materials/effectRenderer" {
  63062. import { Nullable } from "babylonjs/types";
  63063. import { Texture } from "babylonjs/Materials/Textures/texture";
  63064. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63065. import { Viewport } from "babylonjs/Maths/math.viewport";
  63066. import { Observable } from "babylonjs/Misc/observable";
  63067. import { Effect } from "babylonjs/Materials/effect";
  63068. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63069. import "babylonjs/Shaders/postprocess.vertex";
  63070. /**
  63071. * Effect Render Options
  63072. */
  63073. export interface IEffectRendererOptions {
  63074. /**
  63075. * Defines the vertices positions.
  63076. */
  63077. positions?: number[];
  63078. /**
  63079. * Defines the indices.
  63080. */
  63081. indices?: number[];
  63082. }
  63083. /**
  63084. * Helper class to render one or more effects
  63085. */
  63086. export class EffectRenderer {
  63087. private engine;
  63088. private static _DefaultOptions;
  63089. private _vertexBuffers;
  63090. private _indexBuffer;
  63091. private _ringBufferIndex;
  63092. private _ringScreenBuffer;
  63093. private _fullscreenViewport;
  63094. private _getNextFrameBuffer;
  63095. /**
  63096. * Creates an effect renderer
  63097. * @param engine the engine to use for rendering
  63098. * @param options defines the options of the effect renderer
  63099. */
  63100. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63101. /**
  63102. * Sets the current viewport in normalized coordinates 0-1
  63103. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63104. */
  63105. setViewport(viewport?: Viewport): void;
  63106. /**
  63107. * Binds the embedded attributes buffer to the effect.
  63108. * @param effect Defines the effect to bind the attributes for
  63109. */
  63110. bindBuffers(effect: Effect): void;
  63111. /**
  63112. * Sets the current effect wrapper to use during draw.
  63113. * The effect needs to be ready before calling this api.
  63114. * This also sets the default full screen position attribute.
  63115. * @param effectWrapper Defines the effect to draw with
  63116. */
  63117. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63118. /**
  63119. * Draws a full screen quad.
  63120. */
  63121. draw(): void;
  63122. /**
  63123. * renders one or more effects to a specified texture
  63124. * @param effectWrappers list of effects to renderer
  63125. * @param outputTexture texture to draw to, if null it will render to the screen
  63126. */
  63127. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63128. /**
  63129. * Disposes of the effect renderer
  63130. */
  63131. dispose(): void;
  63132. }
  63133. /**
  63134. * Options to create an EffectWrapper
  63135. */
  63136. interface EffectWrapperCreationOptions {
  63137. /**
  63138. * Engine to use to create the effect
  63139. */
  63140. engine: ThinEngine;
  63141. /**
  63142. * Fragment shader for the effect
  63143. */
  63144. fragmentShader: string;
  63145. /**
  63146. * Vertex shader for the effect
  63147. */
  63148. vertexShader?: string;
  63149. /**
  63150. * Attributes to use in the shader
  63151. */
  63152. attributeNames?: Array<string>;
  63153. /**
  63154. * Uniforms to use in the shader
  63155. */
  63156. uniformNames?: Array<string>;
  63157. /**
  63158. * Texture sampler names to use in the shader
  63159. */
  63160. samplerNames?: Array<string>;
  63161. /**
  63162. * The friendly name of the effect displayed in Spector.
  63163. */
  63164. name?: string;
  63165. }
  63166. /**
  63167. * Wraps an effect to be used for rendering
  63168. */
  63169. export class EffectWrapper {
  63170. /**
  63171. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63172. */
  63173. onApplyObservable: Observable<{}>;
  63174. /**
  63175. * The underlying effect
  63176. */
  63177. effect: Effect;
  63178. /**
  63179. * Creates an effect to be renderer
  63180. * @param creationOptions options to create the effect
  63181. */
  63182. constructor(creationOptions: EffectWrapperCreationOptions);
  63183. /**
  63184. * Disposes of the effect wrapper
  63185. */
  63186. dispose(): void;
  63187. }
  63188. }
  63189. declare module "babylonjs/Materials/index" {
  63190. export * from "babylonjs/Materials/Background/index";
  63191. export * from "babylonjs/Materials/colorCurves";
  63192. export * from "babylonjs/Materials/iEffectFallbacks";
  63193. export * from "babylonjs/Materials/effectFallbacks";
  63194. export * from "babylonjs/Materials/effect";
  63195. export * from "babylonjs/Materials/fresnelParameters";
  63196. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63197. export * from "babylonjs/Materials/material";
  63198. export * from "babylonjs/Materials/materialDefines";
  63199. export * from "babylonjs/Materials/materialHelper";
  63200. export * from "babylonjs/Materials/multiMaterial";
  63201. export * from "babylonjs/Materials/PBR/index";
  63202. export * from "babylonjs/Materials/pushMaterial";
  63203. export * from "babylonjs/Materials/shaderMaterial";
  63204. export * from "babylonjs/Materials/standardMaterial";
  63205. export * from "babylonjs/Materials/Textures/index";
  63206. export * from "babylonjs/Materials/uniformBuffer";
  63207. export * from "babylonjs/Materials/materialFlags";
  63208. export * from "babylonjs/Materials/Node/index";
  63209. export * from "babylonjs/Materials/effectRenderer";
  63210. }
  63211. declare module "babylonjs/Maths/index" {
  63212. export * from "babylonjs/Maths/math.scalar";
  63213. export * from "babylonjs/Maths/math";
  63214. export * from "babylonjs/Maths/sphericalPolynomial";
  63215. }
  63216. declare module "babylonjs/Misc/workerPool" {
  63217. import { IDisposable } from "babylonjs/scene";
  63218. /**
  63219. * Helper class to push actions to a pool of workers.
  63220. */
  63221. export class WorkerPool implements IDisposable {
  63222. private _workerInfos;
  63223. private _pendingActions;
  63224. /**
  63225. * Constructor
  63226. * @param workers Array of workers to use for actions
  63227. */
  63228. constructor(workers: Array<Worker>);
  63229. /**
  63230. * Terminates all workers and clears any pending actions.
  63231. */
  63232. dispose(): void;
  63233. /**
  63234. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63235. * pended until a worker has completed its action.
  63236. * @param action The action to perform. Call onComplete when the action is complete.
  63237. */
  63238. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63239. private _execute;
  63240. }
  63241. }
  63242. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63243. import { IDisposable } from "babylonjs/scene";
  63244. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63245. /**
  63246. * Configuration for Draco compression
  63247. */
  63248. export interface IDracoCompressionConfiguration {
  63249. /**
  63250. * Configuration for the decoder.
  63251. */
  63252. decoder: {
  63253. /**
  63254. * The url to the WebAssembly module.
  63255. */
  63256. wasmUrl?: string;
  63257. /**
  63258. * The url to the WebAssembly binary.
  63259. */
  63260. wasmBinaryUrl?: string;
  63261. /**
  63262. * The url to the fallback JavaScript module.
  63263. */
  63264. fallbackUrl?: string;
  63265. };
  63266. }
  63267. /**
  63268. * Draco compression (https://google.github.io/draco/)
  63269. *
  63270. * This class wraps the Draco module.
  63271. *
  63272. * **Encoder**
  63273. *
  63274. * The encoder is not currently implemented.
  63275. *
  63276. * **Decoder**
  63277. *
  63278. * 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.
  63279. *
  63280. * To update the configuration, use the following code:
  63281. * ```javascript
  63282. * DracoCompression.Configuration = {
  63283. * decoder: {
  63284. * wasmUrl: "<url to the WebAssembly library>",
  63285. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63286. * fallbackUrl: "<url to the fallback JavaScript library>",
  63287. * }
  63288. * };
  63289. * ```
  63290. *
  63291. * 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.
  63292. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63293. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63294. *
  63295. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63296. * ```javascript
  63297. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63298. * ```
  63299. *
  63300. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63301. */
  63302. export class DracoCompression implements IDisposable {
  63303. private _workerPoolPromise?;
  63304. private _decoderModulePromise?;
  63305. /**
  63306. * The configuration. Defaults to the following urls:
  63307. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63308. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63309. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63310. */
  63311. static Configuration: IDracoCompressionConfiguration;
  63312. /**
  63313. * Returns true if the decoder configuration is available.
  63314. */
  63315. static get DecoderAvailable(): boolean;
  63316. /**
  63317. * Default number of workers to create when creating the draco compression object.
  63318. */
  63319. static DefaultNumWorkers: number;
  63320. private static GetDefaultNumWorkers;
  63321. private static _Default;
  63322. /**
  63323. * Default instance for the draco compression object.
  63324. */
  63325. static get Default(): DracoCompression;
  63326. /**
  63327. * Constructor
  63328. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63329. */
  63330. constructor(numWorkers?: number);
  63331. /**
  63332. * Stop all async operations and release resources.
  63333. */
  63334. dispose(): void;
  63335. /**
  63336. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63337. * @returns a promise that resolves when ready
  63338. */
  63339. whenReadyAsync(): Promise<void>;
  63340. /**
  63341. * Decode Draco compressed mesh data to vertex data.
  63342. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63343. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63344. * @returns A promise that resolves with the decoded vertex data
  63345. */
  63346. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63347. [kind: string]: number;
  63348. }): Promise<VertexData>;
  63349. }
  63350. }
  63351. declare module "babylonjs/Meshes/Compression/index" {
  63352. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63353. }
  63354. declare module "babylonjs/Meshes/csg" {
  63355. import { Nullable } from "babylonjs/types";
  63356. import { Scene } from "babylonjs/scene";
  63357. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63358. import { Mesh } from "babylonjs/Meshes/mesh";
  63359. import { Material } from "babylonjs/Materials/material";
  63360. /**
  63361. * Class for building Constructive Solid Geometry
  63362. */
  63363. export class CSG {
  63364. private polygons;
  63365. /**
  63366. * The world matrix
  63367. */
  63368. matrix: Matrix;
  63369. /**
  63370. * Stores the position
  63371. */
  63372. position: Vector3;
  63373. /**
  63374. * Stores the rotation
  63375. */
  63376. rotation: Vector3;
  63377. /**
  63378. * Stores the rotation quaternion
  63379. */
  63380. rotationQuaternion: Nullable<Quaternion>;
  63381. /**
  63382. * Stores the scaling vector
  63383. */
  63384. scaling: Vector3;
  63385. /**
  63386. * Convert the Mesh to CSG
  63387. * @param mesh The Mesh to convert to CSG
  63388. * @returns A new CSG from the Mesh
  63389. */
  63390. static FromMesh(mesh: Mesh): CSG;
  63391. /**
  63392. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63393. * @param polygons Polygons used to construct a CSG solid
  63394. */
  63395. private static FromPolygons;
  63396. /**
  63397. * Clones, or makes a deep copy, of the CSG
  63398. * @returns A new CSG
  63399. */
  63400. clone(): CSG;
  63401. /**
  63402. * Unions this CSG with another CSG
  63403. * @param csg The CSG to union against this CSG
  63404. * @returns The unioned CSG
  63405. */
  63406. union(csg: CSG): CSG;
  63407. /**
  63408. * Unions this CSG with another CSG in place
  63409. * @param csg The CSG to union against this CSG
  63410. */
  63411. unionInPlace(csg: CSG): void;
  63412. /**
  63413. * Subtracts this CSG with another CSG
  63414. * @param csg The CSG to subtract against this CSG
  63415. * @returns A new CSG
  63416. */
  63417. subtract(csg: CSG): CSG;
  63418. /**
  63419. * Subtracts this CSG with another CSG in place
  63420. * @param csg The CSG to subtact against this CSG
  63421. */
  63422. subtractInPlace(csg: CSG): void;
  63423. /**
  63424. * Intersect this CSG with another CSG
  63425. * @param csg The CSG to intersect against this CSG
  63426. * @returns A new CSG
  63427. */
  63428. intersect(csg: CSG): CSG;
  63429. /**
  63430. * Intersects this CSG with another CSG in place
  63431. * @param csg The CSG to intersect against this CSG
  63432. */
  63433. intersectInPlace(csg: CSG): void;
  63434. /**
  63435. * Return a new CSG solid with solid and empty space switched. This solid is
  63436. * not modified.
  63437. * @returns A new CSG solid with solid and empty space switched
  63438. */
  63439. inverse(): CSG;
  63440. /**
  63441. * Inverses the CSG in place
  63442. */
  63443. inverseInPlace(): void;
  63444. /**
  63445. * This is used to keep meshes transformations so they can be restored
  63446. * when we build back a Babylon Mesh
  63447. * NB : All CSG operations are performed in world coordinates
  63448. * @param csg The CSG to copy the transform attributes from
  63449. * @returns This CSG
  63450. */
  63451. copyTransformAttributes(csg: CSG): CSG;
  63452. /**
  63453. * Build Raw mesh from CSG
  63454. * Coordinates here are in world space
  63455. * @param name The name of the mesh geometry
  63456. * @param scene The Scene
  63457. * @param keepSubMeshes Specifies if the submeshes should be kept
  63458. * @returns A new Mesh
  63459. */
  63460. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63461. /**
  63462. * Build Mesh from CSG taking material and transforms into account
  63463. * @param name The name of the Mesh
  63464. * @param material The material of the Mesh
  63465. * @param scene The Scene
  63466. * @param keepSubMeshes Specifies if submeshes should be kept
  63467. * @returns The new Mesh
  63468. */
  63469. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63470. }
  63471. }
  63472. declare module "babylonjs/Meshes/trailMesh" {
  63473. import { Mesh } from "babylonjs/Meshes/mesh";
  63474. import { Scene } from "babylonjs/scene";
  63475. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63476. /**
  63477. * Class used to create a trail following a mesh
  63478. */
  63479. export class TrailMesh extends Mesh {
  63480. private _generator;
  63481. private _autoStart;
  63482. private _running;
  63483. private _diameter;
  63484. private _length;
  63485. private _sectionPolygonPointsCount;
  63486. private _sectionVectors;
  63487. private _sectionNormalVectors;
  63488. private _beforeRenderObserver;
  63489. /**
  63490. * @constructor
  63491. * @param name The value used by scene.getMeshByName() to do a lookup.
  63492. * @param generator The mesh or transform node to generate a trail.
  63493. * @param scene The scene to add this mesh to.
  63494. * @param diameter Diameter of trailing mesh. Default is 1.
  63495. * @param length Length of trailing mesh. Default is 60.
  63496. * @param autoStart Automatically start trailing mesh. Default true.
  63497. */
  63498. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63499. /**
  63500. * "TrailMesh"
  63501. * @returns "TrailMesh"
  63502. */
  63503. getClassName(): string;
  63504. private _createMesh;
  63505. /**
  63506. * Start trailing mesh.
  63507. */
  63508. start(): void;
  63509. /**
  63510. * Stop trailing mesh.
  63511. */
  63512. stop(): void;
  63513. /**
  63514. * Update trailing mesh geometry.
  63515. */
  63516. update(): void;
  63517. /**
  63518. * Returns a new TrailMesh object.
  63519. * @param name is a string, the name given to the new mesh
  63520. * @param newGenerator use new generator object for cloned trail mesh
  63521. * @returns a new mesh
  63522. */
  63523. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63524. /**
  63525. * Serializes this trail mesh
  63526. * @param serializationObject object to write serialization to
  63527. */
  63528. serialize(serializationObject: any): void;
  63529. /**
  63530. * Parses a serialized trail mesh
  63531. * @param parsedMesh the serialized mesh
  63532. * @param scene the scene to create the trail mesh in
  63533. * @returns the created trail mesh
  63534. */
  63535. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63536. }
  63537. }
  63538. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63539. import { Nullable } from "babylonjs/types";
  63540. import { Scene } from "babylonjs/scene";
  63541. import { Vector4 } from "babylonjs/Maths/math.vector";
  63542. import { Color4 } from "babylonjs/Maths/math.color";
  63543. import { Mesh } from "babylonjs/Meshes/mesh";
  63544. /**
  63545. * Class containing static functions to help procedurally build meshes
  63546. */
  63547. export class TiledBoxBuilder {
  63548. /**
  63549. * Creates a box mesh
  63550. * 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)
  63551. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63555. * @param name defines the name of the mesh
  63556. * @param options defines the options used to create the mesh
  63557. * @param scene defines the hosting scene
  63558. * @returns the box mesh
  63559. */
  63560. static CreateTiledBox(name: string, options: {
  63561. pattern?: number;
  63562. width?: number;
  63563. height?: number;
  63564. depth?: number;
  63565. tileSize?: number;
  63566. tileWidth?: number;
  63567. tileHeight?: number;
  63568. alignHorizontal?: number;
  63569. alignVertical?: number;
  63570. faceUV?: Vector4[];
  63571. faceColors?: Color4[];
  63572. sideOrientation?: number;
  63573. updatable?: boolean;
  63574. }, scene?: Nullable<Scene>): Mesh;
  63575. }
  63576. }
  63577. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63578. import { Vector4 } from "babylonjs/Maths/math.vector";
  63579. import { Mesh } from "babylonjs/Meshes/mesh";
  63580. /**
  63581. * Class containing static functions to help procedurally build meshes
  63582. */
  63583. export class TorusKnotBuilder {
  63584. /**
  63585. * Creates a torus knot mesh
  63586. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63587. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63588. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63589. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63593. * @param name defines the name of the mesh
  63594. * @param options defines the options used to create the mesh
  63595. * @param scene defines the hosting scene
  63596. * @returns the torus knot mesh
  63597. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63598. */
  63599. static CreateTorusKnot(name: string, options: {
  63600. radius?: number;
  63601. tube?: number;
  63602. radialSegments?: number;
  63603. tubularSegments?: number;
  63604. p?: number;
  63605. q?: number;
  63606. updatable?: boolean;
  63607. sideOrientation?: number;
  63608. frontUVs?: Vector4;
  63609. backUVs?: Vector4;
  63610. }, scene: any): Mesh;
  63611. }
  63612. }
  63613. declare module "babylonjs/Meshes/polygonMesh" {
  63614. import { Scene } from "babylonjs/scene";
  63615. import { Vector2 } from "babylonjs/Maths/math.vector";
  63616. import { Mesh } from "babylonjs/Meshes/mesh";
  63617. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63618. import { Path2 } from "babylonjs/Maths/math.path";
  63619. /**
  63620. * Polygon
  63621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63622. */
  63623. export class Polygon {
  63624. /**
  63625. * Creates a rectangle
  63626. * @param xmin bottom X coord
  63627. * @param ymin bottom Y coord
  63628. * @param xmax top X coord
  63629. * @param ymax top Y coord
  63630. * @returns points that make the resulting rectation
  63631. */
  63632. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63633. /**
  63634. * Creates a circle
  63635. * @param radius radius of circle
  63636. * @param cx scale in x
  63637. * @param cy scale in y
  63638. * @param numberOfSides number of sides that make up the circle
  63639. * @returns points that make the resulting circle
  63640. */
  63641. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63642. /**
  63643. * Creates a polygon from input string
  63644. * @param input Input polygon data
  63645. * @returns the parsed points
  63646. */
  63647. static Parse(input: string): Vector2[];
  63648. /**
  63649. * Starts building a polygon from x and y coordinates
  63650. * @param x x coordinate
  63651. * @param y y coordinate
  63652. * @returns the started path2
  63653. */
  63654. static StartingAt(x: number, y: number): Path2;
  63655. }
  63656. /**
  63657. * Builds a polygon
  63658. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63659. */
  63660. export class PolygonMeshBuilder {
  63661. private _points;
  63662. private _outlinepoints;
  63663. private _holes;
  63664. private _name;
  63665. private _scene;
  63666. private _epoints;
  63667. private _eholes;
  63668. private _addToepoint;
  63669. /**
  63670. * Babylon reference to the earcut plugin.
  63671. */
  63672. bjsEarcut: any;
  63673. /**
  63674. * Creates a PolygonMeshBuilder
  63675. * @param name name of the builder
  63676. * @param contours Path of the polygon
  63677. * @param scene scene to add to when creating the mesh
  63678. * @param earcutInjection can be used to inject your own earcut reference
  63679. */
  63680. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63681. /**
  63682. * Adds a whole within the polygon
  63683. * @param hole Array of points defining the hole
  63684. * @returns this
  63685. */
  63686. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63687. /**
  63688. * Creates the polygon
  63689. * @param updatable If the mesh should be updatable
  63690. * @param depth The depth of the mesh created
  63691. * @returns the created mesh
  63692. */
  63693. build(updatable?: boolean, depth?: number): Mesh;
  63694. /**
  63695. * Creates the polygon
  63696. * @param depth The depth of the mesh created
  63697. * @returns the created VertexData
  63698. */
  63699. buildVertexData(depth?: number): VertexData;
  63700. /**
  63701. * Adds a side to the polygon
  63702. * @param positions points that make the polygon
  63703. * @param normals normals of the polygon
  63704. * @param uvs uvs of the polygon
  63705. * @param indices indices of the polygon
  63706. * @param bounds bounds of the polygon
  63707. * @param points points of the polygon
  63708. * @param depth depth of the polygon
  63709. * @param flip flip of the polygon
  63710. */
  63711. private addSide;
  63712. }
  63713. }
  63714. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63715. import { Scene } from "babylonjs/scene";
  63716. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63717. import { Color4 } from "babylonjs/Maths/math.color";
  63718. import { Mesh } from "babylonjs/Meshes/mesh";
  63719. import { Nullable } from "babylonjs/types";
  63720. /**
  63721. * Class containing static functions to help procedurally build meshes
  63722. */
  63723. export class PolygonBuilder {
  63724. /**
  63725. * Creates a polygon mesh
  63726. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63727. * * 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
  63728. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63731. * * Remember you can only change the shape positions, not their number when updating a polygon
  63732. * @param name defines the name of the mesh
  63733. * @param options defines the options used to create the mesh
  63734. * @param scene defines the hosting scene
  63735. * @param earcutInjection can be used to inject your own earcut reference
  63736. * @returns the polygon mesh
  63737. */
  63738. static CreatePolygon(name: string, options: {
  63739. shape: Vector3[];
  63740. holes?: Vector3[][];
  63741. depth?: number;
  63742. faceUV?: Vector4[];
  63743. faceColors?: Color4[];
  63744. updatable?: boolean;
  63745. sideOrientation?: number;
  63746. frontUVs?: Vector4;
  63747. backUVs?: Vector4;
  63748. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63749. /**
  63750. * Creates an extruded polygon mesh, with depth in the Y direction.
  63751. * * 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)
  63752. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63753. * @param name defines the name of the mesh
  63754. * @param options defines the options used to create the mesh
  63755. * @param scene defines the hosting scene
  63756. * @param earcutInjection can be used to inject your own earcut reference
  63757. * @returns the polygon mesh
  63758. */
  63759. static ExtrudePolygon(name: string, options: {
  63760. shape: Vector3[];
  63761. holes?: Vector3[][];
  63762. depth?: number;
  63763. faceUV?: Vector4[];
  63764. faceColors?: Color4[];
  63765. updatable?: boolean;
  63766. sideOrientation?: number;
  63767. frontUVs?: Vector4;
  63768. backUVs?: Vector4;
  63769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63770. }
  63771. }
  63772. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63773. import { Scene } from "babylonjs/scene";
  63774. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63775. import { Mesh } from "babylonjs/Meshes/mesh";
  63776. import { Nullable } from "babylonjs/types";
  63777. /**
  63778. * Class containing static functions to help procedurally build meshes
  63779. */
  63780. export class LatheBuilder {
  63781. /**
  63782. * Creates lathe mesh.
  63783. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63784. * * 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
  63785. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63786. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63787. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63788. * * 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
  63789. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63790. * * 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
  63791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63795. * @param name defines the name of the mesh
  63796. * @param options defines the options used to create the mesh
  63797. * @param scene defines the hosting scene
  63798. * @returns the lathe mesh
  63799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63800. */
  63801. static CreateLathe(name: string, options: {
  63802. shape: Vector3[];
  63803. radius?: number;
  63804. tessellation?: number;
  63805. clip?: number;
  63806. arc?: number;
  63807. closed?: boolean;
  63808. updatable?: boolean;
  63809. sideOrientation?: number;
  63810. frontUVs?: Vector4;
  63811. backUVs?: Vector4;
  63812. cap?: number;
  63813. invertUV?: boolean;
  63814. }, scene?: Nullable<Scene>): Mesh;
  63815. }
  63816. }
  63817. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63818. import { Nullable } from "babylonjs/types";
  63819. import { Scene } from "babylonjs/scene";
  63820. import { Vector4 } from "babylonjs/Maths/math.vector";
  63821. import { Mesh } from "babylonjs/Meshes/mesh";
  63822. /**
  63823. * Class containing static functions to help procedurally build meshes
  63824. */
  63825. export class TiledPlaneBuilder {
  63826. /**
  63827. * Creates a tiled plane mesh
  63828. * * The parameter `pattern` will, depending on value, do nothing or
  63829. * * * flip (reflect about central vertical) alternate tiles across and up
  63830. * * * flip every tile on alternate rows
  63831. * * * rotate (180 degs) alternate tiles across and up
  63832. * * * rotate every tile on alternate rows
  63833. * * * flip and rotate alternate tiles across and up
  63834. * * * flip and rotate every tile on alternate rows
  63835. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63836. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63839. * * 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)
  63840. * * 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)
  63841. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63842. * @param name defines the name of the mesh
  63843. * @param options defines the options used to create the mesh
  63844. * @param scene defines the hosting scene
  63845. * @returns the box mesh
  63846. */
  63847. static CreateTiledPlane(name: string, options: {
  63848. pattern?: number;
  63849. tileSize?: number;
  63850. tileWidth?: number;
  63851. tileHeight?: number;
  63852. size?: number;
  63853. width?: number;
  63854. height?: number;
  63855. alignHorizontal?: number;
  63856. alignVertical?: number;
  63857. sideOrientation?: number;
  63858. frontUVs?: Vector4;
  63859. backUVs?: Vector4;
  63860. updatable?: boolean;
  63861. }, scene?: Nullable<Scene>): Mesh;
  63862. }
  63863. }
  63864. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63865. import { Nullable } from "babylonjs/types";
  63866. import { Scene } from "babylonjs/scene";
  63867. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63868. import { Mesh } from "babylonjs/Meshes/mesh";
  63869. /**
  63870. * Class containing static functions to help procedurally build meshes
  63871. */
  63872. export class TubeBuilder {
  63873. /**
  63874. * Creates a tube mesh.
  63875. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63876. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63877. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63878. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63879. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63880. * * 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)
  63881. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63882. * * 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
  63883. * * 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
  63884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63888. * @param name defines the name of the mesh
  63889. * @param options defines the options used to create the mesh
  63890. * @param scene defines the hosting scene
  63891. * @returns the tube mesh
  63892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63893. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63894. */
  63895. static CreateTube(name: string, options: {
  63896. path: Vector3[];
  63897. radius?: number;
  63898. tessellation?: number;
  63899. radiusFunction?: {
  63900. (i: number, distance: number): number;
  63901. };
  63902. cap?: number;
  63903. arc?: number;
  63904. updatable?: boolean;
  63905. sideOrientation?: number;
  63906. frontUVs?: Vector4;
  63907. backUVs?: Vector4;
  63908. instance?: Mesh;
  63909. invertUV?: boolean;
  63910. }, scene?: Nullable<Scene>): Mesh;
  63911. }
  63912. }
  63913. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63914. import { Scene } from "babylonjs/scene";
  63915. import { Vector4 } from "babylonjs/Maths/math.vector";
  63916. import { Mesh } from "babylonjs/Meshes/mesh";
  63917. import { Nullable } from "babylonjs/types";
  63918. /**
  63919. * Class containing static functions to help procedurally build meshes
  63920. */
  63921. export class IcoSphereBuilder {
  63922. /**
  63923. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63924. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63925. * * 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`)
  63926. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63927. * * 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
  63928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63931. * @param name defines the name of the mesh
  63932. * @param options defines the options used to create the mesh
  63933. * @param scene defines the hosting scene
  63934. * @returns the icosahedron mesh
  63935. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63936. */
  63937. static CreateIcoSphere(name: string, options: {
  63938. radius?: number;
  63939. radiusX?: number;
  63940. radiusY?: number;
  63941. radiusZ?: number;
  63942. flat?: boolean;
  63943. subdivisions?: number;
  63944. sideOrientation?: number;
  63945. frontUVs?: Vector4;
  63946. backUVs?: Vector4;
  63947. updatable?: boolean;
  63948. }, scene?: Nullable<Scene>): Mesh;
  63949. }
  63950. }
  63951. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63952. import { Vector3 } from "babylonjs/Maths/math.vector";
  63953. import { Mesh } from "babylonjs/Meshes/mesh";
  63954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63955. /**
  63956. * Class containing static functions to help procedurally build meshes
  63957. */
  63958. export class DecalBuilder {
  63959. /**
  63960. * Creates a decal mesh.
  63961. * 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
  63962. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63963. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63964. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63965. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63966. * @param name defines the name of the mesh
  63967. * @param sourceMesh defines the mesh where the decal must be applied
  63968. * @param options defines the options used to create the mesh
  63969. * @param scene defines the hosting scene
  63970. * @returns the decal mesh
  63971. * @see https://doc.babylonjs.com/how_to/decals
  63972. */
  63973. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63974. position?: Vector3;
  63975. normal?: Vector3;
  63976. size?: Vector3;
  63977. angle?: number;
  63978. }): Mesh;
  63979. }
  63980. }
  63981. declare module "babylonjs/Meshes/meshBuilder" {
  63982. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63983. import { Nullable } from "babylonjs/types";
  63984. import { Scene } from "babylonjs/scene";
  63985. import { Mesh } from "babylonjs/Meshes/mesh";
  63986. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63987. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63989. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63990. import { Plane } from "babylonjs/Maths/math.plane";
  63991. /**
  63992. * Class containing static functions to help procedurally build meshes
  63993. */
  63994. export class MeshBuilder {
  63995. /**
  63996. * Creates a box mesh
  63997. * * The parameter `size` sets the size (float) of each box side (default 1)
  63998. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63999. * * 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)
  64000. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64004. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64005. * @param name defines the name of the mesh
  64006. * @param options defines the options used to create the mesh
  64007. * @param scene defines the hosting scene
  64008. * @returns the box mesh
  64009. */
  64010. static CreateBox(name: string, options: {
  64011. size?: number;
  64012. width?: number;
  64013. height?: number;
  64014. depth?: number;
  64015. faceUV?: Vector4[];
  64016. faceColors?: Color4[];
  64017. sideOrientation?: number;
  64018. frontUVs?: Vector4;
  64019. backUVs?: Vector4;
  64020. updatable?: boolean;
  64021. }, scene?: Nullable<Scene>): Mesh;
  64022. /**
  64023. * Creates a tiled box mesh
  64024. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64026. * @param name defines the name of the mesh
  64027. * @param options defines the options used to create the mesh
  64028. * @param scene defines the hosting scene
  64029. * @returns the tiled box mesh
  64030. */
  64031. static CreateTiledBox(name: string, options: {
  64032. pattern?: number;
  64033. size?: number;
  64034. width?: number;
  64035. height?: number;
  64036. depth: number;
  64037. tileSize?: number;
  64038. tileWidth?: number;
  64039. tileHeight?: number;
  64040. faceUV?: Vector4[];
  64041. faceColors?: Color4[];
  64042. alignHorizontal?: number;
  64043. alignVertical?: number;
  64044. sideOrientation?: number;
  64045. updatable?: boolean;
  64046. }, scene?: Nullable<Scene>): Mesh;
  64047. /**
  64048. * Creates a sphere mesh
  64049. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64050. * * 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`)
  64051. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64052. * * 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
  64053. * * 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)
  64054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64057. * @param name defines the name of the mesh
  64058. * @param options defines the options used to create the mesh
  64059. * @param scene defines the hosting scene
  64060. * @returns the sphere mesh
  64061. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64062. */
  64063. static CreateSphere(name: string, options: {
  64064. segments?: number;
  64065. diameter?: number;
  64066. diameterX?: number;
  64067. diameterY?: number;
  64068. diameterZ?: number;
  64069. arc?: number;
  64070. slice?: number;
  64071. sideOrientation?: number;
  64072. frontUVs?: Vector4;
  64073. backUVs?: Vector4;
  64074. updatable?: boolean;
  64075. }, scene?: Nullable<Scene>): Mesh;
  64076. /**
  64077. * Creates a plane polygonal mesh. By default, this is a disc
  64078. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64079. * * 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
  64080. * * 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
  64081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64084. * @param name defines the name of the mesh
  64085. * @param options defines the options used to create the mesh
  64086. * @param scene defines the hosting scene
  64087. * @returns the plane polygonal mesh
  64088. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64089. */
  64090. static CreateDisc(name: string, options: {
  64091. radius?: number;
  64092. tessellation?: number;
  64093. arc?: number;
  64094. updatable?: boolean;
  64095. sideOrientation?: number;
  64096. frontUVs?: Vector4;
  64097. backUVs?: Vector4;
  64098. }, scene?: Nullable<Scene>): Mesh;
  64099. /**
  64100. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64101. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64102. * * 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`)
  64103. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64104. * * 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
  64105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64108. * @param name defines the name of the mesh
  64109. * @param options defines the options used to create the mesh
  64110. * @param scene defines the hosting scene
  64111. * @returns the icosahedron mesh
  64112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64113. */
  64114. static CreateIcoSphere(name: string, options: {
  64115. radius?: number;
  64116. radiusX?: number;
  64117. radiusY?: number;
  64118. radiusZ?: number;
  64119. flat?: boolean;
  64120. subdivisions?: number;
  64121. sideOrientation?: number;
  64122. frontUVs?: Vector4;
  64123. backUVs?: Vector4;
  64124. updatable?: boolean;
  64125. }, scene?: Nullable<Scene>): Mesh;
  64126. /**
  64127. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64128. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64129. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64130. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64131. * * 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
  64132. * * 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
  64133. * * 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
  64134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64137. * * 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
  64138. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64139. * * 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
  64140. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64142. * @param name defines the name of the mesh
  64143. * @param options defines the options used to create the mesh
  64144. * @param scene defines the hosting scene
  64145. * @returns the ribbon mesh
  64146. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64148. */
  64149. static CreateRibbon(name: string, options: {
  64150. pathArray: Vector3[][];
  64151. closeArray?: boolean;
  64152. closePath?: boolean;
  64153. offset?: number;
  64154. updatable?: boolean;
  64155. sideOrientation?: number;
  64156. frontUVs?: Vector4;
  64157. backUVs?: Vector4;
  64158. instance?: Mesh;
  64159. invertUV?: boolean;
  64160. uvs?: Vector2[];
  64161. colors?: Color4[];
  64162. }, scene?: Nullable<Scene>): Mesh;
  64163. /**
  64164. * Creates a cylinder or a cone mesh
  64165. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64166. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64167. * * 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.
  64168. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64169. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64170. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64171. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64172. * * 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).
  64173. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64174. * * 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).
  64175. * * 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
  64176. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64177. * * 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
  64178. * * 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.
  64179. * * If `enclose` is false, a ring surface is one element.
  64180. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64181. * * 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
  64182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64185. * @param name defines the name of the mesh
  64186. * @param options defines the options used to create the mesh
  64187. * @param scene defines the hosting scene
  64188. * @returns the cylinder mesh
  64189. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64190. */
  64191. static CreateCylinder(name: string, options: {
  64192. height?: number;
  64193. diameterTop?: number;
  64194. diameterBottom?: number;
  64195. diameter?: number;
  64196. tessellation?: number;
  64197. subdivisions?: number;
  64198. arc?: number;
  64199. faceColors?: Color4[];
  64200. faceUV?: Vector4[];
  64201. updatable?: boolean;
  64202. hasRings?: boolean;
  64203. enclose?: boolean;
  64204. cap?: number;
  64205. sideOrientation?: number;
  64206. frontUVs?: Vector4;
  64207. backUVs?: Vector4;
  64208. }, scene?: Nullable<Scene>): Mesh;
  64209. /**
  64210. * Creates a torus mesh
  64211. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64212. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64213. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64217. * @param name defines the name of the mesh
  64218. * @param options defines the options used to create the mesh
  64219. * @param scene defines the hosting scene
  64220. * @returns the torus mesh
  64221. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64222. */
  64223. static CreateTorus(name: string, options: {
  64224. diameter?: number;
  64225. thickness?: number;
  64226. tessellation?: number;
  64227. updatable?: boolean;
  64228. sideOrientation?: number;
  64229. frontUVs?: Vector4;
  64230. backUVs?: Vector4;
  64231. }, scene?: Nullable<Scene>): Mesh;
  64232. /**
  64233. * Creates a torus knot mesh
  64234. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64235. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64236. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64237. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64241. * @param name defines the name of the mesh
  64242. * @param options defines the options used to create the mesh
  64243. * @param scene defines the hosting scene
  64244. * @returns the torus knot mesh
  64245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64246. */
  64247. static CreateTorusKnot(name: string, options: {
  64248. radius?: number;
  64249. tube?: number;
  64250. radialSegments?: number;
  64251. tubularSegments?: number;
  64252. p?: number;
  64253. q?: number;
  64254. updatable?: boolean;
  64255. sideOrientation?: number;
  64256. frontUVs?: Vector4;
  64257. backUVs?: Vector4;
  64258. }, scene?: Nullable<Scene>): Mesh;
  64259. /**
  64260. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64261. * * 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
  64262. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64263. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64264. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64265. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64266. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64267. * * 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
  64268. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64271. * @param name defines the name of the new line system
  64272. * @param options defines the options used to create the line system
  64273. * @param scene defines the hosting scene
  64274. * @returns a new line system mesh
  64275. */
  64276. static CreateLineSystem(name: string, options: {
  64277. lines: Vector3[][];
  64278. updatable?: boolean;
  64279. instance?: Nullable<LinesMesh>;
  64280. colors?: Nullable<Color4[][]>;
  64281. useVertexAlpha?: boolean;
  64282. }, scene: Nullable<Scene>): LinesMesh;
  64283. /**
  64284. * Creates a line mesh
  64285. * 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
  64286. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64287. * * The parameter `points` is an array successive Vector3
  64288. * * 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
  64289. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64290. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64291. * * When updating an instance, remember that only point positions can change, not the number of points
  64292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64294. * @param name defines the name of the new line system
  64295. * @param options defines the options used to create the line system
  64296. * @param scene defines the hosting scene
  64297. * @returns a new line mesh
  64298. */
  64299. static CreateLines(name: string, options: {
  64300. points: Vector3[];
  64301. updatable?: boolean;
  64302. instance?: Nullable<LinesMesh>;
  64303. colors?: Color4[];
  64304. useVertexAlpha?: boolean;
  64305. }, scene?: Nullable<Scene>): LinesMesh;
  64306. /**
  64307. * Creates a dashed line mesh
  64308. * * 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
  64309. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64310. * * The parameter `points` is an array successive Vector3
  64311. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64312. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64313. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64314. * * 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
  64315. * * When updating an instance, remember that only point positions can change, not the number of points
  64316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64317. * @param name defines the name of the mesh
  64318. * @param options defines the options used to create the mesh
  64319. * @param scene defines the hosting scene
  64320. * @returns the dashed line mesh
  64321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64322. */
  64323. static CreateDashedLines(name: string, options: {
  64324. points: Vector3[];
  64325. dashSize?: number;
  64326. gapSize?: number;
  64327. dashNb?: number;
  64328. updatable?: boolean;
  64329. instance?: LinesMesh;
  64330. }, scene?: Nullable<Scene>): LinesMesh;
  64331. /**
  64332. * 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.
  64333. * * 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.
  64334. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64335. * * 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.
  64336. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64337. * * 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
  64338. * * 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
  64339. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64344. * @param name defines the name of the mesh
  64345. * @param options defines the options used to create the mesh
  64346. * @param scene defines the hosting scene
  64347. * @returns the extruded shape mesh
  64348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64350. */
  64351. static ExtrudeShape(name: string, options: {
  64352. shape: Vector3[];
  64353. path: Vector3[];
  64354. scale?: number;
  64355. rotation?: number;
  64356. cap?: number;
  64357. updatable?: boolean;
  64358. sideOrientation?: number;
  64359. frontUVs?: Vector4;
  64360. backUVs?: Vector4;
  64361. instance?: Mesh;
  64362. invertUV?: boolean;
  64363. }, scene?: Nullable<Scene>): Mesh;
  64364. /**
  64365. * Creates an custom extruded shape mesh.
  64366. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64367. * * 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.
  64368. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64369. * * 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
  64370. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64371. * * 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
  64372. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64373. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64374. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64375. * * 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
  64376. * * 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
  64377. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64380. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64382. * @param name defines the name of the mesh
  64383. * @param options defines the options used to create the mesh
  64384. * @param scene defines the hosting scene
  64385. * @returns the custom extruded shape mesh
  64386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64389. */
  64390. static ExtrudeShapeCustom(name: string, options: {
  64391. shape: Vector3[];
  64392. path: Vector3[];
  64393. scaleFunction?: any;
  64394. rotationFunction?: any;
  64395. ribbonCloseArray?: boolean;
  64396. ribbonClosePath?: boolean;
  64397. cap?: number;
  64398. updatable?: boolean;
  64399. sideOrientation?: number;
  64400. frontUVs?: Vector4;
  64401. backUVs?: Vector4;
  64402. instance?: Mesh;
  64403. invertUV?: boolean;
  64404. }, scene?: Nullable<Scene>): Mesh;
  64405. /**
  64406. * Creates lathe mesh.
  64407. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64408. * * 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
  64409. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64410. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64411. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64412. * * 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
  64413. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64414. * * 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
  64415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64419. * @param name defines the name of the mesh
  64420. * @param options defines the options used to create the mesh
  64421. * @param scene defines the hosting scene
  64422. * @returns the lathe mesh
  64423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64424. */
  64425. static CreateLathe(name: string, options: {
  64426. shape: Vector3[];
  64427. radius?: number;
  64428. tessellation?: number;
  64429. clip?: number;
  64430. arc?: number;
  64431. closed?: boolean;
  64432. updatable?: boolean;
  64433. sideOrientation?: number;
  64434. frontUVs?: Vector4;
  64435. backUVs?: Vector4;
  64436. cap?: number;
  64437. invertUV?: boolean;
  64438. }, scene?: Nullable<Scene>): Mesh;
  64439. /**
  64440. * Creates a tiled plane mesh
  64441. * * You can set a limited pattern arrangement with the tiles
  64442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64445. * @param name defines the name of the mesh
  64446. * @param options defines the options used to create the mesh
  64447. * @param scene defines the hosting scene
  64448. * @returns the plane mesh
  64449. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64450. */
  64451. static CreateTiledPlane(name: string, options: {
  64452. pattern?: number;
  64453. tileSize?: number;
  64454. tileWidth?: number;
  64455. tileHeight?: number;
  64456. size?: number;
  64457. width?: number;
  64458. height?: number;
  64459. alignHorizontal?: number;
  64460. alignVertical?: number;
  64461. sideOrientation?: number;
  64462. frontUVs?: Vector4;
  64463. backUVs?: Vector4;
  64464. updatable?: boolean;
  64465. }, scene?: Nullable<Scene>): Mesh;
  64466. /**
  64467. * Creates a plane mesh
  64468. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64469. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64470. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64474. * @param name defines the name of the mesh
  64475. * @param options defines the options used to create the mesh
  64476. * @param scene defines the hosting scene
  64477. * @returns the plane mesh
  64478. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64479. */
  64480. static CreatePlane(name: string, options: {
  64481. size?: number;
  64482. width?: number;
  64483. height?: number;
  64484. sideOrientation?: number;
  64485. frontUVs?: Vector4;
  64486. backUVs?: Vector4;
  64487. updatable?: boolean;
  64488. sourcePlane?: Plane;
  64489. }, scene?: Nullable<Scene>): Mesh;
  64490. /**
  64491. * Creates a ground mesh
  64492. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64493. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64495. * @param name defines the name of the mesh
  64496. * @param options defines the options used to create the mesh
  64497. * @param scene defines the hosting scene
  64498. * @returns the ground mesh
  64499. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64500. */
  64501. static CreateGround(name: string, options: {
  64502. width?: number;
  64503. height?: number;
  64504. subdivisions?: number;
  64505. subdivisionsX?: number;
  64506. subdivisionsY?: number;
  64507. updatable?: boolean;
  64508. }, scene?: Nullable<Scene>): Mesh;
  64509. /**
  64510. * Creates a tiled ground mesh
  64511. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64512. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64513. * * 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
  64514. * * 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
  64515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64516. * @param name defines the name of the mesh
  64517. * @param options defines the options used to create the mesh
  64518. * @param scene defines the hosting scene
  64519. * @returns the tiled ground mesh
  64520. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64521. */
  64522. static CreateTiledGround(name: string, options: {
  64523. xmin: number;
  64524. zmin: number;
  64525. xmax: number;
  64526. zmax: number;
  64527. subdivisions?: {
  64528. w: number;
  64529. h: number;
  64530. };
  64531. precision?: {
  64532. w: number;
  64533. h: number;
  64534. };
  64535. updatable?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a ground mesh from a height map
  64539. * * The parameter `url` sets the URL of the height map image resource.
  64540. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64541. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64542. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64543. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64544. * * 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.
  64545. * * 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).
  64546. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64548. * @param name defines the name of the mesh
  64549. * @param url defines the url to the height map
  64550. * @param options defines the options used to create the mesh
  64551. * @param scene defines the hosting scene
  64552. * @returns the ground mesh
  64553. * @see https://doc.babylonjs.com/babylon101/height_map
  64554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64555. */
  64556. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64557. width?: number;
  64558. height?: number;
  64559. subdivisions?: number;
  64560. minHeight?: number;
  64561. maxHeight?: number;
  64562. colorFilter?: Color3;
  64563. alphaFilter?: number;
  64564. updatable?: boolean;
  64565. onReady?: (mesh: GroundMesh) => void;
  64566. }, scene?: Nullable<Scene>): GroundMesh;
  64567. /**
  64568. * Creates a polygon mesh
  64569. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64570. * * 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
  64571. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64574. * * Remember you can only change the shape positions, not their number when updating a polygon
  64575. * @param name defines the name of the mesh
  64576. * @param options defines the options used to create the mesh
  64577. * @param scene defines the hosting scene
  64578. * @param earcutInjection can be used to inject your own earcut reference
  64579. * @returns the polygon mesh
  64580. */
  64581. static CreatePolygon(name: string, options: {
  64582. shape: Vector3[];
  64583. holes?: Vector3[][];
  64584. depth?: number;
  64585. faceUV?: Vector4[];
  64586. faceColors?: Color4[];
  64587. updatable?: boolean;
  64588. sideOrientation?: number;
  64589. frontUVs?: Vector4;
  64590. backUVs?: Vector4;
  64591. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64592. /**
  64593. * Creates an extruded polygon mesh, with depth in the Y direction.
  64594. * * 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)
  64595. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64596. * @param name defines the name of the mesh
  64597. * @param options defines the options used to create the mesh
  64598. * @param scene defines the hosting scene
  64599. * @param earcutInjection can be used to inject your own earcut reference
  64600. * @returns the polygon mesh
  64601. */
  64602. static ExtrudePolygon(name: string, options: {
  64603. shape: Vector3[];
  64604. holes?: Vector3[][];
  64605. depth?: number;
  64606. faceUV?: Vector4[];
  64607. faceColors?: Color4[];
  64608. updatable?: boolean;
  64609. sideOrientation?: number;
  64610. frontUVs?: Vector4;
  64611. backUVs?: Vector4;
  64612. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64613. /**
  64614. * Creates a tube mesh.
  64615. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64616. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64617. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64618. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64619. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64620. * * 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)
  64621. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64622. * * 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
  64623. * * 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
  64624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64628. * @param name defines the name of the mesh
  64629. * @param options defines the options used to create the mesh
  64630. * @param scene defines the hosting scene
  64631. * @returns the tube mesh
  64632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64633. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64634. */
  64635. static CreateTube(name: string, options: {
  64636. path: Vector3[];
  64637. radius?: number;
  64638. tessellation?: number;
  64639. radiusFunction?: {
  64640. (i: number, distance: number): number;
  64641. };
  64642. cap?: number;
  64643. arc?: number;
  64644. updatable?: boolean;
  64645. sideOrientation?: number;
  64646. frontUVs?: Vector4;
  64647. backUVs?: Vector4;
  64648. instance?: Mesh;
  64649. invertUV?: boolean;
  64650. }, scene?: Nullable<Scene>): Mesh;
  64651. /**
  64652. * Creates a polyhedron mesh
  64653. * * 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
  64654. * * The parameter `size` (positive float, default 1) sets the polygon size
  64655. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64656. * * 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`
  64657. * * 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
  64658. * * 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)`)
  64659. * * 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
  64660. * * 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
  64661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64664. * @param name defines the name of the mesh
  64665. * @param options defines the options used to create the mesh
  64666. * @param scene defines the hosting scene
  64667. * @returns the polyhedron mesh
  64668. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64669. */
  64670. static CreatePolyhedron(name: string, options: {
  64671. type?: number;
  64672. size?: number;
  64673. sizeX?: number;
  64674. sizeY?: number;
  64675. sizeZ?: number;
  64676. custom?: any;
  64677. faceUV?: Vector4[];
  64678. faceColors?: Color4[];
  64679. flat?: boolean;
  64680. updatable?: boolean;
  64681. sideOrientation?: number;
  64682. frontUVs?: Vector4;
  64683. backUVs?: Vector4;
  64684. }, scene?: Nullable<Scene>): Mesh;
  64685. /**
  64686. * Creates a decal mesh.
  64687. * 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
  64688. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64689. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64690. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64691. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64692. * @param name defines the name of the mesh
  64693. * @param sourceMesh defines the mesh where the decal must be applied
  64694. * @param options defines the options used to create the mesh
  64695. * @param scene defines the hosting scene
  64696. * @returns the decal mesh
  64697. * @see https://doc.babylonjs.com/how_to/decals
  64698. */
  64699. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64700. position?: Vector3;
  64701. normal?: Vector3;
  64702. size?: Vector3;
  64703. angle?: number;
  64704. }): Mesh;
  64705. }
  64706. }
  64707. declare module "babylonjs/Meshes/meshSimplification" {
  64708. import { Mesh } from "babylonjs/Meshes/mesh";
  64709. /**
  64710. * A simplifier interface for future simplification implementations
  64711. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64712. */
  64713. export interface ISimplifier {
  64714. /**
  64715. * Simplification of a given mesh according to the given settings.
  64716. * Since this requires computation, it is assumed that the function runs async.
  64717. * @param settings The settings of the simplification, including quality and distance
  64718. * @param successCallback A callback that will be called after the mesh was simplified.
  64719. * @param errorCallback in case of an error, this callback will be called. optional.
  64720. */
  64721. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64722. }
  64723. /**
  64724. * Expected simplification settings.
  64725. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64727. */
  64728. export interface ISimplificationSettings {
  64729. /**
  64730. * Gets or sets the expected quality
  64731. */
  64732. quality: number;
  64733. /**
  64734. * Gets or sets the distance when this optimized version should be used
  64735. */
  64736. distance: number;
  64737. /**
  64738. * Gets an already optimized mesh
  64739. */
  64740. optimizeMesh?: boolean;
  64741. }
  64742. /**
  64743. * Class used to specify simplification options
  64744. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64745. */
  64746. export class SimplificationSettings implements ISimplificationSettings {
  64747. /** expected quality */
  64748. quality: number;
  64749. /** distance when this optimized version should be used */
  64750. distance: number;
  64751. /** already optimized mesh */
  64752. optimizeMesh?: boolean | undefined;
  64753. /**
  64754. * Creates a SimplificationSettings
  64755. * @param quality expected quality
  64756. * @param distance distance when this optimized version should be used
  64757. * @param optimizeMesh already optimized mesh
  64758. */
  64759. constructor(
  64760. /** expected quality */
  64761. quality: number,
  64762. /** distance when this optimized version should be used */
  64763. distance: number,
  64764. /** already optimized mesh */
  64765. optimizeMesh?: boolean | undefined);
  64766. }
  64767. /**
  64768. * Interface used to define a simplification task
  64769. */
  64770. export interface ISimplificationTask {
  64771. /**
  64772. * Array of settings
  64773. */
  64774. settings: Array<ISimplificationSettings>;
  64775. /**
  64776. * Simplification type
  64777. */
  64778. simplificationType: SimplificationType;
  64779. /**
  64780. * Mesh to simplify
  64781. */
  64782. mesh: Mesh;
  64783. /**
  64784. * Callback called on success
  64785. */
  64786. successCallback?: () => void;
  64787. /**
  64788. * Defines if parallel processing can be used
  64789. */
  64790. parallelProcessing: boolean;
  64791. }
  64792. /**
  64793. * Queue used to order the simplification tasks
  64794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64795. */
  64796. export class SimplificationQueue {
  64797. private _simplificationArray;
  64798. /**
  64799. * Gets a boolean indicating that the process is still running
  64800. */
  64801. running: boolean;
  64802. /**
  64803. * Creates a new queue
  64804. */
  64805. constructor();
  64806. /**
  64807. * Adds a new simplification task
  64808. * @param task defines a task to add
  64809. */
  64810. addTask(task: ISimplificationTask): void;
  64811. /**
  64812. * Execute next task
  64813. */
  64814. executeNext(): void;
  64815. /**
  64816. * Execute a simplification task
  64817. * @param task defines the task to run
  64818. */
  64819. runSimplification(task: ISimplificationTask): void;
  64820. private getSimplifier;
  64821. }
  64822. /**
  64823. * The implemented types of simplification
  64824. * At the moment only Quadratic Error Decimation is implemented
  64825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64826. */
  64827. export enum SimplificationType {
  64828. /** Quadratic error decimation */
  64829. QUADRATIC = 0
  64830. }
  64831. }
  64832. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64833. import { Scene } from "babylonjs/scene";
  64834. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64835. import { ISceneComponent } from "babylonjs/sceneComponent";
  64836. module "babylonjs/scene" {
  64837. interface Scene {
  64838. /** @hidden (Backing field) */
  64839. _simplificationQueue: SimplificationQueue;
  64840. /**
  64841. * Gets or sets the simplification queue attached to the scene
  64842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64843. */
  64844. simplificationQueue: SimplificationQueue;
  64845. }
  64846. }
  64847. module "babylonjs/Meshes/mesh" {
  64848. interface Mesh {
  64849. /**
  64850. * Simplify the mesh according to the given array of settings.
  64851. * Function will return immediately and will simplify async
  64852. * @param settings a collection of simplification settings
  64853. * @param parallelProcessing should all levels calculate parallel or one after the other
  64854. * @param simplificationType the type of simplification to run
  64855. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64856. * @returns the current mesh
  64857. */
  64858. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64859. }
  64860. }
  64861. /**
  64862. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64863. * created in a scene
  64864. */
  64865. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64866. /**
  64867. * The component name helpfull to identify the component in the list of scene components.
  64868. */
  64869. readonly name: string;
  64870. /**
  64871. * The scene the component belongs to.
  64872. */
  64873. scene: Scene;
  64874. /**
  64875. * Creates a new instance of the component for the given scene
  64876. * @param scene Defines the scene to register the component in
  64877. */
  64878. constructor(scene: Scene);
  64879. /**
  64880. * Registers the component in a given scene
  64881. */
  64882. register(): void;
  64883. /**
  64884. * Rebuilds the elements related to this component in case of
  64885. * context lost for instance.
  64886. */
  64887. rebuild(): void;
  64888. /**
  64889. * Disposes the component and the associated ressources
  64890. */
  64891. dispose(): void;
  64892. private _beforeCameraUpdate;
  64893. }
  64894. }
  64895. declare module "babylonjs/Meshes/Builders/index" {
  64896. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64897. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64898. export * from "babylonjs/Meshes/Builders/discBuilder";
  64899. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64900. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64901. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64902. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64903. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64904. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64905. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64906. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64907. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64908. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64909. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64910. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64911. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64912. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64913. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64914. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64915. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64916. }
  64917. declare module "babylonjs/Meshes/index" {
  64918. export * from "babylonjs/Meshes/abstractMesh";
  64919. export * from "babylonjs/Meshes/buffer";
  64920. export * from "babylonjs/Meshes/Compression/index";
  64921. export * from "babylonjs/Meshes/csg";
  64922. export * from "babylonjs/Meshes/geometry";
  64923. export * from "babylonjs/Meshes/groundMesh";
  64924. export * from "babylonjs/Meshes/trailMesh";
  64925. export * from "babylonjs/Meshes/instancedMesh";
  64926. export * from "babylonjs/Meshes/linesMesh";
  64927. export * from "babylonjs/Meshes/mesh";
  64928. export * from "babylonjs/Meshes/mesh.vertexData";
  64929. export * from "babylonjs/Meshes/meshBuilder";
  64930. export * from "babylonjs/Meshes/meshSimplification";
  64931. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64932. export * from "babylonjs/Meshes/polygonMesh";
  64933. export * from "babylonjs/Meshes/subMesh";
  64934. export * from "babylonjs/Meshes/meshLODLevel";
  64935. export * from "babylonjs/Meshes/transformNode";
  64936. export * from "babylonjs/Meshes/Builders/index";
  64937. export * from "babylonjs/Meshes/dataBuffer";
  64938. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64939. }
  64940. declare module "babylonjs/Morph/index" {
  64941. export * from "babylonjs/Morph/morphTarget";
  64942. export * from "babylonjs/Morph/morphTargetManager";
  64943. }
  64944. declare module "babylonjs/Navigation/INavigationEngine" {
  64945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64946. import { Vector3 } from "babylonjs/Maths/math";
  64947. import { Mesh } from "babylonjs/Meshes/mesh";
  64948. import { Scene } from "babylonjs/scene";
  64949. /**
  64950. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64951. */
  64952. export interface INavigationEnginePlugin {
  64953. /**
  64954. * plugin name
  64955. */
  64956. name: string;
  64957. /**
  64958. * Creates a navigation mesh
  64959. * @param meshes array of all the geometry used to compute the navigatio mesh
  64960. * @param parameters bunch of parameters used to filter geometry
  64961. */
  64962. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64963. /**
  64964. * Create a navigation mesh debug mesh
  64965. * @param scene is where the mesh will be added
  64966. * @returns debug display mesh
  64967. */
  64968. createDebugNavMesh(scene: Scene): Mesh;
  64969. /**
  64970. * Get a navigation mesh constrained position, closest to the parameter position
  64971. * @param position world position
  64972. * @returns the closest point to position constrained by the navigation mesh
  64973. */
  64974. getClosestPoint(position: Vector3): Vector3;
  64975. /**
  64976. * Get a navigation mesh constrained position, within a particular radius
  64977. * @param position world position
  64978. * @param maxRadius the maximum distance to the constrained world position
  64979. * @returns the closest point to position constrained by the navigation mesh
  64980. */
  64981. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64982. /**
  64983. * Compute the final position from a segment made of destination-position
  64984. * @param position world position
  64985. * @param destination world position
  64986. * @returns the resulting point along the navmesh
  64987. */
  64988. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64989. /**
  64990. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64991. * @param start world position
  64992. * @param end world position
  64993. * @returns array containing world position composing the path
  64994. */
  64995. computePath(start: Vector3, end: Vector3): Vector3[];
  64996. /**
  64997. * If this plugin is supported
  64998. * @returns true if plugin is supported
  64999. */
  65000. isSupported(): boolean;
  65001. /**
  65002. * Create a new Crowd so you can add agents
  65003. * @param maxAgents the maximum agent count in the crowd
  65004. * @param maxAgentRadius the maximum radius an agent can have
  65005. * @param scene to attach the crowd to
  65006. * @returns the crowd you can add agents to
  65007. */
  65008. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65009. /**
  65010. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65011. * The queries will try to find a solution within those bounds
  65012. * default is (1,1,1)
  65013. * @param extent x,y,z value that define the extent around the queries point of reference
  65014. */
  65015. setDefaultQueryExtent(extent: Vector3): void;
  65016. /**
  65017. * Get the Bounding box extent specified by setDefaultQueryExtent
  65018. * @returns the box extent values
  65019. */
  65020. getDefaultQueryExtent(): Vector3;
  65021. /**
  65022. * Release all resources
  65023. */
  65024. dispose(): void;
  65025. }
  65026. /**
  65027. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65028. */
  65029. export interface ICrowd {
  65030. /**
  65031. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65032. * You can attach anything to that node. The node position is updated in the scene update tick.
  65033. * @param pos world position that will be constrained by the navigation mesh
  65034. * @param parameters agent parameters
  65035. * @param transform hooked to the agent that will be update by the scene
  65036. * @returns agent index
  65037. */
  65038. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65039. /**
  65040. * Returns the agent position in world space
  65041. * @param index agent index returned by addAgent
  65042. * @returns world space position
  65043. */
  65044. getAgentPosition(index: number): Vector3;
  65045. /**
  65046. * Gets the agent velocity in world space
  65047. * @param index agent index returned by addAgent
  65048. * @returns world space velocity
  65049. */
  65050. getAgentVelocity(index: number): Vector3;
  65051. /**
  65052. * remove a particular agent previously created
  65053. * @param index agent index returned by addAgent
  65054. */
  65055. removeAgent(index: number): void;
  65056. /**
  65057. * get the list of all agents attached to this crowd
  65058. * @returns list of agent indices
  65059. */
  65060. getAgents(): number[];
  65061. /**
  65062. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65063. * @param deltaTime in seconds
  65064. */
  65065. update(deltaTime: number): void;
  65066. /**
  65067. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65068. * @param index agent index returned by addAgent
  65069. * @param destination targeted world position
  65070. */
  65071. agentGoto(index: number, destination: Vector3): void;
  65072. /**
  65073. * Teleport the agent to a new position
  65074. * @param index agent index returned by addAgent
  65075. * @param destination targeted world position
  65076. */
  65077. agentTeleport(index: number, destination: Vector3): void;
  65078. /**
  65079. * Update agent parameters
  65080. * @param index agent index returned by addAgent
  65081. * @param parameters agent parameters
  65082. */
  65083. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65084. /**
  65085. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65086. * The queries will try to find a solution within those bounds
  65087. * default is (1,1,1)
  65088. * @param extent x,y,z value that define the extent around the queries point of reference
  65089. */
  65090. setDefaultQueryExtent(extent: Vector3): void;
  65091. /**
  65092. * Get the Bounding box extent specified by setDefaultQueryExtent
  65093. * @returns the box extent values
  65094. */
  65095. getDefaultQueryExtent(): Vector3;
  65096. /**
  65097. * Release all resources
  65098. */
  65099. dispose(): void;
  65100. }
  65101. /**
  65102. * Configures an agent
  65103. */
  65104. export interface IAgentParameters {
  65105. /**
  65106. * Agent radius. [Limit: >= 0]
  65107. */
  65108. radius: number;
  65109. /**
  65110. * Agent height. [Limit: > 0]
  65111. */
  65112. height: number;
  65113. /**
  65114. * Maximum allowed acceleration. [Limit: >= 0]
  65115. */
  65116. maxAcceleration: number;
  65117. /**
  65118. * Maximum allowed speed. [Limit: >= 0]
  65119. */
  65120. maxSpeed: number;
  65121. /**
  65122. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65123. */
  65124. collisionQueryRange: number;
  65125. /**
  65126. * The path visibility optimization range. [Limit: > 0]
  65127. */
  65128. pathOptimizationRange: number;
  65129. /**
  65130. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65131. */
  65132. separationWeight: number;
  65133. }
  65134. /**
  65135. * Configures the navigation mesh creation
  65136. */
  65137. export interface INavMeshParameters {
  65138. /**
  65139. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65140. */
  65141. cs: number;
  65142. /**
  65143. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65144. */
  65145. ch: number;
  65146. /**
  65147. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65148. */
  65149. walkableSlopeAngle: number;
  65150. /**
  65151. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65152. * be considered walkable. [Limit: >= 3] [Units: vx]
  65153. */
  65154. walkableHeight: number;
  65155. /**
  65156. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65157. */
  65158. walkableClimb: number;
  65159. /**
  65160. * The distance to erode/shrink the walkable area of the heightfield away from
  65161. * obstructions. [Limit: >=0] [Units: vx]
  65162. */
  65163. walkableRadius: number;
  65164. /**
  65165. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65166. */
  65167. maxEdgeLen: number;
  65168. /**
  65169. * The maximum distance a simplfied contour's border edges should deviate
  65170. * the original raw contour. [Limit: >=0] [Units: vx]
  65171. */
  65172. maxSimplificationError: number;
  65173. /**
  65174. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65175. */
  65176. minRegionArea: number;
  65177. /**
  65178. * Any regions with a span count smaller than this value will, if possible,
  65179. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65180. */
  65181. mergeRegionArea: number;
  65182. /**
  65183. * The maximum number of vertices allowed for polygons generated during the
  65184. * contour to polygon conversion process. [Limit: >= 3]
  65185. */
  65186. maxVertsPerPoly: number;
  65187. /**
  65188. * Sets the sampling distance to use when generating the detail mesh.
  65189. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65190. */
  65191. detailSampleDist: number;
  65192. /**
  65193. * The maximum distance the detail mesh surface should deviate from heightfield
  65194. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65195. */
  65196. detailSampleMaxError: number;
  65197. }
  65198. }
  65199. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65200. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65201. import { Mesh } from "babylonjs/Meshes/mesh";
  65202. import { Scene } from "babylonjs/scene";
  65203. import { Vector3 } from "babylonjs/Maths/math";
  65204. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65205. /**
  65206. * RecastJS navigation plugin
  65207. */
  65208. export class RecastJSPlugin implements INavigationEnginePlugin {
  65209. /**
  65210. * Reference to the Recast library
  65211. */
  65212. bjsRECAST: any;
  65213. /**
  65214. * plugin name
  65215. */
  65216. name: string;
  65217. /**
  65218. * the first navmesh created. We might extend this to support multiple navmeshes
  65219. */
  65220. navMesh: any;
  65221. /**
  65222. * Initializes the recastJS plugin
  65223. * @param recastInjection can be used to inject your own recast reference
  65224. */
  65225. constructor(recastInjection?: any);
  65226. /**
  65227. * Creates a navigation mesh
  65228. * @param meshes array of all the geometry used to compute the navigatio mesh
  65229. * @param parameters bunch of parameters used to filter geometry
  65230. */
  65231. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65232. /**
  65233. * Create a navigation mesh debug mesh
  65234. * @param scene is where the mesh will be added
  65235. * @returns debug display mesh
  65236. */
  65237. createDebugNavMesh(scene: Scene): Mesh;
  65238. /**
  65239. * Get a navigation mesh constrained position, closest to the parameter position
  65240. * @param position world position
  65241. * @returns the closest point to position constrained by the navigation mesh
  65242. */
  65243. getClosestPoint(position: Vector3): Vector3;
  65244. /**
  65245. * Get a navigation mesh constrained position, within a particular radius
  65246. * @param position world position
  65247. * @param maxRadius the maximum distance to the constrained world position
  65248. * @returns the closest point to position constrained by the navigation mesh
  65249. */
  65250. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65251. /**
  65252. * Compute the final position from a segment made of destination-position
  65253. * @param position world position
  65254. * @param destination world position
  65255. * @returns the resulting point along the navmesh
  65256. */
  65257. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65258. /**
  65259. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65260. * @param start world position
  65261. * @param end world position
  65262. * @returns array containing world position composing the path
  65263. */
  65264. computePath(start: Vector3, end: Vector3): Vector3[];
  65265. /**
  65266. * Create a new Crowd so you can add agents
  65267. * @param maxAgents the maximum agent count in the crowd
  65268. * @param maxAgentRadius the maximum radius an agent can have
  65269. * @param scene to attach the crowd to
  65270. * @returns the crowd you can add agents to
  65271. */
  65272. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65273. /**
  65274. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65275. * The queries will try to find a solution within those bounds
  65276. * default is (1,1,1)
  65277. * @param extent x,y,z value that define the extent around the queries point of reference
  65278. */
  65279. setDefaultQueryExtent(extent: Vector3): void;
  65280. /**
  65281. * Get the Bounding box extent specified by setDefaultQueryExtent
  65282. * @returns the box extent values
  65283. */
  65284. getDefaultQueryExtent(): Vector3;
  65285. /**
  65286. * Disposes
  65287. */
  65288. dispose(): void;
  65289. /**
  65290. * If this plugin is supported
  65291. * @returns true if plugin is supported
  65292. */
  65293. isSupported(): boolean;
  65294. }
  65295. /**
  65296. * Recast detour crowd implementation
  65297. */
  65298. export class RecastJSCrowd implements ICrowd {
  65299. /**
  65300. * Recast/detour plugin
  65301. */
  65302. bjsRECASTPlugin: RecastJSPlugin;
  65303. /**
  65304. * Link to the detour crowd
  65305. */
  65306. recastCrowd: any;
  65307. /**
  65308. * One transform per agent
  65309. */
  65310. transforms: TransformNode[];
  65311. /**
  65312. * All agents created
  65313. */
  65314. agents: number[];
  65315. /**
  65316. * Link to the scene is kept to unregister the crowd from the scene
  65317. */
  65318. private _scene;
  65319. /**
  65320. * Observer for crowd updates
  65321. */
  65322. private _onBeforeAnimationsObserver;
  65323. /**
  65324. * Constructor
  65325. * @param plugin recastJS plugin
  65326. * @param maxAgents the maximum agent count in the crowd
  65327. * @param maxAgentRadius the maximum radius an agent can have
  65328. * @param scene to attach the crowd to
  65329. * @returns the crowd you can add agents to
  65330. */
  65331. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65332. /**
  65333. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65334. * You can attach anything to that node. The node position is updated in the scene update tick.
  65335. * @param pos world position that will be constrained by the navigation mesh
  65336. * @param parameters agent parameters
  65337. * @param transform hooked to the agent that will be update by the scene
  65338. * @returns agent index
  65339. */
  65340. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65341. /**
  65342. * Returns the agent position in world space
  65343. * @param index agent index returned by addAgent
  65344. * @returns world space position
  65345. */
  65346. getAgentPosition(index: number): Vector3;
  65347. /**
  65348. * Returns the agent velocity in world space
  65349. * @param index agent index returned by addAgent
  65350. * @returns world space velocity
  65351. */
  65352. getAgentVelocity(index: number): Vector3;
  65353. /**
  65354. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65355. * @param index agent index returned by addAgent
  65356. * @param destination targeted world position
  65357. */
  65358. agentGoto(index: number, destination: Vector3): void;
  65359. /**
  65360. * Teleport the agent to a new position
  65361. * @param index agent index returned by addAgent
  65362. * @param destination targeted world position
  65363. */
  65364. agentTeleport(index: number, destination: Vector3): void;
  65365. /**
  65366. * Update agent parameters
  65367. * @param index agent index returned by addAgent
  65368. * @param parameters agent parameters
  65369. */
  65370. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65371. /**
  65372. * remove a particular agent previously created
  65373. * @param index agent index returned by addAgent
  65374. */
  65375. removeAgent(index: number): void;
  65376. /**
  65377. * get the list of all agents attached to this crowd
  65378. * @returns list of agent indices
  65379. */
  65380. getAgents(): number[];
  65381. /**
  65382. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65383. * @param deltaTime in seconds
  65384. */
  65385. update(deltaTime: number): void;
  65386. /**
  65387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65388. * The queries will try to find a solution within those bounds
  65389. * default is (1,1,1)
  65390. * @param extent x,y,z value that define the extent around the queries point of reference
  65391. */
  65392. setDefaultQueryExtent(extent: Vector3): void;
  65393. /**
  65394. * Get the Bounding box extent specified by setDefaultQueryExtent
  65395. * @returns the box extent values
  65396. */
  65397. getDefaultQueryExtent(): Vector3;
  65398. /**
  65399. * Release all resources
  65400. */
  65401. dispose(): void;
  65402. }
  65403. }
  65404. declare module "babylonjs/Navigation/Plugins/index" {
  65405. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65406. }
  65407. declare module "babylonjs/Navigation/index" {
  65408. export * from "babylonjs/Navigation/INavigationEngine";
  65409. export * from "babylonjs/Navigation/Plugins/index";
  65410. }
  65411. declare module "babylonjs/Offline/database" {
  65412. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65413. /**
  65414. * Class used to enable access to IndexedDB
  65415. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65416. */
  65417. export class Database implements IOfflineProvider {
  65418. private _callbackManifestChecked;
  65419. private _currentSceneUrl;
  65420. private _db;
  65421. private _enableSceneOffline;
  65422. private _enableTexturesOffline;
  65423. private _manifestVersionFound;
  65424. private _mustUpdateRessources;
  65425. private _hasReachedQuota;
  65426. private _isSupported;
  65427. private _idbFactory;
  65428. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65429. private static IsUASupportingBlobStorage;
  65430. /**
  65431. * Gets a boolean indicating if Database storate is enabled (off by default)
  65432. */
  65433. static IDBStorageEnabled: boolean;
  65434. /**
  65435. * Gets a boolean indicating if scene must be saved in the database
  65436. */
  65437. get enableSceneOffline(): boolean;
  65438. /**
  65439. * Gets a boolean indicating if textures must be saved in the database
  65440. */
  65441. get enableTexturesOffline(): boolean;
  65442. /**
  65443. * Creates a new Database
  65444. * @param urlToScene defines the url to load the scene
  65445. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65446. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65447. */
  65448. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65449. private static _ParseURL;
  65450. private static _ReturnFullUrlLocation;
  65451. private _checkManifestFile;
  65452. /**
  65453. * Open the database and make it available
  65454. * @param successCallback defines the callback to call on success
  65455. * @param errorCallback defines the callback to call on error
  65456. */
  65457. open(successCallback: () => void, errorCallback: () => void): void;
  65458. /**
  65459. * Loads an image from the database
  65460. * @param url defines the url to load from
  65461. * @param image defines the target DOM image
  65462. */
  65463. loadImage(url: string, image: HTMLImageElement): void;
  65464. private _loadImageFromDBAsync;
  65465. private _saveImageIntoDBAsync;
  65466. private _checkVersionFromDB;
  65467. private _loadVersionFromDBAsync;
  65468. private _saveVersionIntoDBAsync;
  65469. /**
  65470. * Loads a file from database
  65471. * @param url defines the URL to load from
  65472. * @param sceneLoaded defines a callback to call on success
  65473. * @param progressCallBack defines a callback to call when progress changed
  65474. * @param errorCallback defines a callback to call on error
  65475. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65476. */
  65477. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65478. private _loadFileAsync;
  65479. private _saveFileAsync;
  65480. /**
  65481. * Validates if xhr data is correct
  65482. * @param xhr defines the request to validate
  65483. * @param dataType defines the expected data type
  65484. * @returns true if data is correct
  65485. */
  65486. private static _ValidateXHRData;
  65487. }
  65488. }
  65489. declare module "babylonjs/Offline/index" {
  65490. export * from "babylonjs/Offline/database";
  65491. export * from "babylonjs/Offline/IOfflineProvider";
  65492. }
  65493. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65494. /** @hidden */
  65495. export var gpuUpdateParticlesPixelShader: {
  65496. name: string;
  65497. shader: string;
  65498. };
  65499. }
  65500. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65501. /** @hidden */
  65502. export var gpuUpdateParticlesVertexShader: {
  65503. name: string;
  65504. shader: string;
  65505. };
  65506. }
  65507. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65508. /** @hidden */
  65509. export var clipPlaneFragmentDeclaration2: {
  65510. name: string;
  65511. shader: string;
  65512. };
  65513. }
  65514. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65515. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65516. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65517. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65520. /** @hidden */
  65521. export var gpuRenderParticlesPixelShader: {
  65522. name: string;
  65523. shader: string;
  65524. };
  65525. }
  65526. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65527. /** @hidden */
  65528. export var clipPlaneVertexDeclaration2: {
  65529. name: string;
  65530. shader: string;
  65531. };
  65532. }
  65533. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65535. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65536. /** @hidden */
  65537. export var gpuRenderParticlesVertexShader: {
  65538. name: string;
  65539. shader: string;
  65540. };
  65541. }
  65542. declare module "babylonjs/Particles/gpuParticleSystem" {
  65543. import { Nullable } from "babylonjs/types";
  65544. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65545. import { Observable } from "babylonjs/Misc/observable";
  65546. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65547. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65548. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65549. import { Scene, IDisposable } from "babylonjs/scene";
  65550. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65551. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65552. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65553. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65554. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65555. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65556. /**
  65557. * This represents a GPU particle system in Babylon
  65558. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65559. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65560. */
  65561. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65562. /**
  65563. * The layer mask we are rendering the particles through.
  65564. */
  65565. layerMask: number;
  65566. private _capacity;
  65567. private _activeCount;
  65568. private _currentActiveCount;
  65569. private _accumulatedCount;
  65570. private _renderEffect;
  65571. private _updateEffect;
  65572. private _buffer0;
  65573. private _buffer1;
  65574. private _spriteBuffer;
  65575. private _updateVAO;
  65576. private _renderVAO;
  65577. private _targetIndex;
  65578. private _sourceBuffer;
  65579. private _targetBuffer;
  65580. private _engine;
  65581. private _currentRenderId;
  65582. private _started;
  65583. private _stopped;
  65584. private _timeDelta;
  65585. private _randomTexture;
  65586. private _randomTexture2;
  65587. private _attributesStrideSize;
  65588. private _updateEffectOptions;
  65589. private _randomTextureSize;
  65590. private _actualFrame;
  65591. private readonly _rawTextureWidth;
  65592. /**
  65593. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65594. */
  65595. static get IsSupported(): boolean;
  65596. /**
  65597. * An event triggered when the system is disposed.
  65598. */
  65599. onDisposeObservable: Observable<GPUParticleSystem>;
  65600. /**
  65601. * Gets the maximum number of particles active at the same time.
  65602. * @returns The max number of active particles.
  65603. */
  65604. getCapacity(): number;
  65605. /**
  65606. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65607. * to override the particles.
  65608. */
  65609. forceDepthWrite: boolean;
  65610. /**
  65611. * Gets or set the number of active particles
  65612. */
  65613. get activeParticleCount(): number;
  65614. set activeParticleCount(value: number);
  65615. private _preWarmDone;
  65616. /**
  65617. * Is this system ready to be used/rendered
  65618. * @return true if the system is ready
  65619. */
  65620. isReady(): boolean;
  65621. /**
  65622. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65623. * @returns True if it has been started, otherwise false.
  65624. */
  65625. isStarted(): boolean;
  65626. /**
  65627. * Starts the particle system and begins to emit
  65628. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65629. */
  65630. start(delay?: number): void;
  65631. /**
  65632. * Stops the particle system.
  65633. */
  65634. stop(): void;
  65635. /**
  65636. * Remove all active particles
  65637. */
  65638. reset(): void;
  65639. /**
  65640. * Returns the string "GPUParticleSystem"
  65641. * @returns a string containing the class name
  65642. */
  65643. getClassName(): string;
  65644. private _colorGradientsTexture;
  65645. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65646. /**
  65647. * Adds a new color gradient
  65648. * @param gradient defines the gradient to use (between 0 and 1)
  65649. * @param color1 defines the color to affect to the specified gradient
  65650. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65651. * @returns the current particle system
  65652. */
  65653. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65654. /**
  65655. * Remove a specific color gradient
  65656. * @param gradient defines the gradient to remove
  65657. * @returns the current particle system
  65658. */
  65659. removeColorGradient(gradient: number): GPUParticleSystem;
  65660. private _angularSpeedGradientsTexture;
  65661. private _sizeGradientsTexture;
  65662. private _velocityGradientsTexture;
  65663. private _limitVelocityGradientsTexture;
  65664. private _dragGradientsTexture;
  65665. private _addFactorGradient;
  65666. /**
  65667. * Adds a new size gradient
  65668. * @param gradient defines the gradient to use (between 0 and 1)
  65669. * @param factor defines the size factor to affect to the specified gradient
  65670. * @returns the current particle system
  65671. */
  65672. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65673. /**
  65674. * Remove a specific size gradient
  65675. * @param gradient defines the gradient to remove
  65676. * @returns the current particle system
  65677. */
  65678. removeSizeGradient(gradient: number): GPUParticleSystem;
  65679. /**
  65680. * Adds a new angular speed gradient
  65681. * @param gradient defines the gradient to use (between 0 and 1)
  65682. * @param factor defines the angular speed to affect to the specified gradient
  65683. * @returns the current particle system
  65684. */
  65685. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65686. /**
  65687. * Remove a specific angular speed gradient
  65688. * @param gradient defines the gradient to remove
  65689. * @returns the current particle system
  65690. */
  65691. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65692. /**
  65693. * Adds a new velocity gradient
  65694. * @param gradient defines the gradient to use (between 0 and 1)
  65695. * @param factor defines the velocity to affect to the specified gradient
  65696. * @returns the current particle system
  65697. */
  65698. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65699. /**
  65700. * Remove a specific velocity gradient
  65701. * @param gradient defines the gradient to remove
  65702. * @returns the current particle system
  65703. */
  65704. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65705. /**
  65706. * Adds a new limit velocity gradient
  65707. * @param gradient defines the gradient to use (between 0 and 1)
  65708. * @param factor defines the limit velocity value to affect to the specified gradient
  65709. * @returns the current particle system
  65710. */
  65711. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65712. /**
  65713. * Remove a specific limit velocity gradient
  65714. * @param gradient defines the gradient to remove
  65715. * @returns the current particle system
  65716. */
  65717. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65718. /**
  65719. * Adds a new drag gradient
  65720. * @param gradient defines the gradient to use (between 0 and 1)
  65721. * @param factor defines the drag value to affect to the specified gradient
  65722. * @returns the current particle system
  65723. */
  65724. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65725. /**
  65726. * Remove a specific drag gradient
  65727. * @param gradient defines the gradient to remove
  65728. * @returns the current particle system
  65729. */
  65730. removeDragGradient(gradient: number): GPUParticleSystem;
  65731. /**
  65732. * Not supported by GPUParticleSystem
  65733. * @param gradient defines the gradient to use (between 0 and 1)
  65734. * @param factor defines the emit rate value to affect to the specified gradient
  65735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65736. * @returns the current particle system
  65737. */
  65738. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65739. /**
  65740. * Not supported by GPUParticleSystem
  65741. * @param gradient defines the gradient to remove
  65742. * @returns the current particle system
  65743. */
  65744. removeEmitRateGradient(gradient: number): IParticleSystem;
  65745. /**
  65746. * Not supported by GPUParticleSystem
  65747. * @param gradient defines the gradient to use (between 0 and 1)
  65748. * @param factor defines the start size value to affect to the specified gradient
  65749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65750. * @returns the current particle system
  65751. */
  65752. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65753. /**
  65754. * Not supported by GPUParticleSystem
  65755. * @param gradient defines the gradient to remove
  65756. * @returns the current particle system
  65757. */
  65758. removeStartSizeGradient(gradient: number): IParticleSystem;
  65759. /**
  65760. * Not supported by GPUParticleSystem
  65761. * @param gradient defines the gradient to use (between 0 and 1)
  65762. * @param min defines the color remap minimal range
  65763. * @param max defines the color remap maximal range
  65764. * @returns the current particle system
  65765. */
  65766. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65767. /**
  65768. * Not supported by GPUParticleSystem
  65769. * @param gradient defines the gradient to remove
  65770. * @returns the current particle system
  65771. */
  65772. removeColorRemapGradient(): IParticleSystem;
  65773. /**
  65774. * Not supported by GPUParticleSystem
  65775. * @param gradient defines the gradient to use (between 0 and 1)
  65776. * @param min defines the alpha remap minimal range
  65777. * @param max defines the alpha remap maximal range
  65778. * @returns the current particle system
  65779. */
  65780. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65781. /**
  65782. * Not supported by GPUParticleSystem
  65783. * @param gradient defines the gradient to remove
  65784. * @returns the current particle system
  65785. */
  65786. removeAlphaRemapGradient(): IParticleSystem;
  65787. /**
  65788. * Not supported by GPUParticleSystem
  65789. * @param gradient defines the gradient to use (between 0 and 1)
  65790. * @param color defines the color to affect to the specified gradient
  65791. * @returns the current particle system
  65792. */
  65793. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65794. /**
  65795. * Not supported by GPUParticleSystem
  65796. * @param gradient defines the gradient to remove
  65797. * @returns the current particle system
  65798. */
  65799. removeRampGradient(): IParticleSystem;
  65800. /**
  65801. * Not supported by GPUParticleSystem
  65802. * @returns the list of ramp gradients
  65803. */
  65804. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65805. /**
  65806. * Not supported by GPUParticleSystem
  65807. * Gets or sets a boolean indicating that ramp gradients must be used
  65808. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65809. */
  65810. get useRampGradients(): boolean;
  65811. set useRampGradients(value: boolean);
  65812. /**
  65813. * Not supported by GPUParticleSystem
  65814. * @param gradient defines the gradient to use (between 0 and 1)
  65815. * @param factor defines the life time factor to affect to the specified gradient
  65816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65817. * @returns the current particle system
  65818. */
  65819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65820. /**
  65821. * Not supported by GPUParticleSystem
  65822. * @param gradient defines the gradient to remove
  65823. * @returns the current particle system
  65824. */
  65825. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65826. /**
  65827. * Instantiates a GPU particle system.
  65828. * 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.
  65829. * @param name The name of the particle system
  65830. * @param options The options used to create the system
  65831. * @param scene The scene the particle system belongs to
  65832. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65833. */
  65834. constructor(name: string, options: Partial<{
  65835. capacity: number;
  65836. randomTextureSize: number;
  65837. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65838. protected _reset(): void;
  65839. private _createUpdateVAO;
  65840. private _createRenderVAO;
  65841. private _initialize;
  65842. /** @hidden */
  65843. _recreateUpdateEffect(): void;
  65844. /** @hidden */
  65845. _recreateRenderEffect(): void;
  65846. /**
  65847. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65848. * @param preWarm defines if we are in the pre-warmimg phase
  65849. */
  65850. animate(preWarm?: boolean): void;
  65851. private _createFactorGradientTexture;
  65852. private _createSizeGradientTexture;
  65853. private _createAngularSpeedGradientTexture;
  65854. private _createVelocityGradientTexture;
  65855. private _createLimitVelocityGradientTexture;
  65856. private _createDragGradientTexture;
  65857. private _createColorGradientTexture;
  65858. /**
  65859. * Renders the particle system in its current state
  65860. * @param preWarm defines if the system should only update the particles but not render them
  65861. * @returns the current number of particles
  65862. */
  65863. render(preWarm?: boolean): number;
  65864. /**
  65865. * Rebuilds the particle system
  65866. */
  65867. rebuild(): void;
  65868. private _releaseBuffers;
  65869. private _releaseVAOs;
  65870. /**
  65871. * Disposes the particle system and free the associated resources
  65872. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65873. */
  65874. dispose(disposeTexture?: boolean): void;
  65875. /**
  65876. * Clones the particle system.
  65877. * @param name The name of the cloned object
  65878. * @param newEmitter The new emitter to use
  65879. * @returns the cloned particle system
  65880. */
  65881. clone(name: string, newEmitter: any): GPUParticleSystem;
  65882. /**
  65883. * Serializes the particle system to a JSON object.
  65884. * @returns the JSON object
  65885. */
  65886. serialize(): any;
  65887. /**
  65888. * Parses a JSON object to create a GPU particle system.
  65889. * @param parsedParticleSystem The JSON object to parse
  65890. * @param scene The scene to create the particle system in
  65891. * @param rootUrl The root url to use to load external dependencies like texture
  65892. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65893. * @returns the parsed GPU particle system
  65894. */
  65895. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65896. }
  65897. }
  65898. declare module "babylonjs/Particles/particleSystemSet" {
  65899. import { Nullable } from "babylonjs/types";
  65900. import { Color3 } from "babylonjs/Maths/math.color";
  65901. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65903. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65904. import { Scene, IDisposable } from "babylonjs/scene";
  65905. /**
  65906. * Represents a set of particle systems working together to create a specific effect
  65907. */
  65908. export class ParticleSystemSet implements IDisposable {
  65909. /**
  65910. * Gets or sets base Assets URL
  65911. */
  65912. static BaseAssetsUrl: string;
  65913. private _emitterCreationOptions;
  65914. private _emitterNode;
  65915. /**
  65916. * Gets the particle system list
  65917. */
  65918. systems: IParticleSystem[];
  65919. /**
  65920. * Gets the emitter node used with this set
  65921. */
  65922. get emitterNode(): Nullable<TransformNode>;
  65923. /**
  65924. * Creates a new emitter mesh as a sphere
  65925. * @param options defines the options used to create the sphere
  65926. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65927. * @param scene defines the hosting scene
  65928. */
  65929. setEmitterAsSphere(options: {
  65930. diameter: number;
  65931. segments: number;
  65932. color: Color3;
  65933. }, renderingGroupId: number, scene: Scene): void;
  65934. /**
  65935. * Starts all particle systems of the set
  65936. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65937. */
  65938. start(emitter?: AbstractMesh): void;
  65939. /**
  65940. * Release all associated resources
  65941. */
  65942. dispose(): void;
  65943. /**
  65944. * Serialize the set into a JSON compatible object
  65945. * @returns a JSON compatible representation of the set
  65946. */
  65947. serialize(): any;
  65948. /**
  65949. * Parse a new ParticleSystemSet from a serialized source
  65950. * @param data defines a JSON compatible representation of the set
  65951. * @param scene defines the hosting scene
  65952. * @param gpu defines if we want GPU particles or CPU particles
  65953. * @returns a new ParticleSystemSet
  65954. */
  65955. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65956. }
  65957. }
  65958. declare module "babylonjs/Particles/particleHelper" {
  65959. import { Nullable } from "babylonjs/types";
  65960. import { Scene } from "babylonjs/scene";
  65961. import { Vector3 } from "babylonjs/Maths/math.vector";
  65962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65963. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65964. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65965. /**
  65966. * This class is made for on one-liner static method to help creating particle system set.
  65967. */
  65968. export class ParticleHelper {
  65969. /**
  65970. * Gets or sets base Assets URL
  65971. */
  65972. static BaseAssetsUrl: string;
  65973. /**
  65974. * Create a default particle system that you can tweak
  65975. * @param emitter defines the emitter to use
  65976. * @param capacity defines the system capacity (default is 500 particles)
  65977. * @param scene defines the hosting scene
  65978. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65979. * @returns the new Particle system
  65980. */
  65981. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65982. /**
  65983. * This is the main static method (one-liner) of this helper to create different particle systems
  65984. * @param type This string represents the type to the particle system to create
  65985. * @param scene The scene where the particle system should live
  65986. * @param gpu If the system will use gpu
  65987. * @returns the ParticleSystemSet created
  65988. */
  65989. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65990. /**
  65991. * Static function used to export a particle system to a ParticleSystemSet variable.
  65992. * Please note that the emitter shape is not exported
  65993. * @param systems defines the particle systems to export
  65994. * @returns the created particle system set
  65995. */
  65996. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65997. }
  65998. }
  65999. declare module "babylonjs/Particles/particleSystemComponent" {
  66000. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66001. import { Effect } from "babylonjs/Materials/effect";
  66002. import "babylonjs/Shaders/particles.vertex";
  66003. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66004. module "babylonjs/Engines/engine" {
  66005. interface Engine {
  66006. /**
  66007. * Create an effect to use with particle systems.
  66008. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66009. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66010. * @param uniformsNames defines a list of attribute names
  66011. * @param samplers defines an array of string used to represent textures
  66012. * @param defines defines the string containing the defines to use to compile the shaders
  66013. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66014. * @param onCompiled defines a function to call when the effect creation is successful
  66015. * @param onError defines a function to call when the effect creation has failed
  66016. * @returns the new Effect
  66017. */
  66018. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66019. }
  66020. }
  66021. module "babylonjs/Meshes/mesh" {
  66022. interface Mesh {
  66023. /**
  66024. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66025. * @returns an array of IParticleSystem
  66026. */
  66027. getEmittedParticleSystems(): IParticleSystem[];
  66028. /**
  66029. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66030. * @returns an array of IParticleSystem
  66031. */
  66032. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66033. }
  66034. }
  66035. /**
  66036. * @hidden
  66037. */
  66038. export var _IDoNeedToBeInTheBuild: number;
  66039. }
  66040. declare module "babylonjs/Particles/pointsCloudSystem" {
  66041. import { Color4 } from "babylonjs/Maths/math";
  66042. import { Mesh } from "babylonjs/Meshes/mesh";
  66043. import { Scene, IDisposable } from "babylonjs/scene";
  66044. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66045. /** Defines the 4 color options */
  66046. export enum PointColor {
  66047. /** color value */
  66048. Color = 2,
  66049. /** uv value */
  66050. UV = 1,
  66051. /** random value */
  66052. Random = 0,
  66053. /** stated value */
  66054. Stated = 3
  66055. }
  66056. /**
  66057. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66058. * 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.
  66059. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66060. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66061. *
  66062. * Full documentation here : TO BE ENTERED
  66063. */
  66064. export class PointsCloudSystem implements IDisposable {
  66065. /**
  66066. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66067. * Example : var p = SPS.particles[i];
  66068. */
  66069. particles: CloudPoint[];
  66070. /**
  66071. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66072. */
  66073. nbParticles: number;
  66074. /**
  66075. * This a counter for your own usage. It's not set by any SPS functions.
  66076. */
  66077. counter: number;
  66078. /**
  66079. * The PCS name. This name is also given to the underlying mesh.
  66080. */
  66081. name: string;
  66082. /**
  66083. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66084. */
  66085. mesh: Mesh;
  66086. /**
  66087. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66088. * Please read :
  66089. */
  66090. vars: any;
  66091. /**
  66092. * @hidden
  66093. */
  66094. _size: number;
  66095. private _scene;
  66096. private _promises;
  66097. private _positions;
  66098. private _indices;
  66099. private _normals;
  66100. private _colors;
  66101. private _uvs;
  66102. private _indices32;
  66103. private _positions32;
  66104. private _colors32;
  66105. private _uvs32;
  66106. private _updatable;
  66107. private _isVisibilityBoxLocked;
  66108. private _alwaysVisible;
  66109. private _groups;
  66110. private _groupCounter;
  66111. private _computeParticleColor;
  66112. private _computeParticleTexture;
  66113. private _computeParticleRotation;
  66114. private _computeBoundingBox;
  66115. private _isReady;
  66116. /**
  66117. * Creates a PCS (Points Cloud System) object
  66118. * @param name (String) is the PCS name, this will be the underlying mesh name
  66119. * @param pointSize (number) is the size for each point
  66120. * @param scene (Scene) is the scene in which the PCS is added
  66121. * @param options defines the options of the PCS e.g.
  66122. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66123. */
  66124. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66125. updatable?: boolean;
  66126. });
  66127. /**
  66128. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66129. * If no points were added to the PCS, the returned mesh is just a single point.
  66130. * @returns a promise for the created mesh
  66131. */
  66132. buildMeshAsync(): Promise<Mesh>;
  66133. /**
  66134. * @hidden
  66135. */
  66136. private _buildMesh;
  66137. private _addParticle;
  66138. private _randomUnitVector;
  66139. private _getColorIndicesForCoord;
  66140. private _setPointsColorOrUV;
  66141. private _colorFromTexture;
  66142. private _calculateDensity;
  66143. /**
  66144. * Adds points to the PCS in random positions within a unit sphere
  66145. * @param nb (positive integer) the number of particles to be created from this model
  66146. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66147. * @returns the number of groups in the system
  66148. */
  66149. addPoints(nb: number, pointFunction?: any): number;
  66150. /**
  66151. * Adds points to the PCS from the surface of the model shape
  66152. * @param mesh is any Mesh object that will be used as a surface model for the points
  66153. * @param nb (positive integer) the number of particles to be created from this model
  66154. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66155. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66156. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66157. * @returns the number of groups in the system
  66158. */
  66159. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66160. /**
  66161. * Adds points to the PCS inside the model shape
  66162. * @param mesh is any Mesh object that will be used as a surface model for the points
  66163. * @param nb (positive integer) the number of particles to be created from this model
  66164. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66165. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66166. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66167. * @returns the number of groups in the system
  66168. */
  66169. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66170. /**
  66171. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66172. * This method calls `updateParticle()` for each particle of the SPS.
  66173. * For an animated SPS, it is usually called within the render loop.
  66174. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66175. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66176. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66177. * @returns the PCS.
  66178. */
  66179. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66180. /**
  66181. * Disposes the PCS.
  66182. */
  66183. dispose(): void;
  66184. /**
  66185. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66186. * doc :
  66187. * @returns the PCS.
  66188. */
  66189. refreshVisibleSize(): PointsCloudSystem;
  66190. /**
  66191. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66192. * @param size the size (float) of the visibility box
  66193. * note : this doesn't lock the PCS mesh bounding box.
  66194. * doc :
  66195. */
  66196. setVisibilityBox(size: number): void;
  66197. /**
  66198. * Gets whether the PCS is always visible or not
  66199. * doc :
  66200. */
  66201. get isAlwaysVisible(): boolean;
  66202. /**
  66203. * Sets the PCS as always visible or not
  66204. * doc :
  66205. */
  66206. set isAlwaysVisible(val: boolean);
  66207. /**
  66208. * Tells to `setParticles()` to compute the particle rotations or not
  66209. * Default value : false. The PCS is faster when it's set to false
  66210. * Note : particle rotations are only applied to parent particles
  66211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66212. */
  66213. set computeParticleRotation(val: boolean);
  66214. /**
  66215. * Tells to `setParticles()` to compute the particle colors or not.
  66216. * Default value : true. The PCS is faster when it's set to false.
  66217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66218. */
  66219. set computeParticleColor(val: boolean);
  66220. set computeParticleTexture(val: boolean);
  66221. /**
  66222. * Gets if `setParticles()` computes the particle colors or not.
  66223. * Default value : false. The PCS is faster when it's set to false.
  66224. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66225. */
  66226. get computeParticleColor(): boolean;
  66227. /**
  66228. * Gets if `setParticles()` computes the particle textures or not.
  66229. * Default value : false. The PCS is faster when it's set to false.
  66230. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66231. */
  66232. get computeParticleTexture(): boolean;
  66233. /**
  66234. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66235. */
  66236. set computeBoundingBox(val: boolean);
  66237. /**
  66238. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66239. */
  66240. get computeBoundingBox(): boolean;
  66241. /**
  66242. * This function does nothing. It may be overwritten to set all the particle first values.
  66243. * The PCS doesn't call this function, you may have to call it by your own.
  66244. * doc :
  66245. */
  66246. initParticles(): void;
  66247. /**
  66248. * This function does nothing. It may be overwritten to recycle a particle
  66249. * The PCS doesn't call this function, you can to call it
  66250. * doc :
  66251. * @param particle The particle to recycle
  66252. * @returns the recycled particle
  66253. */
  66254. recycleParticle(particle: CloudPoint): CloudPoint;
  66255. /**
  66256. * Updates a particle : this function should be overwritten by the user.
  66257. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66258. * doc :
  66259. * @example : just set a particle position or velocity and recycle conditions
  66260. * @param particle The particle to update
  66261. * @returns the updated particle
  66262. */
  66263. updateParticle(particle: CloudPoint): CloudPoint;
  66264. /**
  66265. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66266. * This does nothing and may be overwritten by the user.
  66267. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66268. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66269. * @param update the boolean update value actually passed to setParticles()
  66270. */
  66271. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66272. /**
  66273. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66274. * This will be passed three parameters.
  66275. * This does nothing and may be overwritten by the user.
  66276. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66277. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66278. * @param update the boolean update value actually passed to setParticles()
  66279. */
  66280. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66281. }
  66282. }
  66283. declare module "babylonjs/Particles/cloudPoint" {
  66284. import { Nullable } from "babylonjs/types";
  66285. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66286. import { Mesh } from "babylonjs/Meshes/mesh";
  66287. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66288. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66289. /**
  66290. * Represents one particle of a points cloud system.
  66291. */
  66292. export class CloudPoint {
  66293. /**
  66294. * particle global index
  66295. */
  66296. idx: number;
  66297. /**
  66298. * The color of the particle
  66299. */
  66300. color: Nullable<Color4>;
  66301. /**
  66302. * The world space position of the particle.
  66303. */
  66304. position: Vector3;
  66305. /**
  66306. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66307. */
  66308. rotation: Vector3;
  66309. /**
  66310. * The world space rotation quaternion of the particle.
  66311. */
  66312. rotationQuaternion: Nullable<Quaternion>;
  66313. /**
  66314. * The uv of the particle.
  66315. */
  66316. uv: Nullable<Vector2>;
  66317. /**
  66318. * The current speed of the particle.
  66319. */
  66320. velocity: Vector3;
  66321. /**
  66322. * The pivot point in the particle local space.
  66323. */
  66324. pivot: Vector3;
  66325. /**
  66326. * Must the particle be translated from its pivot point in its local space ?
  66327. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66328. * Default : false
  66329. */
  66330. translateFromPivot: boolean;
  66331. /**
  66332. * Index of this particle in the global "positions" array (Internal use)
  66333. * @hidden
  66334. */
  66335. _pos: number;
  66336. /**
  66337. * @hidden Index of this particle in the global "indices" array (Internal use)
  66338. */
  66339. _ind: number;
  66340. /**
  66341. * Group this particle belongs to
  66342. */
  66343. _group: PointsGroup;
  66344. /**
  66345. * Group id of this particle
  66346. */
  66347. groupId: number;
  66348. /**
  66349. * Index of the particle in its group id (Internal use)
  66350. */
  66351. idxInGroup: number;
  66352. /**
  66353. * @hidden Particle BoundingInfo object (Internal use)
  66354. */
  66355. _boundingInfo: BoundingInfo;
  66356. /**
  66357. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66358. */
  66359. _pcs: PointsCloudSystem;
  66360. /**
  66361. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66362. */
  66363. _stillInvisible: boolean;
  66364. /**
  66365. * @hidden Last computed particle rotation matrix
  66366. */
  66367. _rotationMatrix: number[];
  66368. /**
  66369. * Parent particle Id, if any.
  66370. * Default null.
  66371. */
  66372. parentId: Nullable<number>;
  66373. /**
  66374. * @hidden Internal global position in the PCS.
  66375. */
  66376. _globalPosition: Vector3;
  66377. /**
  66378. * Creates a Point Cloud object.
  66379. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66380. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66381. * @param group (PointsGroup) is the group the particle belongs to
  66382. * @param groupId (integer) is the group identifier in the PCS.
  66383. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66384. * @param pcs defines the PCS it is associated to
  66385. */
  66386. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66387. /**
  66388. * get point size
  66389. */
  66390. get size(): Vector3;
  66391. /**
  66392. * Set point size
  66393. */
  66394. set size(scale: Vector3);
  66395. /**
  66396. * Legacy support, changed quaternion to rotationQuaternion
  66397. */
  66398. get quaternion(): Nullable<Quaternion>;
  66399. /**
  66400. * Legacy support, changed quaternion to rotationQuaternion
  66401. */
  66402. set quaternion(q: Nullable<Quaternion>);
  66403. /**
  66404. * Returns a boolean. True if the particle intersects a mesh, else false
  66405. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66406. * @param target is the object (point or mesh) what the intersection is computed against
  66407. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66408. * @returns true if it intersects
  66409. */
  66410. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66411. /**
  66412. * get the rotation matrix of the particle
  66413. * @hidden
  66414. */
  66415. getRotationMatrix(m: Matrix): void;
  66416. }
  66417. /**
  66418. * Represents a group of points in a points cloud system
  66419. * * PCS internal tool, don't use it manually.
  66420. */
  66421. export class PointsGroup {
  66422. /**
  66423. * The group id
  66424. * @hidden
  66425. */
  66426. groupID: number;
  66427. /**
  66428. * image data for group (internal use)
  66429. * @hidden
  66430. */
  66431. _groupImageData: Nullable<ArrayBufferView>;
  66432. /**
  66433. * Image Width (internal use)
  66434. * @hidden
  66435. */
  66436. _groupImgWidth: number;
  66437. /**
  66438. * Image Height (internal use)
  66439. * @hidden
  66440. */
  66441. _groupImgHeight: number;
  66442. /**
  66443. * Custom position function (internal use)
  66444. * @hidden
  66445. */
  66446. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66447. /**
  66448. * density per facet for surface points
  66449. * @hidden
  66450. */
  66451. _groupDensity: number[];
  66452. /**
  66453. * Only when points are colored by texture carries pointer to texture list array
  66454. * @hidden
  66455. */
  66456. _textureNb: number;
  66457. /**
  66458. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66459. * PCS internal tool, don't use it manually.
  66460. * @hidden
  66461. */
  66462. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66463. }
  66464. }
  66465. declare module "babylonjs/Particles/index" {
  66466. export * from "babylonjs/Particles/baseParticleSystem";
  66467. export * from "babylonjs/Particles/EmitterTypes/index";
  66468. export * from "babylonjs/Particles/gpuParticleSystem";
  66469. export * from "babylonjs/Particles/IParticleSystem";
  66470. export * from "babylonjs/Particles/particle";
  66471. export * from "babylonjs/Particles/particleHelper";
  66472. export * from "babylonjs/Particles/particleSystem";
  66473. export * from "babylonjs/Particles/particleSystemComponent";
  66474. export * from "babylonjs/Particles/particleSystemSet";
  66475. export * from "babylonjs/Particles/solidParticle";
  66476. export * from "babylonjs/Particles/solidParticleSystem";
  66477. export * from "babylonjs/Particles/cloudPoint";
  66478. export * from "babylonjs/Particles/pointsCloudSystem";
  66479. export * from "babylonjs/Particles/subEmitter";
  66480. }
  66481. declare module "babylonjs/Physics/physicsEngineComponent" {
  66482. import { Nullable } from "babylonjs/types";
  66483. import { Observable, Observer } from "babylonjs/Misc/observable";
  66484. import { Vector3 } from "babylonjs/Maths/math.vector";
  66485. import { Mesh } from "babylonjs/Meshes/mesh";
  66486. import { ISceneComponent } from "babylonjs/sceneComponent";
  66487. import { Scene } from "babylonjs/scene";
  66488. import { Node } from "babylonjs/node";
  66489. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66490. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66491. module "babylonjs/scene" {
  66492. interface Scene {
  66493. /** @hidden (Backing field) */
  66494. _physicsEngine: Nullable<IPhysicsEngine>;
  66495. /** @hidden */
  66496. _physicsTimeAccumulator: number;
  66497. /**
  66498. * Gets the current physics engine
  66499. * @returns a IPhysicsEngine or null if none attached
  66500. */
  66501. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66502. /**
  66503. * Enables physics to the current scene
  66504. * @param gravity defines the scene's gravity for the physics engine
  66505. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66506. * @return a boolean indicating if the physics engine was initialized
  66507. */
  66508. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66509. /**
  66510. * Disables and disposes the physics engine associated with the scene
  66511. */
  66512. disablePhysicsEngine(): void;
  66513. /**
  66514. * Gets a boolean indicating if there is an active physics engine
  66515. * @returns a boolean indicating if there is an active physics engine
  66516. */
  66517. isPhysicsEnabled(): boolean;
  66518. /**
  66519. * Deletes a physics compound impostor
  66520. * @param compound defines the compound to delete
  66521. */
  66522. deleteCompoundImpostor(compound: any): void;
  66523. /**
  66524. * An event triggered when physic simulation is about to be run
  66525. */
  66526. onBeforePhysicsObservable: Observable<Scene>;
  66527. /**
  66528. * An event triggered when physic simulation has been done
  66529. */
  66530. onAfterPhysicsObservable: Observable<Scene>;
  66531. }
  66532. }
  66533. module "babylonjs/Meshes/abstractMesh" {
  66534. interface AbstractMesh {
  66535. /** @hidden */
  66536. _physicsImpostor: Nullable<PhysicsImpostor>;
  66537. /**
  66538. * Gets or sets impostor used for physic simulation
  66539. * @see http://doc.babylonjs.com/features/physics_engine
  66540. */
  66541. physicsImpostor: Nullable<PhysicsImpostor>;
  66542. /**
  66543. * Gets the current physics impostor
  66544. * @see http://doc.babylonjs.com/features/physics_engine
  66545. * @returns a physics impostor or null
  66546. */
  66547. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66548. /** Apply a physic impulse to the mesh
  66549. * @param force defines the force to apply
  66550. * @param contactPoint defines where to apply the force
  66551. * @returns the current mesh
  66552. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66553. */
  66554. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66555. /**
  66556. * Creates a physic joint between two meshes
  66557. * @param otherMesh defines the other mesh to use
  66558. * @param pivot1 defines the pivot to use on this mesh
  66559. * @param pivot2 defines the pivot to use on the other mesh
  66560. * @param options defines additional options (can be plugin dependent)
  66561. * @returns the current mesh
  66562. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66563. */
  66564. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66565. /** @hidden */
  66566. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66567. }
  66568. }
  66569. /**
  66570. * Defines the physics engine scene component responsible to manage a physics engine
  66571. */
  66572. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66573. /**
  66574. * The component name helpful to identify the component in the list of scene components.
  66575. */
  66576. readonly name: string;
  66577. /**
  66578. * The scene the component belongs to.
  66579. */
  66580. scene: Scene;
  66581. /**
  66582. * Creates a new instance of the component for the given scene
  66583. * @param scene Defines the scene to register the component in
  66584. */
  66585. constructor(scene: Scene);
  66586. /**
  66587. * Registers the component in a given scene
  66588. */
  66589. register(): void;
  66590. /**
  66591. * Rebuilds the elements related to this component in case of
  66592. * context lost for instance.
  66593. */
  66594. rebuild(): void;
  66595. /**
  66596. * Disposes the component and the associated ressources
  66597. */
  66598. dispose(): void;
  66599. }
  66600. }
  66601. declare module "babylonjs/Physics/physicsHelper" {
  66602. import { Nullable } from "babylonjs/types";
  66603. import { Vector3 } from "babylonjs/Maths/math.vector";
  66604. import { Mesh } from "babylonjs/Meshes/mesh";
  66605. import { Scene } from "babylonjs/scene";
  66606. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66607. /**
  66608. * A helper for physics simulations
  66609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66610. */
  66611. export class PhysicsHelper {
  66612. private _scene;
  66613. private _physicsEngine;
  66614. /**
  66615. * Initializes the Physics helper
  66616. * @param scene Babylon.js scene
  66617. */
  66618. constructor(scene: Scene);
  66619. /**
  66620. * Applies a radial explosion impulse
  66621. * @param origin the origin of the explosion
  66622. * @param radiusOrEventOptions the radius or the options of radial explosion
  66623. * @param strength the explosion strength
  66624. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66625. * @returns A physics radial explosion event, or null
  66626. */
  66627. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66628. /**
  66629. * Applies a radial explosion force
  66630. * @param origin the origin of the explosion
  66631. * @param radiusOrEventOptions the radius or the options of radial explosion
  66632. * @param strength the explosion strength
  66633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66634. * @returns A physics radial explosion event, or null
  66635. */
  66636. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66637. /**
  66638. * Creates a gravitational field
  66639. * @param origin the origin of the explosion
  66640. * @param radiusOrEventOptions the radius or the options of radial explosion
  66641. * @param strength the explosion strength
  66642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66643. * @returns A physics gravitational field event, or null
  66644. */
  66645. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66646. /**
  66647. * Creates a physics updraft event
  66648. * @param origin the origin of the updraft
  66649. * @param radiusOrEventOptions the radius or the options of the updraft
  66650. * @param strength the strength of the updraft
  66651. * @param height the height of the updraft
  66652. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66653. * @returns A physics updraft event, or null
  66654. */
  66655. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66656. /**
  66657. * Creates a physics vortex event
  66658. * @param origin the of the vortex
  66659. * @param radiusOrEventOptions the radius or the options of the vortex
  66660. * @param strength the strength of the vortex
  66661. * @param height the height of the vortex
  66662. * @returns a Physics vortex event, or null
  66663. * A physics vortex event or null
  66664. */
  66665. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66666. }
  66667. /**
  66668. * Represents a physics radial explosion event
  66669. */
  66670. class PhysicsRadialExplosionEvent {
  66671. private _scene;
  66672. private _options;
  66673. private _sphere;
  66674. private _dataFetched;
  66675. /**
  66676. * Initializes a radial explosioin event
  66677. * @param _scene BabylonJS scene
  66678. * @param _options The options for the vortex event
  66679. */
  66680. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66681. /**
  66682. * Returns the data related to the radial explosion event (sphere).
  66683. * @returns The radial explosion event data
  66684. */
  66685. getData(): PhysicsRadialExplosionEventData;
  66686. /**
  66687. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66688. * @param impostor A physics imposter
  66689. * @param origin the origin of the explosion
  66690. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66691. */
  66692. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66693. /**
  66694. * Triggers affecterd impostors callbacks
  66695. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66696. */
  66697. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66698. /**
  66699. * Disposes the sphere.
  66700. * @param force Specifies if the sphere should be disposed by force
  66701. */
  66702. dispose(force?: boolean): void;
  66703. /*** Helpers ***/
  66704. private _prepareSphere;
  66705. private _intersectsWithSphere;
  66706. }
  66707. /**
  66708. * Represents a gravitational field event
  66709. */
  66710. class PhysicsGravitationalFieldEvent {
  66711. private _physicsHelper;
  66712. private _scene;
  66713. private _origin;
  66714. private _options;
  66715. private _tickCallback;
  66716. private _sphere;
  66717. private _dataFetched;
  66718. /**
  66719. * Initializes the physics gravitational field event
  66720. * @param _physicsHelper A physics helper
  66721. * @param _scene BabylonJS scene
  66722. * @param _origin The origin position of the gravitational field event
  66723. * @param _options The options for the vortex event
  66724. */
  66725. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66726. /**
  66727. * Returns the data related to the gravitational field event (sphere).
  66728. * @returns A gravitational field event
  66729. */
  66730. getData(): PhysicsGravitationalFieldEventData;
  66731. /**
  66732. * Enables the gravitational field.
  66733. */
  66734. enable(): void;
  66735. /**
  66736. * Disables the gravitational field.
  66737. */
  66738. disable(): void;
  66739. /**
  66740. * Disposes the sphere.
  66741. * @param force The force to dispose from the gravitational field event
  66742. */
  66743. dispose(force?: boolean): void;
  66744. private _tick;
  66745. }
  66746. /**
  66747. * Represents a physics updraft event
  66748. */
  66749. class PhysicsUpdraftEvent {
  66750. private _scene;
  66751. private _origin;
  66752. private _options;
  66753. private _physicsEngine;
  66754. private _originTop;
  66755. private _originDirection;
  66756. private _tickCallback;
  66757. private _cylinder;
  66758. private _cylinderPosition;
  66759. private _dataFetched;
  66760. /**
  66761. * Initializes the physics updraft event
  66762. * @param _scene BabylonJS scene
  66763. * @param _origin The origin position of the updraft
  66764. * @param _options The options for the updraft event
  66765. */
  66766. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66767. /**
  66768. * Returns the data related to the updraft event (cylinder).
  66769. * @returns A physics updraft event
  66770. */
  66771. getData(): PhysicsUpdraftEventData;
  66772. /**
  66773. * Enables the updraft.
  66774. */
  66775. enable(): void;
  66776. /**
  66777. * Disables the updraft.
  66778. */
  66779. disable(): void;
  66780. /**
  66781. * Disposes the cylinder.
  66782. * @param force Specifies if the updraft should be disposed by force
  66783. */
  66784. dispose(force?: boolean): void;
  66785. private getImpostorHitData;
  66786. private _tick;
  66787. /*** Helpers ***/
  66788. private _prepareCylinder;
  66789. private _intersectsWithCylinder;
  66790. }
  66791. /**
  66792. * Represents a physics vortex event
  66793. */
  66794. class PhysicsVortexEvent {
  66795. private _scene;
  66796. private _origin;
  66797. private _options;
  66798. private _physicsEngine;
  66799. private _originTop;
  66800. private _tickCallback;
  66801. private _cylinder;
  66802. private _cylinderPosition;
  66803. private _dataFetched;
  66804. /**
  66805. * Initializes the physics vortex event
  66806. * @param _scene The BabylonJS scene
  66807. * @param _origin The origin position of the vortex
  66808. * @param _options The options for the vortex event
  66809. */
  66810. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66811. /**
  66812. * Returns the data related to the vortex event (cylinder).
  66813. * @returns The physics vortex event data
  66814. */
  66815. getData(): PhysicsVortexEventData;
  66816. /**
  66817. * Enables the vortex.
  66818. */
  66819. enable(): void;
  66820. /**
  66821. * Disables the cortex.
  66822. */
  66823. disable(): void;
  66824. /**
  66825. * Disposes the sphere.
  66826. * @param force
  66827. */
  66828. dispose(force?: boolean): void;
  66829. private getImpostorHitData;
  66830. private _tick;
  66831. /*** Helpers ***/
  66832. private _prepareCylinder;
  66833. private _intersectsWithCylinder;
  66834. }
  66835. /**
  66836. * Options fot the radial explosion event
  66837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66838. */
  66839. export class PhysicsRadialExplosionEventOptions {
  66840. /**
  66841. * The radius of the sphere for the radial explosion.
  66842. */
  66843. radius: number;
  66844. /**
  66845. * The strenth of the explosion.
  66846. */
  66847. strength: number;
  66848. /**
  66849. * The strenght of the force in correspondence to the distance of the affected object
  66850. */
  66851. falloff: PhysicsRadialImpulseFalloff;
  66852. /**
  66853. * Sphere options for the radial explosion.
  66854. */
  66855. sphere: {
  66856. segments: number;
  66857. diameter: number;
  66858. };
  66859. /**
  66860. * Sphere options for the radial explosion.
  66861. */
  66862. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66863. }
  66864. /**
  66865. * Options fot the updraft event
  66866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66867. */
  66868. export class PhysicsUpdraftEventOptions {
  66869. /**
  66870. * The radius of the cylinder for the vortex
  66871. */
  66872. radius: number;
  66873. /**
  66874. * The strenth of the updraft.
  66875. */
  66876. strength: number;
  66877. /**
  66878. * The height of the cylinder for the updraft.
  66879. */
  66880. height: number;
  66881. /**
  66882. * The mode for the the updraft.
  66883. */
  66884. updraftMode: PhysicsUpdraftMode;
  66885. }
  66886. /**
  66887. * Options fot the vortex event
  66888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66889. */
  66890. export class PhysicsVortexEventOptions {
  66891. /**
  66892. * The radius of the cylinder for the vortex
  66893. */
  66894. radius: number;
  66895. /**
  66896. * The strenth of the vortex.
  66897. */
  66898. strength: number;
  66899. /**
  66900. * The height of the cylinder for the vortex.
  66901. */
  66902. height: number;
  66903. /**
  66904. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66905. */
  66906. centripetalForceThreshold: number;
  66907. /**
  66908. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66909. */
  66910. centripetalForceMultiplier: number;
  66911. /**
  66912. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66913. */
  66914. centrifugalForceMultiplier: number;
  66915. /**
  66916. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66917. */
  66918. updraftForceMultiplier: number;
  66919. }
  66920. /**
  66921. * The strenght of the force in correspondence to the distance of the affected object
  66922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66923. */
  66924. export enum PhysicsRadialImpulseFalloff {
  66925. /** Defines that impulse is constant in strength across it's whole radius */
  66926. Constant = 0,
  66927. /** Defines that impulse gets weaker if it's further from the origin */
  66928. Linear = 1
  66929. }
  66930. /**
  66931. * The strength of the force in correspondence to the distance of the affected object
  66932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66933. */
  66934. export enum PhysicsUpdraftMode {
  66935. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66936. Center = 0,
  66937. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66938. Perpendicular = 1
  66939. }
  66940. /**
  66941. * Interface for a physics hit data
  66942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66943. */
  66944. export interface PhysicsHitData {
  66945. /**
  66946. * The force applied at the contact point
  66947. */
  66948. force: Vector3;
  66949. /**
  66950. * The contact point
  66951. */
  66952. contactPoint: Vector3;
  66953. /**
  66954. * The distance from the origin to the contact point
  66955. */
  66956. distanceFromOrigin: number;
  66957. }
  66958. /**
  66959. * Interface for radial explosion event data
  66960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66961. */
  66962. export interface PhysicsRadialExplosionEventData {
  66963. /**
  66964. * A sphere used for the radial explosion event
  66965. */
  66966. sphere: Mesh;
  66967. }
  66968. /**
  66969. * Interface for gravitational field event data
  66970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66971. */
  66972. export interface PhysicsGravitationalFieldEventData {
  66973. /**
  66974. * A sphere mesh used for the gravitational field event
  66975. */
  66976. sphere: Mesh;
  66977. }
  66978. /**
  66979. * Interface for updraft event data
  66980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66981. */
  66982. export interface PhysicsUpdraftEventData {
  66983. /**
  66984. * A cylinder used for the updraft event
  66985. */
  66986. cylinder: Mesh;
  66987. }
  66988. /**
  66989. * Interface for vortex event data
  66990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66991. */
  66992. export interface PhysicsVortexEventData {
  66993. /**
  66994. * A cylinder used for the vortex event
  66995. */
  66996. cylinder: Mesh;
  66997. }
  66998. /**
  66999. * Interface for an affected physics impostor
  67000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67001. */
  67002. export interface PhysicsAffectedImpostorWithData {
  67003. /**
  67004. * The impostor affected by the effect
  67005. */
  67006. impostor: PhysicsImpostor;
  67007. /**
  67008. * The data about the hit/horce from the explosion
  67009. */
  67010. hitData: PhysicsHitData;
  67011. }
  67012. }
  67013. declare module "babylonjs/Physics/Plugins/index" {
  67014. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67015. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67016. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67017. }
  67018. declare module "babylonjs/Physics/index" {
  67019. export * from "babylonjs/Physics/IPhysicsEngine";
  67020. export * from "babylonjs/Physics/physicsEngine";
  67021. export * from "babylonjs/Physics/physicsEngineComponent";
  67022. export * from "babylonjs/Physics/physicsHelper";
  67023. export * from "babylonjs/Physics/physicsImpostor";
  67024. export * from "babylonjs/Physics/physicsJoint";
  67025. export * from "babylonjs/Physics/Plugins/index";
  67026. }
  67027. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67028. /** @hidden */
  67029. export var blackAndWhitePixelShader: {
  67030. name: string;
  67031. shader: string;
  67032. };
  67033. }
  67034. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67036. import { Camera } from "babylonjs/Cameras/camera";
  67037. import { Engine } from "babylonjs/Engines/engine";
  67038. import "babylonjs/Shaders/blackAndWhite.fragment";
  67039. /**
  67040. * Post process used to render in black and white
  67041. */
  67042. export class BlackAndWhitePostProcess extends PostProcess {
  67043. /**
  67044. * Linear about to convert he result to black and white (default: 1)
  67045. */
  67046. degree: number;
  67047. /**
  67048. * Creates a black and white post process
  67049. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67050. * @param name The name of the effect.
  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. */
  67057. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67058. }
  67059. }
  67060. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67061. import { Nullable } from "babylonjs/types";
  67062. import { Camera } from "babylonjs/Cameras/camera";
  67063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67064. import { Engine } from "babylonjs/Engines/engine";
  67065. /**
  67066. * This represents a set of one or more post processes in Babylon.
  67067. * A post process can be used to apply a shader to a texture after it is rendered.
  67068. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67069. */
  67070. export class PostProcessRenderEffect {
  67071. private _postProcesses;
  67072. private _getPostProcesses;
  67073. private _singleInstance;
  67074. private _cameras;
  67075. private _indicesForCamera;
  67076. /**
  67077. * Name of the effect
  67078. * @hidden
  67079. */
  67080. _name: string;
  67081. /**
  67082. * Instantiates a post process render effect.
  67083. * A post process can be used to apply a shader to a texture after it is rendered.
  67084. * @param engine The engine the effect is tied to
  67085. * @param name The name of the effect
  67086. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67087. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67088. */
  67089. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67090. /**
  67091. * Checks if all the post processes in the effect are supported.
  67092. */
  67093. get isSupported(): boolean;
  67094. /**
  67095. * Updates the current state of the effect
  67096. * @hidden
  67097. */
  67098. _update(): void;
  67099. /**
  67100. * Attaches the effect on cameras
  67101. * @param cameras The camera to attach to.
  67102. * @hidden
  67103. */
  67104. _attachCameras(cameras: Camera): void;
  67105. /**
  67106. * Attaches the effect on cameras
  67107. * @param cameras The camera to attach to.
  67108. * @hidden
  67109. */
  67110. _attachCameras(cameras: Camera[]): void;
  67111. /**
  67112. * Detaches the effect on cameras
  67113. * @param cameras The camera to detatch from.
  67114. * @hidden
  67115. */
  67116. _detachCameras(cameras: Camera): void;
  67117. /**
  67118. * Detatches the effect on cameras
  67119. * @param cameras The camera to detatch from.
  67120. * @hidden
  67121. */
  67122. _detachCameras(cameras: Camera[]): void;
  67123. /**
  67124. * Enables the effect on given cameras
  67125. * @param cameras The camera to enable.
  67126. * @hidden
  67127. */
  67128. _enable(cameras: Camera): void;
  67129. /**
  67130. * Enables the effect on given cameras
  67131. * @param cameras The camera to enable.
  67132. * @hidden
  67133. */
  67134. _enable(cameras: Nullable<Camera[]>): void;
  67135. /**
  67136. * Disables the effect on the given cameras
  67137. * @param cameras The camera to disable.
  67138. * @hidden
  67139. */
  67140. _disable(cameras: Camera): void;
  67141. /**
  67142. * Disables the effect on the given cameras
  67143. * @param cameras The camera to disable.
  67144. * @hidden
  67145. */
  67146. _disable(cameras: Nullable<Camera[]>): void;
  67147. /**
  67148. * Gets a list of the post processes contained in the effect.
  67149. * @param camera The camera to get the post processes on.
  67150. * @returns The list of the post processes in the effect.
  67151. */
  67152. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67153. }
  67154. }
  67155. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67156. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67157. /** @hidden */
  67158. export var extractHighlightsPixelShader: {
  67159. name: string;
  67160. shader: string;
  67161. };
  67162. }
  67163. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67164. import { Nullable } from "babylonjs/types";
  67165. import { Camera } from "babylonjs/Cameras/camera";
  67166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67167. import { Engine } from "babylonjs/Engines/engine";
  67168. import "babylonjs/Shaders/extractHighlights.fragment";
  67169. /**
  67170. * 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.
  67171. */
  67172. export class ExtractHighlightsPostProcess extends PostProcess {
  67173. /**
  67174. * The luminance threshold, pixels below this value will be set to black.
  67175. */
  67176. threshold: number;
  67177. /** @hidden */
  67178. _exposure: number;
  67179. /**
  67180. * Post process which has the input texture to be used when performing highlight extraction
  67181. * @hidden
  67182. */
  67183. _inputPostProcess: Nullable<PostProcess>;
  67184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67185. }
  67186. }
  67187. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67188. /** @hidden */
  67189. export var bloomMergePixelShader: {
  67190. name: string;
  67191. shader: string;
  67192. };
  67193. }
  67194. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67196. import { Nullable } from "babylonjs/types";
  67197. import { Engine } from "babylonjs/Engines/engine";
  67198. import { Camera } from "babylonjs/Cameras/camera";
  67199. import "babylonjs/Shaders/bloomMerge.fragment";
  67200. /**
  67201. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67202. */
  67203. export class BloomMergePostProcess extends PostProcess {
  67204. /** Weight of the bloom to be added to the original input. */
  67205. weight: number;
  67206. /**
  67207. * Creates a new instance of @see BloomMergePostProcess
  67208. * @param name The name of the effect.
  67209. * @param originalFromInput Post process which's input will be used for the merge.
  67210. * @param blurred Blurred highlights post process which's output will be used.
  67211. * @param weight Weight of the bloom to be added to the original input.
  67212. * @param options The required width/height ratio to downsize to before computing the render pass.
  67213. * @param camera The camera to apply the render pass to.
  67214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67215. * @param engine The engine which the post process will be applied. (default: current engine)
  67216. * @param reusable If the post process can be reused on the same frame. (default: false)
  67217. * @param textureType Type of textures used when performing the post process. (default: 0)
  67218. * @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)
  67219. */
  67220. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67221. /** Weight of the bloom to be added to the original input. */
  67222. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67223. }
  67224. }
  67225. declare module "babylonjs/PostProcesses/bloomEffect" {
  67226. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67227. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67228. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67229. import { Camera } from "babylonjs/Cameras/camera";
  67230. import { Scene } from "babylonjs/scene";
  67231. /**
  67232. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67233. */
  67234. export class BloomEffect extends PostProcessRenderEffect {
  67235. private bloomScale;
  67236. /**
  67237. * @hidden Internal
  67238. */
  67239. _effects: Array<PostProcess>;
  67240. /**
  67241. * @hidden Internal
  67242. */
  67243. _downscale: ExtractHighlightsPostProcess;
  67244. private _blurX;
  67245. private _blurY;
  67246. private _merge;
  67247. /**
  67248. * The luminance threshold to find bright areas of the image to bloom.
  67249. */
  67250. get threshold(): number;
  67251. set threshold(value: number);
  67252. /**
  67253. * The strength of the bloom.
  67254. */
  67255. get weight(): number;
  67256. set weight(value: number);
  67257. /**
  67258. * Specifies the size of the bloom blur kernel, relative to the final output size
  67259. */
  67260. get kernel(): number;
  67261. set kernel(value: number);
  67262. /**
  67263. * Creates a new instance of @see BloomEffect
  67264. * @param scene The scene the effect belongs to.
  67265. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67266. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67267. * @param bloomWeight The the strength of bloom.
  67268. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67269. * @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)
  67270. */
  67271. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67272. /**
  67273. * Disposes each of the internal effects for a given camera.
  67274. * @param camera The camera to dispose the effect on.
  67275. */
  67276. disposeEffects(camera: Camera): void;
  67277. /**
  67278. * @hidden Internal
  67279. */
  67280. _updateEffects(): void;
  67281. /**
  67282. * Internal
  67283. * @returns if all the contained post processes are ready.
  67284. * @hidden
  67285. */
  67286. _isReady(): boolean;
  67287. }
  67288. }
  67289. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67290. /** @hidden */
  67291. export var chromaticAberrationPixelShader: {
  67292. name: string;
  67293. shader: string;
  67294. };
  67295. }
  67296. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67297. import { Vector2 } from "babylonjs/Maths/math.vector";
  67298. import { Nullable } from "babylonjs/types";
  67299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67300. import { Camera } from "babylonjs/Cameras/camera";
  67301. import { Engine } from "babylonjs/Engines/engine";
  67302. import "babylonjs/Shaders/chromaticAberration.fragment";
  67303. /**
  67304. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67305. */
  67306. export class ChromaticAberrationPostProcess extends PostProcess {
  67307. /**
  67308. * The amount of seperation of rgb channels (default: 30)
  67309. */
  67310. aberrationAmount: number;
  67311. /**
  67312. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67313. */
  67314. radialIntensity: number;
  67315. /**
  67316. * 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))
  67317. */
  67318. direction: Vector2;
  67319. /**
  67320. * 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))
  67321. */
  67322. centerPosition: Vector2;
  67323. /**
  67324. * Creates a new instance ChromaticAberrationPostProcess
  67325. * @param name The name of the effect.
  67326. * @param screenWidth The width of the screen to apply the effect on.
  67327. * @param screenHeight The height of the screen to apply the effect on.
  67328. * @param options The required width/height ratio to downsize to before computing the render pass.
  67329. * @param camera The camera to apply the render pass to.
  67330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67331. * @param engine The engine which the post process will be applied. (default: current engine)
  67332. * @param reusable If the post process can be reused on the same frame. (default: false)
  67333. * @param textureType Type of textures used when performing the post process. (default: 0)
  67334. * @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)
  67335. */
  67336. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67337. }
  67338. }
  67339. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67340. /** @hidden */
  67341. export var circleOfConfusionPixelShader: {
  67342. name: string;
  67343. shader: string;
  67344. };
  67345. }
  67346. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67347. import { Nullable } from "babylonjs/types";
  67348. import { Engine } from "babylonjs/Engines/engine";
  67349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67351. import { Camera } from "babylonjs/Cameras/camera";
  67352. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67353. /**
  67354. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67355. */
  67356. export class CircleOfConfusionPostProcess extends PostProcess {
  67357. /**
  67358. * 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.
  67359. */
  67360. lensSize: number;
  67361. /**
  67362. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67363. */
  67364. fStop: number;
  67365. /**
  67366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67367. */
  67368. focusDistance: number;
  67369. /**
  67370. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67371. */
  67372. focalLength: number;
  67373. private _depthTexture;
  67374. /**
  67375. * Creates a new instance CircleOfConfusionPostProcess
  67376. * @param name The name of the effect.
  67377. * @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.
  67378. * @param options The required width/height ratio to downsize to before computing the render pass.
  67379. * @param camera The camera to apply the render pass to.
  67380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67381. * @param engine The engine which the post process will be applied. (default: current engine)
  67382. * @param reusable If the post process can be reused on the same frame. (default: false)
  67383. * @param textureType Type of textures used when performing the post process. (default: 0)
  67384. * @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)
  67385. */
  67386. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67387. /**
  67388. * 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.
  67389. */
  67390. set depthTexture(value: RenderTargetTexture);
  67391. }
  67392. }
  67393. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67394. /** @hidden */
  67395. export var colorCorrectionPixelShader: {
  67396. name: string;
  67397. shader: string;
  67398. };
  67399. }
  67400. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67401. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67402. import { Engine } from "babylonjs/Engines/engine";
  67403. import { Camera } from "babylonjs/Cameras/camera";
  67404. import "babylonjs/Shaders/colorCorrection.fragment";
  67405. /**
  67406. *
  67407. * This post-process allows the modification of rendered colors by using
  67408. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67409. *
  67410. * The object needs to be provided an url to a texture containing the color
  67411. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67412. * Use an image editing software to tweak the LUT to match your needs.
  67413. *
  67414. * For an example of a color LUT, see here:
  67415. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67416. * For explanations on color grading, see here:
  67417. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67418. *
  67419. */
  67420. export class ColorCorrectionPostProcess extends PostProcess {
  67421. private _colorTableTexture;
  67422. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67423. }
  67424. }
  67425. declare module "babylonjs/Shaders/convolution.fragment" {
  67426. /** @hidden */
  67427. export var convolutionPixelShader: {
  67428. name: string;
  67429. shader: string;
  67430. };
  67431. }
  67432. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67433. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67434. import { Nullable } from "babylonjs/types";
  67435. import { Camera } from "babylonjs/Cameras/camera";
  67436. import { Engine } from "babylonjs/Engines/engine";
  67437. import "babylonjs/Shaders/convolution.fragment";
  67438. /**
  67439. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67440. * input texture to perform effects such as edge detection or sharpening
  67441. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67442. */
  67443. export class ConvolutionPostProcess extends PostProcess {
  67444. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67445. kernel: number[];
  67446. /**
  67447. * Creates a new instance ConvolutionPostProcess
  67448. * @param name The name of the effect.
  67449. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67450. * @param options The required width/height ratio to downsize to before computing the render pass.
  67451. * @param camera The camera to apply the render pass to.
  67452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67453. * @param engine The engine which the post process will be applied. (default: current engine)
  67454. * @param reusable If the post process can be reused on the same frame. (default: false)
  67455. * @param textureType Type of textures used when performing the post process. (default: 0)
  67456. */
  67457. constructor(name: string,
  67458. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67459. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67460. /**
  67461. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67462. */
  67463. static EdgeDetect0Kernel: number[];
  67464. /**
  67465. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67466. */
  67467. static EdgeDetect1Kernel: number[];
  67468. /**
  67469. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67470. */
  67471. static EdgeDetect2Kernel: number[];
  67472. /**
  67473. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67474. */
  67475. static SharpenKernel: number[];
  67476. /**
  67477. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67478. */
  67479. static EmbossKernel: number[];
  67480. /**
  67481. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67482. */
  67483. static GaussianKernel: number[];
  67484. }
  67485. }
  67486. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67487. import { Nullable } from "babylonjs/types";
  67488. import { Vector2 } from "babylonjs/Maths/math.vector";
  67489. import { Camera } from "babylonjs/Cameras/camera";
  67490. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67491. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67492. import { Engine } from "babylonjs/Engines/engine";
  67493. import { Scene } from "babylonjs/scene";
  67494. /**
  67495. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67496. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67497. * based on samples that have a large difference in distance than the center pixel.
  67498. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67499. */
  67500. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67501. direction: Vector2;
  67502. /**
  67503. * Creates a new instance CircleOfConfusionPostProcess
  67504. * @param name The name of the effect.
  67505. * @param scene The scene the effect belongs to.
  67506. * @param direction The direction the blur should be applied.
  67507. * @param kernel The size of the kernel used to blur.
  67508. * @param options The required width/height ratio to downsize to before computing the render pass.
  67509. * @param camera The camera to apply the render pass to.
  67510. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67511. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67513. * @param engine The engine which the post process will be applied. (default: current engine)
  67514. * @param reusable If the post process can be reused on the same frame. (default: false)
  67515. * @param textureType Type of textures used when performing the post process. (default: 0)
  67516. * @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)
  67517. */
  67518. 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);
  67519. }
  67520. }
  67521. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67522. /** @hidden */
  67523. export var depthOfFieldMergePixelShader: {
  67524. name: string;
  67525. shader: string;
  67526. };
  67527. }
  67528. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67529. import { Nullable } from "babylonjs/types";
  67530. import { Camera } from "babylonjs/Cameras/camera";
  67531. import { Effect } from "babylonjs/Materials/effect";
  67532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67533. import { Engine } from "babylonjs/Engines/engine";
  67534. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67535. /**
  67536. * Options to be set when merging outputs from the default pipeline.
  67537. */
  67538. export class DepthOfFieldMergePostProcessOptions {
  67539. /**
  67540. * The original image to merge on top of
  67541. */
  67542. originalFromInput: PostProcess;
  67543. /**
  67544. * Parameters to perform the merge of the depth of field effect
  67545. */
  67546. depthOfField?: {
  67547. circleOfConfusion: PostProcess;
  67548. blurSteps: Array<PostProcess>;
  67549. };
  67550. /**
  67551. * Parameters to perform the merge of bloom effect
  67552. */
  67553. bloom?: {
  67554. blurred: PostProcess;
  67555. weight: number;
  67556. };
  67557. }
  67558. /**
  67559. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67560. */
  67561. export class DepthOfFieldMergePostProcess extends PostProcess {
  67562. private blurSteps;
  67563. /**
  67564. * Creates a new instance of DepthOfFieldMergePostProcess
  67565. * @param name The name of the effect.
  67566. * @param originalFromInput Post process which's input will be used for the merge.
  67567. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67568. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67569. * @param options The required width/height ratio to downsize to before computing the render pass.
  67570. * @param camera The camera to apply the render pass to.
  67571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67572. * @param engine The engine which the post process will be applied. (default: current engine)
  67573. * @param reusable If the post process can be reused on the same frame. (default: false)
  67574. * @param textureType Type of textures used when performing the post process. (default: 0)
  67575. * @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)
  67576. */
  67577. 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);
  67578. /**
  67579. * Updates the effect with the current post process compile time values and recompiles the shader.
  67580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67583. * @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
  67584. * @param onCompiled Called when the shader has been compiled.
  67585. * @param onError Called if there is an error when compiling a shader.
  67586. */
  67587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67588. }
  67589. }
  67590. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67591. import { Nullable } from "babylonjs/types";
  67592. import { Camera } from "babylonjs/Cameras/camera";
  67593. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67594. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67595. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67596. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67597. import { Scene } from "babylonjs/scene";
  67598. /**
  67599. * Specifies the level of max blur that should be applied when using the depth of field effect
  67600. */
  67601. export enum DepthOfFieldEffectBlurLevel {
  67602. /**
  67603. * Subtle blur
  67604. */
  67605. Low = 0,
  67606. /**
  67607. * Medium blur
  67608. */
  67609. Medium = 1,
  67610. /**
  67611. * Large blur
  67612. */
  67613. High = 2
  67614. }
  67615. /**
  67616. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67617. */
  67618. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67619. private _circleOfConfusion;
  67620. /**
  67621. * @hidden Internal, blurs from high to low
  67622. */
  67623. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67624. private _depthOfFieldBlurY;
  67625. private _dofMerge;
  67626. /**
  67627. * @hidden Internal post processes in depth of field effect
  67628. */
  67629. _effects: Array<PostProcess>;
  67630. /**
  67631. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67632. */
  67633. set focalLength(value: number);
  67634. get focalLength(): number;
  67635. /**
  67636. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67637. */
  67638. set fStop(value: number);
  67639. get fStop(): number;
  67640. /**
  67641. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67642. */
  67643. set focusDistance(value: number);
  67644. get focusDistance(): number;
  67645. /**
  67646. * 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.
  67647. */
  67648. set lensSize(value: number);
  67649. get lensSize(): number;
  67650. /**
  67651. * Creates a new instance DepthOfFieldEffect
  67652. * @param scene The scene the effect belongs to.
  67653. * @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.
  67654. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67655. * @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)
  67656. */
  67657. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67658. /**
  67659. * Get the current class name of the current effet
  67660. * @returns "DepthOfFieldEffect"
  67661. */
  67662. getClassName(): string;
  67663. /**
  67664. * 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.
  67665. */
  67666. set depthTexture(value: RenderTargetTexture);
  67667. /**
  67668. * Disposes each of the internal effects for a given camera.
  67669. * @param camera The camera to dispose the effect on.
  67670. */
  67671. disposeEffects(camera: Camera): void;
  67672. /**
  67673. * @hidden Internal
  67674. */
  67675. _updateEffects(): void;
  67676. /**
  67677. * Internal
  67678. * @returns if all the contained post processes are ready.
  67679. * @hidden
  67680. */
  67681. _isReady(): boolean;
  67682. }
  67683. }
  67684. declare module "babylonjs/Shaders/displayPass.fragment" {
  67685. /** @hidden */
  67686. export var displayPassPixelShader: {
  67687. name: string;
  67688. shader: string;
  67689. };
  67690. }
  67691. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67692. import { Nullable } from "babylonjs/types";
  67693. import { Camera } from "babylonjs/Cameras/camera";
  67694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67695. import { Engine } from "babylonjs/Engines/engine";
  67696. import "babylonjs/Shaders/displayPass.fragment";
  67697. /**
  67698. * DisplayPassPostProcess which produces an output the same as it's input
  67699. */
  67700. export class DisplayPassPostProcess extends PostProcess {
  67701. /**
  67702. * Creates the DisplayPassPostProcess
  67703. * @param name The name of the effect.
  67704. * @param options The required width/height ratio to downsize to before computing the render pass.
  67705. * @param camera The camera to apply the render pass to.
  67706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67707. * @param engine The engine which the post process will be applied. (default: current engine)
  67708. * @param reusable If the post process can be reused on the same frame. (default: false)
  67709. */
  67710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67711. }
  67712. }
  67713. declare module "babylonjs/Shaders/filter.fragment" {
  67714. /** @hidden */
  67715. export var filterPixelShader: {
  67716. name: string;
  67717. shader: string;
  67718. };
  67719. }
  67720. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67721. import { Nullable } from "babylonjs/types";
  67722. import { Matrix } from "babylonjs/Maths/math.vector";
  67723. import { Camera } from "babylonjs/Cameras/camera";
  67724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67725. import { Engine } from "babylonjs/Engines/engine";
  67726. import "babylonjs/Shaders/filter.fragment";
  67727. /**
  67728. * Applies a kernel filter to the image
  67729. */
  67730. export class FilterPostProcess extends PostProcess {
  67731. /** The matrix to be applied to the image */
  67732. kernelMatrix: Matrix;
  67733. /**
  67734. *
  67735. * @param name The name of the effect.
  67736. * @param kernelMatrix The matrix to be applied to the image
  67737. * @param options The required width/height ratio to downsize to before computing the render pass.
  67738. * @param camera The camera to apply the render pass to.
  67739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67740. * @param engine The engine which the post process will be applied. (default: current engine)
  67741. * @param reusable If the post process can be reused on the same frame. (default: false)
  67742. */
  67743. constructor(name: string,
  67744. /** The matrix to be applied to the image */
  67745. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67746. }
  67747. }
  67748. declare module "babylonjs/Shaders/fxaa.fragment" {
  67749. /** @hidden */
  67750. export var fxaaPixelShader: {
  67751. name: string;
  67752. shader: string;
  67753. };
  67754. }
  67755. declare module "babylonjs/Shaders/fxaa.vertex" {
  67756. /** @hidden */
  67757. export var fxaaVertexShader: {
  67758. name: string;
  67759. shader: string;
  67760. };
  67761. }
  67762. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67763. import { Nullable } from "babylonjs/types";
  67764. import { Camera } from "babylonjs/Cameras/camera";
  67765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67766. import { Engine } from "babylonjs/Engines/engine";
  67767. import "babylonjs/Shaders/fxaa.fragment";
  67768. import "babylonjs/Shaders/fxaa.vertex";
  67769. /**
  67770. * Fxaa post process
  67771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67772. */
  67773. export class FxaaPostProcess extends PostProcess {
  67774. /** @hidden */
  67775. texelWidth: number;
  67776. /** @hidden */
  67777. texelHeight: number;
  67778. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67779. private _getDefines;
  67780. }
  67781. }
  67782. declare module "babylonjs/Shaders/grain.fragment" {
  67783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67784. /** @hidden */
  67785. export var grainPixelShader: {
  67786. name: string;
  67787. shader: string;
  67788. };
  67789. }
  67790. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67791. import { Nullable } from "babylonjs/types";
  67792. import { Camera } from "babylonjs/Cameras/camera";
  67793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67794. import { Engine } from "babylonjs/Engines/engine";
  67795. import "babylonjs/Shaders/grain.fragment";
  67796. /**
  67797. * The GrainPostProcess adds noise to the image at mid luminance levels
  67798. */
  67799. export class GrainPostProcess extends PostProcess {
  67800. /**
  67801. * The intensity of the grain added (default: 30)
  67802. */
  67803. intensity: number;
  67804. /**
  67805. * If the grain should be randomized on every frame
  67806. */
  67807. animated: boolean;
  67808. /**
  67809. * Creates a new instance of @see GrainPostProcess
  67810. * @param name The name of the effect.
  67811. * @param options The required width/height ratio to downsize to before computing the render pass.
  67812. * @param camera The camera to apply the render pass to.
  67813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67814. * @param engine The engine which the post process will be applied. (default: current engine)
  67815. * @param reusable If the post process can be reused on the same frame. (default: false)
  67816. * @param textureType Type of textures used when performing the post process. (default: 0)
  67817. * @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)
  67818. */
  67819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67820. }
  67821. }
  67822. declare module "babylonjs/Shaders/highlights.fragment" {
  67823. /** @hidden */
  67824. export var highlightsPixelShader: {
  67825. name: string;
  67826. shader: string;
  67827. };
  67828. }
  67829. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67830. import { Nullable } from "babylonjs/types";
  67831. import { Camera } from "babylonjs/Cameras/camera";
  67832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67833. import { Engine } from "babylonjs/Engines/engine";
  67834. import "babylonjs/Shaders/highlights.fragment";
  67835. /**
  67836. * Extracts highlights from the image
  67837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67838. */
  67839. export class HighlightsPostProcess extends PostProcess {
  67840. /**
  67841. * Extracts highlights from the image
  67842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67843. * @param name The name of the effect.
  67844. * @param options The required width/height ratio to downsize to before computing the render pass.
  67845. * @param camera The camera to apply the render pass to.
  67846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67847. * @param engine The engine which the post process will be applied. (default: current engine)
  67848. * @param reusable If the post process can be reused on the same frame. (default: false)
  67849. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67850. */
  67851. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67852. }
  67853. }
  67854. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67855. /** @hidden */
  67856. export var mrtFragmentDeclaration: {
  67857. name: string;
  67858. shader: string;
  67859. };
  67860. }
  67861. declare module "babylonjs/Shaders/geometry.fragment" {
  67862. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67863. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67864. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67865. /** @hidden */
  67866. export var geometryPixelShader: {
  67867. name: string;
  67868. shader: string;
  67869. };
  67870. }
  67871. declare module "babylonjs/Shaders/geometry.vertex" {
  67872. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67873. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67874. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67875. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67876. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67877. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67878. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67879. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67880. /** @hidden */
  67881. export var geometryVertexShader: {
  67882. name: string;
  67883. shader: string;
  67884. };
  67885. }
  67886. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67887. import { Matrix } from "babylonjs/Maths/math.vector";
  67888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67889. import { Mesh } from "babylonjs/Meshes/mesh";
  67890. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67891. import { Effect } from "babylonjs/Materials/effect";
  67892. import { Scene } from "babylonjs/scene";
  67893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67894. import "babylonjs/Shaders/geometry.fragment";
  67895. import "babylonjs/Shaders/geometry.vertex";
  67896. /** @hidden */
  67897. interface ISavedTransformationMatrix {
  67898. world: Matrix;
  67899. viewProjection: Matrix;
  67900. }
  67901. /**
  67902. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67903. */
  67904. export class GeometryBufferRenderer {
  67905. /**
  67906. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67907. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67908. */
  67909. static readonly POSITION_TEXTURE_TYPE: number;
  67910. /**
  67911. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67912. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67913. */
  67914. static readonly VELOCITY_TEXTURE_TYPE: number;
  67915. /**
  67916. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67917. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67918. */
  67919. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67920. /**
  67921. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67922. * in order to compute objects velocities when enableVelocity is set to "true"
  67923. * @hidden
  67924. */
  67925. _previousTransformationMatrices: {
  67926. [index: number]: ISavedTransformationMatrix;
  67927. };
  67928. /**
  67929. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67930. * in order to compute objects velocities when enableVelocity is set to "true"
  67931. * @hidden
  67932. */
  67933. _previousBonesTransformationMatrices: {
  67934. [index: number]: Float32Array;
  67935. };
  67936. /**
  67937. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67938. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67939. */
  67940. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67941. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67942. renderTransparentMeshes: boolean;
  67943. private _scene;
  67944. private _multiRenderTarget;
  67945. private _ratio;
  67946. private _enablePosition;
  67947. private _enableVelocity;
  67948. private _enableReflectivity;
  67949. private _positionIndex;
  67950. private _velocityIndex;
  67951. private _reflectivityIndex;
  67952. protected _effect: Effect;
  67953. protected _cachedDefines: string;
  67954. /**
  67955. * Set the render list (meshes to be rendered) used in the G buffer.
  67956. */
  67957. set renderList(meshes: Mesh[]);
  67958. /**
  67959. * Gets wether or not G buffer are supported by the running hardware.
  67960. * This requires draw buffer supports
  67961. */
  67962. get isSupported(): boolean;
  67963. /**
  67964. * Returns the index of the given texture type in the G-Buffer textures array
  67965. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67966. * @returns the index of the given texture type in the G-Buffer textures array
  67967. */
  67968. getTextureIndex(textureType: number): number;
  67969. /**
  67970. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67971. */
  67972. get enablePosition(): boolean;
  67973. /**
  67974. * Sets whether or not objects positions are enabled for the G buffer.
  67975. */
  67976. set enablePosition(enable: boolean);
  67977. /**
  67978. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67979. */
  67980. get enableVelocity(): boolean;
  67981. /**
  67982. * Sets wether or not objects velocities are enabled for the G buffer.
  67983. */
  67984. set enableVelocity(enable: boolean);
  67985. /**
  67986. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67987. */
  67988. get enableReflectivity(): boolean;
  67989. /**
  67990. * Sets wether or not objects roughness are enabled for the G buffer.
  67991. */
  67992. set enableReflectivity(enable: boolean);
  67993. /**
  67994. * Gets the scene associated with the buffer.
  67995. */
  67996. get scene(): Scene;
  67997. /**
  67998. * Gets the ratio used by the buffer during its creation.
  67999. * How big is the buffer related to the main canvas.
  68000. */
  68001. get ratio(): number;
  68002. /** @hidden */
  68003. static _SceneComponentInitialization: (scene: Scene) => void;
  68004. /**
  68005. * Creates a new G Buffer for the scene
  68006. * @param scene The scene the buffer belongs to
  68007. * @param ratio How big is the buffer related to the main canvas.
  68008. */
  68009. constructor(scene: Scene, ratio?: number);
  68010. /**
  68011. * Checks wether everything is ready to render a submesh to the G buffer.
  68012. * @param subMesh the submesh to check readiness for
  68013. * @param useInstances is the mesh drawn using instance or not
  68014. * @returns true if ready otherwise false
  68015. */
  68016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68017. /**
  68018. * Gets the current underlying G Buffer.
  68019. * @returns the buffer
  68020. */
  68021. getGBuffer(): MultiRenderTarget;
  68022. /**
  68023. * Gets the number of samples used to render the buffer (anti aliasing).
  68024. */
  68025. get samples(): number;
  68026. /**
  68027. * Sets the number of samples used to render the buffer (anti aliasing).
  68028. */
  68029. set samples(value: number);
  68030. /**
  68031. * Disposes the renderer and frees up associated resources.
  68032. */
  68033. dispose(): void;
  68034. protected _createRenderTargets(): void;
  68035. private _copyBonesTransformationMatrices;
  68036. }
  68037. }
  68038. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68039. import { Nullable } from "babylonjs/types";
  68040. import { Scene } from "babylonjs/scene";
  68041. import { ISceneComponent } from "babylonjs/sceneComponent";
  68042. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68043. module "babylonjs/scene" {
  68044. interface Scene {
  68045. /** @hidden (Backing field) */
  68046. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68047. /**
  68048. * Gets or Sets the current geometry buffer associated to the scene.
  68049. */
  68050. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68051. /**
  68052. * Enables a GeometryBufferRender and associates it with the scene
  68053. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68054. * @returns the GeometryBufferRenderer
  68055. */
  68056. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68057. /**
  68058. * Disables the GeometryBufferRender associated with the scene
  68059. */
  68060. disableGeometryBufferRenderer(): void;
  68061. }
  68062. }
  68063. /**
  68064. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68065. * in several rendering techniques.
  68066. */
  68067. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68068. /**
  68069. * The component name helpful to identify the component in the list of scene components.
  68070. */
  68071. readonly name: string;
  68072. /**
  68073. * The scene the component belongs to.
  68074. */
  68075. scene: Scene;
  68076. /**
  68077. * Creates a new instance of the component for the given scene
  68078. * @param scene Defines the scene to register the component in
  68079. */
  68080. constructor(scene: Scene);
  68081. /**
  68082. * Registers the component in a given scene
  68083. */
  68084. register(): void;
  68085. /**
  68086. * Rebuilds the elements related to this component in case of
  68087. * context lost for instance.
  68088. */
  68089. rebuild(): void;
  68090. /**
  68091. * Disposes the component and the associated ressources
  68092. */
  68093. dispose(): void;
  68094. private _gatherRenderTargets;
  68095. }
  68096. }
  68097. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68098. /** @hidden */
  68099. export var motionBlurPixelShader: {
  68100. name: string;
  68101. shader: string;
  68102. };
  68103. }
  68104. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68105. import { Nullable } from "babylonjs/types";
  68106. import { Camera } from "babylonjs/Cameras/camera";
  68107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68108. import { Scene } from "babylonjs/scene";
  68109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68110. import "babylonjs/Animations/animatable";
  68111. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68112. import "babylonjs/Shaders/motionBlur.fragment";
  68113. import { Engine } from "babylonjs/Engines/engine";
  68114. /**
  68115. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68116. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68117. * As an example, all you have to do is to create the post-process:
  68118. * var mb = new BABYLON.MotionBlurPostProcess(
  68119. * 'mb', // The name of the effect.
  68120. * scene, // The scene containing the objects to blur according to their velocity.
  68121. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68122. * camera // The camera to apply the render pass to.
  68123. * );
  68124. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68125. */
  68126. export class MotionBlurPostProcess extends PostProcess {
  68127. /**
  68128. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68129. */
  68130. motionStrength: number;
  68131. /**
  68132. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68133. */
  68134. get motionBlurSamples(): number;
  68135. /**
  68136. * Sets the number of iterations to be used for motion blur quality
  68137. */
  68138. set motionBlurSamples(samples: number);
  68139. private _motionBlurSamples;
  68140. private _geometryBufferRenderer;
  68141. /**
  68142. * Creates a new instance MotionBlurPostProcess
  68143. * @param name The name of the effect.
  68144. * @param scene The scene containing the objects to blur according to their velocity.
  68145. * @param options The required width/height ratio to downsize to before computing the render pass.
  68146. * @param camera The camera to apply the render pass to.
  68147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68148. * @param engine The engine which the post process will be applied. (default: current engine)
  68149. * @param reusable If the post process can be reused on the same frame. (default: false)
  68150. * @param textureType Type of textures used when performing the post process. (default: 0)
  68151. * @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)
  68152. */
  68153. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68154. /**
  68155. * Excludes the given skinned mesh from computing bones velocities.
  68156. * 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.
  68157. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68158. */
  68159. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68160. /**
  68161. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68162. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68163. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68164. */
  68165. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68166. /**
  68167. * Disposes the post process.
  68168. * @param camera The camera to dispose the post process on.
  68169. */
  68170. dispose(camera?: Camera): void;
  68171. }
  68172. }
  68173. declare module "babylonjs/Shaders/refraction.fragment" {
  68174. /** @hidden */
  68175. export var refractionPixelShader: {
  68176. name: string;
  68177. shader: string;
  68178. };
  68179. }
  68180. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68181. import { Color3 } from "babylonjs/Maths/math.color";
  68182. import { Camera } from "babylonjs/Cameras/camera";
  68183. import { Texture } from "babylonjs/Materials/Textures/texture";
  68184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68185. import { Engine } from "babylonjs/Engines/engine";
  68186. import "babylonjs/Shaders/refraction.fragment";
  68187. /**
  68188. * Post process which applies a refractin texture
  68189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68190. */
  68191. export class RefractionPostProcess extends PostProcess {
  68192. /** the base color of the refraction (used to taint the rendering) */
  68193. color: Color3;
  68194. /** simulated refraction depth */
  68195. depth: number;
  68196. /** the coefficient of the base color (0 to remove base color tainting) */
  68197. colorLevel: number;
  68198. private _refTexture;
  68199. private _ownRefractionTexture;
  68200. /**
  68201. * Gets or sets the refraction texture
  68202. * Please note that you are responsible for disposing the texture if you set it manually
  68203. */
  68204. get refractionTexture(): Texture;
  68205. set refractionTexture(value: Texture);
  68206. /**
  68207. * Initializes the RefractionPostProcess
  68208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68209. * @param name The name of the effect.
  68210. * @param refractionTextureUrl Url of the refraction texture to use
  68211. * @param color the base color of the refraction (used to taint the rendering)
  68212. * @param depth simulated refraction depth
  68213. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68214. * @param camera The camera to apply the render pass to.
  68215. * @param options The required width/height ratio to downsize to before computing the render pass.
  68216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68217. * @param engine The engine which the post process will be applied. (default: current engine)
  68218. * @param reusable If the post process can be reused on the same frame. (default: false)
  68219. */
  68220. constructor(name: string, refractionTextureUrl: string,
  68221. /** the base color of the refraction (used to taint the rendering) */
  68222. color: Color3,
  68223. /** simulated refraction depth */
  68224. depth: number,
  68225. /** the coefficient of the base color (0 to remove base color tainting) */
  68226. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68227. /**
  68228. * Disposes of the post process
  68229. * @param camera Camera to dispose post process on
  68230. */
  68231. dispose(camera: Camera): void;
  68232. }
  68233. }
  68234. declare module "babylonjs/Shaders/sharpen.fragment" {
  68235. /** @hidden */
  68236. export var sharpenPixelShader: {
  68237. name: string;
  68238. shader: string;
  68239. };
  68240. }
  68241. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68242. import { Nullable } from "babylonjs/types";
  68243. import { Camera } from "babylonjs/Cameras/camera";
  68244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68245. import "babylonjs/Shaders/sharpen.fragment";
  68246. import { Engine } from "babylonjs/Engines/engine";
  68247. /**
  68248. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68249. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68250. */
  68251. export class SharpenPostProcess extends PostProcess {
  68252. /**
  68253. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68254. */
  68255. colorAmount: number;
  68256. /**
  68257. * How much sharpness should be applied (default: 0.3)
  68258. */
  68259. edgeAmount: number;
  68260. /**
  68261. * Creates a new instance ConvolutionPostProcess
  68262. * @param name The name of the effect.
  68263. * @param options The required width/height ratio to downsize to before computing the render pass.
  68264. * @param camera The camera to apply the render pass to.
  68265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68266. * @param engine The engine which the post process will be applied. (default: current engine)
  68267. * @param reusable If the post process can be reused on the same frame. (default: false)
  68268. * @param textureType Type of textures used when performing the post process. (default: 0)
  68269. * @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)
  68270. */
  68271. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68272. }
  68273. }
  68274. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68275. import { Nullable } from "babylonjs/types";
  68276. import { Camera } from "babylonjs/Cameras/camera";
  68277. import { Engine } from "babylonjs/Engines/engine";
  68278. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68279. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68280. /**
  68281. * PostProcessRenderPipeline
  68282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68283. */
  68284. export class PostProcessRenderPipeline {
  68285. private engine;
  68286. private _renderEffects;
  68287. private _renderEffectsForIsolatedPass;
  68288. /**
  68289. * List of inspectable custom properties (used by the Inspector)
  68290. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68291. */
  68292. inspectableCustomProperties: IInspectable[];
  68293. /**
  68294. * @hidden
  68295. */
  68296. protected _cameras: Camera[];
  68297. /** @hidden */
  68298. _name: string;
  68299. /**
  68300. * Gets pipeline name
  68301. */
  68302. get name(): string;
  68303. /** Gets the list of attached cameras */
  68304. get cameras(): Camera[];
  68305. /**
  68306. * Initializes a PostProcessRenderPipeline
  68307. * @param engine engine to add the pipeline to
  68308. * @param name name of the pipeline
  68309. */
  68310. constructor(engine: Engine, name: string);
  68311. /**
  68312. * Gets the class name
  68313. * @returns "PostProcessRenderPipeline"
  68314. */
  68315. getClassName(): string;
  68316. /**
  68317. * If all the render effects in the pipeline are supported
  68318. */
  68319. get isSupported(): boolean;
  68320. /**
  68321. * Adds an effect to the pipeline
  68322. * @param renderEffect the effect to add
  68323. */
  68324. addEffect(renderEffect: PostProcessRenderEffect): void;
  68325. /** @hidden */
  68326. _rebuild(): void;
  68327. /** @hidden */
  68328. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68329. /** @hidden */
  68330. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68331. /** @hidden */
  68332. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68333. /** @hidden */
  68334. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68335. /** @hidden */
  68336. _attachCameras(cameras: Camera, unique: boolean): void;
  68337. /** @hidden */
  68338. _attachCameras(cameras: Camera[], unique: boolean): void;
  68339. /** @hidden */
  68340. _detachCameras(cameras: Camera): void;
  68341. /** @hidden */
  68342. _detachCameras(cameras: Nullable<Camera[]>): void;
  68343. /** @hidden */
  68344. _update(): void;
  68345. /** @hidden */
  68346. _reset(): void;
  68347. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68348. /**
  68349. * Disposes of the pipeline
  68350. */
  68351. dispose(): void;
  68352. }
  68353. }
  68354. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68355. import { Camera } from "babylonjs/Cameras/camera";
  68356. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68357. /**
  68358. * PostProcessRenderPipelineManager class
  68359. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68360. */
  68361. export class PostProcessRenderPipelineManager {
  68362. private _renderPipelines;
  68363. /**
  68364. * Initializes a PostProcessRenderPipelineManager
  68365. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68366. */
  68367. constructor();
  68368. /**
  68369. * Gets the list of supported render pipelines
  68370. */
  68371. get supportedPipelines(): PostProcessRenderPipeline[];
  68372. /**
  68373. * Adds a pipeline to the manager
  68374. * @param renderPipeline The pipeline to add
  68375. */
  68376. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68377. /**
  68378. * Attaches a camera to the pipeline
  68379. * @param renderPipelineName The name of the pipeline to attach to
  68380. * @param cameras the camera to attach
  68381. * @param unique if the camera can be attached multiple times to the pipeline
  68382. */
  68383. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68384. /**
  68385. * Detaches a camera from the pipeline
  68386. * @param renderPipelineName The name of the pipeline to detach from
  68387. * @param cameras the camera to detach
  68388. */
  68389. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68390. /**
  68391. * Enables an effect by name on a pipeline
  68392. * @param renderPipelineName the name of the pipeline to enable the effect in
  68393. * @param renderEffectName the name of the effect to enable
  68394. * @param cameras the cameras that the effect should be enabled on
  68395. */
  68396. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68397. /**
  68398. * Disables an effect by name on a pipeline
  68399. * @param renderPipelineName the name of the pipeline to disable the effect in
  68400. * @param renderEffectName the name of the effect to disable
  68401. * @param cameras the cameras that the effect should be disabled on
  68402. */
  68403. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68404. /**
  68405. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68406. */
  68407. update(): void;
  68408. /** @hidden */
  68409. _rebuild(): void;
  68410. /**
  68411. * Disposes of the manager and pipelines
  68412. */
  68413. dispose(): void;
  68414. }
  68415. }
  68416. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68417. import { ISceneComponent } from "babylonjs/sceneComponent";
  68418. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68419. import { Scene } from "babylonjs/scene";
  68420. module "babylonjs/scene" {
  68421. interface Scene {
  68422. /** @hidden (Backing field) */
  68423. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68424. /**
  68425. * Gets the postprocess render pipeline manager
  68426. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68427. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68428. */
  68429. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68430. }
  68431. }
  68432. /**
  68433. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68434. */
  68435. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68436. /**
  68437. * The component name helpfull to identify the component in the list of scene components.
  68438. */
  68439. readonly name: string;
  68440. /**
  68441. * The scene the component belongs to.
  68442. */
  68443. scene: Scene;
  68444. /**
  68445. * Creates a new instance of the component for the given scene
  68446. * @param scene Defines the scene to register the component in
  68447. */
  68448. constructor(scene: Scene);
  68449. /**
  68450. * Registers the component in a given scene
  68451. */
  68452. register(): void;
  68453. /**
  68454. * Rebuilds the elements related to this component in case of
  68455. * context lost for instance.
  68456. */
  68457. rebuild(): void;
  68458. /**
  68459. * Disposes the component and the associated ressources
  68460. */
  68461. dispose(): void;
  68462. private _gatherRenderTargets;
  68463. }
  68464. }
  68465. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68466. import { Nullable } from "babylonjs/types";
  68467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68468. import { Camera } from "babylonjs/Cameras/camera";
  68469. import { IDisposable } from "babylonjs/scene";
  68470. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68471. import { Scene } from "babylonjs/scene";
  68472. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68473. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68474. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68475. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68476. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68477. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68478. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68479. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68480. import { Animation } from "babylonjs/Animations/animation";
  68481. /**
  68482. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68483. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68484. */
  68485. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68486. private _scene;
  68487. private _camerasToBeAttached;
  68488. /**
  68489. * ID of the sharpen post process,
  68490. */
  68491. private readonly SharpenPostProcessId;
  68492. /**
  68493. * @ignore
  68494. * ID of the image processing post process;
  68495. */
  68496. readonly ImageProcessingPostProcessId: string;
  68497. /**
  68498. * @ignore
  68499. * ID of the Fast Approximate Anti-Aliasing post process;
  68500. */
  68501. readonly FxaaPostProcessId: string;
  68502. /**
  68503. * ID of the chromatic aberration post process,
  68504. */
  68505. private readonly ChromaticAberrationPostProcessId;
  68506. /**
  68507. * ID of the grain post process
  68508. */
  68509. private readonly GrainPostProcessId;
  68510. /**
  68511. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68512. */
  68513. sharpen: SharpenPostProcess;
  68514. private _sharpenEffect;
  68515. private bloom;
  68516. /**
  68517. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68518. */
  68519. depthOfField: DepthOfFieldEffect;
  68520. /**
  68521. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68522. */
  68523. fxaa: FxaaPostProcess;
  68524. /**
  68525. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68526. */
  68527. imageProcessing: ImageProcessingPostProcess;
  68528. /**
  68529. * Chromatic aberration post process which will shift rgb colors in the image
  68530. */
  68531. chromaticAberration: ChromaticAberrationPostProcess;
  68532. private _chromaticAberrationEffect;
  68533. /**
  68534. * Grain post process which add noise to the image
  68535. */
  68536. grain: GrainPostProcess;
  68537. private _grainEffect;
  68538. /**
  68539. * Glow post process which adds a glow to emissive areas of the image
  68540. */
  68541. private _glowLayer;
  68542. /**
  68543. * Animations which can be used to tweak settings over a period of time
  68544. */
  68545. animations: Animation[];
  68546. private _imageProcessingConfigurationObserver;
  68547. private _sharpenEnabled;
  68548. private _bloomEnabled;
  68549. private _depthOfFieldEnabled;
  68550. private _depthOfFieldBlurLevel;
  68551. private _fxaaEnabled;
  68552. private _imageProcessingEnabled;
  68553. private _defaultPipelineTextureType;
  68554. private _bloomScale;
  68555. private _chromaticAberrationEnabled;
  68556. private _grainEnabled;
  68557. private _buildAllowed;
  68558. /**
  68559. * Gets active scene
  68560. */
  68561. get scene(): Scene;
  68562. /**
  68563. * Enable or disable the sharpen process from the pipeline
  68564. */
  68565. set sharpenEnabled(enabled: boolean);
  68566. get sharpenEnabled(): boolean;
  68567. private _resizeObserver;
  68568. private _hardwareScaleLevel;
  68569. private _bloomKernel;
  68570. /**
  68571. * Specifies the size of the bloom blur kernel, relative to the final output size
  68572. */
  68573. get bloomKernel(): number;
  68574. set bloomKernel(value: number);
  68575. /**
  68576. * Specifies the weight of the bloom in the final rendering
  68577. */
  68578. private _bloomWeight;
  68579. /**
  68580. * Specifies the luma threshold for the area that will be blurred by the bloom
  68581. */
  68582. private _bloomThreshold;
  68583. private _hdr;
  68584. /**
  68585. * The strength of the bloom.
  68586. */
  68587. set bloomWeight(value: number);
  68588. get bloomWeight(): number;
  68589. /**
  68590. * The strength of the bloom.
  68591. */
  68592. set bloomThreshold(value: number);
  68593. get bloomThreshold(): number;
  68594. /**
  68595. * The scale of the bloom, lower value will provide better performance.
  68596. */
  68597. set bloomScale(value: number);
  68598. get bloomScale(): number;
  68599. /**
  68600. * Enable or disable the bloom from the pipeline
  68601. */
  68602. set bloomEnabled(enabled: boolean);
  68603. get bloomEnabled(): boolean;
  68604. private _rebuildBloom;
  68605. /**
  68606. * If the depth of field is enabled.
  68607. */
  68608. get depthOfFieldEnabled(): boolean;
  68609. set depthOfFieldEnabled(enabled: boolean);
  68610. /**
  68611. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68612. */
  68613. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68614. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68615. /**
  68616. * If the anti aliasing is enabled.
  68617. */
  68618. set fxaaEnabled(enabled: boolean);
  68619. get fxaaEnabled(): boolean;
  68620. private _samples;
  68621. /**
  68622. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68623. */
  68624. set samples(sampleCount: number);
  68625. get samples(): number;
  68626. /**
  68627. * If image processing is enabled.
  68628. */
  68629. set imageProcessingEnabled(enabled: boolean);
  68630. get imageProcessingEnabled(): boolean;
  68631. /**
  68632. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68633. */
  68634. set glowLayerEnabled(enabled: boolean);
  68635. get glowLayerEnabled(): boolean;
  68636. /**
  68637. * Gets the glow layer (or null if not defined)
  68638. */
  68639. get glowLayer(): Nullable<GlowLayer>;
  68640. /**
  68641. * Enable or disable the chromaticAberration process from the pipeline
  68642. */
  68643. set chromaticAberrationEnabled(enabled: boolean);
  68644. get chromaticAberrationEnabled(): boolean;
  68645. /**
  68646. * Enable or disable the grain process from the pipeline
  68647. */
  68648. set grainEnabled(enabled: boolean);
  68649. get grainEnabled(): boolean;
  68650. /**
  68651. * @constructor
  68652. * @param name - The rendering pipeline name (default: "")
  68653. * @param hdr - If high dynamic range textures should be used (default: true)
  68654. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68655. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68656. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68657. */
  68658. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68659. /**
  68660. * Get the class name
  68661. * @returns "DefaultRenderingPipeline"
  68662. */
  68663. getClassName(): string;
  68664. /**
  68665. * Force the compilation of the entire pipeline.
  68666. */
  68667. prepare(): void;
  68668. private _hasCleared;
  68669. private _prevPostProcess;
  68670. private _prevPrevPostProcess;
  68671. private _setAutoClearAndTextureSharing;
  68672. private _depthOfFieldSceneObserver;
  68673. private _buildPipeline;
  68674. private _disposePostProcesses;
  68675. /**
  68676. * Adds a camera to the pipeline
  68677. * @param camera the camera to be added
  68678. */
  68679. addCamera(camera: Camera): void;
  68680. /**
  68681. * Removes a camera from the pipeline
  68682. * @param camera the camera to remove
  68683. */
  68684. removeCamera(camera: Camera): void;
  68685. /**
  68686. * Dispose of the pipeline and stop all post processes
  68687. */
  68688. dispose(): void;
  68689. /**
  68690. * Serialize the rendering pipeline (Used when exporting)
  68691. * @returns the serialized object
  68692. */
  68693. serialize(): any;
  68694. /**
  68695. * Parse the serialized pipeline
  68696. * @param source Source pipeline.
  68697. * @param scene The scene to load the pipeline to.
  68698. * @param rootUrl The URL of the serialized pipeline.
  68699. * @returns An instantiated pipeline from the serialized object.
  68700. */
  68701. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68702. }
  68703. }
  68704. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68705. /** @hidden */
  68706. export var lensHighlightsPixelShader: {
  68707. name: string;
  68708. shader: string;
  68709. };
  68710. }
  68711. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68712. /** @hidden */
  68713. export var depthOfFieldPixelShader: {
  68714. name: string;
  68715. shader: string;
  68716. };
  68717. }
  68718. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68719. import { Camera } from "babylonjs/Cameras/camera";
  68720. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68721. import { Scene } from "babylonjs/scene";
  68722. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68723. import "babylonjs/Shaders/chromaticAberration.fragment";
  68724. import "babylonjs/Shaders/lensHighlights.fragment";
  68725. import "babylonjs/Shaders/depthOfField.fragment";
  68726. /**
  68727. * BABYLON.JS Chromatic Aberration GLSL Shader
  68728. * Author: Olivier Guyot
  68729. * Separates very slightly R, G and B colors on the edges of the screen
  68730. * Inspired by Francois Tarlier & Martins Upitis
  68731. */
  68732. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68733. /**
  68734. * @ignore
  68735. * The chromatic aberration PostProcess id in the pipeline
  68736. */
  68737. LensChromaticAberrationEffect: string;
  68738. /**
  68739. * @ignore
  68740. * The highlights enhancing PostProcess id in the pipeline
  68741. */
  68742. HighlightsEnhancingEffect: string;
  68743. /**
  68744. * @ignore
  68745. * The depth-of-field PostProcess id in the pipeline
  68746. */
  68747. LensDepthOfFieldEffect: string;
  68748. private _scene;
  68749. private _depthTexture;
  68750. private _grainTexture;
  68751. private _chromaticAberrationPostProcess;
  68752. private _highlightsPostProcess;
  68753. private _depthOfFieldPostProcess;
  68754. private _edgeBlur;
  68755. private _grainAmount;
  68756. private _chromaticAberration;
  68757. private _distortion;
  68758. private _highlightsGain;
  68759. private _highlightsThreshold;
  68760. private _dofDistance;
  68761. private _dofAperture;
  68762. private _dofDarken;
  68763. private _dofPentagon;
  68764. private _blurNoise;
  68765. /**
  68766. * @constructor
  68767. *
  68768. * Effect parameters are as follow:
  68769. * {
  68770. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68771. * edge_blur: number; // from 0 to x (1 for realism)
  68772. * distortion: number; // from 0 to x (1 for realism)
  68773. * grain_amount: number; // from 0 to 1
  68774. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68775. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68776. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68777. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68778. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68779. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68780. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68781. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68782. * }
  68783. * Note: if an effect parameter is unset, effect is disabled
  68784. *
  68785. * @param name The rendering pipeline name
  68786. * @param parameters - An object containing all parameters (see above)
  68787. * @param scene The scene linked to this pipeline
  68788. * @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)
  68789. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68790. */
  68791. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68792. /**
  68793. * Get the class name
  68794. * @returns "LensRenderingPipeline"
  68795. */
  68796. getClassName(): string;
  68797. /**
  68798. * Gets associated scene
  68799. */
  68800. get scene(): Scene;
  68801. /**
  68802. * Gets or sets the edge blur
  68803. */
  68804. get edgeBlur(): number;
  68805. set edgeBlur(value: number);
  68806. /**
  68807. * Gets or sets the grain amount
  68808. */
  68809. get grainAmount(): number;
  68810. set grainAmount(value: number);
  68811. /**
  68812. * Gets or sets the chromatic aberration amount
  68813. */
  68814. get chromaticAberration(): number;
  68815. set chromaticAberration(value: number);
  68816. /**
  68817. * Gets or sets the depth of field aperture
  68818. */
  68819. get dofAperture(): number;
  68820. set dofAperture(value: number);
  68821. /**
  68822. * Gets or sets the edge distortion
  68823. */
  68824. get edgeDistortion(): number;
  68825. set edgeDistortion(value: number);
  68826. /**
  68827. * Gets or sets the depth of field distortion
  68828. */
  68829. get dofDistortion(): number;
  68830. set dofDistortion(value: number);
  68831. /**
  68832. * Gets or sets the darken out of focus amount
  68833. */
  68834. get darkenOutOfFocus(): number;
  68835. set darkenOutOfFocus(value: number);
  68836. /**
  68837. * Gets or sets a boolean indicating if blur noise is enabled
  68838. */
  68839. get blurNoise(): boolean;
  68840. set blurNoise(value: boolean);
  68841. /**
  68842. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68843. */
  68844. get pentagonBokeh(): boolean;
  68845. set pentagonBokeh(value: boolean);
  68846. /**
  68847. * Gets or sets the highlight grain amount
  68848. */
  68849. get highlightsGain(): number;
  68850. set highlightsGain(value: number);
  68851. /**
  68852. * Gets or sets the highlight threshold
  68853. */
  68854. get highlightsThreshold(): number;
  68855. set highlightsThreshold(value: number);
  68856. /**
  68857. * Sets the amount of blur at the edges
  68858. * @param amount blur amount
  68859. */
  68860. setEdgeBlur(amount: number): void;
  68861. /**
  68862. * Sets edge blur to 0
  68863. */
  68864. disableEdgeBlur(): void;
  68865. /**
  68866. * Sets the amout of grain
  68867. * @param amount Amount of grain
  68868. */
  68869. setGrainAmount(amount: number): void;
  68870. /**
  68871. * Set grain amount to 0
  68872. */
  68873. disableGrain(): void;
  68874. /**
  68875. * Sets the chromatic aberration amount
  68876. * @param amount amount of chromatic aberration
  68877. */
  68878. setChromaticAberration(amount: number): void;
  68879. /**
  68880. * Sets chromatic aberration amount to 0
  68881. */
  68882. disableChromaticAberration(): void;
  68883. /**
  68884. * Sets the EdgeDistortion amount
  68885. * @param amount amount of EdgeDistortion
  68886. */
  68887. setEdgeDistortion(amount: number): void;
  68888. /**
  68889. * Sets edge distortion to 0
  68890. */
  68891. disableEdgeDistortion(): void;
  68892. /**
  68893. * Sets the FocusDistance amount
  68894. * @param amount amount of FocusDistance
  68895. */
  68896. setFocusDistance(amount: number): void;
  68897. /**
  68898. * Disables depth of field
  68899. */
  68900. disableDepthOfField(): void;
  68901. /**
  68902. * Sets the Aperture amount
  68903. * @param amount amount of Aperture
  68904. */
  68905. setAperture(amount: number): void;
  68906. /**
  68907. * Sets the DarkenOutOfFocus amount
  68908. * @param amount amount of DarkenOutOfFocus
  68909. */
  68910. setDarkenOutOfFocus(amount: number): void;
  68911. private _pentagonBokehIsEnabled;
  68912. /**
  68913. * Creates a pentagon bokeh effect
  68914. */
  68915. enablePentagonBokeh(): void;
  68916. /**
  68917. * Disables the pentagon bokeh effect
  68918. */
  68919. disablePentagonBokeh(): void;
  68920. /**
  68921. * Enables noise blur
  68922. */
  68923. enableNoiseBlur(): void;
  68924. /**
  68925. * Disables noise blur
  68926. */
  68927. disableNoiseBlur(): void;
  68928. /**
  68929. * Sets the HighlightsGain amount
  68930. * @param amount amount of HighlightsGain
  68931. */
  68932. setHighlightsGain(amount: number): void;
  68933. /**
  68934. * Sets the HighlightsThreshold amount
  68935. * @param amount amount of HighlightsThreshold
  68936. */
  68937. setHighlightsThreshold(amount: number): void;
  68938. /**
  68939. * Disables highlights
  68940. */
  68941. disableHighlights(): void;
  68942. /**
  68943. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68944. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68945. */
  68946. dispose(disableDepthRender?: boolean): void;
  68947. private _createChromaticAberrationPostProcess;
  68948. private _createHighlightsPostProcess;
  68949. private _createDepthOfFieldPostProcess;
  68950. private _createGrainTexture;
  68951. }
  68952. }
  68953. declare module "babylonjs/Shaders/ssao2.fragment" {
  68954. /** @hidden */
  68955. export var ssao2PixelShader: {
  68956. name: string;
  68957. shader: string;
  68958. };
  68959. }
  68960. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68961. /** @hidden */
  68962. export var ssaoCombinePixelShader: {
  68963. name: string;
  68964. shader: string;
  68965. };
  68966. }
  68967. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68968. import { Camera } from "babylonjs/Cameras/camera";
  68969. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68970. import { Scene } from "babylonjs/scene";
  68971. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68972. import "babylonjs/Shaders/ssao2.fragment";
  68973. import "babylonjs/Shaders/ssaoCombine.fragment";
  68974. /**
  68975. * Render pipeline to produce ssao effect
  68976. */
  68977. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68978. /**
  68979. * @ignore
  68980. * The PassPostProcess id in the pipeline that contains the original scene color
  68981. */
  68982. SSAOOriginalSceneColorEffect: string;
  68983. /**
  68984. * @ignore
  68985. * The SSAO PostProcess id in the pipeline
  68986. */
  68987. SSAORenderEffect: string;
  68988. /**
  68989. * @ignore
  68990. * The horizontal blur PostProcess id in the pipeline
  68991. */
  68992. SSAOBlurHRenderEffect: string;
  68993. /**
  68994. * @ignore
  68995. * The vertical blur PostProcess id in the pipeline
  68996. */
  68997. SSAOBlurVRenderEffect: string;
  68998. /**
  68999. * @ignore
  69000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69001. */
  69002. SSAOCombineRenderEffect: string;
  69003. /**
  69004. * The output strength of the SSAO post-process. Default value is 1.0.
  69005. */
  69006. totalStrength: number;
  69007. /**
  69008. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69009. */
  69010. maxZ: number;
  69011. /**
  69012. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69013. */
  69014. minZAspect: number;
  69015. private _samples;
  69016. /**
  69017. * Number of samples used for the SSAO calculations. Default value is 8
  69018. */
  69019. set samples(n: number);
  69020. get samples(): number;
  69021. private _textureSamples;
  69022. /**
  69023. * Number of samples to use for antialiasing
  69024. */
  69025. set textureSamples(n: number);
  69026. get textureSamples(): number;
  69027. /**
  69028. * Ratio object used for SSAO ratio and blur ratio
  69029. */
  69030. private _ratio;
  69031. /**
  69032. * Dynamically generated sphere sampler.
  69033. */
  69034. private _sampleSphere;
  69035. /**
  69036. * Blur filter offsets
  69037. */
  69038. private _samplerOffsets;
  69039. private _expensiveBlur;
  69040. /**
  69041. * If bilateral blur should be used
  69042. */
  69043. set expensiveBlur(b: boolean);
  69044. get expensiveBlur(): boolean;
  69045. /**
  69046. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69047. */
  69048. radius: number;
  69049. /**
  69050. * The base color of the SSAO post-process
  69051. * The final result is "base + ssao" between [0, 1]
  69052. */
  69053. base: number;
  69054. /**
  69055. * Support test.
  69056. */
  69057. static get IsSupported(): boolean;
  69058. private _scene;
  69059. private _depthTexture;
  69060. private _normalTexture;
  69061. private _randomTexture;
  69062. private _originalColorPostProcess;
  69063. private _ssaoPostProcess;
  69064. private _blurHPostProcess;
  69065. private _blurVPostProcess;
  69066. private _ssaoCombinePostProcess;
  69067. /**
  69068. * Gets active scene
  69069. */
  69070. get scene(): Scene;
  69071. /**
  69072. * @constructor
  69073. * @param name The rendering pipeline name
  69074. * @param scene The scene linked to this pipeline
  69075. * @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 }
  69076. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69077. */
  69078. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69079. /**
  69080. * Get the class name
  69081. * @returns "SSAO2RenderingPipeline"
  69082. */
  69083. getClassName(): string;
  69084. /**
  69085. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69086. */
  69087. dispose(disableGeometryBufferRenderer?: boolean): void;
  69088. private _createBlurPostProcess;
  69089. /** @hidden */
  69090. _rebuild(): void;
  69091. private _bits;
  69092. private _radicalInverse_VdC;
  69093. private _hammersley;
  69094. private _hemisphereSample_uniform;
  69095. private _generateHemisphere;
  69096. private _createSSAOPostProcess;
  69097. private _createSSAOCombinePostProcess;
  69098. private _createRandomTexture;
  69099. /**
  69100. * Serialize the rendering pipeline (Used when exporting)
  69101. * @returns the serialized object
  69102. */
  69103. serialize(): any;
  69104. /**
  69105. * Parse the serialized pipeline
  69106. * @param source Source pipeline.
  69107. * @param scene The scene to load the pipeline to.
  69108. * @param rootUrl The URL of the serialized pipeline.
  69109. * @returns An instantiated pipeline from the serialized object.
  69110. */
  69111. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69112. }
  69113. }
  69114. declare module "babylonjs/Shaders/ssao.fragment" {
  69115. /** @hidden */
  69116. export var ssaoPixelShader: {
  69117. name: string;
  69118. shader: string;
  69119. };
  69120. }
  69121. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69122. import { Camera } from "babylonjs/Cameras/camera";
  69123. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69124. import { Scene } from "babylonjs/scene";
  69125. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69126. import "babylonjs/Shaders/ssao.fragment";
  69127. import "babylonjs/Shaders/ssaoCombine.fragment";
  69128. /**
  69129. * Render pipeline to produce ssao effect
  69130. */
  69131. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69132. /**
  69133. * @ignore
  69134. * The PassPostProcess id in the pipeline that contains the original scene color
  69135. */
  69136. SSAOOriginalSceneColorEffect: string;
  69137. /**
  69138. * @ignore
  69139. * The SSAO PostProcess id in the pipeline
  69140. */
  69141. SSAORenderEffect: string;
  69142. /**
  69143. * @ignore
  69144. * The horizontal blur PostProcess id in the pipeline
  69145. */
  69146. SSAOBlurHRenderEffect: string;
  69147. /**
  69148. * @ignore
  69149. * The vertical blur PostProcess id in the pipeline
  69150. */
  69151. SSAOBlurVRenderEffect: string;
  69152. /**
  69153. * @ignore
  69154. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69155. */
  69156. SSAOCombineRenderEffect: string;
  69157. /**
  69158. * The output strength of the SSAO post-process. Default value is 1.0.
  69159. */
  69160. totalStrength: number;
  69161. /**
  69162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69163. */
  69164. radius: number;
  69165. /**
  69166. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69167. * Must not be equal to fallOff and superior to fallOff.
  69168. * Default value is 0.0075
  69169. */
  69170. area: number;
  69171. /**
  69172. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69173. * Must not be equal to area and inferior to area.
  69174. * Default value is 0.000001
  69175. */
  69176. fallOff: number;
  69177. /**
  69178. * The base color of the SSAO post-process
  69179. * The final result is "base + ssao" between [0, 1]
  69180. */
  69181. base: number;
  69182. private _scene;
  69183. private _depthTexture;
  69184. private _randomTexture;
  69185. private _originalColorPostProcess;
  69186. private _ssaoPostProcess;
  69187. private _blurHPostProcess;
  69188. private _blurVPostProcess;
  69189. private _ssaoCombinePostProcess;
  69190. private _firstUpdate;
  69191. /**
  69192. * Gets active scene
  69193. */
  69194. get scene(): Scene;
  69195. /**
  69196. * @constructor
  69197. * @param name - The rendering pipeline name
  69198. * @param scene - The scene linked to this pipeline
  69199. * @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 }
  69200. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69201. */
  69202. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69203. /**
  69204. * Get the class name
  69205. * @returns "SSAORenderingPipeline"
  69206. */
  69207. getClassName(): string;
  69208. /**
  69209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69210. */
  69211. dispose(disableDepthRender?: boolean): void;
  69212. private _createBlurPostProcess;
  69213. /** @hidden */
  69214. _rebuild(): void;
  69215. private _createSSAOPostProcess;
  69216. private _createSSAOCombinePostProcess;
  69217. private _createRandomTexture;
  69218. }
  69219. }
  69220. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69221. /** @hidden */
  69222. export var screenSpaceReflectionPixelShader: {
  69223. name: string;
  69224. shader: string;
  69225. };
  69226. }
  69227. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69228. import { Nullable } from "babylonjs/types";
  69229. import { Camera } from "babylonjs/Cameras/camera";
  69230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69231. import { Scene } from "babylonjs/scene";
  69232. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69233. import { Engine } from "babylonjs/Engines/engine";
  69234. /**
  69235. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69236. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69237. */
  69238. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69239. /**
  69240. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69241. */
  69242. threshold: number;
  69243. /**
  69244. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69245. */
  69246. strength: number;
  69247. /**
  69248. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69249. */
  69250. reflectionSpecularFalloffExponent: number;
  69251. /**
  69252. * 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]
  69253. */
  69254. step: number;
  69255. /**
  69256. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69257. */
  69258. roughnessFactor: number;
  69259. private _geometryBufferRenderer;
  69260. private _enableSmoothReflections;
  69261. private _reflectionSamples;
  69262. private _smoothSteps;
  69263. /**
  69264. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69265. * @param name The name of the effect.
  69266. * @param scene The scene containing the objects to calculate reflections.
  69267. * @param options The required width/height ratio to downsize to before computing the render pass.
  69268. * @param camera The camera to apply the render pass to.
  69269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69270. * @param engine The engine which the post process will be applied. (default: current engine)
  69271. * @param reusable If the post process can be reused on the same frame. (default: false)
  69272. * @param textureType Type of textures used when performing the post process. (default: 0)
  69273. * @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)
  69274. */
  69275. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69276. /**
  69277. * Gets wether or not smoothing reflections is enabled.
  69278. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69279. */
  69280. get enableSmoothReflections(): boolean;
  69281. /**
  69282. * Sets wether or not smoothing reflections is enabled.
  69283. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69284. */
  69285. set enableSmoothReflections(enabled: boolean);
  69286. /**
  69287. * Gets the number of samples taken while computing reflections. More samples count is high,
  69288. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69289. */
  69290. get reflectionSamples(): number;
  69291. /**
  69292. * Sets the number of samples taken while computing reflections. More samples count is high,
  69293. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69294. */
  69295. set reflectionSamples(samples: number);
  69296. /**
  69297. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69298. * more the post-process will require GPU power and can generate a drop in FPS.
  69299. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69300. */
  69301. get smoothSteps(): number;
  69302. set smoothSteps(steps: number);
  69303. private _updateEffectDefines;
  69304. }
  69305. }
  69306. declare module "babylonjs/Shaders/standard.fragment" {
  69307. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69308. /** @hidden */
  69309. export var standardPixelShader: {
  69310. name: string;
  69311. shader: string;
  69312. };
  69313. }
  69314. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69315. import { Nullable } from "babylonjs/types";
  69316. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69317. import { Camera } from "babylonjs/Cameras/camera";
  69318. import { Texture } from "babylonjs/Materials/Textures/texture";
  69319. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69320. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69321. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69322. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69323. import { IDisposable } from "babylonjs/scene";
  69324. import { SpotLight } from "babylonjs/Lights/spotLight";
  69325. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69326. import { Scene } from "babylonjs/scene";
  69327. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69328. import { Animation } from "babylonjs/Animations/animation";
  69329. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69330. import "babylonjs/Shaders/standard.fragment";
  69331. /**
  69332. * Standard rendering pipeline
  69333. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69334. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69335. */
  69336. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69337. /**
  69338. * Public members
  69339. */
  69340. /**
  69341. * Post-process which contains the original scene color before the pipeline applies all the effects
  69342. */
  69343. originalPostProcess: Nullable<PostProcess>;
  69344. /**
  69345. * Post-process used to down scale an image x4
  69346. */
  69347. downSampleX4PostProcess: Nullable<PostProcess>;
  69348. /**
  69349. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69350. */
  69351. brightPassPostProcess: Nullable<PostProcess>;
  69352. /**
  69353. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69354. */
  69355. blurHPostProcesses: PostProcess[];
  69356. /**
  69357. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69358. */
  69359. blurVPostProcesses: PostProcess[];
  69360. /**
  69361. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69362. */
  69363. textureAdderPostProcess: Nullable<PostProcess>;
  69364. /**
  69365. * Post-process used to create volumetric lighting effect
  69366. */
  69367. volumetricLightPostProcess: Nullable<PostProcess>;
  69368. /**
  69369. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69370. */
  69371. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69372. /**
  69373. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69374. */
  69375. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69376. /**
  69377. * Post-process used to merge the volumetric light effect and the real scene color
  69378. */
  69379. volumetricLightMergePostProces: Nullable<PostProcess>;
  69380. /**
  69381. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69382. */
  69383. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69384. /**
  69385. * Base post-process used to calculate the average luminance of the final image for HDR
  69386. */
  69387. luminancePostProcess: Nullable<PostProcess>;
  69388. /**
  69389. * Post-processes used to create down sample post-processes in order to get
  69390. * the average luminance of the final image for HDR
  69391. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69392. */
  69393. luminanceDownSamplePostProcesses: PostProcess[];
  69394. /**
  69395. * Post-process used to create a HDR effect (light adaptation)
  69396. */
  69397. hdrPostProcess: Nullable<PostProcess>;
  69398. /**
  69399. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69400. */
  69401. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69402. /**
  69403. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69404. */
  69405. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69406. /**
  69407. * Post-process used to merge the final HDR post-process and the real scene color
  69408. */
  69409. hdrFinalPostProcess: Nullable<PostProcess>;
  69410. /**
  69411. * Post-process used to create a lens flare effect
  69412. */
  69413. lensFlarePostProcess: Nullable<PostProcess>;
  69414. /**
  69415. * Post-process that merges the result of the lens flare post-process and the real scene color
  69416. */
  69417. lensFlareComposePostProcess: Nullable<PostProcess>;
  69418. /**
  69419. * Post-process used to create a motion blur effect
  69420. */
  69421. motionBlurPostProcess: Nullable<PostProcess>;
  69422. /**
  69423. * Post-process used to create a depth of field effect
  69424. */
  69425. depthOfFieldPostProcess: Nullable<PostProcess>;
  69426. /**
  69427. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69428. */
  69429. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69430. /**
  69431. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69432. */
  69433. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69434. /**
  69435. * Represents the brightness threshold in order to configure the illuminated surfaces
  69436. */
  69437. brightThreshold: number;
  69438. /**
  69439. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69440. */
  69441. blurWidth: number;
  69442. /**
  69443. * Sets if the blur for highlighted surfaces must be only horizontal
  69444. */
  69445. horizontalBlur: boolean;
  69446. /**
  69447. * Gets the overall exposure used by the pipeline
  69448. */
  69449. get exposure(): number;
  69450. /**
  69451. * Sets the overall exposure used by the pipeline
  69452. */
  69453. set exposure(value: number);
  69454. /**
  69455. * Texture used typically to simulate "dirty" on camera lens
  69456. */
  69457. lensTexture: Nullable<Texture>;
  69458. /**
  69459. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69460. */
  69461. volumetricLightCoefficient: number;
  69462. /**
  69463. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69464. */
  69465. volumetricLightPower: number;
  69466. /**
  69467. * Used the set the blur intensity to smooth the volumetric lights
  69468. */
  69469. volumetricLightBlurScale: number;
  69470. /**
  69471. * Light (spot or directional) used to generate the volumetric lights rays
  69472. * The source light must have a shadow generate so the pipeline can get its
  69473. * depth map
  69474. */
  69475. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69476. /**
  69477. * For eye adaptation, represents the minimum luminance the eye can see
  69478. */
  69479. hdrMinimumLuminance: number;
  69480. /**
  69481. * For eye adaptation, represents the decrease luminance speed
  69482. */
  69483. hdrDecreaseRate: number;
  69484. /**
  69485. * For eye adaptation, represents the increase luminance speed
  69486. */
  69487. hdrIncreaseRate: number;
  69488. /**
  69489. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69490. */
  69491. get hdrAutoExposure(): boolean;
  69492. /**
  69493. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69494. */
  69495. set hdrAutoExposure(value: boolean);
  69496. /**
  69497. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69498. */
  69499. lensColorTexture: Nullable<Texture>;
  69500. /**
  69501. * The overall strengh for the lens flare effect
  69502. */
  69503. lensFlareStrength: number;
  69504. /**
  69505. * Dispersion coefficient for lens flare ghosts
  69506. */
  69507. lensFlareGhostDispersal: number;
  69508. /**
  69509. * Main lens flare halo width
  69510. */
  69511. lensFlareHaloWidth: number;
  69512. /**
  69513. * Based on the lens distortion effect, defines how much the lens flare result
  69514. * is distorted
  69515. */
  69516. lensFlareDistortionStrength: number;
  69517. /**
  69518. * Configures the blur intensity used for for lens flare (halo)
  69519. */
  69520. lensFlareBlurWidth: number;
  69521. /**
  69522. * Lens star texture must be used to simulate rays on the flares and is available
  69523. * in the documentation
  69524. */
  69525. lensStarTexture: Nullable<Texture>;
  69526. /**
  69527. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69528. * flare effect by taking account of the dirt texture
  69529. */
  69530. lensFlareDirtTexture: Nullable<Texture>;
  69531. /**
  69532. * Represents the focal length for the depth of field effect
  69533. */
  69534. depthOfFieldDistance: number;
  69535. /**
  69536. * Represents the blur intensity for the blurred part of the depth of field effect
  69537. */
  69538. depthOfFieldBlurWidth: number;
  69539. /**
  69540. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69541. */
  69542. get motionStrength(): number;
  69543. /**
  69544. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69545. */
  69546. set motionStrength(strength: number);
  69547. /**
  69548. * Gets wether or not the motion blur post-process is object based or screen based.
  69549. */
  69550. get objectBasedMotionBlur(): boolean;
  69551. /**
  69552. * Sets wether or not the motion blur post-process should be object based or screen based
  69553. */
  69554. set objectBasedMotionBlur(value: boolean);
  69555. /**
  69556. * List of animations for the pipeline (IAnimatable implementation)
  69557. */
  69558. animations: Animation[];
  69559. /**
  69560. * Private members
  69561. */
  69562. private _scene;
  69563. private _currentDepthOfFieldSource;
  69564. private _basePostProcess;
  69565. private _fixedExposure;
  69566. private _currentExposure;
  69567. private _hdrAutoExposure;
  69568. private _hdrCurrentLuminance;
  69569. private _motionStrength;
  69570. private _isObjectBasedMotionBlur;
  69571. private _floatTextureType;
  69572. private _camerasToBeAttached;
  69573. private _ratio;
  69574. private _bloomEnabled;
  69575. private _depthOfFieldEnabled;
  69576. private _vlsEnabled;
  69577. private _lensFlareEnabled;
  69578. private _hdrEnabled;
  69579. private _motionBlurEnabled;
  69580. private _fxaaEnabled;
  69581. private _screenSpaceReflectionsEnabled;
  69582. private _motionBlurSamples;
  69583. private _volumetricLightStepsCount;
  69584. private _samples;
  69585. /**
  69586. * @ignore
  69587. * Specifies if the bloom pipeline is enabled
  69588. */
  69589. get BloomEnabled(): boolean;
  69590. set BloomEnabled(enabled: boolean);
  69591. /**
  69592. * @ignore
  69593. * Specifies if the depth of field pipeline is enabed
  69594. */
  69595. get DepthOfFieldEnabled(): boolean;
  69596. set DepthOfFieldEnabled(enabled: boolean);
  69597. /**
  69598. * @ignore
  69599. * Specifies if the lens flare pipeline is enabed
  69600. */
  69601. get LensFlareEnabled(): boolean;
  69602. set LensFlareEnabled(enabled: boolean);
  69603. /**
  69604. * @ignore
  69605. * Specifies if the HDR pipeline is enabled
  69606. */
  69607. get HDREnabled(): boolean;
  69608. set HDREnabled(enabled: boolean);
  69609. /**
  69610. * @ignore
  69611. * Specifies if the volumetric lights scattering effect is enabled
  69612. */
  69613. get VLSEnabled(): boolean;
  69614. set VLSEnabled(enabled: boolean);
  69615. /**
  69616. * @ignore
  69617. * Specifies if the motion blur effect is enabled
  69618. */
  69619. get MotionBlurEnabled(): boolean;
  69620. set MotionBlurEnabled(enabled: boolean);
  69621. /**
  69622. * Specifies if anti-aliasing is enabled
  69623. */
  69624. get fxaaEnabled(): boolean;
  69625. set fxaaEnabled(enabled: boolean);
  69626. /**
  69627. * Specifies if screen space reflections are enabled.
  69628. */
  69629. get screenSpaceReflectionsEnabled(): boolean;
  69630. set screenSpaceReflectionsEnabled(enabled: boolean);
  69631. /**
  69632. * Specifies the number of steps used to calculate the volumetric lights
  69633. * Typically in interval [50, 200]
  69634. */
  69635. get volumetricLightStepsCount(): number;
  69636. set volumetricLightStepsCount(count: number);
  69637. /**
  69638. * Specifies the number of samples used for the motion blur effect
  69639. * Typically in interval [16, 64]
  69640. */
  69641. get motionBlurSamples(): number;
  69642. set motionBlurSamples(samples: number);
  69643. /**
  69644. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69645. */
  69646. get samples(): number;
  69647. set samples(sampleCount: number);
  69648. /**
  69649. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69650. * @constructor
  69651. * @param name The rendering pipeline name
  69652. * @param scene The scene linked to this pipeline
  69653. * @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)
  69654. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69656. */
  69657. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69658. private _buildPipeline;
  69659. private _createDownSampleX4PostProcess;
  69660. private _createBrightPassPostProcess;
  69661. private _createBlurPostProcesses;
  69662. private _createTextureAdderPostProcess;
  69663. private _createVolumetricLightPostProcess;
  69664. private _createLuminancePostProcesses;
  69665. private _createHdrPostProcess;
  69666. private _createLensFlarePostProcess;
  69667. private _createDepthOfFieldPostProcess;
  69668. private _createMotionBlurPostProcess;
  69669. private _getDepthTexture;
  69670. private _disposePostProcesses;
  69671. /**
  69672. * Dispose of the pipeline and stop all post processes
  69673. */
  69674. dispose(): void;
  69675. /**
  69676. * Serialize the rendering pipeline (Used when exporting)
  69677. * @returns the serialized object
  69678. */
  69679. serialize(): any;
  69680. /**
  69681. * Parse the serialized pipeline
  69682. * @param source Source pipeline.
  69683. * @param scene The scene to load the pipeline to.
  69684. * @param rootUrl The URL of the serialized pipeline.
  69685. * @returns An instantiated pipeline from the serialized object.
  69686. */
  69687. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69688. /**
  69689. * Luminance steps
  69690. */
  69691. static LuminanceSteps: number;
  69692. }
  69693. }
  69694. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69695. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69696. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69697. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69698. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69699. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69700. }
  69701. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69702. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69703. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69704. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69705. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69706. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69707. }
  69708. declare module "babylonjs/Shaders/tonemap.fragment" {
  69709. /** @hidden */
  69710. export var tonemapPixelShader: {
  69711. name: string;
  69712. shader: string;
  69713. };
  69714. }
  69715. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69716. import { Camera } from "babylonjs/Cameras/camera";
  69717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69718. import "babylonjs/Shaders/tonemap.fragment";
  69719. import { Engine } from "babylonjs/Engines/engine";
  69720. /** Defines operator used for tonemapping */
  69721. export enum TonemappingOperator {
  69722. /** Hable */
  69723. Hable = 0,
  69724. /** Reinhard */
  69725. Reinhard = 1,
  69726. /** HejiDawson */
  69727. HejiDawson = 2,
  69728. /** Photographic */
  69729. Photographic = 3
  69730. }
  69731. /**
  69732. * Defines a post process to apply tone mapping
  69733. */
  69734. export class TonemapPostProcess extends PostProcess {
  69735. private _operator;
  69736. /** Defines the required exposure adjustement */
  69737. exposureAdjustment: number;
  69738. /**
  69739. * Creates a new TonemapPostProcess
  69740. * @param name defines the name of the postprocess
  69741. * @param _operator defines the operator to use
  69742. * @param exposureAdjustment defines the required exposure adjustement
  69743. * @param camera defines the camera to use (can be null)
  69744. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69745. * @param engine defines the hosting engine (can be ignore if camera is set)
  69746. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69747. */
  69748. constructor(name: string, _operator: TonemappingOperator,
  69749. /** Defines the required exposure adjustement */
  69750. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69751. }
  69752. }
  69753. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69754. /** @hidden */
  69755. export var volumetricLightScatteringPixelShader: {
  69756. name: string;
  69757. shader: string;
  69758. };
  69759. }
  69760. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69761. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69764. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69766. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69767. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69768. /** @hidden */
  69769. export var volumetricLightScatteringPassVertexShader: {
  69770. name: string;
  69771. shader: string;
  69772. };
  69773. }
  69774. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69775. /** @hidden */
  69776. export var volumetricLightScatteringPassPixelShader: {
  69777. name: string;
  69778. shader: string;
  69779. };
  69780. }
  69781. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69782. import { Vector3 } from "babylonjs/Maths/math.vector";
  69783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69784. import { Mesh } from "babylonjs/Meshes/mesh";
  69785. import { Camera } from "babylonjs/Cameras/camera";
  69786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69787. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69788. import { Scene } from "babylonjs/scene";
  69789. import "babylonjs/Meshes/Builders/planeBuilder";
  69790. import "babylonjs/Shaders/depth.vertex";
  69791. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69792. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69793. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69794. import { Engine } from "babylonjs/Engines/engine";
  69795. /**
  69796. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69797. */
  69798. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69799. private _volumetricLightScatteringPass;
  69800. private _volumetricLightScatteringRTT;
  69801. private _viewPort;
  69802. private _screenCoordinates;
  69803. private _cachedDefines;
  69804. /**
  69805. * If not undefined, the mesh position is computed from the attached node position
  69806. */
  69807. attachedNode: {
  69808. position: Vector3;
  69809. };
  69810. /**
  69811. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69812. */
  69813. customMeshPosition: Vector3;
  69814. /**
  69815. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69816. */
  69817. useCustomMeshPosition: boolean;
  69818. /**
  69819. * If the post-process should inverse the light scattering direction
  69820. */
  69821. invert: boolean;
  69822. /**
  69823. * The internal mesh used by the post-process
  69824. */
  69825. mesh: Mesh;
  69826. /**
  69827. * @hidden
  69828. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69829. */
  69830. get useDiffuseColor(): boolean;
  69831. set useDiffuseColor(useDiffuseColor: boolean);
  69832. /**
  69833. * Array containing the excluded meshes not rendered in the internal pass
  69834. */
  69835. excludedMeshes: AbstractMesh[];
  69836. /**
  69837. * Controls the overall intensity of the post-process
  69838. */
  69839. exposure: number;
  69840. /**
  69841. * Dissipates each sample's contribution in range [0, 1]
  69842. */
  69843. decay: number;
  69844. /**
  69845. * Controls the overall intensity of each sample
  69846. */
  69847. weight: number;
  69848. /**
  69849. * Controls the density of each sample
  69850. */
  69851. density: number;
  69852. /**
  69853. * @constructor
  69854. * @param name The post-process name
  69855. * @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)
  69856. * @param camera The camera that the post-process will be attached to
  69857. * @param mesh The mesh used to create the light scattering
  69858. * @param samples The post-process quality, default 100
  69859. * @param samplingModeThe post-process filtering mode
  69860. * @param engine The babylon engine
  69861. * @param reusable If the post-process is reusable
  69862. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69863. */
  69864. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69865. /**
  69866. * Returns the string "VolumetricLightScatteringPostProcess"
  69867. * @returns "VolumetricLightScatteringPostProcess"
  69868. */
  69869. getClassName(): string;
  69870. private _isReady;
  69871. /**
  69872. * Sets the new light position for light scattering effect
  69873. * @param position The new custom light position
  69874. */
  69875. setCustomMeshPosition(position: Vector3): void;
  69876. /**
  69877. * Returns the light position for light scattering effect
  69878. * @return Vector3 The custom light position
  69879. */
  69880. getCustomMeshPosition(): Vector3;
  69881. /**
  69882. * Disposes the internal assets and detaches the post-process from the camera
  69883. */
  69884. dispose(camera: Camera): void;
  69885. /**
  69886. * Returns the render target texture used by the post-process
  69887. * @return the render target texture used by the post-process
  69888. */
  69889. getPass(): RenderTargetTexture;
  69890. private _meshExcluded;
  69891. private _createPass;
  69892. private _updateMeshScreenCoordinates;
  69893. /**
  69894. * Creates a default mesh for the Volumeric Light Scattering post-process
  69895. * @param name The mesh name
  69896. * @param scene The scene where to create the mesh
  69897. * @return the default mesh
  69898. */
  69899. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69900. }
  69901. }
  69902. declare module "babylonjs/PostProcesses/index" {
  69903. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69904. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69905. export * from "babylonjs/PostProcesses/bloomEffect";
  69906. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69907. export * from "babylonjs/PostProcesses/blurPostProcess";
  69908. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69909. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69910. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69911. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69912. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69913. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69914. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69915. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69916. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69917. export * from "babylonjs/PostProcesses/filterPostProcess";
  69918. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69919. export * from "babylonjs/PostProcesses/grainPostProcess";
  69920. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69921. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69922. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69923. export * from "babylonjs/PostProcesses/passPostProcess";
  69924. export * from "babylonjs/PostProcesses/postProcess";
  69925. export * from "babylonjs/PostProcesses/postProcessManager";
  69926. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69927. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69928. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69929. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69930. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69931. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69932. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69933. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69934. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69935. }
  69936. declare module "babylonjs/Probes/index" {
  69937. export * from "babylonjs/Probes/reflectionProbe";
  69938. }
  69939. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69940. import { Scene } from "babylonjs/scene";
  69941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69942. import { SmartArray } from "babylonjs/Misc/smartArray";
  69943. import { ISceneComponent } from "babylonjs/sceneComponent";
  69944. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69945. import "babylonjs/Meshes/Builders/boxBuilder";
  69946. import "babylonjs/Shaders/color.fragment";
  69947. import "babylonjs/Shaders/color.vertex";
  69948. import { Color3 } from "babylonjs/Maths/math.color";
  69949. module "babylonjs/scene" {
  69950. interface Scene {
  69951. /** @hidden (Backing field) */
  69952. _boundingBoxRenderer: BoundingBoxRenderer;
  69953. /** @hidden (Backing field) */
  69954. _forceShowBoundingBoxes: boolean;
  69955. /**
  69956. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69957. */
  69958. forceShowBoundingBoxes: boolean;
  69959. /**
  69960. * Gets the bounding box renderer associated with the scene
  69961. * @returns a BoundingBoxRenderer
  69962. */
  69963. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69964. }
  69965. }
  69966. module "babylonjs/Meshes/abstractMesh" {
  69967. interface AbstractMesh {
  69968. /** @hidden (Backing field) */
  69969. _showBoundingBox: boolean;
  69970. /**
  69971. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69972. */
  69973. showBoundingBox: boolean;
  69974. }
  69975. }
  69976. /**
  69977. * Component responsible of rendering the bounding box of the meshes in a scene.
  69978. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69979. */
  69980. export class BoundingBoxRenderer implements ISceneComponent {
  69981. /**
  69982. * The component name helpfull to identify the component in the list of scene components.
  69983. */
  69984. readonly name: string;
  69985. /**
  69986. * The scene the component belongs to.
  69987. */
  69988. scene: Scene;
  69989. /**
  69990. * Color of the bounding box lines placed in front of an object
  69991. */
  69992. frontColor: Color3;
  69993. /**
  69994. * Color of the bounding box lines placed behind an object
  69995. */
  69996. backColor: Color3;
  69997. /**
  69998. * Defines if the renderer should show the back lines or not
  69999. */
  70000. showBackLines: boolean;
  70001. /**
  70002. * @hidden
  70003. */
  70004. renderList: SmartArray<BoundingBox>;
  70005. private _colorShader;
  70006. private _vertexBuffers;
  70007. private _indexBuffer;
  70008. private _fillIndexBuffer;
  70009. private _fillIndexData;
  70010. /**
  70011. * Instantiates a new bounding box renderer in a scene.
  70012. * @param scene the scene the renderer renders in
  70013. */
  70014. constructor(scene: Scene);
  70015. /**
  70016. * Registers the component in a given scene
  70017. */
  70018. register(): void;
  70019. private _evaluateSubMesh;
  70020. private _activeMesh;
  70021. private _prepareRessources;
  70022. private _createIndexBuffer;
  70023. /**
  70024. * Rebuilds the elements related to this component in case of
  70025. * context lost for instance.
  70026. */
  70027. rebuild(): void;
  70028. /**
  70029. * @hidden
  70030. */
  70031. reset(): void;
  70032. /**
  70033. * Render the bounding boxes of a specific rendering group
  70034. * @param renderingGroupId defines the rendering group to render
  70035. */
  70036. render(renderingGroupId: number): void;
  70037. /**
  70038. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70039. * @param mesh Define the mesh to render the occlusion bounding box for
  70040. */
  70041. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70042. /**
  70043. * Dispose and release the resources attached to this renderer.
  70044. */
  70045. dispose(): void;
  70046. }
  70047. }
  70048. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70049. import { Nullable } from "babylonjs/types";
  70050. import { Scene } from "babylonjs/scene";
  70051. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70052. import { Camera } from "babylonjs/Cameras/camera";
  70053. import { ISceneComponent } from "babylonjs/sceneComponent";
  70054. module "babylonjs/scene" {
  70055. interface Scene {
  70056. /** @hidden (Backing field) */
  70057. _depthRenderer: {
  70058. [id: string]: DepthRenderer;
  70059. };
  70060. /**
  70061. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70062. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70063. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70064. * @returns the created depth renderer
  70065. */
  70066. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70067. /**
  70068. * Disables a depth renderer for a given camera
  70069. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70070. */
  70071. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70072. }
  70073. }
  70074. /**
  70075. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70076. * in several rendering techniques.
  70077. */
  70078. export class DepthRendererSceneComponent implements ISceneComponent {
  70079. /**
  70080. * The component name helpfull to identify the component in the list of scene components.
  70081. */
  70082. readonly name: string;
  70083. /**
  70084. * The scene the component belongs to.
  70085. */
  70086. scene: Scene;
  70087. /**
  70088. * Creates a new instance of the component for the given scene
  70089. * @param scene Defines the scene to register the component in
  70090. */
  70091. constructor(scene: Scene);
  70092. /**
  70093. * Registers the component in a given scene
  70094. */
  70095. register(): void;
  70096. /**
  70097. * Rebuilds the elements related to this component in case of
  70098. * context lost for instance.
  70099. */
  70100. rebuild(): void;
  70101. /**
  70102. * Disposes the component and the associated ressources
  70103. */
  70104. dispose(): void;
  70105. private _gatherRenderTargets;
  70106. private _gatherActiveCameraRenderTargets;
  70107. }
  70108. }
  70109. declare module "babylonjs/Shaders/outline.fragment" {
  70110. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70111. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70112. /** @hidden */
  70113. export var outlinePixelShader: {
  70114. name: string;
  70115. shader: string;
  70116. };
  70117. }
  70118. declare module "babylonjs/Shaders/outline.vertex" {
  70119. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70122. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70123. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70124. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70125. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70126. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70127. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70128. /** @hidden */
  70129. export var outlineVertexShader: {
  70130. name: string;
  70131. shader: string;
  70132. };
  70133. }
  70134. declare module "babylonjs/Rendering/outlineRenderer" {
  70135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70136. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70137. import { Scene } from "babylonjs/scene";
  70138. import { ISceneComponent } from "babylonjs/sceneComponent";
  70139. import "babylonjs/Shaders/outline.fragment";
  70140. import "babylonjs/Shaders/outline.vertex";
  70141. module "babylonjs/scene" {
  70142. interface Scene {
  70143. /** @hidden */
  70144. _outlineRenderer: OutlineRenderer;
  70145. /**
  70146. * Gets the outline renderer associated with the scene
  70147. * @returns a OutlineRenderer
  70148. */
  70149. getOutlineRenderer(): OutlineRenderer;
  70150. }
  70151. }
  70152. module "babylonjs/Meshes/abstractMesh" {
  70153. interface AbstractMesh {
  70154. /** @hidden (Backing field) */
  70155. _renderOutline: boolean;
  70156. /**
  70157. * Gets or sets a boolean indicating if the outline must be rendered as well
  70158. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70159. */
  70160. renderOutline: boolean;
  70161. /** @hidden (Backing field) */
  70162. _renderOverlay: boolean;
  70163. /**
  70164. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70165. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70166. */
  70167. renderOverlay: boolean;
  70168. }
  70169. }
  70170. /**
  70171. * This class is responsible to draw bothe outline/overlay of meshes.
  70172. * It should not be used directly but through the available method on mesh.
  70173. */
  70174. export class OutlineRenderer implements ISceneComponent {
  70175. /**
  70176. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70177. */
  70178. private static _StencilReference;
  70179. /**
  70180. * The name of the component. Each component must have a unique name.
  70181. */
  70182. name: string;
  70183. /**
  70184. * The scene the component belongs to.
  70185. */
  70186. scene: Scene;
  70187. /**
  70188. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70189. */
  70190. zOffset: number;
  70191. private _engine;
  70192. private _effect;
  70193. private _cachedDefines;
  70194. private _savedDepthWrite;
  70195. /**
  70196. * Instantiates a new outline renderer. (There could be only one per scene).
  70197. * @param scene Defines the scene it belongs to
  70198. */
  70199. constructor(scene: Scene);
  70200. /**
  70201. * Register the component to one instance of a scene.
  70202. */
  70203. register(): void;
  70204. /**
  70205. * Rebuilds the elements related to this component in case of
  70206. * context lost for instance.
  70207. */
  70208. rebuild(): void;
  70209. /**
  70210. * Disposes the component and the associated ressources.
  70211. */
  70212. dispose(): void;
  70213. /**
  70214. * Renders the outline in the canvas.
  70215. * @param subMesh Defines the sumesh to render
  70216. * @param batch Defines the batch of meshes in case of instances
  70217. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70218. */
  70219. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70220. /**
  70221. * Returns whether or not the outline renderer is ready for a given submesh.
  70222. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70223. * @param subMesh Defines the submesh to check readyness for
  70224. * @param useInstances Defines wheter wee are trying to render instances or not
  70225. * @returns true if ready otherwise false
  70226. */
  70227. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70228. private _beforeRenderingMesh;
  70229. private _afterRenderingMesh;
  70230. }
  70231. }
  70232. declare module "babylonjs/Rendering/index" {
  70233. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70234. export * from "babylonjs/Rendering/depthRenderer";
  70235. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70236. export * from "babylonjs/Rendering/edgesRenderer";
  70237. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70238. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70239. export * from "babylonjs/Rendering/outlineRenderer";
  70240. export * from "babylonjs/Rendering/renderingGroup";
  70241. export * from "babylonjs/Rendering/renderingManager";
  70242. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70243. }
  70244. declare module "babylonjs/Sprites/ISprites" {
  70245. /**
  70246. * Defines the basic options interface of a Sprite Frame Source Size.
  70247. */
  70248. export interface ISpriteJSONSpriteSourceSize {
  70249. /**
  70250. * number of the original width of the Frame
  70251. */
  70252. w: number;
  70253. /**
  70254. * number of the original height of the Frame
  70255. */
  70256. h: number;
  70257. }
  70258. /**
  70259. * Defines the basic options interface of a Sprite Frame Data.
  70260. */
  70261. export interface ISpriteJSONSpriteFrameData {
  70262. /**
  70263. * number of the x offset of the Frame
  70264. */
  70265. x: number;
  70266. /**
  70267. * number of the y offset of the Frame
  70268. */
  70269. y: number;
  70270. /**
  70271. * number of the width of the Frame
  70272. */
  70273. w: number;
  70274. /**
  70275. * number of the height of the Frame
  70276. */
  70277. h: number;
  70278. }
  70279. /**
  70280. * Defines the basic options interface of a JSON Sprite.
  70281. */
  70282. export interface ISpriteJSONSprite {
  70283. /**
  70284. * string name of the Frame
  70285. */
  70286. filename: string;
  70287. /**
  70288. * ISpriteJSONSpriteFrame basic object of the frame data
  70289. */
  70290. frame: ISpriteJSONSpriteFrameData;
  70291. /**
  70292. * boolean to flag is the frame was rotated.
  70293. */
  70294. rotated: boolean;
  70295. /**
  70296. * boolean to flag is the frame was trimmed.
  70297. */
  70298. trimmed: boolean;
  70299. /**
  70300. * ISpriteJSONSpriteFrame basic object of the source data
  70301. */
  70302. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70303. /**
  70304. * ISpriteJSONSpriteFrame basic object of the source data
  70305. */
  70306. sourceSize: ISpriteJSONSpriteSourceSize;
  70307. }
  70308. /**
  70309. * Defines the basic options interface of a JSON atlas.
  70310. */
  70311. export interface ISpriteJSONAtlas {
  70312. /**
  70313. * Array of objects that contain the frame data.
  70314. */
  70315. frames: Array<ISpriteJSONSprite>;
  70316. /**
  70317. * object basic object containing the sprite meta data.
  70318. */
  70319. meta?: object;
  70320. }
  70321. }
  70322. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70323. /** @hidden */
  70324. export var spriteMapPixelShader: {
  70325. name: string;
  70326. shader: string;
  70327. };
  70328. }
  70329. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70330. /** @hidden */
  70331. export var spriteMapVertexShader: {
  70332. name: string;
  70333. shader: string;
  70334. };
  70335. }
  70336. declare module "babylonjs/Sprites/spriteMap" {
  70337. import { IDisposable, Scene } from "babylonjs/scene";
  70338. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70339. import { Texture } from "babylonjs/Materials/Textures/texture";
  70340. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70341. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70342. import "babylonjs/Meshes/Builders/planeBuilder";
  70343. import "babylonjs/Shaders/spriteMap.fragment";
  70344. import "babylonjs/Shaders/spriteMap.vertex";
  70345. /**
  70346. * Defines the basic options interface of a SpriteMap
  70347. */
  70348. export interface ISpriteMapOptions {
  70349. /**
  70350. * Vector2 of the number of cells in the grid.
  70351. */
  70352. stageSize?: Vector2;
  70353. /**
  70354. * Vector2 of the size of the output plane in World Units.
  70355. */
  70356. outputSize?: Vector2;
  70357. /**
  70358. * Vector3 of the position of the output plane in World Units.
  70359. */
  70360. outputPosition?: Vector3;
  70361. /**
  70362. * Vector3 of the rotation of the output plane.
  70363. */
  70364. outputRotation?: Vector3;
  70365. /**
  70366. * number of layers that the system will reserve in resources.
  70367. */
  70368. layerCount?: number;
  70369. /**
  70370. * number of max animation frames a single cell will reserve in resources.
  70371. */
  70372. maxAnimationFrames?: number;
  70373. /**
  70374. * number cell index of the base tile when the system compiles.
  70375. */
  70376. baseTile?: number;
  70377. /**
  70378. * boolean flip the sprite after its been repositioned by the framing data.
  70379. */
  70380. flipU?: boolean;
  70381. /**
  70382. * Vector3 scalar of the global RGB values of the SpriteMap.
  70383. */
  70384. colorMultiply?: Vector3;
  70385. }
  70386. /**
  70387. * Defines the IDisposable interface in order to be cleanable from resources.
  70388. */
  70389. export interface ISpriteMap extends IDisposable {
  70390. /**
  70391. * String name of the SpriteMap.
  70392. */
  70393. name: string;
  70394. /**
  70395. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70396. */
  70397. atlasJSON: ISpriteJSONAtlas;
  70398. /**
  70399. * Texture of the SpriteMap.
  70400. */
  70401. spriteSheet: Texture;
  70402. /**
  70403. * The parameters to initialize the SpriteMap with.
  70404. */
  70405. options: ISpriteMapOptions;
  70406. }
  70407. /**
  70408. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70409. */
  70410. export class SpriteMap implements ISpriteMap {
  70411. /** The Name of the spriteMap */
  70412. name: string;
  70413. /** The JSON file with the frame and meta data */
  70414. atlasJSON: ISpriteJSONAtlas;
  70415. /** The systems Sprite Sheet Texture */
  70416. spriteSheet: Texture;
  70417. /** Arguments passed with the Constructor */
  70418. options: ISpriteMapOptions;
  70419. /** Public Sprite Storage array, parsed from atlasJSON */
  70420. sprites: Array<ISpriteJSONSprite>;
  70421. /** Returns the Number of Sprites in the System */
  70422. get spriteCount(): number;
  70423. /** Returns the Position of Output Plane*/
  70424. get position(): Vector3;
  70425. /** Returns the Position of Output Plane*/
  70426. set position(v: Vector3);
  70427. /** Returns the Rotation of Output Plane*/
  70428. get rotation(): Vector3;
  70429. /** Returns the Rotation of Output Plane*/
  70430. set rotation(v: Vector3);
  70431. /** Sets the AnimationMap*/
  70432. get animationMap(): RawTexture;
  70433. /** Sets the AnimationMap*/
  70434. set animationMap(v: RawTexture);
  70435. /** Scene that the SpriteMap was created in */
  70436. private _scene;
  70437. /** Texture Buffer of Float32 that holds tile frame data*/
  70438. private _frameMap;
  70439. /** Texture Buffers of Float32 that holds tileMap data*/
  70440. private _tileMaps;
  70441. /** Texture Buffer of Float32 that holds Animation Data*/
  70442. private _animationMap;
  70443. /** Custom ShaderMaterial Central to the System*/
  70444. private _material;
  70445. /** Custom ShaderMaterial Central to the System*/
  70446. private _output;
  70447. /** Systems Time Ticker*/
  70448. private _time;
  70449. /**
  70450. * Creates a new SpriteMap
  70451. * @param name defines the SpriteMaps Name
  70452. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70453. * @param spriteSheet is the Texture that the Sprites are on.
  70454. * @param options a basic deployment configuration
  70455. * @param scene The Scene that the map is deployed on
  70456. */
  70457. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70458. /**
  70459. * Returns tileID location
  70460. * @returns Vector2 the cell position ID
  70461. */
  70462. getTileID(): Vector2;
  70463. /**
  70464. * Gets the UV location of the mouse over the SpriteMap.
  70465. * @returns Vector2 the UV position of the mouse interaction
  70466. */
  70467. getMousePosition(): Vector2;
  70468. /**
  70469. * Creates the "frame" texture Buffer
  70470. * -------------------------------------
  70471. * Structure of frames
  70472. * "filename": "Falling-Water-2.png",
  70473. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70474. * "rotated": true,
  70475. * "trimmed": true,
  70476. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70477. * "sourceSize": {"w":32,"h":32}
  70478. * @returns RawTexture of the frameMap
  70479. */
  70480. private _createFrameBuffer;
  70481. /**
  70482. * Creates the tileMap texture Buffer
  70483. * @param buffer normally and array of numbers, or a false to generate from scratch
  70484. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70485. * @returns RawTexture of the tileMap
  70486. */
  70487. private _createTileBuffer;
  70488. /**
  70489. * Modifies the data of the tileMaps
  70490. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70491. * @param pos is the iVector2 Coordinates of the Tile
  70492. * @param tile The SpriteIndex of the new Tile
  70493. */
  70494. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70495. /**
  70496. * Creates the animationMap texture Buffer
  70497. * @param buffer normally and array of numbers, or a false to generate from scratch
  70498. * @returns RawTexture of the animationMap
  70499. */
  70500. private _createTileAnimationBuffer;
  70501. /**
  70502. * Modifies the data of the animationMap
  70503. * @param cellID is the Index of the Sprite
  70504. * @param _frame is the target Animation frame
  70505. * @param toCell is the Target Index of the next frame of the animation
  70506. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70507. * @param speed is a global scalar of the time variable on the map.
  70508. */
  70509. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70510. /**
  70511. * Exports the .tilemaps file
  70512. */
  70513. saveTileMaps(): void;
  70514. /**
  70515. * Imports the .tilemaps file
  70516. * @param url of the .tilemaps file
  70517. */
  70518. loadTileMaps(url: string): void;
  70519. /**
  70520. * Release associated resources
  70521. */
  70522. dispose(): void;
  70523. }
  70524. }
  70525. declare module "babylonjs/Sprites/spritePackedManager" {
  70526. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70527. import { Scene } from "babylonjs/scene";
  70528. /**
  70529. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70530. * @see http://doc.babylonjs.com/babylon101/sprites
  70531. */
  70532. export class SpritePackedManager extends SpriteManager {
  70533. /** defines the packed manager's name */
  70534. name: string;
  70535. /**
  70536. * Creates a new sprite manager from a packed sprite sheet
  70537. * @param name defines the manager's name
  70538. * @param imgUrl defines the sprite sheet url
  70539. * @param capacity defines the maximum allowed number of sprites
  70540. * @param scene defines the hosting scene
  70541. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70542. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70543. * @param samplingMode defines the smapling mode to use with spritesheet
  70544. * @param fromPacked set to true; do not alter
  70545. */
  70546. constructor(
  70547. /** defines the packed manager's name */
  70548. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70549. }
  70550. }
  70551. declare module "babylonjs/Sprites/index" {
  70552. export * from "babylonjs/Sprites/sprite";
  70553. export * from "babylonjs/Sprites/ISprites";
  70554. export * from "babylonjs/Sprites/spriteManager";
  70555. export * from "babylonjs/Sprites/spriteMap";
  70556. export * from "babylonjs/Sprites/spritePackedManager";
  70557. export * from "babylonjs/Sprites/spriteSceneComponent";
  70558. }
  70559. declare module "babylonjs/States/index" {
  70560. export * from "babylonjs/States/alphaCullingState";
  70561. export * from "babylonjs/States/depthCullingState";
  70562. export * from "babylonjs/States/stencilState";
  70563. }
  70564. declare module "babylonjs/Misc/assetsManager" {
  70565. import { Scene } from "babylonjs/scene";
  70566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70567. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70568. import { Skeleton } from "babylonjs/Bones/skeleton";
  70569. import { Observable } from "babylonjs/Misc/observable";
  70570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70571. import { Texture } from "babylonjs/Materials/Textures/texture";
  70572. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70573. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70574. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70575. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70576. /**
  70577. * Defines the list of states available for a task inside a AssetsManager
  70578. */
  70579. export enum AssetTaskState {
  70580. /**
  70581. * Initialization
  70582. */
  70583. INIT = 0,
  70584. /**
  70585. * Running
  70586. */
  70587. RUNNING = 1,
  70588. /**
  70589. * Done
  70590. */
  70591. DONE = 2,
  70592. /**
  70593. * Error
  70594. */
  70595. ERROR = 3
  70596. }
  70597. /**
  70598. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70599. */
  70600. export abstract class AbstractAssetTask {
  70601. /**
  70602. * Task name
  70603. */ name: string;
  70604. /**
  70605. * Callback called when the task is successful
  70606. */
  70607. onSuccess: (task: any) => void;
  70608. /**
  70609. * Callback called when the task is not successful
  70610. */
  70611. onError: (task: any, message?: string, exception?: any) => void;
  70612. /**
  70613. * Creates a new AssetsManager
  70614. * @param name defines the name of the task
  70615. */
  70616. constructor(
  70617. /**
  70618. * Task name
  70619. */ name: string);
  70620. private _isCompleted;
  70621. private _taskState;
  70622. private _errorObject;
  70623. /**
  70624. * Get if the task is completed
  70625. */
  70626. get isCompleted(): boolean;
  70627. /**
  70628. * Gets the current state of the task
  70629. */
  70630. get taskState(): AssetTaskState;
  70631. /**
  70632. * Gets the current error object (if task is in error)
  70633. */
  70634. get errorObject(): {
  70635. message?: string;
  70636. exception?: any;
  70637. };
  70638. /**
  70639. * Internal only
  70640. * @hidden
  70641. */
  70642. _setErrorObject(message?: string, exception?: any): void;
  70643. /**
  70644. * Execute the current task
  70645. * @param scene defines the scene where you want your assets to be loaded
  70646. * @param onSuccess is a callback called when the task is successfully executed
  70647. * @param onError is a callback called if an error occurs
  70648. */
  70649. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70650. /**
  70651. * Execute the current task
  70652. * @param scene defines the scene where you want your assets to be loaded
  70653. * @param onSuccess is a callback called when the task is successfully executed
  70654. * @param onError is a callback called if an error occurs
  70655. */
  70656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70657. /**
  70658. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70659. * This can be used with failed tasks that have the reason for failure fixed.
  70660. */
  70661. reset(): void;
  70662. private onErrorCallback;
  70663. private onDoneCallback;
  70664. }
  70665. /**
  70666. * Define the interface used by progress events raised during assets loading
  70667. */
  70668. export interface IAssetsProgressEvent {
  70669. /**
  70670. * Defines the number of remaining tasks to process
  70671. */
  70672. remainingCount: number;
  70673. /**
  70674. * Defines the total number of tasks
  70675. */
  70676. totalCount: number;
  70677. /**
  70678. * Defines the task that was just processed
  70679. */
  70680. task: AbstractAssetTask;
  70681. }
  70682. /**
  70683. * Class used to share progress information about assets loading
  70684. */
  70685. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70686. /**
  70687. * Defines the number of remaining tasks to process
  70688. */
  70689. remainingCount: number;
  70690. /**
  70691. * Defines the total number of tasks
  70692. */
  70693. totalCount: number;
  70694. /**
  70695. * Defines the task that was just processed
  70696. */
  70697. task: AbstractAssetTask;
  70698. /**
  70699. * Creates a AssetsProgressEvent
  70700. * @param remainingCount defines the number of remaining tasks to process
  70701. * @param totalCount defines the total number of tasks
  70702. * @param task defines the task that was just processed
  70703. */
  70704. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70705. }
  70706. /**
  70707. * Define a task used by AssetsManager to load meshes
  70708. */
  70709. export class MeshAssetTask extends AbstractAssetTask {
  70710. /**
  70711. * Defines the name of the task
  70712. */
  70713. name: string;
  70714. /**
  70715. * Defines the list of mesh's names you want to load
  70716. */
  70717. meshesNames: any;
  70718. /**
  70719. * Defines the root url to use as a base to load your meshes and associated resources
  70720. */
  70721. rootUrl: string;
  70722. /**
  70723. * Defines the filename of the scene to load from
  70724. */
  70725. sceneFilename: string;
  70726. /**
  70727. * Gets the list of loaded meshes
  70728. */
  70729. loadedMeshes: Array<AbstractMesh>;
  70730. /**
  70731. * Gets the list of loaded particle systems
  70732. */
  70733. loadedParticleSystems: Array<IParticleSystem>;
  70734. /**
  70735. * Gets the list of loaded skeletons
  70736. */
  70737. loadedSkeletons: Array<Skeleton>;
  70738. /**
  70739. * Gets the list of loaded animation groups
  70740. */
  70741. loadedAnimationGroups: Array<AnimationGroup>;
  70742. /**
  70743. * Callback called when the task is successful
  70744. */
  70745. onSuccess: (task: MeshAssetTask) => void;
  70746. /**
  70747. * Callback called when the task is successful
  70748. */
  70749. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70750. /**
  70751. * Creates a new MeshAssetTask
  70752. * @param name defines the name of the task
  70753. * @param meshesNames defines the list of mesh's names you want to load
  70754. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70755. * @param sceneFilename defines the filename of the scene to load from
  70756. */
  70757. constructor(
  70758. /**
  70759. * Defines the name of the task
  70760. */
  70761. name: string,
  70762. /**
  70763. * Defines the list of mesh's names you want to load
  70764. */
  70765. meshesNames: any,
  70766. /**
  70767. * Defines the root url to use as a base to load your meshes and associated resources
  70768. */
  70769. rootUrl: string,
  70770. /**
  70771. * Defines the filename of the scene to load from
  70772. */
  70773. sceneFilename: string);
  70774. /**
  70775. * Execute the current task
  70776. * @param scene defines the scene where you want your assets to be loaded
  70777. * @param onSuccess is a callback called when the task is successfully executed
  70778. * @param onError is a callback called if an error occurs
  70779. */
  70780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70781. }
  70782. /**
  70783. * Define a task used by AssetsManager to load text content
  70784. */
  70785. export class TextFileAssetTask extends AbstractAssetTask {
  70786. /**
  70787. * Defines the name of the task
  70788. */
  70789. name: string;
  70790. /**
  70791. * Defines the location of the file to load
  70792. */
  70793. url: string;
  70794. /**
  70795. * Gets the loaded text string
  70796. */
  70797. text: string;
  70798. /**
  70799. * Callback called when the task is successful
  70800. */
  70801. onSuccess: (task: TextFileAssetTask) => void;
  70802. /**
  70803. * Callback called when the task is successful
  70804. */
  70805. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70806. /**
  70807. * Creates a new TextFileAssetTask object
  70808. * @param name defines the name of the task
  70809. * @param url defines the location of the file to load
  70810. */
  70811. constructor(
  70812. /**
  70813. * Defines the name of the task
  70814. */
  70815. name: string,
  70816. /**
  70817. * Defines the location of the file to load
  70818. */
  70819. url: string);
  70820. /**
  70821. * Execute the current task
  70822. * @param scene defines the scene where you want your assets to be loaded
  70823. * @param onSuccess is a callback called when the task is successfully executed
  70824. * @param onError is a callback called if an error occurs
  70825. */
  70826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70827. }
  70828. /**
  70829. * Define a task used by AssetsManager to load binary data
  70830. */
  70831. export class BinaryFileAssetTask extends AbstractAssetTask {
  70832. /**
  70833. * Defines the name of the task
  70834. */
  70835. name: string;
  70836. /**
  70837. * Defines the location of the file to load
  70838. */
  70839. url: string;
  70840. /**
  70841. * Gets the lodaded data (as an array buffer)
  70842. */
  70843. data: ArrayBuffer;
  70844. /**
  70845. * Callback called when the task is successful
  70846. */
  70847. onSuccess: (task: BinaryFileAssetTask) => void;
  70848. /**
  70849. * Callback called when the task is successful
  70850. */
  70851. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70852. /**
  70853. * Creates a new BinaryFileAssetTask object
  70854. * @param name defines the name of the new task
  70855. * @param url defines the location of the file to load
  70856. */
  70857. constructor(
  70858. /**
  70859. * Defines the name of the task
  70860. */
  70861. name: string,
  70862. /**
  70863. * Defines the location of the file to load
  70864. */
  70865. url: string);
  70866. /**
  70867. * Execute the current task
  70868. * @param scene defines the scene where you want your assets to be loaded
  70869. * @param onSuccess is a callback called when the task is successfully executed
  70870. * @param onError is a callback called if an error occurs
  70871. */
  70872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70873. }
  70874. /**
  70875. * Define a task used by AssetsManager to load images
  70876. */
  70877. export class ImageAssetTask extends AbstractAssetTask {
  70878. /**
  70879. * Defines the name of the task
  70880. */
  70881. name: string;
  70882. /**
  70883. * Defines the location of the image to load
  70884. */
  70885. url: string;
  70886. /**
  70887. * Gets the loaded images
  70888. */
  70889. image: HTMLImageElement;
  70890. /**
  70891. * Callback called when the task is successful
  70892. */
  70893. onSuccess: (task: ImageAssetTask) => void;
  70894. /**
  70895. * Callback called when the task is successful
  70896. */
  70897. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70898. /**
  70899. * Creates a new ImageAssetTask
  70900. * @param name defines the name of the task
  70901. * @param url defines the location of the image to load
  70902. */
  70903. constructor(
  70904. /**
  70905. * Defines the name of the task
  70906. */
  70907. name: string,
  70908. /**
  70909. * Defines the location of the image to load
  70910. */
  70911. url: string);
  70912. /**
  70913. * Execute the current task
  70914. * @param scene defines the scene where you want your assets to be loaded
  70915. * @param onSuccess is a callback called when the task is successfully executed
  70916. * @param onError is a callback called if an error occurs
  70917. */
  70918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70919. }
  70920. /**
  70921. * Defines the interface used by texture loading tasks
  70922. */
  70923. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70924. /**
  70925. * Gets the loaded texture
  70926. */
  70927. texture: TEX;
  70928. }
  70929. /**
  70930. * Define a task used by AssetsManager to load 2D textures
  70931. */
  70932. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70933. /**
  70934. * Defines the name of the task
  70935. */
  70936. name: string;
  70937. /**
  70938. * Defines the location of the file to load
  70939. */
  70940. url: string;
  70941. /**
  70942. * Defines if mipmap should not be generated (default is false)
  70943. */
  70944. noMipmap?: boolean | undefined;
  70945. /**
  70946. * Defines if texture must be inverted on Y axis (default is false)
  70947. */
  70948. invertY?: boolean | undefined;
  70949. /**
  70950. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70951. */
  70952. samplingMode: number;
  70953. /**
  70954. * Gets the loaded texture
  70955. */
  70956. texture: Texture;
  70957. /**
  70958. * Callback called when the task is successful
  70959. */
  70960. onSuccess: (task: TextureAssetTask) => void;
  70961. /**
  70962. * Callback called when the task is successful
  70963. */
  70964. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70965. /**
  70966. * Creates a new TextureAssetTask object
  70967. * @param name defines the name of the task
  70968. * @param url defines the location of the file to load
  70969. * @param noMipmap defines if mipmap should not be generated (default is false)
  70970. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70971. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70972. */
  70973. constructor(
  70974. /**
  70975. * Defines the name of the task
  70976. */
  70977. name: string,
  70978. /**
  70979. * Defines the location of the file to load
  70980. */
  70981. url: string,
  70982. /**
  70983. * Defines if mipmap should not be generated (default is false)
  70984. */
  70985. noMipmap?: boolean | undefined,
  70986. /**
  70987. * Defines if texture must be inverted on Y axis (default is false)
  70988. */
  70989. invertY?: boolean | undefined,
  70990. /**
  70991. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70992. */
  70993. samplingMode?: number);
  70994. /**
  70995. * Execute the current task
  70996. * @param scene defines the scene where you want your assets to be loaded
  70997. * @param onSuccess is a callback called when the task is successfully executed
  70998. * @param onError is a callback called if an error occurs
  70999. */
  71000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71001. }
  71002. /**
  71003. * Define a task used by AssetsManager to load cube textures
  71004. */
  71005. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71006. /**
  71007. * Defines the name of the task
  71008. */
  71009. name: string;
  71010. /**
  71011. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71012. */
  71013. url: string;
  71014. /**
  71015. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71016. */
  71017. extensions?: string[] | undefined;
  71018. /**
  71019. * Defines if mipmaps should not be generated (default is false)
  71020. */
  71021. noMipmap?: boolean | undefined;
  71022. /**
  71023. * Defines the explicit list of files (undefined by default)
  71024. */
  71025. files?: string[] | undefined;
  71026. /**
  71027. * Gets the loaded texture
  71028. */
  71029. texture: CubeTexture;
  71030. /**
  71031. * Callback called when the task is successful
  71032. */
  71033. onSuccess: (task: CubeTextureAssetTask) => void;
  71034. /**
  71035. * Callback called when the task is successful
  71036. */
  71037. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71038. /**
  71039. * Creates a new CubeTextureAssetTask
  71040. * @param name defines the name of the task
  71041. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71042. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71043. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71044. * @param files defines the explicit list of files (undefined by default)
  71045. */
  71046. constructor(
  71047. /**
  71048. * Defines the name of the task
  71049. */
  71050. name: string,
  71051. /**
  71052. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71053. */
  71054. url: string,
  71055. /**
  71056. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71057. */
  71058. extensions?: string[] | undefined,
  71059. /**
  71060. * Defines if mipmaps should not be generated (default is false)
  71061. */
  71062. noMipmap?: boolean | undefined,
  71063. /**
  71064. * Defines the explicit list of files (undefined by default)
  71065. */
  71066. files?: string[] | undefined);
  71067. /**
  71068. * Execute the current task
  71069. * @param scene defines the scene where you want your assets to be loaded
  71070. * @param onSuccess is a callback called when the task is successfully executed
  71071. * @param onError is a callback called if an error occurs
  71072. */
  71073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71074. }
  71075. /**
  71076. * Define a task used by AssetsManager to load HDR cube textures
  71077. */
  71078. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71079. /**
  71080. * Defines the name of the task
  71081. */
  71082. name: string;
  71083. /**
  71084. * Defines the location of the file to load
  71085. */
  71086. url: string;
  71087. /**
  71088. * Defines the desired size (the more it increases the longer the generation will be)
  71089. */
  71090. size: number;
  71091. /**
  71092. * Defines if mipmaps should not be generated (default is false)
  71093. */
  71094. noMipmap: boolean;
  71095. /**
  71096. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71097. */
  71098. generateHarmonics: boolean;
  71099. /**
  71100. * 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)
  71101. */
  71102. gammaSpace: boolean;
  71103. /**
  71104. * Internal Use Only
  71105. */
  71106. reserved: boolean;
  71107. /**
  71108. * Gets the loaded texture
  71109. */
  71110. texture: HDRCubeTexture;
  71111. /**
  71112. * Callback called when the task is successful
  71113. */
  71114. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71115. /**
  71116. * Callback called when the task is successful
  71117. */
  71118. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71119. /**
  71120. * Creates a new HDRCubeTextureAssetTask object
  71121. * @param name defines the name of the task
  71122. * @param url defines the location of the file to load
  71123. * @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.
  71124. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71125. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71126. * @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)
  71127. * @param reserved Internal use only
  71128. */
  71129. constructor(
  71130. /**
  71131. * Defines the name of the task
  71132. */
  71133. name: string,
  71134. /**
  71135. * Defines the location of the file to load
  71136. */
  71137. url: string,
  71138. /**
  71139. * Defines the desired size (the more it increases the longer the generation will be)
  71140. */
  71141. size: number,
  71142. /**
  71143. * Defines if mipmaps should not be generated (default is false)
  71144. */
  71145. noMipmap?: boolean,
  71146. /**
  71147. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71148. */
  71149. generateHarmonics?: boolean,
  71150. /**
  71151. * 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)
  71152. */
  71153. gammaSpace?: boolean,
  71154. /**
  71155. * Internal Use Only
  71156. */
  71157. reserved?: boolean);
  71158. /**
  71159. * Execute the current task
  71160. * @param scene defines the scene where you want your assets to be loaded
  71161. * @param onSuccess is a callback called when the task is successfully executed
  71162. * @param onError is a callback called if an error occurs
  71163. */
  71164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71165. }
  71166. /**
  71167. * Define a task used by AssetsManager to load Equirectangular cube textures
  71168. */
  71169. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71170. /**
  71171. * Defines the name of the task
  71172. */
  71173. name: string;
  71174. /**
  71175. * Defines the location of the file to load
  71176. */
  71177. url: string;
  71178. /**
  71179. * Defines the desired size (the more it increases the longer the generation will be)
  71180. */
  71181. size: number;
  71182. /**
  71183. * Defines if mipmaps should not be generated (default is false)
  71184. */
  71185. noMipmap: boolean;
  71186. /**
  71187. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71188. * but the standard material would require them in Gamma space) (default is true)
  71189. */
  71190. gammaSpace: boolean;
  71191. /**
  71192. * Gets the loaded texture
  71193. */
  71194. texture: EquiRectangularCubeTexture;
  71195. /**
  71196. * Callback called when the task is successful
  71197. */
  71198. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71199. /**
  71200. * Callback called when the task is successful
  71201. */
  71202. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71203. /**
  71204. * Creates a new EquiRectangularCubeTextureAssetTask object
  71205. * @param name defines the name of the task
  71206. * @param url defines the location of the file to load
  71207. * @param size defines the desired size (the more it increases the longer the generation will be)
  71208. * If the size is omitted this implies you are using a preprocessed cubemap.
  71209. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71210. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71211. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71212. * (default is true)
  71213. */
  71214. constructor(
  71215. /**
  71216. * Defines the name of the task
  71217. */
  71218. name: string,
  71219. /**
  71220. * Defines the location of the file to load
  71221. */
  71222. url: string,
  71223. /**
  71224. * Defines the desired size (the more it increases the longer the generation will be)
  71225. */
  71226. size: number,
  71227. /**
  71228. * Defines if mipmaps should not be generated (default is false)
  71229. */
  71230. noMipmap?: boolean,
  71231. /**
  71232. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71233. * but the standard material would require them in Gamma space) (default is true)
  71234. */
  71235. gammaSpace?: boolean);
  71236. /**
  71237. * Execute the current task
  71238. * @param scene defines the scene where you want your assets to be loaded
  71239. * @param onSuccess is a callback called when the task is successfully executed
  71240. * @param onError is a callback called if an error occurs
  71241. */
  71242. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71243. }
  71244. /**
  71245. * This class can be used to easily import assets into a scene
  71246. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71247. */
  71248. export class AssetsManager {
  71249. private _scene;
  71250. private _isLoading;
  71251. protected _tasks: AbstractAssetTask[];
  71252. protected _waitingTasksCount: number;
  71253. protected _totalTasksCount: number;
  71254. /**
  71255. * Callback called when all tasks are processed
  71256. */
  71257. onFinish: (tasks: AbstractAssetTask[]) => void;
  71258. /**
  71259. * Callback called when a task is successful
  71260. */
  71261. onTaskSuccess: (task: AbstractAssetTask) => void;
  71262. /**
  71263. * Callback called when a task had an error
  71264. */
  71265. onTaskError: (task: AbstractAssetTask) => void;
  71266. /**
  71267. * Callback called when a task is done (whatever the result is)
  71268. */
  71269. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71270. /**
  71271. * Observable called when all tasks are processed
  71272. */
  71273. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71274. /**
  71275. * Observable called when a task had an error
  71276. */
  71277. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71278. /**
  71279. * Observable called when all tasks were executed
  71280. */
  71281. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71282. /**
  71283. * Observable called when a task is done (whatever the result is)
  71284. */
  71285. onProgressObservable: Observable<IAssetsProgressEvent>;
  71286. /**
  71287. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71289. */
  71290. useDefaultLoadingScreen: boolean;
  71291. /**
  71292. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71293. * when all assets have been downloaded.
  71294. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71295. */
  71296. autoHideLoadingUI: boolean;
  71297. /**
  71298. * Creates a new AssetsManager
  71299. * @param scene defines the scene to work on
  71300. */
  71301. constructor(scene: Scene);
  71302. /**
  71303. * Add a MeshAssetTask to the list of active tasks
  71304. * @param taskName defines the name of the new task
  71305. * @param meshesNames defines the name of meshes to load
  71306. * @param rootUrl defines the root url to use to locate files
  71307. * @param sceneFilename defines the filename of the scene file
  71308. * @returns a new MeshAssetTask object
  71309. */
  71310. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71311. /**
  71312. * Add a TextFileAssetTask to the list of active tasks
  71313. * @param taskName defines the name of the new task
  71314. * @param url defines the url of the file to load
  71315. * @returns a new TextFileAssetTask object
  71316. */
  71317. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71318. /**
  71319. * Add a BinaryFileAssetTask to the list of active tasks
  71320. * @param taskName defines the name of the new task
  71321. * @param url defines the url of the file to load
  71322. * @returns a new BinaryFileAssetTask object
  71323. */
  71324. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71325. /**
  71326. * Add a ImageAssetTask to the list of active tasks
  71327. * @param taskName defines the name of the new task
  71328. * @param url defines the url of the file to load
  71329. * @returns a new ImageAssetTask object
  71330. */
  71331. addImageTask(taskName: string, url: string): ImageAssetTask;
  71332. /**
  71333. * Add a TextureAssetTask to the list of active tasks
  71334. * @param taskName defines the name of the new task
  71335. * @param url defines the url of the file to load
  71336. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71337. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71338. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71339. * @returns a new TextureAssetTask object
  71340. */
  71341. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71342. /**
  71343. * Add a CubeTextureAssetTask to the list of active tasks
  71344. * @param taskName defines the name of the new task
  71345. * @param url defines the url of the file to load
  71346. * @param extensions defines the extension to use to load the cube map (can be null)
  71347. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71348. * @param files defines the list of files to load (can be null)
  71349. * @returns a new CubeTextureAssetTask object
  71350. */
  71351. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71352. /**
  71353. *
  71354. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71355. * @param taskName defines the name of the new task
  71356. * @param url defines the url of the file to load
  71357. * @param size defines the size you want for the cubemap (can be null)
  71358. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71359. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71360. * @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)
  71361. * @param reserved Internal use only
  71362. * @returns a new HDRCubeTextureAssetTask object
  71363. */
  71364. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71365. /**
  71366. *
  71367. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71368. * @param taskName defines the name of the new task
  71369. * @param url defines the url of the file to load
  71370. * @param size defines the size you want for the cubemap (can be null)
  71371. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71372. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71373. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71374. * @returns a new EquiRectangularCubeTextureAssetTask object
  71375. */
  71376. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71377. /**
  71378. * Remove a task from the assets manager.
  71379. * @param task the task to remove
  71380. */
  71381. removeTask(task: AbstractAssetTask): void;
  71382. private _decreaseWaitingTasksCount;
  71383. private _runTask;
  71384. /**
  71385. * Reset the AssetsManager and remove all tasks
  71386. * @return the current instance of the AssetsManager
  71387. */
  71388. reset(): AssetsManager;
  71389. /**
  71390. * Start the loading process
  71391. * @return the current instance of the AssetsManager
  71392. */
  71393. load(): AssetsManager;
  71394. /**
  71395. * Start the loading process as an async operation
  71396. * @return a promise returning the list of failed tasks
  71397. */
  71398. loadAsync(): Promise<void>;
  71399. }
  71400. }
  71401. declare module "babylonjs/Misc/deferred" {
  71402. /**
  71403. * Wrapper class for promise with external resolve and reject.
  71404. */
  71405. export class Deferred<T> {
  71406. /**
  71407. * The promise associated with this deferred object.
  71408. */
  71409. readonly promise: Promise<T>;
  71410. private _resolve;
  71411. private _reject;
  71412. /**
  71413. * The resolve method of the promise associated with this deferred object.
  71414. */
  71415. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71416. /**
  71417. * The reject method of the promise associated with this deferred object.
  71418. */
  71419. get reject(): (reason?: any) => void;
  71420. /**
  71421. * Constructor for this deferred object.
  71422. */
  71423. constructor();
  71424. }
  71425. }
  71426. declare module "babylonjs/Misc/meshExploder" {
  71427. import { Mesh } from "babylonjs/Meshes/mesh";
  71428. /**
  71429. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71430. */
  71431. export class MeshExploder {
  71432. private _centerMesh;
  71433. private _meshes;
  71434. private _meshesOrigins;
  71435. private _toCenterVectors;
  71436. private _scaledDirection;
  71437. private _newPosition;
  71438. private _centerPosition;
  71439. /**
  71440. * Explodes meshes from a center mesh.
  71441. * @param meshes The meshes to explode.
  71442. * @param centerMesh The mesh to be center of explosion.
  71443. */
  71444. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71445. private _setCenterMesh;
  71446. /**
  71447. * Get class name
  71448. * @returns "MeshExploder"
  71449. */
  71450. getClassName(): string;
  71451. /**
  71452. * "Exploded meshes"
  71453. * @returns Array of meshes with the centerMesh at index 0.
  71454. */
  71455. getMeshes(): Array<Mesh>;
  71456. /**
  71457. * Explodes meshes giving a specific direction
  71458. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71459. */
  71460. explode(direction?: number): void;
  71461. }
  71462. }
  71463. declare module "babylonjs/Misc/filesInput" {
  71464. import { Engine } from "babylonjs/Engines/engine";
  71465. import { Scene } from "babylonjs/scene";
  71466. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71467. /**
  71468. * Class used to help managing file picking and drag'n'drop
  71469. */
  71470. export class FilesInput {
  71471. /**
  71472. * List of files ready to be loaded
  71473. */
  71474. static get FilesToLoad(): {
  71475. [key: string]: File;
  71476. };
  71477. /**
  71478. * Callback called when a file is processed
  71479. */
  71480. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71481. private _engine;
  71482. private _currentScene;
  71483. private _sceneLoadedCallback;
  71484. private _progressCallback;
  71485. private _additionalRenderLoopLogicCallback;
  71486. private _textureLoadingCallback;
  71487. private _startingProcessingFilesCallback;
  71488. private _onReloadCallback;
  71489. private _errorCallback;
  71490. private _elementToMonitor;
  71491. private _sceneFileToLoad;
  71492. private _filesToLoad;
  71493. /**
  71494. * Creates a new FilesInput
  71495. * @param engine defines the rendering engine
  71496. * @param scene defines the hosting scene
  71497. * @param sceneLoadedCallback callback called when scene is loaded
  71498. * @param progressCallback callback called to track progress
  71499. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71500. * @param textureLoadingCallback callback called when a texture is loading
  71501. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71502. * @param onReloadCallback callback called when a reload is requested
  71503. * @param errorCallback callback call if an error occurs
  71504. */
  71505. 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);
  71506. private _dragEnterHandler;
  71507. private _dragOverHandler;
  71508. private _dropHandler;
  71509. /**
  71510. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71511. * @param elementToMonitor defines the DOM element to track
  71512. */
  71513. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71514. /**
  71515. * Release all associated resources
  71516. */
  71517. dispose(): void;
  71518. private renderFunction;
  71519. private drag;
  71520. private drop;
  71521. private _traverseFolder;
  71522. private _processFiles;
  71523. /**
  71524. * Load files from a drop event
  71525. * @param event defines the drop event to use as source
  71526. */
  71527. loadFiles(event: any): void;
  71528. private _processReload;
  71529. /**
  71530. * Reload the current scene from the loaded files
  71531. */
  71532. reload(): void;
  71533. }
  71534. }
  71535. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71536. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71537. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71538. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71539. }
  71540. declare module "babylonjs/Misc/sceneOptimizer" {
  71541. import { Scene, IDisposable } from "babylonjs/scene";
  71542. import { Observable } from "babylonjs/Misc/observable";
  71543. /**
  71544. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71546. */
  71547. export class SceneOptimization {
  71548. /**
  71549. * Defines the priority of this optimization (0 by default which means first in the list)
  71550. */
  71551. priority: number;
  71552. /**
  71553. * Gets a string describing the action executed by the current optimization
  71554. * @returns description string
  71555. */
  71556. getDescription(): string;
  71557. /**
  71558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71559. * @param scene defines the current scene where to apply this optimization
  71560. * @param optimizer defines the current optimizer
  71561. * @returns true if everything that can be done was applied
  71562. */
  71563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71564. /**
  71565. * Creates the SceneOptimization object
  71566. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71567. * @param desc defines the description associated with the optimization
  71568. */
  71569. constructor(
  71570. /**
  71571. * Defines the priority of this optimization (0 by default which means first in the list)
  71572. */
  71573. priority?: number);
  71574. }
  71575. /**
  71576. * Defines an optimization used to reduce the size of render target textures
  71577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71578. */
  71579. export class TextureOptimization extends SceneOptimization {
  71580. /**
  71581. * Defines the priority of this optimization (0 by default which means first in the list)
  71582. */
  71583. priority: number;
  71584. /**
  71585. * 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
  71586. */
  71587. maximumSize: number;
  71588. /**
  71589. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71590. */
  71591. step: number;
  71592. /**
  71593. * Gets a string describing the action executed by the current optimization
  71594. * @returns description string
  71595. */
  71596. getDescription(): string;
  71597. /**
  71598. * Creates the TextureOptimization object
  71599. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71600. * @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
  71601. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71602. */
  71603. constructor(
  71604. /**
  71605. * Defines the priority of this optimization (0 by default which means first in the list)
  71606. */
  71607. priority?: number,
  71608. /**
  71609. * 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
  71610. */
  71611. maximumSize?: number,
  71612. /**
  71613. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71614. */
  71615. step?: number);
  71616. /**
  71617. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71618. * @param scene defines the current scene where to apply this optimization
  71619. * @param optimizer defines the current optimizer
  71620. * @returns true if everything that can be done was applied
  71621. */
  71622. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71623. }
  71624. /**
  71625. * Defines an optimization used to increase or decrease the rendering resolution
  71626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71627. */
  71628. export class HardwareScalingOptimization extends SceneOptimization {
  71629. /**
  71630. * Defines the priority of this optimization (0 by default which means first in the list)
  71631. */
  71632. priority: number;
  71633. /**
  71634. * Defines the maximum scale to use (2 by default)
  71635. */
  71636. maximumScale: number;
  71637. /**
  71638. * Defines the step to use between two passes (0.5 by default)
  71639. */
  71640. step: number;
  71641. private _currentScale;
  71642. private _directionOffset;
  71643. /**
  71644. * Gets a string describing the action executed by the current optimization
  71645. * @return description string
  71646. */
  71647. getDescription(): string;
  71648. /**
  71649. * Creates the HardwareScalingOptimization object
  71650. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71651. * @param maximumScale defines the maximum scale to use (2 by default)
  71652. * @param step defines the step to use between two passes (0.5 by default)
  71653. */
  71654. constructor(
  71655. /**
  71656. * Defines the priority of this optimization (0 by default which means first in the list)
  71657. */
  71658. priority?: number,
  71659. /**
  71660. * Defines the maximum scale to use (2 by default)
  71661. */
  71662. maximumScale?: number,
  71663. /**
  71664. * Defines the step to use between two passes (0.5 by default)
  71665. */
  71666. step?: number);
  71667. /**
  71668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71669. * @param scene defines the current scene where to apply this optimization
  71670. * @param optimizer defines the current optimizer
  71671. * @returns true if everything that can be done was applied
  71672. */
  71673. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71674. }
  71675. /**
  71676. * Defines an optimization used to remove shadows
  71677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71678. */
  71679. export class ShadowsOptimization extends SceneOptimization {
  71680. /**
  71681. * Gets a string describing the action executed by the current optimization
  71682. * @return description string
  71683. */
  71684. getDescription(): string;
  71685. /**
  71686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71687. * @param scene defines the current scene where to apply this optimization
  71688. * @param optimizer defines the current optimizer
  71689. * @returns true if everything that can be done was applied
  71690. */
  71691. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71692. }
  71693. /**
  71694. * Defines an optimization used to turn post-processes off
  71695. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71696. */
  71697. export class PostProcessesOptimization extends SceneOptimization {
  71698. /**
  71699. * Gets a string describing the action executed by the current optimization
  71700. * @return description string
  71701. */
  71702. getDescription(): string;
  71703. /**
  71704. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71705. * @param scene defines the current scene where to apply this optimization
  71706. * @param optimizer defines the current optimizer
  71707. * @returns true if everything that can be done was applied
  71708. */
  71709. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71710. }
  71711. /**
  71712. * Defines an optimization used to turn lens flares off
  71713. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71714. */
  71715. export class LensFlaresOptimization extends SceneOptimization {
  71716. /**
  71717. * Gets a string describing the action executed by the current optimization
  71718. * @return description string
  71719. */
  71720. getDescription(): string;
  71721. /**
  71722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71723. * @param scene defines the current scene where to apply this optimization
  71724. * @param optimizer defines the current optimizer
  71725. * @returns true if everything that can be done was applied
  71726. */
  71727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71728. }
  71729. /**
  71730. * Defines an optimization based on user defined callback.
  71731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71732. */
  71733. export class CustomOptimization extends SceneOptimization {
  71734. /**
  71735. * Callback called to apply the custom optimization.
  71736. */
  71737. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71738. /**
  71739. * Callback called to get custom description
  71740. */
  71741. onGetDescription: () => string;
  71742. /**
  71743. * Gets a string describing the action executed by the current optimization
  71744. * @returns description string
  71745. */
  71746. getDescription(): string;
  71747. /**
  71748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71749. * @param scene defines the current scene where to apply this optimization
  71750. * @param optimizer defines the current optimizer
  71751. * @returns true if everything that can be done was applied
  71752. */
  71753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71754. }
  71755. /**
  71756. * Defines an optimization used to turn particles off
  71757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71758. */
  71759. export class ParticlesOptimization extends SceneOptimization {
  71760. /**
  71761. * Gets a string describing the action executed by the current optimization
  71762. * @return description string
  71763. */
  71764. getDescription(): string;
  71765. /**
  71766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71767. * @param scene defines the current scene where to apply this optimization
  71768. * @param optimizer defines the current optimizer
  71769. * @returns true if everything that can be done was applied
  71770. */
  71771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71772. }
  71773. /**
  71774. * Defines an optimization used to turn render targets off
  71775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71776. */
  71777. export class RenderTargetsOptimization extends SceneOptimization {
  71778. /**
  71779. * Gets a string describing the action executed by the current optimization
  71780. * @return description string
  71781. */
  71782. getDescription(): string;
  71783. /**
  71784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71785. * @param scene defines the current scene where to apply this optimization
  71786. * @param optimizer defines the current optimizer
  71787. * @returns true if everything that can be done was applied
  71788. */
  71789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71790. }
  71791. /**
  71792. * Defines an optimization used to merge meshes with compatible materials
  71793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71794. */
  71795. export class MergeMeshesOptimization extends SceneOptimization {
  71796. private static _UpdateSelectionTree;
  71797. /**
  71798. * Gets or sets a boolean which defines if optimization octree has to be updated
  71799. */
  71800. static get UpdateSelectionTree(): boolean;
  71801. /**
  71802. * Gets or sets a boolean which defines if optimization octree has to be updated
  71803. */
  71804. static set UpdateSelectionTree(value: boolean);
  71805. /**
  71806. * Gets a string describing the action executed by the current optimization
  71807. * @return description string
  71808. */
  71809. getDescription(): string;
  71810. private _canBeMerged;
  71811. /**
  71812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71813. * @param scene defines the current scene where to apply this optimization
  71814. * @param optimizer defines the current optimizer
  71815. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71816. * @returns true if everything that can be done was applied
  71817. */
  71818. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71819. }
  71820. /**
  71821. * Defines a list of options used by SceneOptimizer
  71822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71823. */
  71824. export class SceneOptimizerOptions {
  71825. /**
  71826. * Defines the target frame rate to reach (60 by default)
  71827. */
  71828. targetFrameRate: number;
  71829. /**
  71830. * Defines the interval between two checkes (2000ms by default)
  71831. */
  71832. trackerDuration: number;
  71833. /**
  71834. * Gets the list of optimizations to apply
  71835. */
  71836. optimizations: SceneOptimization[];
  71837. /**
  71838. * Creates a new list of options used by SceneOptimizer
  71839. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71840. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71841. */
  71842. constructor(
  71843. /**
  71844. * Defines the target frame rate to reach (60 by default)
  71845. */
  71846. targetFrameRate?: number,
  71847. /**
  71848. * Defines the interval between two checkes (2000ms by default)
  71849. */
  71850. trackerDuration?: number);
  71851. /**
  71852. * Add a new optimization
  71853. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71854. * @returns the current SceneOptimizerOptions
  71855. */
  71856. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71857. /**
  71858. * Add a new custom optimization
  71859. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71860. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71861. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71862. * @returns the current SceneOptimizerOptions
  71863. */
  71864. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71865. /**
  71866. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71867. * @param targetFrameRate defines the target frame rate (60 by default)
  71868. * @returns a SceneOptimizerOptions object
  71869. */
  71870. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71871. /**
  71872. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71873. * @param targetFrameRate defines the target frame rate (60 by default)
  71874. * @returns a SceneOptimizerOptions object
  71875. */
  71876. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71877. /**
  71878. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71879. * @param targetFrameRate defines the target frame rate (60 by default)
  71880. * @returns a SceneOptimizerOptions object
  71881. */
  71882. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71883. }
  71884. /**
  71885. * Class used to run optimizations in order to reach a target frame rate
  71886. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71887. */
  71888. export class SceneOptimizer implements IDisposable {
  71889. private _isRunning;
  71890. private _options;
  71891. private _scene;
  71892. private _currentPriorityLevel;
  71893. private _targetFrameRate;
  71894. private _trackerDuration;
  71895. private _currentFrameRate;
  71896. private _sceneDisposeObserver;
  71897. private _improvementMode;
  71898. /**
  71899. * Defines an observable called when the optimizer reaches the target frame rate
  71900. */
  71901. onSuccessObservable: Observable<SceneOptimizer>;
  71902. /**
  71903. * Defines an observable called when the optimizer enables an optimization
  71904. */
  71905. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71906. /**
  71907. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71908. */
  71909. onFailureObservable: Observable<SceneOptimizer>;
  71910. /**
  71911. * Gets a boolean indicating if the optimizer is in improvement mode
  71912. */
  71913. get isInImprovementMode(): boolean;
  71914. /**
  71915. * Gets the current priority level (0 at start)
  71916. */
  71917. get currentPriorityLevel(): number;
  71918. /**
  71919. * Gets the current frame rate checked by the SceneOptimizer
  71920. */
  71921. get currentFrameRate(): number;
  71922. /**
  71923. * Gets or sets the current target frame rate (60 by default)
  71924. */
  71925. get targetFrameRate(): number;
  71926. /**
  71927. * Gets or sets the current target frame rate (60 by default)
  71928. */
  71929. set targetFrameRate(value: number);
  71930. /**
  71931. * Gets or sets the current interval between two checks (every 2000ms by default)
  71932. */
  71933. get trackerDuration(): number;
  71934. /**
  71935. * Gets or sets the current interval between two checks (every 2000ms by default)
  71936. */
  71937. set trackerDuration(value: number);
  71938. /**
  71939. * Gets the list of active optimizations
  71940. */
  71941. get optimizations(): SceneOptimization[];
  71942. /**
  71943. * Creates a new SceneOptimizer
  71944. * @param scene defines the scene to work on
  71945. * @param options defines the options to use with the SceneOptimizer
  71946. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71947. * @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)
  71948. */
  71949. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71950. /**
  71951. * Stops the current optimizer
  71952. */
  71953. stop(): void;
  71954. /**
  71955. * Reset the optimizer to initial step (current priority level = 0)
  71956. */
  71957. reset(): void;
  71958. /**
  71959. * Start the optimizer. By default it will try to reach a specific framerate
  71960. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71961. */
  71962. start(): void;
  71963. private _checkCurrentState;
  71964. /**
  71965. * Release all resources
  71966. */
  71967. dispose(): void;
  71968. /**
  71969. * Helper function to create a SceneOptimizer with one single line of code
  71970. * @param scene defines the scene to work on
  71971. * @param options defines the options to use with the SceneOptimizer
  71972. * @param onSuccess defines a callback to call on success
  71973. * @param onFailure defines a callback to call on failure
  71974. * @returns the new SceneOptimizer object
  71975. */
  71976. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71977. }
  71978. }
  71979. declare module "babylonjs/Misc/sceneSerializer" {
  71980. import { Scene } from "babylonjs/scene";
  71981. /**
  71982. * Class used to serialize a scene into a string
  71983. */
  71984. export class SceneSerializer {
  71985. /**
  71986. * Clear cache used by a previous serialization
  71987. */
  71988. static ClearCache(): void;
  71989. /**
  71990. * Serialize a scene into a JSON compatible object
  71991. * @param scene defines the scene to serialize
  71992. * @returns a JSON compatible object
  71993. */
  71994. static Serialize(scene: Scene): any;
  71995. /**
  71996. * Serialize a mesh into a JSON compatible object
  71997. * @param toSerialize defines the mesh to serialize
  71998. * @param withParents defines if parents must be serialized as well
  71999. * @param withChildren defines if children must be serialized as well
  72000. * @returns a JSON compatible object
  72001. */
  72002. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72003. }
  72004. }
  72005. declare module "babylonjs/Misc/textureTools" {
  72006. import { Texture } from "babylonjs/Materials/Textures/texture";
  72007. /**
  72008. * Class used to host texture specific utilities
  72009. */
  72010. export class TextureTools {
  72011. /**
  72012. * Uses the GPU to create a copy texture rescaled at a given size
  72013. * @param texture Texture to copy from
  72014. * @param width defines the desired width
  72015. * @param height defines the desired height
  72016. * @param useBilinearMode defines if bilinear mode has to be used
  72017. * @return the generated texture
  72018. */
  72019. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72020. }
  72021. }
  72022. declare module "babylonjs/Misc/videoRecorder" {
  72023. import { Nullable } from "babylonjs/types";
  72024. import { Engine } from "babylonjs/Engines/engine";
  72025. /**
  72026. * This represents the different options available for the video capture.
  72027. */
  72028. export interface VideoRecorderOptions {
  72029. /** Defines the mime type of the video. */
  72030. mimeType: string;
  72031. /** Defines the FPS the video should be recorded at. */
  72032. fps: number;
  72033. /** Defines the chunk size for the recording data. */
  72034. recordChunckSize: number;
  72035. /** The audio tracks to attach to the recording. */
  72036. audioTracks?: MediaStreamTrack[];
  72037. }
  72038. /**
  72039. * This can help with recording videos from BabylonJS.
  72040. * This is based on the available WebRTC functionalities of the browser.
  72041. *
  72042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72043. */
  72044. export class VideoRecorder {
  72045. private static readonly _defaultOptions;
  72046. /**
  72047. * Returns whether or not the VideoRecorder is available in your browser.
  72048. * @param engine Defines the Babylon Engine.
  72049. * @returns true if supported otherwise false.
  72050. */
  72051. static IsSupported(engine: Engine): boolean;
  72052. private readonly _options;
  72053. private _canvas;
  72054. private _mediaRecorder;
  72055. private _recordedChunks;
  72056. private _fileName;
  72057. private _resolve;
  72058. private _reject;
  72059. /**
  72060. * True when a recording is already in progress.
  72061. */
  72062. get isRecording(): boolean;
  72063. /**
  72064. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72065. * @param engine Defines the BabylonJS Engine you wish to record.
  72066. * @param options Defines options that can be used to customize the capture.
  72067. */
  72068. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72069. /**
  72070. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72071. */
  72072. stopRecording(): void;
  72073. /**
  72074. * Starts recording the canvas for a max duration specified in parameters.
  72075. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72076. * If null no automatic download will start and you can rely on the promise to get the data back.
  72077. * @param maxDuration Defines the maximum recording time in seconds.
  72078. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72079. * @return A promise callback at the end of the recording with the video data in Blob.
  72080. */
  72081. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72082. /**
  72083. * Releases internal resources used during the recording.
  72084. */
  72085. dispose(): void;
  72086. private _handleDataAvailable;
  72087. private _handleError;
  72088. private _handleStop;
  72089. }
  72090. }
  72091. declare module "babylonjs/Misc/screenshotTools" {
  72092. import { Camera } from "babylonjs/Cameras/camera";
  72093. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72094. import { Engine } from "babylonjs/Engines/engine";
  72095. /**
  72096. * Class containing a set of static utilities functions for screenshots
  72097. */
  72098. export class ScreenshotTools {
  72099. /**
  72100. * Captures a screenshot of the current rendering
  72101. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72102. * @param engine defines the rendering engine
  72103. * @param camera defines the source camera
  72104. * @param size This parameter can be set to a single number or to an object with the
  72105. * following (optional) properties: precision, width, height. If a single number is passed,
  72106. * it will be used for both width and height. If an object is passed, the screenshot size
  72107. * will be derived from the parameters. The precision property is a multiplier allowing
  72108. * rendering at a higher or lower resolution
  72109. * @param successCallback defines the callback receives a single parameter which contains the
  72110. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72111. * src parameter of an <img> to display it
  72112. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72113. * Check your browser for supported MIME types
  72114. */
  72115. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72116. /**
  72117. * Captures a screenshot of the current rendering
  72118. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72119. * @param engine defines the rendering engine
  72120. * @param camera defines the source camera
  72121. * @param size This parameter can be set to a single number or to an object with the
  72122. * following (optional) properties: precision, width, height. If a single number is passed,
  72123. * it will be used for both width and height. If an object is passed, the screenshot size
  72124. * will be derived from the parameters. The precision property is a multiplier allowing
  72125. * rendering at a higher or lower resolution
  72126. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72127. * Check your browser for supported MIME types
  72128. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72129. * to the src parameter of an <img> to display it
  72130. */
  72131. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72132. /**
  72133. * Generates an image screenshot from the specified camera.
  72134. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72135. * @param engine The engine to use for rendering
  72136. * @param camera The camera to use for rendering
  72137. * @param size This parameter can be set to a single number or to an object with the
  72138. * following (optional) properties: precision, width, height. If a single number is passed,
  72139. * it will be used for both width and height. If an object is passed, the screenshot size
  72140. * will be derived from the parameters. The precision property is a multiplier allowing
  72141. * rendering at a higher or lower resolution
  72142. * @param successCallback The callback receives a single parameter which contains the
  72143. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72144. * src parameter of an <img> to display it
  72145. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72146. * Check your browser for supported MIME types
  72147. * @param samples Texture samples (default: 1)
  72148. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72149. * @param fileName A name for for the downloaded file.
  72150. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72151. */
  72152. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72153. /**
  72154. * Generates an image screenshot from the specified camera.
  72155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72156. * @param engine The engine to use for rendering
  72157. * @param camera The camera to use for rendering
  72158. * @param size This parameter can be set to a single number or to an object with the
  72159. * following (optional) properties: precision, width, height. If a single number is passed,
  72160. * it will be used for both width and height. If an object is passed, the screenshot size
  72161. * will be derived from the parameters. The precision property is a multiplier allowing
  72162. * rendering at a higher or lower resolution
  72163. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72164. * Check your browser for supported MIME types
  72165. * @param samples Texture samples (default: 1)
  72166. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72167. * @param fileName A name for for the downloaded file.
  72168. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72169. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72170. * to the src parameter of an <img> to display it
  72171. */
  72172. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72173. /**
  72174. * Gets height and width for screenshot size
  72175. * @private
  72176. */
  72177. private static _getScreenshotSize;
  72178. }
  72179. }
  72180. declare module "babylonjs/Misc/dataReader" {
  72181. /**
  72182. * Interface for a data buffer
  72183. */
  72184. export interface IDataBuffer {
  72185. /**
  72186. * Reads bytes from the data buffer.
  72187. * @param byteOffset The byte offset to read
  72188. * @param byteLength The byte length to read
  72189. * @returns A promise that resolves when the bytes are read
  72190. */
  72191. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72192. /**
  72193. * The byte length of the buffer.
  72194. */
  72195. readonly byteLength: number;
  72196. }
  72197. /**
  72198. * Utility class for reading from a data buffer
  72199. */
  72200. export class DataReader {
  72201. /**
  72202. * The data buffer associated with this data reader.
  72203. */
  72204. readonly buffer: IDataBuffer;
  72205. /**
  72206. * The current byte offset from the beginning of the data buffer.
  72207. */
  72208. byteOffset: number;
  72209. private _dataView;
  72210. private _dataByteOffset;
  72211. /**
  72212. * Constructor
  72213. * @param buffer The buffer to read
  72214. */
  72215. constructor(buffer: IDataBuffer);
  72216. /**
  72217. * Loads the given byte length.
  72218. * @param byteLength The byte length to load
  72219. * @returns A promise that resolves when the load is complete
  72220. */
  72221. loadAsync(byteLength: number): Promise<void>;
  72222. /**
  72223. * Read a unsigned 32-bit integer from the currently loaded data range.
  72224. * @returns The 32-bit integer read
  72225. */
  72226. readUint32(): number;
  72227. /**
  72228. * Read a byte array from the currently loaded data range.
  72229. * @param byteLength The byte length to read
  72230. * @returns The byte array read
  72231. */
  72232. readUint8Array(byteLength: number): Uint8Array;
  72233. /**
  72234. * Read a string from the currently loaded data range.
  72235. * @param byteLength The byte length to read
  72236. * @returns The string read
  72237. */
  72238. readString(byteLength: number): string;
  72239. /**
  72240. * Skips the given byte length the currently loaded data range.
  72241. * @param byteLength The byte length to skip
  72242. */
  72243. skipBytes(byteLength: number): void;
  72244. }
  72245. }
  72246. declare module "babylonjs/Misc/index" {
  72247. export * from "babylonjs/Misc/andOrNotEvaluator";
  72248. export * from "babylonjs/Misc/assetsManager";
  72249. export * from "babylonjs/Misc/basis";
  72250. export * from "babylonjs/Misc/dds";
  72251. export * from "babylonjs/Misc/decorators";
  72252. export * from "babylonjs/Misc/deferred";
  72253. export * from "babylonjs/Misc/environmentTextureTools";
  72254. export * from "babylonjs/Misc/meshExploder";
  72255. export * from "babylonjs/Misc/filesInput";
  72256. export * from "babylonjs/Misc/HighDynamicRange/index";
  72257. export * from "babylonjs/Misc/khronosTextureContainer";
  72258. export * from "babylonjs/Misc/observable";
  72259. export * from "babylonjs/Misc/performanceMonitor";
  72260. export * from "babylonjs/Misc/promise";
  72261. export * from "babylonjs/Misc/sceneOptimizer";
  72262. export * from "babylonjs/Misc/sceneSerializer";
  72263. export * from "babylonjs/Misc/smartArray";
  72264. export * from "babylonjs/Misc/stringDictionary";
  72265. export * from "babylonjs/Misc/tags";
  72266. export * from "babylonjs/Misc/textureTools";
  72267. export * from "babylonjs/Misc/tga";
  72268. export * from "babylonjs/Misc/tools";
  72269. export * from "babylonjs/Misc/videoRecorder";
  72270. export * from "babylonjs/Misc/virtualJoystick";
  72271. export * from "babylonjs/Misc/workerPool";
  72272. export * from "babylonjs/Misc/logger";
  72273. export * from "babylonjs/Misc/typeStore";
  72274. export * from "babylonjs/Misc/filesInputStore";
  72275. export * from "babylonjs/Misc/deepCopier";
  72276. export * from "babylonjs/Misc/pivotTools";
  72277. export * from "babylonjs/Misc/precisionDate";
  72278. export * from "babylonjs/Misc/screenshotTools";
  72279. export * from "babylonjs/Misc/typeStore";
  72280. export * from "babylonjs/Misc/webRequest";
  72281. export * from "babylonjs/Misc/iInspectable";
  72282. export * from "babylonjs/Misc/brdfTextureTools";
  72283. export * from "babylonjs/Misc/rgbdTextureTools";
  72284. export * from "babylonjs/Misc/gradients";
  72285. export * from "babylonjs/Misc/perfCounter";
  72286. export * from "babylonjs/Misc/fileRequest";
  72287. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72288. export * from "babylonjs/Misc/retryStrategy";
  72289. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72290. export * from "babylonjs/Misc/canvasGenerator";
  72291. export * from "babylonjs/Misc/fileTools";
  72292. export * from "babylonjs/Misc/stringTools";
  72293. export * from "babylonjs/Misc/dataReader";
  72294. export * from "babylonjs/Misc/minMaxReducer";
  72295. export * from "babylonjs/Misc/depthReducer";
  72296. }
  72297. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72298. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72299. import { Observable } from "babylonjs/Misc/observable";
  72300. import { Matrix } from "babylonjs/Maths/math.vector";
  72301. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72302. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72303. /**
  72304. * Options used for hit testing
  72305. */
  72306. export interface IWebXRHitTestOptions {
  72307. /**
  72308. * Only test when user interacted with the scene. Default - hit test every frame
  72309. */
  72310. testOnPointerDownOnly?: boolean;
  72311. /**
  72312. * The node to use to transform the local results to world coordinates
  72313. */
  72314. worldParentNode?: TransformNode;
  72315. }
  72316. /**
  72317. * Interface defining the babylon result of raycasting/hit-test
  72318. */
  72319. export interface IWebXRHitResult {
  72320. /**
  72321. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72322. */
  72323. transformationMatrix: Matrix;
  72324. /**
  72325. * The native hit test result
  72326. */
  72327. xrHitResult: XRHitResult;
  72328. }
  72329. /**
  72330. * The currently-working hit-test module.
  72331. * Hit test (or Ray-casting) is used to interact with the real world.
  72332. * For further information read here - https://github.com/immersive-web/hit-test
  72333. */
  72334. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72335. /**
  72336. * options to use when constructing this feature
  72337. */
  72338. readonly options: IWebXRHitTestOptions;
  72339. private _direction;
  72340. private _mat;
  72341. private _onSelectEnabled;
  72342. private _origin;
  72343. /**
  72344. * The module's name
  72345. */
  72346. static readonly Name: string;
  72347. /**
  72348. * The (Babylon) version of this module.
  72349. * This is an integer representing the implementation version.
  72350. * This number does not correspond to the WebXR specs version
  72351. */
  72352. static readonly Version: number;
  72353. /**
  72354. * Populated with the last native XR Hit Results
  72355. */
  72356. lastNativeXRHitResults: XRHitResult[];
  72357. /**
  72358. * Triggered when new babylon (transformed) hit test results are available
  72359. */
  72360. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72361. /**
  72362. * Creates a new instance of the (legacy version) hit test feature
  72363. * @param _xrSessionManager an instance of WebXRSessionManager
  72364. * @param options options to use when constructing this feature
  72365. */
  72366. constructor(_xrSessionManager: WebXRSessionManager,
  72367. /**
  72368. * options to use when constructing this feature
  72369. */
  72370. options?: IWebXRHitTestOptions);
  72371. /**
  72372. * execute a hit test with an XR Ray
  72373. *
  72374. * @param xrSession a native xrSession that will execute this hit test
  72375. * @param xrRay the ray (position and direction) to use for ray-casting
  72376. * @param referenceSpace native XR reference space to use for the hit-test
  72377. * @param filter filter function that will filter the results
  72378. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72379. */
  72380. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72381. /**
  72382. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72383. * @param event the (select) event to use to select with
  72384. * @param referenceSpace the reference space to use for this hit test
  72385. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72386. */
  72387. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72388. /**
  72389. * attach this feature
  72390. * Will usually be called by the features manager
  72391. *
  72392. * @returns true if successful.
  72393. */
  72394. attach(): boolean;
  72395. /**
  72396. * detach this feature.
  72397. * Will usually be called by the features manager
  72398. *
  72399. * @returns true if successful.
  72400. */
  72401. detach(): boolean;
  72402. /**
  72403. * Dispose this feature and all of the resources attached
  72404. */
  72405. dispose(): void;
  72406. protected _onXRFrame(frame: XRFrame): void;
  72407. private _onHitTestResults;
  72408. private _onSelect;
  72409. }
  72410. }
  72411. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72414. import { Observable } from "babylonjs/Misc/observable";
  72415. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72416. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72417. /**
  72418. * Options used in the plane detector module
  72419. */
  72420. export interface IWebXRPlaneDetectorOptions {
  72421. /**
  72422. * The node to use to transform the local results to world coordinates
  72423. */
  72424. worldParentNode?: TransformNode;
  72425. }
  72426. /**
  72427. * A babylon interface for a WebXR plane.
  72428. * A Plane is actually a polygon, built from N points in space
  72429. *
  72430. * Supported in chrome 79, not supported in canary 81 ATM
  72431. */
  72432. export interface IWebXRPlane {
  72433. /**
  72434. * a babylon-assigned ID for this polygon
  72435. */
  72436. id: number;
  72437. /**
  72438. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72439. */
  72440. polygonDefinition: Array<Vector3>;
  72441. /**
  72442. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72443. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72444. */
  72445. transformationMatrix: Matrix;
  72446. /**
  72447. * the native xr-plane object
  72448. */
  72449. xrPlane: XRPlane;
  72450. }
  72451. /**
  72452. * The plane detector is used to detect planes in the real world when in AR
  72453. * For more information see https://github.com/immersive-web/real-world-geometry/
  72454. */
  72455. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72456. private _options;
  72457. private _detectedPlanes;
  72458. private _enabled;
  72459. private _lastFrameDetected;
  72460. /**
  72461. * The module's name
  72462. */
  72463. static readonly Name: string;
  72464. /**
  72465. * The (Babylon) version of this module.
  72466. * This is an integer representing the implementation version.
  72467. * This number does not correspond to the WebXR specs version
  72468. */
  72469. static readonly Version: number;
  72470. /**
  72471. * Observers registered here will be executed when a new plane was added to the session
  72472. */
  72473. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72474. /**
  72475. * Observers registered here will be executed when a plane is no longer detected in the session
  72476. */
  72477. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72478. /**
  72479. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72480. * This can execute N times every frame
  72481. */
  72482. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72483. /**
  72484. * construct a new Plane Detector
  72485. * @param _xrSessionManager an instance of xr Session manager
  72486. * @param _options configuration to use when constructing this feature
  72487. */
  72488. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72489. /**
  72490. * Dispose this feature and all of the resources attached
  72491. */
  72492. dispose(): void;
  72493. protected _onXRFrame(frame: XRFrame): void;
  72494. private _init;
  72495. private _updatePlaneWithXRPlane;
  72496. /**
  72497. * avoiding using Array.find for global support.
  72498. * @param xrPlane the plane to find in the array
  72499. */
  72500. private findIndexInPlaneArray;
  72501. }
  72502. }
  72503. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72504. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72505. import { Observable } from "babylonjs/Misc/observable";
  72506. import { Matrix } from "babylonjs/Maths/math.vector";
  72507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72508. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72509. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72510. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72511. /**
  72512. * Configuration options of the anchor system
  72513. */
  72514. export interface IWebXRAnchorSystemOptions {
  72515. /**
  72516. * Should a new anchor be added every time a select event is triggered
  72517. */
  72518. addAnchorOnSelect?: boolean;
  72519. /**
  72520. * should the anchor system use plane detection.
  72521. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72522. */
  72523. usePlaneDetection?: boolean;
  72524. /**
  72525. * a node that will be used to convert local to world coordinates
  72526. */
  72527. worldParentNode?: TransformNode;
  72528. }
  72529. /**
  72530. * A babylon container for an XR Anchor
  72531. */
  72532. export interface IWebXRAnchor {
  72533. /**
  72534. * A babylon-assigned ID for this anchor
  72535. */
  72536. id: number;
  72537. /**
  72538. * Transformation matrix to apply to an object attached to this anchor
  72539. */
  72540. transformationMatrix: Matrix;
  72541. /**
  72542. * The native anchor object
  72543. */
  72544. xrAnchor: XRAnchor;
  72545. }
  72546. /**
  72547. * An implementation of the anchor system of WebXR.
  72548. * Note that the current documented implementation is not available in any browser. Future implementations
  72549. * will use the frame to create an anchor and not the session or a detected plane
  72550. * For further information see https://github.com/immersive-web/anchors/
  72551. */
  72552. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72553. private _options;
  72554. private _enabled;
  72555. private _hitTestModule;
  72556. private _lastFrameDetected;
  72557. private _onSelect;
  72558. private _planeDetector;
  72559. private _trackedAnchors;
  72560. /**
  72561. * The module's name
  72562. */
  72563. static readonly Name: string;
  72564. /**
  72565. * The (Babylon) version of this module.
  72566. * This is an integer representing the implementation version.
  72567. * This number does not correspond to the WebXR specs version
  72568. */
  72569. static readonly Version: number;
  72570. /**
  72571. * Observers registered here will be executed when a new anchor was added to the session
  72572. */
  72573. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72574. /**
  72575. * Observers registered here will be executed when an anchor was removed from the session
  72576. */
  72577. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72578. /**
  72579. * Observers registered here will be executed when an existing anchor updates
  72580. * This can execute N times every frame
  72581. */
  72582. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72583. /**
  72584. * constructs a new anchor system
  72585. * @param _xrSessionManager an instance of WebXRSessionManager
  72586. * @param _options configuration object for this feature
  72587. */
  72588. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72589. /**
  72590. * Add anchor at a specific XR point.
  72591. *
  72592. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72593. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72594. * @returns a promise the fulfills when the anchor was created
  72595. */
  72596. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72597. /**
  72598. * attach this feature
  72599. * Will usually be called by the features manager
  72600. *
  72601. * @returns true if successful.
  72602. */
  72603. attach(): boolean;
  72604. /**
  72605. * detach this feature.
  72606. * Will usually be called by the features manager
  72607. *
  72608. * @returns true if successful.
  72609. */
  72610. detach(): boolean;
  72611. /**
  72612. * Dispose this feature and all of the resources attached
  72613. */
  72614. dispose(): void;
  72615. /**
  72616. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72617. * @param hitTestModule the hit-test module to use.
  72618. */
  72619. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72620. /**
  72621. * set the plane detector to use in order to create anchors from frames
  72622. * @param planeDetector the plane-detector module to use
  72623. * @param enable enable plane-anchors. default is true
  72624. */
  72625. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72626. protected _onXRFrame(frame: XRFrame): void;
  72627. /**
  72628. * avoiding using Array.find for global support.
  72629. * @param xrAnchor the plane to find in the array
  72630. */
  72631. private _findIndexInAnchorArray;
  72632. private _updateAnchorWithXRFrame;
  72633. }
  72634. }
  72635. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72636. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72638. import { Observable } from "babylonjs/Misc/observable";
  72639. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72640. /**
  72641. * Options interface for the background remover plugin
  72642. */
  72643. export interface IWebXRBackgroundRemoverOptions {
  72644. /**
  72645. * Further background meshes to disable when entering AR
  72646. */
  72647. backgroundMeshes?: AbstractMesh[];
  72648. /**
  72649. * flags to configure the removal of the environment helper.
  72650. * If not set, the entire background will be removed. If set, flags should be set as well.
  72651. */
  72652. environmentHelperRemovalFlags?: {
  72653. /**
  72654. * Should the skybox be removed (default false)
  72655. */
  72656. skyBox?: boolean;
  72657. /**
  72658. * Should the ground be removed (default false)
  72659. */
  72660. ground?: boolean;
  72661. };
  72662. /**
  72663. * don't disable the environment helper
  72664. */
  72665. ignoreEnvironmentHelper?: boolean;
  72666. }
  72667. /**
  72668. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72669. */
  72670. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72671. /**
  72672. * read-only options to be used in this module
  72673. */
  72674. readonly options: IWebXRBackgroundRemoverOptions;
  72675. /**
  72676. * The module's name
  72677. */
  72678. static readonly Name: string;
  72679. /**
  72680. * The (Babylon) version of this module.
  72681. * This is an integer representing the implementation version.
  72682. * This number does not correspond to the WebXR specs version
  72683. */
  72684. static readonly Version: number;
  72685. /**
  72686. * registered observers will be triggered when the background state changes
  72687. */
  72688. onBackgroundStateChangedObservable: Observable<boolean>;
  72689. /**
  72690. * constructs a new background remover module
  72691. * @param _xrSessionManager the session manager for this module
  72692. * @param options read-only options to be used in this module
  72693. */
  72694. constructor(_xrSessionManager: WebXRSessionManager,
  72695. /**
  72696. * read-only options to be used in this module
  72697. */
  72698. options?: IWebXRBackgroundRemoverOptions);
  72699. /**
  72700. * attach this feature
  72701. * Will usually be called by the features manager
  72702. *
  72703. * @returns true if successful.
  72704. */
  72705. attach(): boolean;
  72706. /**
  72707. * detach this feature.
  72708. * Will usually be called by the features manager
  72709. *
  72710. * @returns true if successful.
  72711. */
  72712. detach(): boolean;
  72713. /**
  72714. * Dispose this feature and all of the resources attached
  72715. */
  72716. dispose(): void;
  72717. protected _onXRFrame(_xrFrame: XRFrame): void;
  72718. private _setBackgroundState;
  72719. }
  72720. }
  72721. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72722. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72723. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72724. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72725. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72726. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72727. import { Nullable } from "babylonjs/types";
  72728. /**
  72729. * Options for the controller physics feature
  72730. */
  72731. export class IWebXRControllerPhysicsOptions {
  72732. /**
  72733. * Should the headset get its own impostor
  72734. */
  72735. enableHeadsetImpostor?: boolean;
  72736. /**
  72737. * Optional parameters for the headset impostor
  72738. */
  72739. headsetImpostorParams?: {
  72740. /**
  72741. * The type of impostor to create. Default is sphere
  72742. */
  72743. impostorType: number;
  72744. /**
  72745. * the size of the impostor. Defaults to 10cm
  72746. */
  72747. impostorSize?: number | {
  72748. width: number;
  72749. height: number;
  72750. depth: number;
  72751. };
  72752. /**
  72753. * Friction definitions
  72754. */
  72755. friction?: number;
  72756. /**
  72757. * Restitution
  72758. */
  72759. restitution?: number;
  72760. };
  72761. /**
  72762. * The physics properties of the future impostors
  72763. */
  72764. physicsProperties?: {
  72765. /**
  72766. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72767. * Note that this requires a physics engine that supports mesh impostors!
  72768. */
  72769. useControllerMesh?: boolean;
  72770. /**
  72771. * The type of impostor to create. Default is sphere
  72772. */
  72773. impostorType?: number;
  72774. /**
  72775. * the size of the impostor. Defaults to 10cm
  72776. */
  72777. impostorSize?: number | {
  72778. width: number;
  72779. height: number;
  72780. depth: number;
  72781. };
  72782. /**
  72783. * Friction definitions
  72784. */
  72785. friction?: number;
  72786. /**
  72787. * Restitution
  72788. */
  72789. restitution?: number;
  72790. };
  72791. /**
  72792. * the xr input to use with this pointer selection
  72793. */
  72794. xrInput: WebXRInput;
  72795. }
  72796. /**
  72797. * Add physics impostor to your webxr controllers,
  72798. * including naive calculation of their linear and angular velocity
  72799. */
  72800. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72801. private readonly _options;
  72802. private _attachController;
  72803. private _controllers;
  72804. private _debugMode;
  72805. private _delta;
  72806. private _headsetImpostor?;
  72807. private _headsetMesh?;
  72808. private _lastTimestamp;
  72809. private _tmpQuaternion;
  72810. private _tmpVector;
  72811. /**
  72812. * The module's name
  72813. */
  72814. static readonly Name: string;
  72815. /**
  72816. * The (Babylon) version of this module.
  72817. * This is an integer representing the implementation version.
  72818. * This number does not correspond to the webxr specs version
  72819. */
  72820. static readonly Version: number;
  72821. /**
  72822. * Construct a new Controller Physics Feature
  72823. * @param _xrSessionManager the corresponding xr session manager
  72824. * @param _options options to create this feature with
  72825. */
  72826. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72827. /**
  72828. * @hidden
  72829. * enable debugging - will show console outputs and the impostor mesh
  72830. */
  72831. _enablePhysicsDebug(): void;
  72832. /**
  72833. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72834. * @param xrController the controller to add
  72835. */
  72836. addController(xrController: WebXRInputSource): void;
  72837. /**
  72838. * attach this feature
  72839. * Will usually be called by the features manager
  72840. *
  72841. * @returns true if successful.
  72842. */
  72843. attach(): boolean;
  72844. /**
  72845. * detach this feature.
  72846. * Will usually be called by the features manager
  72847. *
  72848. * @returns true if successful.
  72849. */
  72850. detach(): boolean;
  72851. /**
  72852. * Get the headset impostor, if enabled
  72853. * @returns the impostor
  72854. */
  72855. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72856. /**
  72857. * Get the physics impostor of a specific controller.
  72858. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72859. * @param controller the controller or the controller id of which to get the impostor
  72860. * @returns the impostor or null
  72861. */
  72862. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72863. /**
  72864. * Update the physics properties provided in the constructor
  72865. * @param newProperties the new properties object
  72866. */
  72867. setPhysicsProperties(newProperties: {
  72868. impostorType?: number;
  72869. impostorSize?: number | {
  72870. width: number;
  72871. height: number;
  72872. depth: number;
  72873. };
  72874. friction?: number;
  72875. restitution?: number;
  72876. }): void;
  72877. protected _onXRFrame(_xrFrame: any): void;
  72878. private _detachController;
  72879. }
  72880. }
  72881. declare module "babylonjs/XR/features/index" {
  72882. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72883. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72884. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72885. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72886. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72887. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72888. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72889. }
  72890. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72891. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72893. import { Scene } from "babylonjs/scene";
  72894. /**
  72895. * The motion controller class for all microsoft mixed reality controllers
  72896. */
  72897. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72898. protected readonly _mapping: {
  72899. defaultButton: {
  72900. "valueNodeName": string;
  72901. "unpressedNodeName": string;
  72902. "pressedNodeName": string;
  72903. };
  72904. defaultAxis: {
  72905. "valueNodeName": string;
  72906. "minNodeName": string;
  72907. "maxNodeName": string;
  72908. };
  72909. buttons: {
  72910. "xr-standard-trigger": {
  72911. "rootNodeName": string;
  72912. "componentProperty": string;
  72913. "states": string[];
  72914. };
  72915. "xr-standard-squeeze": {
  72916. "rootNodeName": string;
  72917. "componentProperty": string;
  72918. "states": string[];
  72919. };
  72920. "xr-standard-touchpad": {
  72921. "rootNodeName": string;
  72922. "labelAnchorNodeName": string;
  72923. "touchPointNodeName": string;
  72924. };
  72925. "xr-standard-thumbstick": {
  72926. "rootNodeName": string;
  72927. "componentProperty": string;
  72928. "states": string[];
  72929. };
  72930. };
  72931. axes: {
  72932. "xr-standard-touchpad": {
  72933. "x-axis": {
  72934. "rootNodeName": string;
  72935. };
  72936. "y-axis": {
  72937. "rootNodeName": string;
  72938. };
  72939. };
  72940. "xr-standard-thumbstick": {
  72941. "x-axis": {
  72942. "rootNodeName": string;
  72943. };
  72944. "y-axis": {
  72945. "rootNodeName": string;
  72946. };
  72947. };
  72948. };
  72949. };
  72950. /**
  72951. * The base url used to load the left and right controller models
  72952. */
  72953. static MODEL_BASE_URL: string;
  72954. /**
  72955. * The name of the left controller model file
  72956. */
  72957. static MODEL_LEFT_FILENAME: string;
  72958. /**
  72959. * The name of the right controller model file
  72960. */
  72961. static MODEL_RIGHT_FILENAME: string;
  72962. profileId: string;
  72963. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72964. protected _getFilenameAndPath(): {
  72965. filename: string;
  72966. path: string;
  72967. };
  72968. protected _getModelLoadingConstraints(): boolean;
  72969. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72970. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72971. protected _updateModel(): void;
  72972. }
  72973. }
  72974. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72975. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72977. import { Scene } from "babylonjs/scene";
  72978. /**
  72979. * The motion controller class for oculus touch (quest, rift).
  72980. * This class supports legacy mapping as well the standard xr mapping
  72981. */
  72982. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72983. private _forceLegacyControllers;
  72984. private _modelRootNode;
  72985. /**
  72986. * The base url used to load the left and right controller models
  72987. */
  72988. static MODEL_BASE_URL: string;
  72989. /**
  72990. * The name of the left controller model file
  72991. */
  72992. static MODEL_LEFT_FILENAME: string;
  72993. /**
  72994. * The name of the right controller model file
  72995. */
  72996. static MODEL_RIGHT_FILENAME: string;
  72997. /**
  72998. * Base Url for the Quest controller model.
  72999. */
  73000. static QUEST_MODEL_BASE_URL: string;
  73001. profileId: string;
  73002. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73003. protected _getFilenameAndPath(): {
  73004. filename: string;
  73005. path: string;
  73006. };
  73007. protected _getModelLoadingConstraints(): boolean;
  73008. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73009. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73010. protected _updateModel(): void;
  73011. /**
  73012. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73013. * between the touch and touch 2.
  73014. */
  73015. private _isQuest;
  73016. }
  73017. }
  73018. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73019. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73020. import { Scene } from "babylonjs/scene";
  73021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73022. /**
  73023. * The motion controller class for the standard HTC-Vive controllers
  73024. */
  73025. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73026. private _modelRootNode;
  73027. /**
  73028. * The base url used to load the left and right controller models
  73029. */
  73030. static MODEL_BASE_URL: string;
  73031. /**
  73032. * File name for the controller model.
  73033. */
  73034. static MODEL_FILENAME: string;
  73035. profileId: string;
  73036. /**
  73037. * Create a new Vive motion controller object
  73038. * @param scene the scene to use to create this controller
  73039. * @param gamepadObject the corresponding gamepad object
  73040. * @param handness the handness of the controller
  73041. */
  73042. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73043. protected _getFilenameAndPath(): {
  73044. filename: string;
  73045. path: string;
  73046. };
  73047. protected _getModelLoadingConstraints(): boolean;
  73048. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73049. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73050. protected _updateModel(): void;
  73051. }
  73052. }
  73053. declare module "babylonjs/XR/motionController/index" {
  73054. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73055. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73056. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73057. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73058. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73059. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73060. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73061. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73062. }
  73063. declare module "babylonjs/XR/index" {
  73064. export * from "babylonjs/XR/webXRCamera";
  73065. export * from "babylonjs/XR/webXREnterExitUI";
  73066. export * from "babylonjs/XR/webXRExperienceHelper";
  73067. export * from "babylonjs/XR/webXRInput";
  73068. export * from "babylonjs/XR/webXRInputSource";
  73069. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73070. export * from "babylonjs/XR/webXRTypes";
  73071. export * from "babylonjs/XR/webXRSessionManager";
  73072. export * from "babylonjs/XR/webXRDefaultExperience";
  73073. export * from "babylonjs/XR/webXRFeaturesManager";
  73074. export * from "babylonjs/XR/features/index";
  73075. export * from "babylonjs/XR/motionController/index";
  73076. }
  73077. declare module "babylonjs/index" {
  73078. export * from "babylonjs/abstractScene";
  73079. export * from "babylonjs/Actions/index";
  73080. export * from "babylonjs/Animations/index";
  73081. export * from "babylonjs/assetContainer";
  73082. export * from "babylonjs/Audio/index";
  73083. export * from "babylonjs/Behaviors/index";
  73084. export * from "babylonjs/Bones/index";
  73085. export * from "babylonjs/Cameras/index";
  73086. export * from "babylonjs/Collisions/index";
  73087. export * from "babylonjs/Culling/index";
  73088. export * from "babylonjs/Debug/index";
  73089. export * from "babylonjs/Engines/index";
  73090. export * from "babylonjs/Events/index";
  73091. export * from "babylonjs/Gamepads/index";
  73092. export * from "babylonjs/Gizmos/index";
  73093. export * from "babylonjs/Helpers/index";
  73094. export * from "babylonjs/Instrumentation/index";
  73095. export * from "babylonjs/Layers/index";
  73096. export * from "babylonjs/LensFlares/index";
  73097. export * from "babylonjs/Lights/index";
  73098. export * from "babylonjs/Loading/index";
  73099. export * from "babylonjs/Materials/index";
  73100. export * from "babylonjs/Maths/index";
  73101. export * from "babylonjs/Meshes/index";
  73102. export * from "babylonjs/Morph/index";
  73103. export * from "babylonjs/Navigation/index";
  73104. export * from "babylonjs/node";
  73105. export * from "babylonjs/Offline/index";
  73106. export * from "babylonjs/Particles/index";
  73107. export * from "babylonjs/Physics/index";
  73108. export * from "babylonjs/PostProcesses/index";
  73109. export * from "babylonjs/Probes/index";
  73110. export * from "babylonjs/Rendering/index";
  73111. export * from "babylonjs/scene";
  73112. export * from "babylonjs/sceneComponent";
  73113. export * from "babylonjs/Sprites/index";
  73114. export * from "babylonjs/States/index";
  73115. export * from "babylonjs/Misc/index";
  73116. export * from "babylonjs/XR/index";
  73117. export * from "babylonjs/types";
  73118. }
  73119. declare module "babylonjs/Animations/pathCursor" {
  73120. import { Vector3 } from "babylonjs/Maths/math.vector";
  73121. import { Path2 } from "babylonjs/Maths/math.path";
  73122. /**
  73123. * A cursor which tracks a point on a path
  73124. */
  73125. export class PathCursor {
  73126. private path;
  73127. /**
  73128. * Stores path cursor callbacks for when an onchange event is triggered
  73129. */
  73130. private _onchange;
  73131. /**
  73132. * The value of the path cursor
  73133. */
  73134. value: number;
  73135. /**
  73136. * The animation array of the path cursor
  73137. */
  73138. animations: Animation[];
  73139. /**
  73140. * Initializes the path cursor
  73141. * @param path The path to track
  73142. */
  73143. constructor(path: Path2);
  73144. /**
  73145. * Gets the cursor point on the path
  73146. * @returns A point on the path cursor at the cursor location
  73147. */
  73148. getPoint(): Vector3;
  73149. /**
  73150. * Moves the cursor ahead by the step amount
  73151. * @param step The amount to move the cursor forward
  73152. * @returns This path cursor
  73153. */
  73154. moveAhead(step?: number): PathCursor;
  73155. /**
  73156. * Moves the cursor behind by the step amount
  73157. * @param step The amount to move the cursor back
  73158. * @returns This path cursor
  73159. */
  73160. moveBack(step?: number): PathCursor;
  73161. /**
  73162. * Moves the cursor by the step amount
  73163. * If the step amount is greater than one, an exception is thrown
  73164. * @param step The amount to move the cursor
  73165. * @returns This path cursor
  73166. */
  73167. move(step: number): PathCursor;
  73168. /**
  73169. * Ensures that the value is limited between zero and one
  73170. * @returns This path cursor
  73171. */
  73172. private ensureLimits;
  73173. /**
  73174. * Runs onchange callbacks on change (used by the animation engine)
  73175. * @returns This path cursor
  73176. */
  73177. private raiseOnChange;
  73178. /**
  73179. * Executes a function on change
  73180. * @param f A path cursor onchange callback
  73181. * @returns This path cursor
  73182. */
  73183. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73184. }
  73185. }
  73186. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73187. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73188. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73189. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73190. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73191. }
  73192. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73193. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73194. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73195. }
  73196. declare module "babylonjs/Engines/Processors/index" {
  73197. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73198. export * from "babylonjs/Engines/Processors/Expressions/index";
  73199. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73200. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73201. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73202. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73203. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73204. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73205. }
  73206. declare module "babylonjs/Legacy/legacy" {
  73207. import * as Babylon from "babylonjs/index";
  73208. export * from "babylonjs/index";
  73209. }
  73210. declare module "babylonjs/Shaders/blur.fragment" {
  73211. /** @hidden */
  73212. export var blurPixelShader: {
  73213. name: string;
  73214. shader: string;
  73215. };
  73216. }
  73217. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73218. /** @hidden */
  73219. export var pointCloudVertexDeclaration: {
  73220. name: string;
  73221. shader: string;
  73222. };
  73223. }
  73224. declare module "babylonjs" {
  73225. export * from "babylonjs/Legacy/legacy";
  73226. }
  73227. declare module BABYLON {
  73228. /** Alias type for value that can be null */
  73229. export type Nullable<T> = T | null;
  73230. /**
  73231. * Alias type for number that are floats
  73232. * @ignorenaming
  73233. */
  73234. export type float = number;
  73235. /**
  73236. * Alias type for number that are doubles.
  73237. * @ignorenaming
  73238. */
  73239. export type double = number;
  73240. /**
  73241. * Alias type for number that are integer
  73242. * @ignorenaming
  73243. */
  73244. export type int = number;
  73245. /** Alias type for number array or Float32Array */
  73246. export type FloatArray = number[] | Float32Array;
  73247. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73248. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73249. /**
  73250. * Alias for types that can be used by a Buffer or VertexBuffer.
  73251. */
  73252. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73253. /**
  73254. * Alias type for primitive types
  73255. * @ignorenaming
  73256. */
  73257. type Primitive = undefined | null | boolean | string | number | Function;
  73258. /**
  73259. * Type modifier to make all the properties of an object Readonly
  73260. */
  73261. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73262. /**
  73263. * Type modifier to make all the properties of an object Readonly recursively
  73264. */
  73265. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73266. /**
  73267. * Type modifier to make object properties readonly.
  73268. */
  73269. export type DeepImmutableObject<T> = {
  73270. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73271. };
  73272. /** @hidden */
  73273. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73274. }
  73275. }
  73276. declare module BABYLON {
  73277. /**
  73278. * A class serves as a medium between the observable and its observers
  73279. */
  73280. export class EventState {
  73281. /**
  73282. * Create a new EventState
  73283. * @param mask defines the mask associated with this state
  73284. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73285. * @param target defines the original target of the state
  73286. * @param currentTarget defines the current target of the state
  73287. */
  73288. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73289. /**
  73290. * Initialize the current event state
  73291. * @param mask defines the mask associated with this state
  73292. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73293. * @param target defines the original target of the state
  73294. * @param currentTarget defines the current target of the state
  73295. * @returns the current event state
  73296. */
  73297. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73298. /**
  73299. * An Observer can set this property to true to prevent subsequent observers of being notified
  73300. */
  73301. skipNextObservers: boolean;
  73302. /**
  73303. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73304. */
  73305. mask: number;
  73306. /**
  73307. * The object that originally notified the event
  73308. */
  73309. target?: any;
  73310. /**
  73311. * The current object in the bubbling phase
  73312. */
  73313. currentTarget?: any;
  73314. /**
  73315. * This will be populated with the return value of the last function that was executed.
  73316. * If it is the first function in the callback chain it will be the event data.
  73317. */
  73318. lastReturnValue?: any;
  73319. }
  73320. /**
  73321. * Represent an Observer registered to a given Observable object.
  73322. */
  73323. export class Observer<T> {
  73324. /**
  73325. * Defines the callback to call when the observer is notified
  73326. */
  73327. callback: (eventData: T, eventState: EventState) => void;
  73328. /**
  73329. * Defines the mask of the observer (used to filter notifications)
  73330. */
  73331. mask: number;
  73332. /**
  73333. * Defines the current scope used to restore the JS context
  73334. */
  73335. scope: any;
  73336. /** @hidden */
  73337. _willBeUnregistered: boolean;
  73338. /**
  73339. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73340. */
  73341. unregisterOnNextCall: boolean;
  73342. /**
  73343. * Creates a new observer
  73344. * @param callback defines the callback to call when the observer is notified
  73345. * @param mask defines the mask of the observer (used to filter notifications)
  73346. * @param scope defines the current scope used to restore the JS context
  73347. */
  73348. constructor(
  73349. /**
  73350. * Defines the callback to call when the observer is notified
  73351. */
  73352. callback: (eventData: T, eventState: EventState) => void,
  73353. /**
  73354. * Defines the mask of the observer (used to filter notifications)
  73355. */
  73356. mask: number,
  73357. /**
  73358. * Defines the current scope used to restore the JS context
  73359. */
  73360. scope?: any);
  73361. }
  73362. /**
  73363. * Represent a list of observers registered to multiple Observables object.
  73364. */
  73365. export class MultiObserver<T> {
  73366. private _observers;
  73367. private _observables;
  73368. /**
  73369. * Release associated resources
  73370. */
  73371. dispose(): void;
  73372. /**
  73373. * Raise a callback when one of the observable will notify
  73374. * @param observables defines a list of observables to watch
  73375. * @param callback defines the callback to call on notification
  73376. * @param mask defines the mask used to filter notifications
  73377. * @param scope defines the current scope used to restore the JS context
  73378. * @returns the new MultiObserver
  73379. */
  73380. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73381. }
  73382. /**
  73383. * The Observable class is a simple implementation of the Observable pattern.
  73384. *
  73385. * 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.
  73386. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73387. * 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).
  73388. * 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.
  73389. */
  73390. export class Observable<T> {
  73391. private _observers;
  73392. private _eventState;
  73393. private _onObserverAdded;
  73394. /**
  73395. * Gets the list of observers
  73396. */
  73397. get observers(): Array<Observer<T>>;
  73398. /**
  73399. * Creates a new observable
  73400. * @param onObserverAdded defines a callback to call when a new observer is added
  73401. */
  73402. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73403. /**
  73404. * Create a new Observer with the specified callback
  73405. * @param callback the callback that will be executed for that Observer
  73406. * @param mask the mask used to filter observers
  73407. * @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.
  73408. * @param scope optional scope for the callback to be called from
  73409. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73410. * @returns the new observer created for the callback
  73411. */
  73412. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73413. /**
  73414. * Create a new Observer with the specified callback and unregisters after the next notification
  73415. * @param callback the callback that will be executed for that Observer
  73416. * @returns the new observer created for the callback
  73417. */
  73418. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73419. /**
  73420. * Remove an Observer from the Observable object
  73421. * @param observer the instance of the Observer to remove
  73422. * @returns false if it doesn't belong to this Observable
  73423. */
  73424. remove(observer: Nullable<Observer<T>>): boolean;
  73425. /**
  73426. * Remove a callback from the Observable object
  73427. * @param callback the callback to remove
  73428. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73429. * @returns false if it doesn't belong to this Observable
  73430. */
  73431. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73432. private _deferUnregister;
  73433. private _remove;
  73434. /**
  73435. * Moves the observable to the top of the observer list making it get called first when notified
  73436. * @param observer the observer to move
  73437. */
  73438. makeObserverTopPriority(observer: Observer<T>): void;
  73439. /**
  73440. * Moves the observable to the bottom of the observer list making it get called last when notified
  73441. * @param observer the observer to move
  73442. */
  73443. makeObserverBottomPriority(observer: Observer<T>): void;
  73444. /**
  73445. * Notify all Observers by calling their respective callback with the given data
  73446. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73447. * @param eventData defines the data to send to all observers
  73448. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73449. * @param target defines the original target of the state
  73450. * @param currentTarget defines the current target of the state
  73451. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73452. */
  73453. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73454. /**
  73455. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73456. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73457. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73458. * and it is crucial that all callbacks will be executed.
  73459. * The order of the callbacks is kept, callbacks are not executed parallel.
  73460. *
  73461. * @param eventData The data to be sent to each callback
  73462. * @param mask is used to filter observers defaults to -1
  73463. * @param target defines the callback target (see EventState)
  73464. * @param currentTarget defines he current object in the bubbling phase
  73465. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73466. */
  73467. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73468. /**
  73469. * Notify a specific observer
  73470. * @param observer defines the observer to notify
  73471. * @param eventData defines the data to be sent to each callback
  73472. * @param mask is used to filter observers defaults to -1
  73473. */
  73474. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73475. /**
  73476. * Gets a boolean indicating if the observable has at least one observer
  73477. * @returns true is the Observable has at least one Observer registered
  73478. */
  73479. hasObservers(): boolean;
  73480. /**
  73481. * Clear the list of observers
  73482. */
  73483. clear(): void;
  73484. /**
  73485. * Clone the current observable
  73486. * @returns a new observable
  73487. */
  73488. clone(): Observable<T>;
  73489. /**
  73490. * Does this observable handles observer registered with a given mask
  73491. * @param mask defines the mask to be tested
  73492. * @return whether or not one observer registered with the given mask is handeled
  73493. **/
  73494. hasSpecificMask(mask?: number): boolean;
  73495. }
  73496. }
  73497. declare module BABYLON {
  73498. /**
  73499. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73500. * Babylon.js
  73501. */
  73502. export class DomManagement {
  73503. /**
  73504. * Checks if the window object exists
  73505. * @returns true if the window object exists
  73506. */
  73507. static IsWindowObjectExist(): boolean;
  73508. /**
  73509. * Checks if the navigator object exists
  73510. * @returns true if the navigator object exists
  73511. */
  73512. static IsNavigatorAvailable(): boolean;
  73513. /**
  73514. * Extracts text content from a DOM element hierarchy
  73515. * @param element defines the root element
  73516. * @returns a string
  73517. */
  73518. static GetDOMTextContent(element: HTMLElement): string;
  73519. }
  73520. }
  73521. declare module BABYLON {
  73522. /**
  73523. * Logger used througouht the application to allow configuration of
  73524. * the log level required for the messages.
  73525. */
  73526. export class Logger {
  73527. /**
  73528. * No log
  73529. */
  73530. static readonly NoneLogLevel: number;
  73531. /**
  73532. * Only message logs
  73533. */
  73534. static readonly MessageLogLevel: number;
  73535. /**
  73536. * Only warning logs
  73537. */
  73538. static readonly WarningLogLevel: number;
  73539. /**
  73540. * Only error logs
  73541. */
  73542. static readonly ErrorLogLevel: number;
  73543. /**
  73544. * All logs
  73545. */
  73546. static readonly AllLogLevel: number;
  73547. private static _LogCache;
  73548. /**
  73549. * Gets a value indicating the number of loading errors
  73550. * @ignorenaming
  73551. */
  73552. static errorsCount: number;
  73553. /**
  73554. * Callback called when a new log is added
  73555. */
  73556. static OnNewCacheEntry: (entry: string) => void;
  73557. private static _AddLogEntry;
  73558. private static _FormatMessage;
  73559. private static _LogDisabled;
  73560. private static _LogEnabled;
  73561. private static _WarnDisabled;
  73562. private static _WarnEnabled;
  73563. private static _ErrorDisabled;
  73564. private static _ErrorEnabled;
  73565. /**
  73566. * Log a message to the console
  73567. */
  73568. static Log: (message: string) => void;
  73569. /**
  73570. * Write a warning message to the console
  73571. */
  73572. static Warn: (message: string) => void;
  73573. /**
  73574. * Write an error message to the console
  73575. */
  73576. static Error: (message: string) => void;
  73577. /**
  73578. * Gets current log cache (list of logs)
  73579. */
  73580. static get LogCache(): string;
  73581. /**
  73582. * Clears the log cache
  73583. */
  73584. static ClearLogCache(): void;
  73585. /**
  73586. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73587. */
  73588. static set LogLevels(level: number);
  73589. }
  73590. }
  73591. declare module BABYLON {
  73592. /** @hidden */
  73593. export class _TypeStore {
  73594. /** @hidden */
  73595. static RegisteredTypes: {
  73596. [key: string]: Object;
  73597. };
  73598. /** @hidden */
  73599. static GetClass(fqdn: string): any;
  73600. }
  73601. }
  73602. declare module BABYLON {
  73603. /**
  73604. * Helper to manipulate strings
  73605. */
  73606. export class StringTools {
  73607. /**
  73608. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73609. * @param str Source string
  73610. * @param suffix Suffix to search for in the source string
  73611. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73612. */
  73613. static EndsWith(str: string, suffix: string): boolean;
  73614. /**
  73615. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73616. * @param str Source string
  73617. * @param suffix Suffix to search for in the source string
  73618. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73619. */
  73620. static StartsWith(str: string, suffix: string): boolean;
  73621. /**
  73622. * Decodes a buffer into a string
  73623. * @param buffer The buffer to decode
  73624. * @returns The decoded string
  73625. */
  73626. static Decode(buffer: Uint8Array | Uint16Array): string;
  73627. /**
  73628. * Encode a buffer to a base64 string
  73629. * @param buffer defines the buffer to encode
  73630. * @returns the encoded string
  73631. */
  73632. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73633. }
  73634. }
  73635. declare module BABYLON {
  73636. /**
  73637. * Class containing a set of static utilities functions for deep copy.
  73638. */
  73639. export class DeepCopier {
  73640. /**
  73641. * Tries to copy an object by duplicating every property
  73642. * @param source defines the source object
  73643. * @param destination defines the target object
  73644. * @param doNotCopyList defines a list of properties to avoid
  73645. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73646. */
  73647. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73648. }
  73649. }
  73650. declare module BABYLON {
  73651. /**
  73652. * Class containing a set of static utilities functions for precision date
  73653. */
  73654. export class PrecisionDate {
  73655. /**
  73656. * Gets either window.performance.now() if supported or Date.now() else
  73657. */
  73658. static get Now(): number;
  73659. }
  73660. }
  73661. declare module BABYLON {
  73662. /** @hidden */
  73663. export class _DevTools {
  73664. static WarnImport(name: string): string;
  73665. }
  73666. }
  73667. declare module BABYLON {
  73668. /**
  73669. * Interface used to define the mechanism to get data from the network
  73670. */
  73671. export interface IWebRequest {
  73672. /**
  73673. * Returns client's response url
  73674. */
  73675. responseURL: string;
  73676. /**
  73677. * Returns client's status
  73678. */
  73679. status: number;
  73680. /**
  73681. * Returns client's status as a text
  73682. */
  73683. statusText: string;
  73684. }
  73685. }
  73686. declare module BABYLON {
  73687. /**
  73688. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73689. */
  73690. export class WebRequest implements IWebRequest {
  73691. private _xhr;
  73692. /**
  73693. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73694. * i.e. when loading files, where the server/service expects an Authorization header
  73695. */
  73696. static CustomRequestHeaders: {
  73697. [key: string]: string;
  73698. };
  73699. /**
  73700. * Add callback functions in this array to update all the requests before they get sent to the network
  73701. */
  73702. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73703. private _injectCustomRequestHeaders;
  73704. /**
  73705. * Gets or sets a function to be called when loading progress changes
  73706. */
  73707. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73708. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73709. /**
  73710. * Returns client's state
  73711. */
  73712. get readyState(): number;
  73713. /**
  73714. * Returns client's status
  73715. */
  73716. get status(): number;
  73717. /**
  73718. * Returns client's status as a text
  73719. */
  73720. get statusText(): string;
  73721. /**
  73722. * Returns client's response
  73723. */
  73724. get response(): any;
  73725. /**
  73726. * Returns client's response url
  73727. */
  73728. get responseURL(): string;
  73729. /**
  73730. * Returns client's response as text
  73731. */
  73732. get responseText(): string;
  73733. /**
  73734. * Gets or sets the expected response type
  73735. */
  73736. get responseType(): XMLHttpRequestResponseType;
  73737. set responseType(value: XMLHttpRequestResponseType);
  73738. /** @hidden */
  73739. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73740. /** @hidden */
  73741. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73742. /**
  73743. * Cancels any network activity
  73744. */
  73745. abort(): void;
  73746. /**
  73747. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73748. * @param body defines an optional request body
  73749. */
  73750. send(body?: Document | BodyInit | null): void;
  73751. /**
  73752. * Sets the request method, request URL
  73753. * @param method defines the method to use (GET, POST, etc..)
  73754. * @param url defines the url to connect with
  73755. */
  73756. open(method: string, url: string): void;
  73757. /**
  73758. * Sets the value of a request header.
  73759. * @param name The name of the header whose value is to be set
  73760. * @param value The value to set as the body of the header
  73761. */
  73762. setRequestHeader(name: string, value: string): void;
  73763. /**
  73764. * Get the string containing the text of a particular header's value.
  73765. * @param name The name of the header
  73766. * @returns The string containing the text of the given header name
  73767. */
  73768. getResponseHeader(name: string): Nullable<string>;
  73769. }
  73770. }
  73771. declare module BABYLON {
  73772. /**
  73773. * File request interface
  73774. */
  73775. export interface IFileRequest {
  73776. /**
  73777. * Raised when the request is complete (success or error).
  73778. */
  73779. onCompleteObservable: Observable<IFileRequest>;
  73780. /**
  73781. * Aborts the request for a file.
  73782. */
  73783. abort: () => void;
  73784. }
  73785. }
  73786. declare module BABYLON {
  73787. /**
  73788. * Define options used to create a render target texture
  73789. */
  73790. export class RenderTargetCreationOptions {
  73791. /**
  73792. * Specifies is mipmaps must be generated
  73793. */
  73794. generateMipMaps?: boolean;
  73795. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73796. generateDepthBuffer?: boolean;
  73797. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73798. generateStencilBuffer?: boolean;
  73799. /** Defines texture type (int by default) */
  73800. type?: number;
  73801. /** Defines sampling mode (trilinear by default) */
  73802. samplingMode?: number;
  73803. /** Defines format (RGBA by default) */
  73804. format?: number;
  73805. }
  73806. }
  73807. declare module BABYLON {
  73808. /** Defines the cross module used constants to avoid circular dependncies */
  73809. export class Constants {
  73810. /** Defines that alpha blending is disabled */
  73811. static readonly ALPHA_DISABLE: number;
  73812. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73813. static readonly ALPHA_ADD: number;
  73814. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73815. static readonly ALPHA_COMBINE: number;
  73816. /** Defines that alpha blending is DEST - SRC * DEST */
  73817. static readonly ALPHA_SUBTRACT: number;
  73818. /** Defines that alpha blending is SRC * DEST */
  73819. static readonly ALPHA_MULTIPLY: number;
  73820. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73821. static readonly ALPHA_MAXIMIZED: number;
  73822. /** Defines that alpha blending is SRC + DEST */
  73823. static readonly ALPHA_ONEONE: number;
  73824. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73825. static readonly ALPHA_PREMULTIPLIED: number;
  73826. /**
  73827. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73828. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73829. */
  73830. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73831. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73832. static readonly ALPHA_INTERPOLATE: number;
  73833. /**
  73834. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73835. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73836. */
  73837. static readonly ALPHA_SCREENMODE: number;
  73838. /**
  73839. * Defines that alpha blending is SRC + DST
  73840. * Alpha will be set to SRC ALPHA + DST ALPHA
  73841. */
  73842. static readonly ALPHA_ONEONE_ONEONE: number;
  73843. /**
  73844. * Defines that alpha blending is SRC * DST ALPHA + DST
  73845. * Alpha will be set to 0
  73846. */
  73847. static readonly ALPHA_ALPHATOCOLOR: number;
  73848. /**
  73849. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73850. */
  73851. static readonly ALPHA_REVERSEONEMINUS: number;
  73852. /**
  73853. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73854. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73855. */
  73856. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73857. /**
  73858. * Defines that alpha blending is SRC + DST
  73859. * Alpha will be set to SRC ALPHA
  73860. */
  73861. static readonly ALPHA_ONEONE_ONEZERO: number;
  73862. /**
  73863. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73864. * Alpha will be set to DST ALPHA
  73865. */
  73866. static readonly ALPHA_EXCLUSION: number;
  73867. /** Defines that alpha blending equation a SUM */
  73868. static readonly ALPHA_EQUATION_ADD: number;
  73869. /** Defines that alpha blending equation a SUBSTRACTION */
  73870. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73871. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73872. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73873. /** Defines that alpha blending equation a MAX operation */
  73874. static readonly ALPHA_EQUATION_MAX: number;
  73875. /** Defines that alpha blending equation a MIN operation */
  73876. static readonly ALPHA_EQUATION_MIN: number;
  73877. /**
  73878. * Defines that alpha blending equation a DARKEN operation:
  73879. * It takes the min of the src and sums the alpha channels.
  73880. */
  73881. static readonly ALPHA_EQUATION_DARKEN: number;
  73882. /** Defines that the ressource is not delayed*/
  73883. static readonly DELAYLOADSTATE_NONE: number;
  73884. /** Defines that the ressource was successfully delay loaded */
  73885. static readonly DELAYLOADSTATE_LOADED: number;
  73886. /** Defines that the ressource is currently delay loading */
  73887. static readonly DELAYLOADSTATE_LOADING: number;
  73888. /** Defines that the ressource is delayed and has not started loading */
  73889. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73891. static readonly NEVER: number;
  73892. /** 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 */
  73893. static readonly ALWAYS: number;
  73894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73895. static readonly LESS: number;
  73896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73897. static readonly EQUAL: number;
  73898. /** 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 */
  73899. static readonly LEQUAL: number;
  73900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73901. static readonly GREATER: number;
  73902. /** 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 */
  73903. static readonly GEQUAL: number;
  73904. /** 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 */
  73905. static readonly NOTEQUAL: number;
  73906. /** Passed to stencilOperation to specify that stencil value must be kept */
  73907. static readonly KEEP: number;
  73908. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73909. static readonly REPLACE: number;
  73910. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73911. static readonly INCR: number;
  73912. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73913. static readonly DECR: number;
  73914. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73915. static readonly INVERT: number;
  73916. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73917. static readonly INCR_WRAP: number;
  73918. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73919. static readonly DECR_WRAP: number;
  73920. /** Texture is not repeating outside of 0..1 UVs */
  73921. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73922. /** Texture is repeating outside of 0..1 UVs */
  73923. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73924. /** Texture is repeating and mirrored */
  73925. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73926. /** ALPHA */
  73927. static readonly TEXTUREFORMAT_ALPHA: number;
  73928. /** LUMINANCE */
  73929. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73930. /** LUMINANCE_ALPHA */
  73931. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73932. /** RGB */
  73933. static readonly TEXTUREFORMAT_RGB: number;
  73934. /** RGBA */
  73935. static readonly TEXTUREFORMAT_RGBA: number;
  73936. /** RED */
  73937. static readonly TEXTUREFORMAT_RED: number;
  73938. /** RED (2nd reference) */
  73939. static readonly TEXTUREFORMAT_R: number;
  73940. /** RG */
  73941. static readonly TEXTUREFORMAT_RG: number;
  73942. /** RED_INTEGER */
  73943. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73944. /** RED_INTEGER (2nd reference) */
  73945. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73946. /** RG_INTEGER */
  73947. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73948. /** RGB_INTEGER */
  73949. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73950. /** RGBA_INTEGER */
  73951. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73952. /** UNSIGNED_BYTE */
  73953. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73954. /** UNSIGNED_BYTE (2nd reference) */
  73955. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73956. /** FLOAT */
  73957. static readonly TEXTURETYPE_FLOAT: number;
  73958. /** HALF_FLOAT */
  73959. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73960. /** BYTE */
  73961. static readonly TEXTURETYPE_BYTE: number;
  73962. /** SHORT */
  73963. static readonly TEXTURETYPE_SHORT: number;
  73964. /** UNSIGNED_SHORT */
  73965. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73966. /** INT */
  73967. static readonly TEXTURETYPE_INT: number;
  73968. /** UNSIGNED_INT */
  73969. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73970. /** UNSIGNED_SHORT_4_4_4_4 */
  73971. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73972. /** UNSIGNED_SHORT_5_5_5_1 */
  73973. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73974. /** UNSIGNED_SHORT_5_6_5 */
  73975. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73976. /** UNSIGNED_INT_2_10_10_10_REV */
  73977. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73978. /** UNSIGNED_INT_24_8 */
  73979. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73980. /** UNSIGNED_INT_10F_11F_11F_REV */
  73981. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73982. /** UNSIGNED_INT_5_9_9_9_REV */
  73983. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73984. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73985. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73986. /** nearest is mag = nearest and min = nearest and no mip */
  73987. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73988. /** mag = nearest and min = nearest and mip = none */
  73989. static readonly TEXTURE_NEAREST_NEAREST: number;
  73990. /** Bilinear is mag = linear and min = linear and no mip */
  73991. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73992. /** mag = linear and min = linear and mip = none */
  73993. static readonly TEXTURE_LINEAR_LINEAR: number;
  73994. /** Trilinear is mag = linear and min = linear and mip = linear */
  73995. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73996. /** Trilinear is mag = linear and min = linear and mip = linear */
  73997. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73998. /** mag = nearest and min = nearest and mip = nearest */
  73999. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74000. /** mag = nearest and min = linear and mip = nearest */
  74001. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74002. /** mag = nearest and min = linear and mip = linear */
  74003. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74004. /** mag = nearest and min = linear and mip = none */
  74005. static readonly TEXTURE_NEAREST_LINEAR: number;
  74006. /** nearest is mag = nearest and min = nearest and mip = linear */
  74007. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74008. /** mag = linear and min = nearest and mip = nearest */
  74009. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74010. /** mag = linear and min = nearest and mip = linear */
  74011. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74012. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74013. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74014. /** mag = linear and min = nearest and mip = none */
  74015. static readonly TEXTURE_LINEAR_NEAREST: number;
  74016. /** Explicit coordinates mode */
  74017. static readonly TEXTURE_EXPLICIT_MODE: number;
  74018. /** Spherical coordinates mode */
  74019. static readonly TEXTURE_SPHERICAL_MODE: number;
  74020. /** Planar coordinates mode */
  74021. static readonly TEXTURE_PLANAR_MODE: number;
  74022. /** Cubic coordinates mode */
  74023. static readonly TEXTURE_CUBIC_MODE: number;
  74024. /** Projection coordinates mode */
  74025. static readonly TEXTURE_PROJECTION_MODE: number;
  74026. /** Skybox coordinates mode */
  74027. static readonly TEXTURE_SKYBOX_MODE: number;
  74028. /** Inverse Cubic coordinates mode */
  74029. static readonly TEXTURE_INVCUBIC_MODE: number;
  74030. /** Equirectangular coordinates mode */
  74031. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74032. /** Equirectangular Fixed coordinates mode */
  74033. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74034. /** Equirectangular Fixed Mirrored coordinates mode */
  74035. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74036. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74037. static readonly SCALEMODE_FLOOR: number;
  74038. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74039. static readonly SCALEMODE_NEAREST: number;
  74040. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74041. static readonly SCALEMODE_CEILING: number;
  74042. /**
  74043. * The dirty texture flag value
  74044. */
  74045. static readonly MATERIAL_TextureDirtyFlag: number;
  74046. /**
  74047. * The dirty light flag value
  74048. */
  74049. static readonly MATERIAL_LightDirtyFlag: number;
  74050. /**
  74051. * The dirty fresnel flag value
  74052. */
  74053. static readonly MATERIAL_FresnelDirtyFlag: number;
  74054. /**
  74055. * The dirty attribute flag value
  74056. */
  74057. static readonly MATERIAL_AttributesDirtyFlag: number;
  74058. /**
  74059. * The dirty misc flag value
  74060. */
  74061. static readonly MATERIAL_MiscDirtyFlag: number;
  74062. /**
  74063. * The all dirty flag value
  74064. */
  74065. static readonly MATERIAL_AllDirtyFlag: number;
  74066. /**
  74067. * Returns the triangle fill mode
  74068. */
  74069. static readonly MATERIAL_TriangleFillMode: number;
  74070. /**
  74071. * Returns the wireframe mode
  74072. */
  74073. static readonly MATERIAL_WireFrameFillMode: number;
  74074. /**
  74075. * Returns the point fill mode
  74076. */
  74077. static readonly MATERIAL_PointFillMode: number;
  74078. /**
  74079. * Returns the point list draw mode
  74080. */
  74081. static readonly MATERIAL_PointListDrawMode: number;
  74082. /**
  74083. * Returns the line list draw mode
  74084. */
  74085. static readonly MATERIAL_LineListDrawMode: number;
  74086. /**
  74087. * Returns the line loop draw mode
  74088. */
  74089. static readonly MATERIAL_LineLoopDrawMode: number;
  74090. /**
  74091. * Returns the line strip draw mode
  74092. */
  74093. static readonly MATERIAL_LineStripDrawMode: number;
  74094. /**
  74095. * Returns the triangle strip draw mode
  74096. */
  74097. static readonly MATERIAL_TriangleStripDrawMode: number;
  74098. /**
  74099. * Returns the triangle fan draw mode
  74100. */
  74101. static readonly MATERIAL_TriangleFanDrawMode: number;
  74102. /**
  74103. * Stores the clock-wise side orientation
  74104. */
  74105. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74106. /**
  74107. * Stores the counter clock-wise side orientation
  74108. */
  74109. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74110. /**
  74111. * Nothing
  74112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74113. */
  74114. static readonly ACTION_NothingTrigger: number;
  74115. /**
  74116. * On pick
  74117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74118. */
  74119. static readonly ACTION_OnPickTrigger: number;
  74120. /**
  74121. * On left pick
  74122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74123. */
  74124. static readonly ACTION_OnLeftPickTrigger: number;
  74125. /**
  74126. * On right pick
  74127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74128. */
  74129. static readonly ACTION_OnRightPickTrigger: number;
  74130. /**
  74131. * On center pick
  74132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74133. */
  74134. static readonly ACTION_OnCenterPickTrigger: number;
  74135. /**
  74136. * On pick down
  74137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74138. */
  74139. static readonly ACTION_OnPickDownTrigger: number;
  74140. /**
  74141. * On double pick
  74142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74143. */
  74144. static readonly ACTION_OnDoublePickTrigger: number;
  74145. /**
  74146. * On pick up
  74147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74148. */
  74149. static readonly ACTION_OnPickUpTrigger: number;
  74150. /**
  74151. * On pick out.
  74152. * This trigger will only be raised if you also declared a OnPickDown
  74153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74154. */
  74155. static readonly ACTION_OnPickOutTrigger: number;
  74156. /**
  74157. * On long press
  74158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74159. */
  74160. static readonly ACTION_OnLongPressTrigger: number;
  74161. /**
  74162. * On pointer over
  74163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74164. */
  74165. static readonly ACTION_OnPointerOverTrigger: number;
  74166. /**
  74167. * On pointer out
  74168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74169. */
  74170. static readonly ACTION_OnPointerOutTrigger: number;
  74171. /**
  74172. * On every frame
  74173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74174. */
  74175. static readonly ACTION_OnEveryFrameTrigger: number;
  74176. /**
  74177. * On intersection enter
  74178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74179. */
  74180. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74181. /**
  74182. * On intersection exit
  74183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74184. */
  74185. static readonly ACTION_OnIntersectionExitTrigger: number;
  74186. /**
  74187. * On key down
  74188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74189. */
  74190. static readonly ACTION_OnKeyDownTrigger: number;
  74191. /**
  74192. * On key up
  74193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74194. */
  74195. static readonly ACTION_OnKeyUpTrigger: number;
  74196. /**
  74197. * Billboard mode will only apply to Y axis
  74198. */
  74199. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74200. /**
  74201. * Billboard mode will apply to all axes
  74202. */
  74203. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74204. /**
  74205. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74206. */
  74207. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74208. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74209. * Test order :
  74210. * Is the bounding sphere outside the frustum ?
  74211. * If not, are the bounding box vertices outside the frustum ?
  74212. * It not, then the cullable object is in the frustum.
  74213. */
  74214. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74215. /** Culling strategy : Bounding Sphere Only.
  74216. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74217. * It's also less accurate than the standard because some not visible objects can still be selected.
  74218. * Test : is the bounding sphere outside the frustum ?
  74219. * If not, then the cullable object is in the frustum.
  74220. */
  74221. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74222. /** Culling strategy : Optimistic Inclusion.
  74223. * This in an inclusion test first, then the standard exclusion test.
  74224. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74225. * 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.
  74226. * Anyway, it's as accurate as the standard strategy.
  74227. * Test :
  74228. * Is the cullable object bounding sphere center in the frustum ?
  74229. * If not, apply the default culling strategy.
  74230. */
  74231. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74232. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74233. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74234. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74235. * 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.
  74236. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74237. * Test :
  74238. * Is the cullable object bounding sphere center in the frustum ?
  74239. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74240. */
  74241. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74242. /**
  74243. * No logging while loading
  74244. */
  74245. static readonly SCENELOADER_NO_LOGGING: number;
  74246. /**
  74247. * Minimal logging while loading
  74248. */
  74249. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74250. /**
  74251. * Summary logging while loading
  74252. */
  74253. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74254. /**
  74255. * Detailled logging while loading
  74256. */
  74257. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74258. }
  74259. }
  74260. declare module BABYLON {
  74261. /**
  74262. * This represents the required contract to create a new type of texture loader.
  74263. */
  74264. export interface IInternalTextureLoader {
  74265. /**
  74266. * Defines wether the loader supports cascade loading the different faces.
  74267. */
  74268. supportCascades: boolean;
  74269. /**
  74270. * This returns if the loader support the current file information.
  74271. * @param extension defines the file extension of the file being loaded
  74272. * @returns true if the loader can load the specified file
  74273. */
  74274. canLoad(extension: string): boolean;
  74275. /**
  74276. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74277. * @param data contains the texture data
  74278. * @param texture defines the BabylonJS internal texture
  74279. * @param createPolynomials will be true if polynomials have been requested
  74280. * @param onLoad defines the callback to trigger once the texture is ready
  74281. * @param onError defines the callback to trigger in case of error
  74282. */
  74283. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74284. /**
  74285. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74286. * @param data contains the texture data
  74287. * @param texture defines the BabylonJS internal texture
  74288. * @param callback defines the method to call once ready to upload
  74289. */
  74290. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74291. }
  74292. }
  74293. declare module BABYLON {
  74294. /**
  74295. * Class used to store and describe the pipeline context associated with an effect
  74296. */
  74297. export interface IPipelineContext {
  74298. /**
  74299. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74300. */
  74301. isAsync: boolean;
  74302. /**
  74303. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74304. */
  74305. isReady: boolean;
  74306. /** @hidden */
  74307. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74308. }
  74309. }
  74310. declare module BABYLON {
  74311. /**
  74312. * Class used to store gfx data (like WebGLBuffer)
  74313. */
  74314. export class DataBuffer {
  74315. /**
  74316. * Gets or sets the number of objects referencing this buffer
  74317. */
  74318. references: number;
  74319. /** Gets or sets the size of the underlying buffer */
  74320. capacity: number;
  74321. /**
  74322. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74323. */
  74324. is32Bits: boolean;
  74325. /**
  74326. * Gets the underlying buffer
  74327. */
  74328. get underlyingResource(): any;
  74329. }
  74330. }
  74331. declare module BABYLON {
  74332. /** @hidden */
  74333. export interface IShaderProcessor {
  74334. attributeProcessor?: (attribute: string) => string;
  74335. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74336. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74337. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74338. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74339. lineProcessor?: (line: string, isFragment: boolean) => string;
  74340. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74341. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74342. }
  74343. }
  74344. declare module BABYLON {
  74345. /** @hidden */
  74346. export interface ProcessingOptions {
  74347. defines: string[];
  74348. indexParameters: any;
  74349. isFragment: boolean;
  74350. shouldUseHighPrecisionShader: boolean;
  74351. supportsUniformBuffers: boolean;
  74352. shadersRepository: string;
  74353. includesShadersStore: {
  74354. [key: string]: string;
  74355. };
  74356. processor?: IShaderProcessor;
  74357. version: string;
  74358. platformName: string;
  74359. lookForClosingBracketForUniformBuffer?: boolean;
  74360. }
  74361. }
  74362. declare module BABYLON {
  74363. /** @hidden */
  74364. export class ShaderCodeNode {
  74365. line: string;
  74366. children: ShaderCodeNode[];
  74367. additionalDefineKey?: string;
  74368. additionalDefineValue?: string;
  74369. isValid(preprocessors: {
  74370. [key: string]: string;
  74371. }): boolean;
  74372. process(preprocessors: {
  74373. [key: string]: string;
  74374. }, options: ProcessingOptions): string;
  74375. }
  74376. }
  74377. declare module BABYLON {
  74378. /** @hidden */
  74379. export class ShaderCodeCursor {
  74380. private _lines;
  74381. lineIndex: number;
  74382. get currentLine(): string;
  74383. get canRead(): boolean;
  74384. set lines(value: string[]);
  74385. }
  74386. }
  74387. declare module BABYLON {
  74388. /** @hidden */
  74389. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74390. process(preprocessors: {
  74391. [key: string]: string;
  74392. }, options: ProcessingOptions): string;
  74393. }
  74394. }
  74395. declare module BABYLON {
  74396. /** @hidden */
  74397. export class ShaderDefineExpression {
  74398. isTrue(preprocessors: {
  74399. [key: string]: string;
  74400. }): boolean;
  74401. }
  74402. }
  74403. declare module BABYLON {
  74404. /** @hidden */
  74405. export class ShaderCodeTestNode extends ShaderCodeNode {
  74406. testExpression: ShaderDefineExpression;
  74407. isValid(preprocessors: {
  74408. [key: string]: string;
  74409. }): boolean;
  74410. }
  74411. }
  74412. declare module BABYLON {
  74413. /** @hidden */
  74414. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74415. define: string;
  74416. not: boolean;
  74417. constructor(define: string, not?: boolean);
  74418. isTrue(preprocessors: {
  74419. [key: string]: string;
  74420. }): boolean;
  74421. }
  74422. }
  74423. declare module BABYLON {
  74424. /** @hidden */
  74425. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74426. leftOperand: ShaderDefineExpression;
  74427. rightOperand: ShaderDefineExpression;
  74428. isTrue(preprocessors: {
  74429. [key: string]: string;
  74430. }): boolean;
  74431. }
  74432. }
  74433. declare module BABYLON {
  74434. /** @hidden */
  74435. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74436. leftOperand: ShaderDefineExpression;
  74437. rightOperand: ShaderDefineExpression;
  74438. isTrue(preprocessors: {
  74439. [key: string]: string;
  74440. }): boolean;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /** @hidden */
  74445. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74446. define: string;
  74447. operand: string;
  74448. testValue: string;
  74449. constructor(define: string, operand: string, testValue: string);
  74450. isTrue(preprocessors: {
  74451. [key: string]: string;
  74452. }): boolean;
  74453. }
  74454. }
  74455. declare module BABYLON {
  74456. /**
  74457. * Class used to enable access to offline support
  74458. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74459. */
  74460. export interface IOfflineProvider {
  74461. /**
  74462. * Gets a boolean indicating if scene must be saved in the database
  74463. */
  74464. enableSceneOffline: boolean;
  74465. /**
  74466. * Gets a boolean indicating if textures must be saved in the database
  74467. */
  74468. enableTexturesOffline: boolean;
  74469. /**
  74470. * Open the offline support and make it available
  74471. * @param successCallback defines the callback to call on success
  74472. * @param errorCallback defines the callback to call on error
  74473. */
  74474. open(successCallback: () => void, errorCallback: () => void): void;
  74475. /**
  74476. * Loads an image from the offline support
  74477. * @param url defines the url to load from
  74478. * @param image defines the target DOM image
  74479. */
  74480. loadImage(url: string, image: HTMLImageElement): void;
  74481. /**
  74482. * Loads a file from offline support
  74483. * @param url defines the URL to load from
  74484. * @param sceneLoaded defines a callback to call on success
  74485. * @param progressCallBack defines a callback to call when progress changed
  74486. * @param errorCallback defines a callback to call on error
  74487. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74488. */
  74489. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74490. }
  74491. }
  74492. declare module BABYLON {
  74493. /**
  74494. * Class used to help managing file picking and drag'n'drop
  74495. * File Storage
  74496. */
  74497. export class FilesInputStore {
  74498. /**
  74499. * List of files ready to be loaded
  74500. */
  74501. static FilesToLoad: {
  74502. [key: string]: File;
  74503. };
  74504. }
  74505. }
  74506. declare module BABYLON {
  74507. /**
  74508. * Class used to define a retry strategy when error happens while loading assets
  74509. */
  74510. export class RetryStrategy {
  74511. /**
  74512. * Function used to defines an exponential back off strategy
  74513. * @param maxRetries defines the maximum number of retries (3 by default)
  74514. * @param baseInterval defines the interval between retries
  74515. * @returns the strategy function to use
  74516. */
  74517. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74518. }
  74519. }
  74520. declare module BABYLON {
  74521. /**
  74522. * @ignore
  74523. * Application error to support additional information when loading a file
  74524. */
  74525. export abstract class BaseError extends Error {
  74526. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74527. }
  74528. }
  74529. declare module BABYLON {
  74530. /** @ignore */
  74531. export class LoadFileError extends BaseError {
  74532. request?: WebRequest;
  74533. file?: File;
  74534. /**
  74535. * Creates a new LoadFileError
  74536. * @param message defines the message of the error
  74537. * @param request defines the optional web request
  74538. * @param file defines the optional file
  74539. */
  74540. constructor(message: string, object?: WebRequest | File);
  74541. }
  74542. /** @ignore */
  74543. export class RequestFileError extends BaseError {
  74544. request: WebRequest;
  74545. /**
  74546. * Creates a new LoadFileError
  74547. * @param message defines the message of the error
  74548. * @param request defines the optional web request
  74549. */
  74550. constructor(message: string, request: WebRequest);
  74551. }
  74552. /** @ignore */
  74553. export class ReadFileError extends BaseError {
  74554. file: File;
  74555. /**
  74556. * Creates a new ReadFileError
  74557. * @param message defines the message of the error
  74558. * @param file defines the optional file
  74559. */
  74560. constructor(message: string, file: File);
  74561. }
  74562. /**
  74563. * @hidden
  74564. */
  74565. export class FileTools {
  74566. /**
  74567. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74568. */
  74569. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74570. /**
  74571. * Gets or sets the base URL to use to load assets
  74572. */
  74573. static BaseUrl: string;
  74574. /**
  74575. * Default behaviour for cors in the application.
  74576. * It can be a string if the expected behavior is identical in the entire app.
  74577. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74578. */
  74579. static CorsBehavior: string | ((url: string | string[]) => string);
  74580. /**
  74581. * Gets or sets a function used to pre-process url before using them to load assets
  74582. */
  74583. static PreprocessUrl: (url: string) => string;
  74584. /**
  74585. * Removes unwanted characters from an url
  74586. * @param url defines the url to clean
  74587. * @returns the cleaned url
  74588. */
  74589. private static _CleanUrl;
  74590. /**
  74591. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74592. * @param url define the url we are trying
  74593. * @param element define the dom element where to configure the cors policy
  74594. */
  74595. static SetCorsBehavior(url: string | string[], element: {
  74596. crossOrigin: string | null;
  74597. }): void;
  74598. /**
  74599. * Loads an image as an HTMLImageElement.
  74600. * @param input url string, ArrayBuffer, or Blob to load
  74601. * @param onLoad callback called when the image successfully loads
  74602. * @param onError callback called when the image fails to load
  74603. * @param offlineProvider offline provider for caching
  74604. * @param mimeType optional mime type
  74605. * @returns the HTMLImageElement of the loaded image
  74606. */
  74607. 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>;
  74608. /**
  74609. * Reads a file from a File object
  74610. * @param file defines the file to load
  74611. * @param onSuccess defines the callback to call when data is loaded
  74612. * @param onProgress defines the callback to call during loading process
  74613. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74614. * @param onError defines the callback to call when an error occurs
  74615. * @returns a file request object
  74616. */
  74617. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74618. /**
  74619. * Loads a file from a url
  74620. * @param url url to load
  74621. * @param onSuccess callback called when the file successfully loads
  74622. * @param onProgress callback called while file is loading (if the server supports this mode)
  74623. * @param offlineProvider defines the offline provider for caching
  74624. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74625. * @param onError callback called when the file fails to load
  74626. * @returns a file request object
  74627. */
  74628. 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;
  74629. /**
  74630. * Loads a file
  74631. * @param url url to load
  74632. * @param onSuccess callback called when the file successfully loads
  74633. * @param onProgress callback called while file is loading (if the server supports this mode)
  74634. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74635. * @param onError callback called when the file fails to load
  74636. * @param onOpened callback called when the web request is opened
  74637. * @returns a file request object
  74638. */
  74639. 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;
  74640. /**
  74641. * Checks if the loaded document was accessed via `file:`-Protocol.
  74642. * @returns boolean
  74643. */
  74644. static IsFileURL(): boolean;
  74645. }
  74646. }
  74647. declare module BABYLON {
  74648. /** @hidden */
  74649. export class ShaderProcessor {
  74650. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74651. private static _ProcessPrecision;
  74652. private static _ExtractOperation;
  74653. private static _BuildSubExpression;
  74654. private static _BuildExpression;
  74655. private static _MoveCursorWithinIf;
  74656. private static _MoveCursor;
  74657. private static _EvaluatePreProcessors;
  74658. private static _PreparePreProcessors;
  74659. private static _ProcessShaderConversion;
  74660. private static _ProcessIncludes;
  74661. /**
  74662. * Loads a file from a url
  74663. * @param url url to load
  74664. * @param onSuccess callback called when the file successfully loads
  74665. * @param onProgress callback called while file is loading (if the server supports this mode)
  74666. * @param offlineProvider defines the offline provider for caching
  74667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74668. * @param onError callback called when the file fails to load
  74669. * @returns a file request object
  74670. * @hidden
  74671. */
  74672. 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;
  74673. }
  74674. }
  74675. declare module BABYLON {
  74676. /**
  74677. * @hidden
  74678. */
  74679. export interface IColor4Like {
  74680. r: float;
  74681. g: float;
  74682. b: float;
  74683. a: float;
  74684. }
  74685. /**
  74686. * @hidden
  74687. */
  74688. export interface IColor3Like {
  74689. r: float;
  74690. g: float;
  74691. b: float;
  74692. }
  74693. /**
  74694. * @hidden
  74695. */
  74696. export interface IVector4Like {
  74697. x: float;
  74698. y: float;
  74699. z: float;
  74700. w: float;
  74701. }
  74702. /**
  74703. * @hidden
  74704. */
  74705. export interface IVector3Like {
  74706. x: float;
  74707. y: float;
  74708. z: float;
  74709. }
  74710. /**
  74711. * @hidden
  74712. */
  74713. export interface IVector2Like {
  74714. x: float;
  74715. y: float;
  74716. }
  74717. /**
  74718. * @hidden
  74719. */
  74720. export interface IMatrixLike {
  74721. toArray(): DeepImmutable<Float32Array>;
  74722. updateFlag: int;
  74723. }
  74724. /**
  74725. * @hidden
  74726. */
  74727. export interface IViewportLike {
  74728. x: float;
  74729. y: float;
  74730. width: float;
  74731. height: float;
  74732. }
  74733. /**
  74734. * @hidden
  74735. */
  74736. export interface IPlaneLike {
  74737. normal: IVector3Like;
  74738. d: float;
  74739. normalize(): void;
  74740. }
  74741. }
  74742. declare module BABYLON {
  74743. /**
  74744. * Interface used to define common properties for effect fallbacks
  74745. */
  74746. export interface IEffectFallbacks {
  74747. /**
  74748. * Removes the defines that should be removed when falling back.
  74749. * @param currentDefines defines the current define statements for the shader.
  74750. * @param effect defines the current effect we try to compile
  74751. * @returns The resulting defines with defines of the current rank removed.
  74752. */
  74753. reduce(currentDefines: string, effect: Effect): string;
  74754. /**
  74755. * Removes the fallback from the bound mesh.
  74756. */
  74757. unBindMesh(): void;
  74758. /**
  74759. * Checks to see if more fallbacks are still availible.
  74760. */
  74761. hasMoreFallbacks: boolean;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /**
  74766. * Class used to evalaute queries containing `and` and `or` operators
  74767. */
  74768. export class AndOrNotEvaluator {
  74769. /**
  74770. * Evaluate a query
  74771. * @param query defines the query to evaluate
  74772. * @param evaluateCallback defines the callback used to filter result
  74773. * @returns true if the query matches
  74774. */
  74775. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74776. private static _HandleParenthesisContent;
  74777. private static _SimplifyNegation;
  74778. }
  74779. }
  74780. declare module BABYLON {
  74781. /**
  74782. * Class used to store custom tags
  74783. */
  74784. export class Tags {
  74785. /**
  74786. * Adds support for tags on the given object
  74787. * @param obj defines the object to use
  74788. */
  74789. static EnableFor(obj: any): void;
  74790. /**
  74791. * Removes tags support
  74792. * @param obj defines the object to use
  74793. */
  74794. static DisableFor(obj: any): void;
  74795. /**
  74796. * Gets a boolean indicating if the given object has tags
  74797. * @param obj defines the object to use
  74798. * @returns a boolean
  74799. */
  74800. static HasTags(obj: any): boolean;
  74801. /**
  74802. * Gets the tags available on a given object
  74803. * @param obj defines the object to use
  74804. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74805. * @returns the tags
  74806. */
  74807. static GetTags(obj: any, asString?: boolean): any;
  74808. /**
  74809. * Adds tags to an object
  74810. * @param obj defines the object to use
  74811. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74812. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74813. */
  74814. static AddTagsTo(obj: any, tagsString: string): void;
  74815. /**
  74816. * @hidden
  74817. */
  74818. static _AddTagTo(obj: any, tag: string): void;
  74819. /**
  74820. * Removes specific tags from a specific object
  74821. * @param obj defines the object to use
  74822. * @param tagsString defines the tags to remove
  74823. */
  74824. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74825. /**
  74826. * @hidden
  74827. */
  74828. static _RemoveTagFrom(obj: any, tag: string): void;
  74829. /**
  74830. * Defines if tags hosted on an object match a given query
  74831. * @param obj defines the object to use
  74832. * @param tagsQuery defines the tag query
  74833. * @returns a boolean
  74834. */
  74835. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * Scalar computation library
  74841. */
  74842. export class Scalar {
  74843. /**
  74844. * Two pi constants convenient for computation.
  74845. */
  74846. static TwoPi: number;
  74847. /**
  74848. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74849. * @param a number
  74850. * @param b number
  74851. * @param epsilon (default = 1.401298E-45)
  74852. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74853. */
  74854. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74855. /**
  74856. * Returns a string : the upper case translation of the number i to hexadecimal.
  74857. * @param i number
  74858. * @returns the upper case translation of the number i to hexadecimal.
  74859. */
  74860. static ToHex(i: number): string;
  74861. /**
  74862. * Returns -1 if value is negative and +1 is value is positive.
  74863. * @param value the value
  74864. * @returns the value itself if it's equal to zero.
  74865. */
  74866. static Sign(value: number): number;
  74867. /**
  74868. * Returns the value itself if it's between min and max.
  74869. * Returns min if the value is lower than min.
  74870. * Returns max if the value is greater than max.
  74871. * @param value the value to clmap
  74872. * @param min the min value to clamp to (default: 0)
  74873. * @param max the max value to clamp to (default: 1)
  74874. * @returns the clamped value
  74875. */
  74876. static Clamp(value: number, min?: number, max?: number): number;
  74877. /**
  74878. * the log2 of value.
  74879. * @param value the value to compute log2 of
  74880. * @returns the log2 of value.
  74881. */
  74882. static Log2(value: number): number;
  74883. /**
  74884. * Loops the value, so that it is never larger than length and never smaller than 0.
  74885. *
  74886. * This is similar to the modulo operator but it works with floating point numbers.
  74887. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74888. * With t = 5 and length = 2.5, the result would be 0.0.
  74889. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74890. * @param value the value
  74891. * @param length the length
  74892. * @returns the looped value
  74893. */
  74894. static Repeat(value: number, length: number): number;
  74895. /**
  74896. * Normalize the value between 0.0 and 1.0 using min and max values
  74897. * @param value value to normalize
  74898. * @param min max to normalize between
  74899. * @param max min to normalize between
  74900. * @returns the normalized value
  74901. */
  74902. static Normalize(value: number, min: number, max: number): number;
  74903. /**
  74904. * Denormalize the value from 0.0 and 1.0 using min and max values
  74905. * @param normalized value to denormalize
  74906. * @param min max to denormalize between
  74907. * @param max min to denormalize between
  74908. * @returns the denormalized value
  74909. */
  74910. static Denormalize(normalized: number, min: number, max: number): number;
  74911. /**
  74912. * Calculates the shortest difference between two given angles given in degrees.
  74913. * @param current current angle in degrees
  74914. * @param target target angle in degrees
  74915. * @returns the delta
  74916. */
  74917. static DeltaAngle(current: number, target: number): number;
  74918. /**
  74919. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74920. * @param tx value
  74921. * @param length length
  74922. * @returns The returned value will move back and forth between 0 and length
  74923. */
  74924. static PingPong(tx: number, length: number): number;
  74925. /**
  74926. * Interpolates between min and max with smoothing at the limits.
  74927. *
  74928. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74929. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74930. * @param from from
  74931. * @param to to
  74932. * @param tx value
  74933. * @returns the smooth stepped value
  74934. */
  74935. static SmoothStep(from: number, to: number, tx: number): number;
  74936. /**
  74937. * Moves a value current towards target.
  74938. *
  74939. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74940. * Negative values of maxDelta pushes the value away from target.
  74941. * @param current current value
  74942. * @param target target value
  74943. * @param maxDelta max distance to move
  74944. * @returns resulting value
  74945. */
  74946. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74947. /**
  74948. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74949. *
  74950. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74951. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74952. * @param current current value
  74953. * @param target target value
  74954. * @param maxDelta max distance to move
  74955. * @returns resulting angle
  74956. */
  74957. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74958. /**
  74959. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74960. * @param start start value
  74961. * @param end target value
  74962. * @param amount amount to lerp between
  74963. * @returns the lerped value
  74964. */
  74965. static Lerp(start: number, end: number, amount: number): number;
  74966. /**
  74967. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74968. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74969. * @param start start value
  74970. * @param end target value
  74971. * @param amount amount to lerp between
  74972. * @returns the lerped value
  74973. */
  74974. static LerpAngle(start: number, end: number, amount: number): number;
  74975. /**
  74976. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74977. * @param a start value
  74978. * @param b target value
  74979. * @param value value between a and b
  74980. * @returns the inverseLerp value
  74981. */
  74982. static InverseLerp(a: number, b: number, value: number): number;
  74983. /**
  74984. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74985. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74986. * @param value1 spline value
  74987. * @param tangent1 spline value
  74988. * @param value2 spline value
  74989. * @param tangent2 spline value
  74990. * @param amount input value
  74991. * @returns hermite result
  74992. */
  74993. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74994. /**
  74995. * Returns a random float number between and min and max values
  74996. * @param min min value of random
  74997. * @param max max value of random
  74998. * @returns random value
  74999. */
  75000. static RandomRange(min: number, max: number): number;
  75001. /**
  75002. * This function returns percentage of a number in a given range.
  75003. *
  75004. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75005. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75006. * @param number to convert to percentage
  75007. * @param min min range
  75008. * @param max max range
  75009. * @returns the percentage
  75010. */
  75011. static RangeToPercent(number: number, min: number, max: number): number;
  75012. /**
  75013. * This function returns number that corresponds to the percentage in a given range.
  75014. *
  75015. * PercentToRange(0.34,0,100) will return 34.
  75016. * @param percent to convert to number
  75017. * @param min min range
  75018. * @param max max range
  75019. * @returns the number
  75020. */
  75021. static PercentToRange(percent: number, min: number, max: number): number;
  75022. /**
  75023. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75024. * @param angle The angle to normalize in radian.
  75025. * @return The converted angle.
  75026. */
  75027. static NormalizeRadians(angle: number): number;
  75028. }
  75029. }
  75030. declare module BABYLON {
  75031. /**
  75032. * Constant used to convert a value to gamma space
  75033. * @ignorenaming
  75034. */
  75035. export const ToGammaSpace: number;
  75036. /**
  75037. * Constant used to convert a value to linear space
  75038. * @ignorenaming
  75039. */
  75040. export const ToLinearSpace = 2.2;
  75041. /**
  75042. * Constant used to define the minimal number value in Babylon.js
  75043. * @ignorenaming
  75044. */
  75045. let Epsilon: number;
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * Class used to represent a viewport on screen
  75050. */
  75051. export class Viewport {
  75052. /** viewport left coordinate */
  75053. x: number;
  75054. /** viewport top coordinate */
  75055. y: number;
  75056. /**viewport width */
  75057. width: number;
  75058. /** viewport height */
  75059. height: number;
  75060. /**
  75061. * Creates a Viewport object located at (x, y) and sized (width, height)
  75062. * @param x defines viewport left coordinate
  75063. * @param y defines viewport top coordinate
  75064. * @param width defines the viewport width
  75065. * @param height defines the viewport height
  75066. */
  75067. constructor(
  75068. /** viewport left coordinate */
  75069. x: number,
  75070. /** viewport top coordinate */
  75071. y: number,
  75072. /**viewport width */
  75073. width: number,
  75074. /** viewport height */
  75075. height: number);
  75076. /**
  75077. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75078. * @param renderWidth defines the rendering width
  75079. * @param renderHeight defines the rendering height
  75080. * @returns a new Viewport
  75081. */
  75082. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75083. /**
  75084. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75085. * @param renderWidth defines the rendering width
  75086. * @param renderHeight defines the rendering height
  75087. * @param ref defines the target viewport
  75088. * @returns the current viewport
  75089. */
  75090. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75091. /**
  75092. * Returns a new Viewport copied from the current one
  75093. * @returns a new Viewport
  75094. */
  75095. clone(): Viewport;
  75096. }
  75097. }
  75098. declare module BABYLON {
  75099. /**
  75100. * Class containing a set of static utilities functions for arrays.
  75101. */
  75102. export class ArrayTools {
  75103. /**
  75104. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75105. * @param size the number of element to construct and put in the array
  75106. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75107. * @returns a new array filled with new objects
  75108. */
  75109. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75110. }
  75111. }
  75112. declare module BABYLON {
  75113. /**
  75114. * Class representing a vector containing 2 coordinates
  75115. */
  75116. export class Vector2 {
  75117. /** defines the first coordinate */
  75118. x: number;
  75119. /** defines the second coordinate */
  75120. y: number;
  75121. /**
  75122. * Creates a new Vector2 from the given x and y coordinates
  75123. * @param x defines the first coordinate
  75124. * @param y defines the second coordinate
  75125. */
  75126. constructor(
  75127. /** defines the first coordinate */
  75128. x?: number,
  75129. /** defines the second coordinate */
  75130. y?: number);
  75131. /**
  75132. * Gets a string with the Vector2 coordinates
  75133. * @returns a string with the Vector2 coordinates
  75134. */
  75135. toString(): string;
  75136. /**
  75137. * Gets class name
  75138. * @returns the string "Vector2"
  75139. */
  75140. getClassName(): string;
  75141. /**
  75142. * Gets current vector hash code
  75143. * @returns the Vector2 hash code as a number
  75144. */
  75145. getHashCode(): number;
  75146. /**
  75147. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75148. * @param array defines the source array
  75149. * @param index defines the offset in source array
  75150. * @returns the current Vector2
  75151. */
  75152. toArray(array: FloatArray, index?: number): Vector2;
  75153. /**
  75154. * Copy the current vector to an array
  75155. * @returns a new array with 2 elements: the Vector2 coordinates.
  75156. */
  75157. asArray(): number[];
  75158. /**
  75159. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75160. * @param source defines the source Vector2
  75161. * @returns the current updated Vector2
  75162. */
  75163. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75164. /**
  75165. * Sets the Vector2 coordinates with the given floats
  75166. * @param x defines the first coordinate
  75167. * @param y defines the second coordinate
  75168. * @returns the current updated Vector2
  75169. */
  75170. copyFromFloats(x: number, y: number): Vector2;
  75171. /**
  75172. * Sets the Vector2 coordinates with the given floats
  75173. * @param x defines the first coordinate
  75174. * @param y defines the second coordinate
  75175. * @returns the current updated Vector2
  75176. */
  75177. set(x: number, y: number): Vector2;
  75178. /**
  75179. * Add another vector with the current one
  75180. * @param otherVector defines the other vector
  75181. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75182. */
  75183. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75184. /**
  75185. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75186. * @param otherVector defines the other vector
  75187. * @param result defines the target vector
  75188. * @returns the unmodified current Vector2
  75189. */
  75190. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75191. /**
  75192. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75193. * @param otherVector defines the other vector
  75194. * @returns the current updated Vector2
  75195. */
  75196. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75197. /**
  75198. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75199. * @param otherVector defines the other vector
  75200. * @returns a new Vector2
  75201. */
  75202. addVector3(otherVector: Vector3): Vector2;
  75203. /**
  75204. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75205. * @param otherVector defines the other vector
  75206. * @returns a new Vector2
  75207. */
  75208. subtract(otherVector: Vector2): Vector2;
  75209. /**
  75210. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75211. * @param otherVector defines the other vector
  75212. * @param result defines the target vector
  75213. * @returns the unmodified current Vector2
  75214. */
  75215. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75216. /**
  75217. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75218. * @param otherVector defines the other vector
  75219. * @returns the current updated Vector2
  75220. */
  75221. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75222. /**
  75223. * Multiplies in place the current Vector2 coordinates by the given ones
  75224. * @param otherVector defines the other vector
  75225. * @returns the current updated Vector2
  75226. */
  75227. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75228. /**
  75229. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75230. * @param otherVector defines the other vector
  75231. * @returns a new Vector2
  75232. */
  75233. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75234. /**
  75235. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75236. * @param otherVector defines the other vector
  75237. * @param result defines the target vector
  75238. * @returns the unmodified current Vector2
  75239. */
  75240. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75241. /**
  75242. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75243. * @param x defines the first coordinate
  75244. * @param y defines the second coordinate
  75245. * @returns a new Vector2
  75246. */
  75247. multiplyByFloats(x: number, y: number): Vector2;
  75248. /**
  75249. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75250. * @param otherVector defines the other vector
  75251. * @returns a new Vector2
  75252. */
  75253. divide(otherVector: Vector2): Vector2;
  75254. /**
  75255. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75256. * @param otherVector defines the other vector
  75257. * @param result defines the target vector
  75258. * @returns the unmodified current Vector2
  75259. */
  75260. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75261. /**
  75262. * Divides the current Vector2 coordinates by the given ones
  75263. * @param otherVector defines the other vector
  75264. * @returns the current updated Vector2
  75265. */
  75266. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75267. /**
  75268. * Gets a new Vector2 with current Vector2 negated coordinates
  75269. * @returns a new Vector2
  75270. */
  75271. negate(): Vector2;
  75272. /**
  75273. * Negate this vector in place
  75274. * @returns this
  75275. */
  75276. negateInPlace(): Vector2;
  75277. /**
  75278. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75279. * @param result defines the Vector3 object where to store the result
  75280. * @returns the current Vector2
  75281. */
  75282. negateToRef(result: Vector2): Vector2;
  75283. /**
  75284. * Multiply the Vector2 coordinates by scale
  75285. * @param scale defines the scaling factor
  75286. * @returns the current updated Vector2
  75287. */
  75288. scaleInPlace(scale: number): Vector2;
  75289. /**
  75290. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75291. * @param scale defines the scaling factor
  75292. * @returns a new Vector2
  75293. */
  75294. scale(scale: number): Vector2;
  75295. /**
  75296. * Scale the current Vector2 values by a factor to a given Vector2
  75297. * @param scale defines the scale factor
  75298. * @param result defines the Vector2 object where to store the result
  75299. * @returns the unmodified current Vector2
  75300. */
  75301. scaleToRef(scale: number, result: Vector2): Vector2;
  75302. /**
  75303. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75304. * @param scale defines the scale factor
  75305. * @param result defines the Vector2 object where to store the result
  75306. * @returns the unmodified current Vector2
  75307. */
  75308. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75309. /**
  75310. * Gets a boolean if two vectors are equals
  75311. * @param otherVector defines the other vector
  75312. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75313. */
  75314. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75315. /**
  75316. * Gets a boolean if two vectors are equals (using an epsilon value)
  75317. * @param otherVector defines the other vector
  75318. * @param epsilon defines the minimal distance to consider equality
  75319. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75320. */
  75321. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75322. /**
  75323. * Gets a new Vector2 from current Vector2 floored values
  75324. * @returns a new Vector2
  75325. */
  75326. floor(): Vector2;
  75327. /**
  75328. * Gets a new Vector2 from current Vector2 floored values
  75329. * @returns a new Vector2
  75330. */
  75331. fract(): Vector2;
  75332. /**
  75333. * Gets the length of the vector
  75334. * @returns the vector length (float)
  75335. */
  75336. length(): number;
  75337. /**
  75338. * Gets the vector squared length
  75339. * @returns the vector squared length (float)
  75340. */
  75341. lengthSquared(): number;
  75342. /**
  75343. * Normalize the vector
  75344. * @returns the current updated Vector2
  75345. */
  75346. normalize(): Vector2;
  75347. /**
  75348. * Gets a new Vector2 copied from the Vector2
  75349. * @returns a new Vector2
  75350. */
  75351. clone(): Vector2;
  75352. /**
  75353. * Gets a new Vector2(0, 0)
  75354. * @returns a new Vector2
  75355. */
  75356. static Zero(): Vector2;
  75357. /**
  75358. * Gets a new Vector2(1, 1)
  75359. * @returns a new Vector2
  75360. */
  75361. static One(): Vector2;
  75362. /**
  75363. * Gets a new Vector2 set from the given index element of the given array
  75364. * @param array defines the data source
  75365. * @param offset defines the offset in the data source
  75366. * @returns a new Vector2
  75367. */
  75368. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75369. /**
  75370. * Sets "result" from the given index element of the given array
  75371. * @param array defines the data source
  75372. * @param offset defines the offset in the data source
  75373. * @param result defines the target vector
  75374. */
  75375. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75376. /**
  75377. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75378. * @param value1 defines 1st point of control
  75379. * @param value2 defines 2nd point of control
  75380. * @param value3 defines 3rd point of control
  75381. * @param value4 defines 4th point of control
  75382. * @param amount defines the interpolation factor
  75383. * @returns a new Vector2
  75384. */
  75385. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75386. /**
  75387. * 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".
  75388. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75389. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75390. * @param value defines the value to clamp
  75391. * @param min defines the lower limit
  75392. * @param max defines the upper limit
  75393. * @returns a new Vector2
  75394. */
  75395. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75396. /**
  75397. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75398. * @param value1 defines the 1st control point
  75399. * @param tangent1 defines the outgoing tangent
  75400. * @param value2 defines the 2nd control point
  75401. * @param tangent2 defines the incoming tangent
  75402. * @param amount defines the interpolation factor
  75403. * @returns a new Vector2
  75404. */
  75405. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75406. /**
  75407. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75408. * @param start defines the start vector
  75409. * @param end defines the end vector
  75410. * @param amount defines the interpolation factor
  75411. * @returns a new Vector2
  75412. */
  75413. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75414. /**
  75415. * Gets the dot product of the vector "left" and the vector "right"
  75416. * @param left defines first vector
  75417. * @param right defines second vector
  75418. * @returns the dot product (float)
  75419. */
  75420. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75421. /**
  75422. * Returns a new Vector2 equal to the normalized given vector
  75423. * @param vector defines the vector to normalize
  75424. * @returns a new Vector2
  75425. */
  75426. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75427. /**
  75428. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75429. * @param left defines 1st vector
  75430. * @param right defines 2nd vector
  75431. * @returns a new Vector2
  75432. */
  75433. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75434. /**
  75435. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75436. * @param left defines 1st vector
  75437. * @param right defines 2nd vector
  75438. * @returns a new Vector2
  75439. */
  75440. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75441. /**
  75442. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75443. * @param vector defines the vector to transform
  75444. * @param transformation defines the matrix to apply
  75445. * @returns a new Vector2
  75446. */
  75447. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75448. /**
  75449. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75450. * @param vector defines the vector to transform
  75451. * @param transformation defines the matrix to apply
  75452. * @param result defines the target vector
  75453. */
  75454. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75455. /**
  75456. * Determines if a given vector is included in a triangle
  75457. * @param p defines the vector to test
  75458. * @param p0 defines 1st triangle point
  75459. * @param p1 defines 2nd triangle point
  75460. * @param p2 defines 3rd triangle point
  75461. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75462. */
  75463. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75464. /**
  75465. * Gets the distance between the vectors "value1" and "value2"
  75466. * @param value1 defines first vector
  75467. * @param value2 defines second vector
  75468. * @returns the distance between vectors
  75469. */
  75470. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75471. /**
  75472. * Returns the squared distance between the vectors "value1" and "value2"
  75473. * @param value1 defines first vector
  75474. * @param value2 defines second vector
  75475. * @returns the squared distance between vectors
  75476. */
  75477. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75478. /**
  75479. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75480. * @param value1 defines first vector
  75481. * @param value2 defines second vector
  75482. * @returns a new Vector2
  75483. */
  75484. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75485. /**
  75486. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75487. * @param p defines the middle point
  75488. * @param segA defines one point of the segment
  75489. * @param segB defines the other point of the segment
  75490. * @returns the shortest distance
  75491. */
  75492. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75493. }
  75494. /**
  75495. * Class used to store (x,y,z) vector representation
  75496. * A Vector3 is the main object used in 3D geometry
  75497. * It can represent etiher the coordinates of a point the space, either a direction
  75498. * Reminder: js uses a left handed forward facing system
  75499. */
  75500. export class Vector3 {
  75501. /**
  75502. * Defines the first coordinates (on X axis)
  75503. */
  75504. x: number;
  75505. /**
  75506. * Defines the second coordinates (on Y axis)
  75507. */
  75508. y: number;
  75509. /**
  75510. * Defines the third coordinates (on Z axis)
  75511. */
  75512. z: number;
  75513. private static _UpReadOnly;
  75514. private static _ZeroReadOnly;
  75515. /**
  75516. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75517. * @param x defines the first coordinates (on X axis)
  75518. * @param y defines the second coordinates (on Y axis)
  75519. * @param z defines the third coordinates (on Z axis)
  75520. */
  75521. constructor(
  75522. /**
  75523. * Defines the first coordinates (on X axis)
  75524. */
  75525. x?: number,
  75526. /**
  75527. * Defines the second coordinates (on Y axis)
  75528. */
  75529. y?: number,
  75530. /**
  75531. * Defines the third coordinates (on Z axis)
  75532. */
  75533. z?: number);
  75534. /**
  75535. * Creates a string representation of the Vector3
  75536. * @returns a string with the Vector3 coordinates.
  75537. */
  75538. toString(): string;
  75539. /**
  75540. * Gets the class name
  75541. * @returns the string "Vector3"
  75542. */
  75543. getClassName(): string;
  75544. /**
  75545. * Creates the Vector3 hash code
  75546. * @returns a number which tends to be unique between Vector3 instances
  75547. */
  75548. getHashCode(): number;
  75549. /**
  75550. * Creates an array containing three elements : the coordinates of the Vector3
  75551. * @returns a new array of numbers
  75552. */
  75553. asArray(): number[];
  75554. /**
  75555. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75556. * @param array defines the destination array
  75557. * @param index defines the offset in the destination array
  75558. * @returns the current Vector3
  75559. */
  75560. toArray(array: FloatArray, index?: number): Vector3;
  75561. /**
  75562. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75563. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75564. */
  75565. toQuaternion(): Quaternion;
  75566. /**
  75567. * Adds the given vector to the current Vector3
  75568. * @param otherVector defines the second operand
  75569. * @returns the current updated Vector3
  75570. */
  75571. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75572. /**
  75573. * Adds the given coordinates to the current Vector3
  75574. * @param x defines the x coordinate of the operand
  75575. * @param y defines the y coordinate of the operand
  75576. * @param z defines the z coordinate of the operand
  75577. * @returns the current updated Vector3
  75578. */
  75579. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75580. /**
  75581. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75582. * @param otherVector defines the second operand
  75583. * @returns the resulting Vector3
  75584. */
  75585. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75586. /**
  75587. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75588. * @param otherVector defines the second operand
  75589. * @param result defines the Vector3 object where to store the result
  75590. * @returns the current Vector3
  75591. */
  75592. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75593. /**
  75594. * Subtract the given vector from the current Vector3
  75595. * @param otherVector defines the second operand
  75596. * @returns the current updated Vector3
  75597. */
  75598. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75599. /**
  75600. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75601. * @param otherVector defines the second operand
  75602. * @returns the resulting Vector3
  75603. */
  75604. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75605. /**
  75606. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75607. * @param otherVector defines the second operand
  75608. * @param result defines the Vector3 object where to store the result
  75609. * @returns the current Vector3
  75610. */
  75611. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75612. /**
  75613. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75614. * @param x defines the x coordinate of the operand
  75615. * @param y defines the y coordinate of the operand
  75616. * @param z defines the z coordinate of the operand
  75617. * @returns the resulting Vector3
  75618. */
  75619. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75620. /**
  75621. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75622. * @param x defines the x coordinate of the operand
  75623. * @param y defines the y coordinate of the operand
  75624. * @param z defines the z coordinate of the operand
  75625. * @param result defines the Vector3 object where to store the result
  75626. * @returns the current Vector3
  75627. */
  75628. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75629. /**
  75630. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75631. * @returns a new Vector3
  75632. */
  75633. negate(): Vector3;
  75634. /**
  75635. * Negate this vector in place
  75636. * @returns this
  75637. */
  75638. negateInPlace(): Vector3;
  75639. /**
  75640. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75641. * @param result defines the Vector3 object where to store the result
  75642. * @returns the current Vector3
  75643. */
  75644. negateToRef(result: Vector3): Vector3;
  75645. /**
  75646. * Multiplies the Vector3 coordinates by the float "scale"
  75647. * @param scale defines the multiplier factor
  75648. * @returns the current updated Vector3
  75649. */
  75650. scaleInPlace(scale: number): Vector3;
  75651. /**
  75652. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75653. * @param scale defines the multiplier factor
  75654. * @returns a new Vector3
  75655. */
  75656. scale(scale: number): Vector3;
  75657. /**
  75658. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75659. * @param scale defines the multiplier factor
  75660. * @param result defines the Vector3 object where to store the result
  75661. * @returns the current Vector3
  75662. */
  75663. scaleToRef(scale: number, result: Vector3): Vector3;
  75664. /**
  75665. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75666. * @param scale defines the scale factor
  75667. * @param result defines the Vector3 object where to store the result
  75668. * @returns the unmodified current Vector3
  75669. */
  75670. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75671. /**
  75672. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75673. * @param otherVector defines the second operand
  75674. * @returns true if both vectors are equals
  75675. */
  75676. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75677. /**
  75678. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75679. * @param otherVector defines the second operand
  75680. * @param epsilon defines the minimal distance to define values as equals
  75681. * @returns true if both vectors are distant less than epsilon
  75682. */
  75683. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75684. /**
  75685. * Returns true if the current Vector3 coordinates equals the given floats
  75686. * @param x defines the x coordinate of the operand
  75687. * @param y defines the y coordinate of the operand
  75688. * @param z defines the z coordinate of the operand
  75689. * @returns true if both vectors are equals
  75690. */
  75691. equalsToFloats(x: number, y: number, z: number): boolean;
  75692. /**
  75693. * Multiplies the current Vector3 coordinates by the given ones
  75694. * @param otherVector defines the second operand
  75695. * @returns the current updated Vector3
  75696. */
  75697. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75698. /**
  75699. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75700. * @param otherVector defines the second operand
  75701. * @returns the new Vector3
  75702. */
  75703. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75704. /**
  75705. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75706. * @param otherVector defines the second operand
  75707. * @param result defines the Vector3 object where to store the result
  75708. * @returns the current Vector3
  75709. */
  75710. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75711. /**
  75712. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75713. * @param x defines the x coordinate of the operand
  75714. * @param y defines the y coordinate of the operand
  75715. * @param z defines the z coordinate of the operand
  75716. * @returns the new Vector3
  75717. */
  75718. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75719. /**
  75720. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75721. * @param otherVector defines the second operand
  75722. * @returns the new Vector3
  75723. */
  75724. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75725. /**
  75726. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75727. * @param otherVector defines the second operand
  75728. * @param result defines the Vector3 object where to store the result
  75729. * @returns the current Vector3
  75730. */
  75731. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75732. /**
  75733. * Divides the current Vector3 coordinates by the given ones.
  75734. * @param otherVector defines the second operand
  75735. * @returns the current updated Vector3
  75736. */
  75737. divideInPlace(otherVector: Vector3): Vector3;
  75738. /**
  75739. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75740. * @param other defines the second operand
  75741. * @returns the current updated Vector3
  75742. */
  75743. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75744. /**
  75745. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75746. * @param other defines the second operand
  75747. * @returns the current updated Vector3
  75748. */
  75749. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75750. /**
  75751. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75752. * @param x defines the x coordinate of the operand
  75753. * @param y defines the y coordinate of the operand
  75754. * @param z defines the z coordinate of the operand
  75755. * @returns the current updated Vector3
  75756. */
  75757. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75758. /**
  75759. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75760. * @param x defines the x coordinate of the operand
  75761. * @param y defines the y coordinate of the operand
  75762. * @param z defines the z coordinate of the operand
  75763. * @returns the current updated Vector3
  75764. */
  75765. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75766. /**
  75767. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75768. * Check if is non uniform within a certain amount of decimal places to account for this
  75769. * @param epsilon the amount the values can differ
  75770. * @returns if the the vector is non uniform to a certain number of decimal places
  75771. */
  75772. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75773. /**
  75774. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75775. */
  75776. get isNonUniform(): boolean;
  75777. /**
  75778. * Gets a new Vector3 from current Vector3 floored values
  75779. * @returns a new Vector3
  75780. */
  75781. floor(): Vector3;
  75782. /**
  75783. * Gets a new Vector3 from current Vector3 floored values
  75784. * @returns a new Vector3
  75785. */
  75786. fract(): Vector3;
  75787. /**
  75788. * Gets the length of the Vector3
  75789. * @returns the length of the Vector3
  75790. */
  75791. length(): number;
  75792. /**
  75793. * Gets the squared length of the Vector3
  75794. * @returns squared length of the Vector3
  75795. */
  75796. lengthSquared(): number;
  75797. /**
  75798. * Normalize the current Vector3.
  75799. * Please note that this is an in place operation.
  75800. * @returns the current updated Vector3
  75801. */
  75802. normalize(): Vector3;
  75803. /**
  75804. * Reorders the x y z properties of the vector in place
  75805. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75806. * @returns the current updated vector
  75807. */
  75808. reorderInPlace(order: string): this;
  75809. /**
  75810. * Rotates the vector around 0,0,0 by a quaternion
  75811. * @param quaternion the rotation quaternion
  75812. * @param result vector to store the result
  75813. * @returns the resulting vector
  75814. */
  75815. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75816. /**
  75817. * Rotates a vector around a given point
  75818. * @param quaternion the rotation quaternion
  75819. * @param point the point to rotate around
  75820. * @param result vector to store the result
  75821. * @returns the resulting vector
  75822. */
  75823. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75824. /**
  75825. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75826. * The cross product is then orthogonal to both current and "other"
  75827. * @param other defines the right operand
  75828. * @returns the cross product
  75829. */
  75830. cross(other: Vector3): Vector3;
  75831. /**
  75832. * Normalize the current Vector3 with the given input length.
  75833. * Please note that this is an in place operation.
  75834. * @param len the length of the vector
  75835. * @returns the current updated Vector3
  75836. */
  75837. normalizeFromLength(len: number): Vector3;
  75838. /**
  75839. * Normalize the current Vector3 to a new vector
  75840. * @returns the new Vector3
  75841. */
  75842. normalizeToNew(): Vector3;
  75843. /**
  75844. * Normalize the current Vector3 to the reference
  75845. * @param reference define the Vector3 to update
  75846. * @returns the updated Vector3
  75847. */
  75848. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75849. /**
  75850. * Creates a new Vector3 copied from the current Vector3
  75851. * @returns the new Vector3
  75852. */
  75853. clone(): Vector3;
  75854. /**
  75855. * Copies the given vector coordinates to the current Vector3 ones
  75856. * @param source defines the source Vector3
  75857. * @returns the current updated Vector3
  75858. */
  75859. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75860. /**
  75861. * Copies the given floats to the current Vector3 coordinates
  75862. * @param x defines the x coordinate of the operand
  75863. * @param y defines the y coordinate of the operand
  75864. * @param z defines the z coordinate of the operand
  75865. * @returns the current updated Vector3
  75866. */
  75867. copyFromFloats(x: number, y: number, z: number): Vector3;
  75868. /**
  75869. * Copies the given floats to the current Vector3 coordinates
  75870. * @param x defines the x coordinate of the operand
  75871. * @param y defines the y coordinate of the operand
  75872. * @param z defines the z coordinate of the operand
  75873. * @returns the current updated Vector3
  75874. */
  75875. set(x: number, y: number, z: number): Vector3;
  75876. /**
  75877. * Copies the given float to the current Vector3 coordinates
  75878. * @param v defines the x, y and z coordinates of the operand
  75879. * @returns the current updated Vector3
  75880. */
  75881. setAll(v: number): Vector3;
  75882. /**
  75883. * Get the clip factor between two vectors
  75884. * @param vector0 defines the first operand
  75885. * @param vector1 defines the second operand
  75886. * @param axis defines the axis to use
  75887. * @param size defines the size along the axis
  75888. * @returns the clip factor
  75889. */
  75890. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75891. /**
  75892. * Get angle between two vectors
  75893. * @param vector0 angle between vector0 and vector1
  75894. * @param vector1 angle between vector0 and vector1
  75895. * @param normal direction of the normal
  75896. * @return the angle between vector0 and vector1
  75897. */
  75898. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75899. /**
  75900. * Returns a new Vector3 set from the index "offset" of the given array
  75901. * @param array defines the source array
  75902. * @param offset defines the offset in the source array
  75903. * @returns the new Vector3
  75904. */
  75905. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75906. /**
  75907. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75908. * @param array defines the source array
  75909. * @param offset defines the offset in the source array
  75910. * @returns the new Vector3
  75911. * @deprecated Please use FromArray instead.
  75912. */
  75913. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75914. /**
  75915. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75916. * @param array defines the source array
  75917. * @param offset defines the offset in the source array
  75918. * @param result defines the Vector3 where to store the result
  75919. */
  75920. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75921. /**
  75922. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75923. * @param array defines the source array
  75924. * @param offset defines the offset in the source array
  75925. * @param result defines the Vector3 where to store the result
  75926. * @deprecated Please use FromArrayToRef instead.
  75927. */
  75928. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75929. /**
  75930. * Sets the given vector "result" with the given floats.
  75931. * @param x defines the x coordinate of the source
  75932. * @param y defines the y coordinate of the source
  75933. * @param z defines the z coordinate of the source
  75934. * @param result defines the Vector3 where to store the result
  75935. */
  75936. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75937. /**
  75938. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75939. * @returns a new empty Vector3
  75940. */
  75941. static Zero(): Vector3;
  75942. /**
  75943. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75944. * @returns a new unit Vector3
  75945. */
  75946. static One(): Vector3;
  75947. /**
  75948. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75949. * @returns a new up Vector3
  75950. */
  75951. static Up(): Vector3;
  75952. /**
  75953. * Gets a up Vector3 that must not be updated
  75954. */
  75955. static get UpReadOnly(): DeepImmutable<Vector3>;
  75956. /**
  75957. * Gets a zero Vector3 that must not be updated
  75958. */
  75959. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75960. /**
  75961. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75962. * @returns a new down Vector3
  75963. */
  75964. static Down(): Vector3;
  75965. /**
  75966. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75967. * @returns a new forward Vector3
  75968. */
  75969. static Forward(): Vector3;
  75970. /**
  75971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75972. * @returns a new forward Vector3
  75973. */
  75974. static Backward(): Vector3;
  75975. /**
  75976. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75977. * @returns a new right Vector3
  75978. */
  75979. static Right(): Vector3;
  75980. /**
  75981. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75982. * @returns a new left Vector3
  75983. */
  75984. static Left(): Vector3;
  75985. /**
  75986. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75987. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75988. * @param vector defines the Vector3 to transform
  75989. * @param transformation defines the transformation matrix
  75990. * @returns the transformed Vector3
  75991. */
  75992. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75993. /**
  75994. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75995. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75996. * @param vector defines the Vector3 to transform
  75997. * @param transformation defines the transformation matrix
  75998. * @param result defines the Vector3 where to store the result
  75999. */
  76000. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76001. /**
  76002. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76003. * This method computes tranformed coordinates only, not transformed direction vectors
  76004. * @param x define the x coordinate of the source vector
  76005. * @param y define the y coordinate of the source vector
  76006. * @param z define the z coordinate of the source vector
  76007. * @param transformation defines the transformation matrix
  76008. * @param result defines the Vector3 where to store the result
  76009. */
  76010. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76011. /**
  76012. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76013. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76014. * @param vector defines the Vector3 to transform
  76015. * @param transformation defines the transformation matrix
  76016. * @returns the new Vector3
  76017. */
  76018. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76019. /**
  76020. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76021. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76022. * @param vector defines the Vector3 to transform
  76023. * @param transformation defines the transformation matrix
  76024. * @param result defines the Vector3 where to store the result
  76025. */
  76026. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76027. /**
  76028. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76029. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76030. * @param x define the x coordinate of the source vector
  76031. * @param y define the y coordinate of the source vector
  76032. * @param z define the z coordinate of the source vector
  76033. * @param transformation defines the transformation matrix
  76034. * @param result defines the Vector3 where to store the result
  76035. */
  76036. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76037. /**
  76038. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76039. * @param value1 defines the first control point
  76040. * @param value2 defines the second control point
  76041. * @param value3 defines the third control point
  76042. * @param value4 defines the fourth control point
  76043. * @param amount defines the amount on the spline to use
  76044. * @returns the new Vector3
  76045. */
  76046. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76047. /**
  76048. * 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"
  76049. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76050. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76051. * @param value defines the current value
  76052. * @param min defines the lower range value
  76053. * @param max defines the upper range value
  76054. * @returns the new Vector3
  76055. */
  76056. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76057. /**
  76058. * 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"
  76059. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76060. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76061. * @param value defines the current value
  76062. * @param min defines the lower range value
  76063. * @param max defines the upper range value
  76064. * @param result defines the Vector3 where to store the result
  76065. */
  76066. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76067. /**
  76068. * Checks if a given vector is inside a specific range
  76069. * @param v defines the vector to test
  76070. * @param min defines the minimum range
  76071. * @param max defines the maximum range
  76072. */
  76073. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76074. /**
  76075. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76076. * @param value1 defines the first control point
  76077. * @param tangent1 defines the first tangent vector
  76078. * @param value2 defines the second control point
  76079. * @param tangent2 defines the second tangent vector
  76080. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76081. * @returns the new Vector3
  76082. */
  76083. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76084. /**
  76085. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76086. * @param start defines the start value
  76087. * @param end defines the end value
  76088. * @param amount max defines amount between both (between 0 and 1)
  76089. * @returns the new Vector3
  76090. */
  76091. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76092. /**
  76093. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76094. * @param start defines the start value
  76095. * @param end defines the end value
  76096. * @param amount max defines amount between both (between 0 and 1)
  76097. * @param result defines the Vector3 where to store the result
  76098. */
  76099. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76100. /**
  76101. * Returns the dot product (float) between the vectors "left" and "right"
  76102. * @param left defines the left operand
  76103. * @param right defines the right operand
  76104. * @returns the dot product
  76105. */
  76106. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76107. /**
  76108. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76109. * The cross product is then orthogonal to both "left" and "right"
  76110. * @param left defines the left operand
  76111. * @param right defines the right operand
  76112. * @returns the cross product
  76113. */
  76114. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76115. /**
  76116. * Sets the given vector "result" with the cross product of "left" and "right"
  76117. * The cross product is then orthogonal to both "left" and "right"
  76118. * @param left defines the left operand
  76119. * @param right defines the right operand
  76120. * @param result defines the Vector3 where to store the result
  76121. */
  76122. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76123. /**
  76124. * Returns a new Vector3 as the normalization of the given vector
  76125. * @param vector defines the Vector3 to normalize
  76126. * @returns the new Vector3
  76127. */
  76128. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76129. /**
  76130. * Sets the given vector "result" with the normalization of the given first vector
  76131. * @param vector defines the Vector3 to normalize
  76132. * @param result defines the Vector3 where to store the result
  76133. */
  76134. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76135. /**
  76136. * Project a Vector3 onto screen space
  76137. * @param vector defines the Vector3 to project
  76138. * @param world defines the world matrix to use
  76139. * @param transform defines the transform (view x projection) matrix to use
  76140. * @param viewport defines the screen viewport to use
  76141. * @returns the new Vector3
  76142. */
  76143. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76144. /** @hidden */
  76145. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76146. /**
  76147. * Unproject from screen space to object space
  76148. * @param source defines the screen space Vector3 to use
  76149. * @param viewportWidth defines the current width of the viewport
  76150. * @param viewportHeight defines the current height of the viewport
  76151. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76152. * @param transform defines the transform (view x projection) matrix to use
  76153. * @returns the new Vector3
  76154. */
  76155. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76156. /**
  76157. * Unproject from screen space to object space
  76158. * @param source defines the screen space Vector3 to use
  76159. * @param viewportWidth defines the current width of the viewport
  76160. * @param viewportHeight defines the current height of the viewport
  76161. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76162. * @param view defines the view matrix to use
  76163. * @param projection defines the projection matrix to use
  76164. * @returns the new Vector3
  76165. */
  76166. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76167. /**
  76168. * Unproject from screen space to object space
  76169. * @param source defines the screen space Vector3 to use
  76170. * @param viewportWidth defines the current width of the viewport
  76171. * @param viewportHeight defines the current height of the viewport
  76172. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76173. * @param view defines the view matrix to use
  76174. * @param projection defines the projection matrix to use
  76175. * @param result defines the Vector3 where to store the result
  76176. */
  76177. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76178. /**
  76179. * Unproject from screen space to object space
  76180. * @param sourceX defines the screen space x coordinate to use
  76181. * @param sourceY defines the screen space y coordinate to use
  76182. * @param sourceZ defines the screen space z coordinate to use
  76183. * @param viewportWidth defines the current width of the viewport
  76184. * @param viewportHeight defines the current height of the viewport
  76185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76186. * @param view defines the view matrix to use
  76187. * @param projection defines the projection matrix to use
  76188. * @param result defines the Vector3 where to store the result
  76189. */
  76190. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76191. /**
  76192. * Gets the minimal coordinate values between two Vector3
  76193. * @param left defines the first operand
  76194. * @param right defines the second operand
  76195. * @returns the new Vector3
  76196. */
  76197. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76198. /**
  76199. * Gets the maximal coordinate values between two Vector3
  76200. * @param left defines the first operand
  76201. * @param right defines the second operand
  76202. * @returns the new Vector3
  76203. */
  76204. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76205. /**
  76206. * Returns the distance between the vectors "value1" and "value2"
  76207. * @param value1 defines the first operand
  76208. * @param value2 defines the second operand
  76209. * @returns the distance
  76210. */
  76211. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76212. /**
  76213. * Returns the squared distance between the vectors "value1" and "value2"
  76214. * @param value1 defines the first operand
  76215. * @param value2 defines the second operand
  76216. * @returns the squared distance
  76217. */
  76218. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76219. /**
  76220. * Returns a new Vector3 located at the center between "value1" and "value2"
  76221. * @param value1 defines the first operand
  76222. * @param value2 defines the second operand
  76223. * @returns the new Vector3
  76224. */
  76225. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76226. /**
  76227. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76228. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76229. * to something in order to rotate it from its local system to the given target system
  76230. * Note: axis1, axis2 and axis3 are normalized during this operation
  76231. * @param axis1 defines the first axis
  76232. * @param axis2 defines the second axis
  76233. * @param axis3 defines the third axis
  76234. * @returns a new Vector3
  76235. */
  76236. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76237. /**
  76238. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76239. * @param axis1 defines the first axis
  76240. * @param axis2 defines the second axis
  76241. * @param axis3 defines the third axis
  76242. * @param ref defines the Vector3 where to store the result
  76243. */
  76244. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76245. }
  76246. /**
  76247. * Vector4 class created for EulerAngle class conversion to Quaternion
  76248. */
  76249. export class Vector4 {
  76250. /** x value of the vector */
  76251. x: number;
  76252. /** y value of the vector */
  76253. y: number;
  76254. /** z value of the vector */
  76255. z: number;
  76256. /** w value of the vector */
  76257. w: number;
  76258. /**
  76259. * Creates a Vector4 object from the given floats.
  76260. * @param x x value of the vector
  76261. * @param y y value of the vector
  76262. * @param z z value of the vector
  76263. * @param w w value of the vector
  76264. */
  76265. constructor(
  76266. /** x value of the vector */
  76267. x: number,
  76268. /** y value of the vector */
  76269. y: number,
  76270. /** z value of the vector */
  76271. z: number,
  76272. /** w value of the vector */
  76273. w: number);
  76274. /**
  76275. * Returns the string with the Vector4 coordinates.
  76276. * @returns a string containing all the vector values
  76277. */
  76278. toString(): string;
  76279. /**
  76280. * Returns the string "Vector4".
  76281. * @returns "Vector4"
  76282. */
  76283. getClassName(): string;
  76284. /**
  76285. * Returns the Vector4 hash code.
  76286. * @returns a unique hash code
  76287. */
  76288. getHashCode(): number;
  76289. /**
  76290. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76291. * @returns the resulting array
  76292. */
  76293. asArray(): number[];
  76294. /**
  76295. * Populates the given array from the given index with the Vector4 coordinates.
  76296. * @param array array to populate
  76297. * @param index index of the array to start at (default: 0)
  76298. * @returns the Vector4.
  76299. */
  76300. toArray(array: FloatArray, index?: number): Vector4;
  76301. /**
  76302. * Adds the given vector to the current Vector4.
  76303. * @param otherVector the vector to add
  76304. * @returns the updated Vector4.
  76305. */
  76306. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76307. /**
  76308. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76309. * @param otherVector the vector to add
  76310. * @returns the resulting vector
  76311. */
  76312. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76313. /**
  76314. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76315. * @param otherVector the vector to add
  76316. * @param result the vector to store the result
  76317. * @returns the current Vector4.
  76318. */
  76319. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76320. /**
  76321. * Subtract in place the given vector from the current Vector4.
  76322. * @param otherVector the vector to subtract
  76323. * @returns the updated Vector4.
  76324. */
  76325. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76326. /**
  76327. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76328. * @param otherVector the vector to add
  76329. * @returns the new vector with the result
  76330. */
  76331. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76332. /**
  76333. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76334. * @param otherVector the vector to subtract
  76335. * @param result the vector to store the result
  76336. * @returns the current Vector4.
  76337. */
  76338. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76339. /**
  76340. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76341. */
  76342. /**
  76343. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76344. * @param x value to subtract
  76345. * @param y value to subtract
  76346. * @param z value to subtract
  76347. * @param w value to subtract
  76348. * @returns new vector containing the result
  76349. */
  76350. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76351. /**
  76352. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76353. * @param x value to subtract
  76354. * @param y value to subtract
  76355. * @param z value to subtract
  76356. * @param w value to subtract
  76357. * @param result the vector to store the result in
  76358. * @returns the current Vector4.
  76359. */
  76360. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76361. /**
  76362. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76363. * @returns a new vector with the negated values
  76364. */
  76365. negate(): Vector4;
  76366. /**
  76367. * Negate this vector in place
  76368. * @returns this
  76369. */
  76370. negateInPlace(): Vector4;
  76371. /**
  76372. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76373. * @param result defines the Vector3 object where to store the result
  76374. * @returns the current Vector4
  76375. */
  76376. negateToRef(result: Vector4): Vector4;
  76377. /**
  76378. * Multiplies the current Vector4 coordinates by scale (float).
  76379. * @param scale the number to scale with
  76380. * @returns the updated Vector4.
  76381. */
  76382. scaleInPlace(scale: number): Vector4;
  76383. /**
  76384. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76385. * @param scale the number to scale with
  76386. * @returns a new vector with the result
  76387. */
  76388. scale(scale: number): Vector4;
  76389. /**
  76390. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76391. * @param scale the number to scale with
  76392. * @param result a vector to store the result in
  76393. * @returns the current Vector4.
  76394. */
  76395. scaleToRef(scale: number, result: Vector4): Vector4;
  76396. /**
  76397. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76398. * @param scale defines the scale factor
  76399. * @param result defines the Vector4 object where to store the result
  76400. * @returns the unmodified current Vector4
  76401. */
  76402. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76403. /**
  76404. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76405. * @param otherVector the vector to compare against
  76406. * @returns true if they are equal
  76407. */
  76408. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76409. /**
  76410. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76411. * @param otherVector vector to compare against
  76412. * @param epsilon (Default: very small number)
  76413. * @returns true if they are equal
  76414. */
  76415. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76416. /**
  76417. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76418. * @param x x value to compare against
  76419. * @param y y value to compare against
  76420. * @param z z value to compare against
  76421. * @param w w value to compare against
  76422. * @returns true if equal
  76423. */
  76424. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76425. /**
  76426. * Multiplies in place the current Vector4 by the given one.
  76427. * @param otherVector vector to multiple with
  76428. * @returns the updated Vector4.
  76429. */
  76430. multiplyInPlace(otherVector: Vector4): Vector4;
  76431. /**
  76432. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76433. * @param otherVector vector to multiple with
  76434. * @returns resulting new vector
  76435. */
  76436. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76437. /**
  76438. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76439. * @param otherVector vector to multiple with
  76440. * @param result vector to store the result
  76441. * @returns the current Vector4.
  76442. */
  76443. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76444. /**
  76445. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76446. * @param x x value multiply with
  76447. * @param y y value multiply with
  76448. * @param z z value multiply with
  76449. * @param w w value multiply with
  76450. * @returns resulting new vector
  76451. */
  76452. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76453. /**
  76454. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76455. * @param otherVector vector to devide with
  76456. * @returns resulting new vector
  76457. */
  76458. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76459. /**
  76460. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76461. * @param otherVector vector to devide with
  76462. * @param result vector to store the result
  76463. * @returns the current Vector4.
  76464. */
  76465. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76466. /**
  76467. * Divides the current Vector3 coordinates by the given ones.
  76468. * @param otherVector vector to devide with
  76469. * @returns the updated Vector3.
  76470. */
  76471. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76472. /**
  76473. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76474. * @param other defines the second operand
  76475. * @returns the current updated Vector4
  76476. */
  76477. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76478. /**
  76479. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76480. * @param other defines the second operand
  76481. * @returns the current updated Vector4
  76482. */
  76483. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76484. /**
  76485. * Gets a new Vector4 from current Vector4 floored values
  76486. * @returns a new Vector4
  76487. */
  76488. floor(): Vector4;
  76489. /**
  76490. * Gets a new Vector4 from current Vector3 floored values
  76491. * @returns a new Vector4
  76492. */
  76493. fract(): Vector4;
  76494. /**
  76495. * Returns the Vector4 length (float).
  76496. * @returns the length
  76497. */
  76498. length(): number;
  76499. /**
  76500. * Returns the Vector4 squared length (float).
  76501. * @returns the length squared
  76502. */
  76503. lengthSquared(): number;
  76504. /**
  76505. * Normalizes in place the Vector4.
  76506. * @returns the updated Vector4.
  76507. */
  76508. normalize(): Vector4;
  76509. /**
  76510. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76511. * @returns this converted to a new vector3
  76512. */
  76513. toVector3(): Vector3;
  76514. /**
  76515. * Returns a new Vector4 copied from the current one.
  76516. * @returns the new cloned vector
  76517. */
  76518. clone(): Vector4;
  76519. /**
  76520. * Updates the current Vector4 with the given one coordinates.
  76521. * @param source the source vector to copy from
  76522. * @returns the updated Vector4.
  76523. */
  76524. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76525. /**
  76526. * Updates the current Vector4 coordinates with the given floats.
  76527. * @param x float to copy from
  76528. * @param y float to copy from
  76529. * @param z float to copy from
  76530. * @param w float to copy from
  76531. * @returns the updated Vector4.
  76532. */
  76533. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76534. /**
  76535. * Updates the current Vector4 coordinates with the given floats.
  76536. * @param x float to set from
  76537. * @param y float to set from
  76538. * @param z float to set from
  76539. * @param w float to set from
  76540. * @returns the updated Vector4.
  76541. */
  76542. set(x: number, y: number, z: number, w: number): Vector4;
  76543. /**
  76544. * Copies the given float to the current Vector3 coordinates
  76545. * @param v defines the x, y, z and w coordinates of the operand
  76546. * @returns the current updated Vector3
  76547. */
  76548. setAll(v: number): Vector4;
  76549. /**
  76550. * Returns a new Vector4 set from the starting index of the given array.
  76551. * @param array the array to pull values from
  76552. * @param offset the offset into the array to start at
  76553. * @returns the new vector
  76554. */
  76555. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76556. /**
  76557. * Updates the given vector "result" from the starting index of the given array.
  76558. * @param array the array to pull values from
  76559. * @param offset the offset into the array to start at
  76560. * @param result the vector to store the result in
  76561. */
  76562. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76563. /**
  76564. * Updates the given vector "result" from the starting index of the given Float32Array.
  76565. * @param array the array to pull values from
  76566. * @param offset the offset into the array to start at
  76567. * @param result the vector to store the result in
  76568. */
  76569. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76570. /**
  76571. * Updates the given vector "result" coordinates from the given floats.
  76572. * @param x float to set from
  76573. * @param y float to set from
  76574. * @param z float to set from
  76575. * @param w float to set from
  76576. * @param result the vector to the floats in
  76577. */
  76578. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76579. /**
  76580. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76581. * @returns the new vector
  76582. */
  76583. static Zero(): Vector4;
  76584. /**
  76585. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76586. * @returns the new vector
  76587. */
  76588. static One(): Vector4;
  76589. /**
  76590. * Returns a new normalized Vector4 from the given one.
  76591. * @param vector the vector to normalize
  76592. * @returns the vector
  76593. */
  76594. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76595. /**
  76596. * Updates the given vector "result" from the normalization of the given one.
  76597. * @param vector the vector to normalize
  76598. * @param result the vector to store the result in
  76599. */
  76600. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76601. /**
  76602. * Returns a vector with the minimum values from the left and right vectors
  76603. * @param left left vector to minimize
  76604. * @param right right vector to minimize
  76605. * @returns a new vector with the minimum of the left and right vector values
  76606. */
  76607. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76608. /**
  76609. * Returns a vector with the maximum values from the left and right vectors
  76610. * @param left left vector to maximize
  76611. * @param right right vector to maximize
  76612. * @returns a new vector with the maximum of the left and right vector values
  76613. */
  76614. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76615. /**
  76616. * Returns the distance (float) between the vectors "value1" and "value2".
  76617. * @param value1 value to calulate the distance between
  76618. * @param value2 value to calulate the distance between
  76619. * @return the distance between the two vectors
  76620. */
  76621. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76622. /**
  76623. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76624. * @param value1 value to calulate the distance between
  76625. * @param value2 value to calulate the distance between
  76626. * @return the distance between the two vectors squared
  76627. */
  76628. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76629. /**
  76630. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76631. * @param value1 value to calulate the center between
  76632. * @param value2 value to calulate the center between
  76633. * @return the center between the two vectors
  76634. */
  76635. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76636. /**
  76637. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76638. * This methods computes transformed normalized direction vectors only.
  76639. * @param vector the vector to transform
  76640. * @param transformation the transformation matrix to apply
  76641. * @returns the new vector
  76642. */
  76643. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76644. /**
  76645. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76646. * This methods computes transformed normalized direction vectors only.
  76647. * @param vector the vector to transform
  76648. * @param transformation the transformation matrix to apply
  76649. * @param result the vector to store the result in
  76650. */
  76651. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76652. /**
  76653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76654. * This methods computes transformed normalized direction vectors only.
  76655. * @param x value to transform
  76656. * @param y value to transform
  76657. * @param z value to transform
  76658. * @param w value to transform
  76659. * @param transformation the transformation matrix to apply
  76660. * @param result the vector to store the results in
  76661. */
  76662. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76663. /**
  76664. * Creates a new Vector4 from a Vector3
  76665. * @param source defines the source data
  76666. * @param w defines the 4th component (default is 0)
  76667. * @returns a new Vector4
  76668. */
  76669. static FromVector3(source: Vector3, w?: number): Vector4;
  76670. }
  76671. /**
  76672. * Class used to store quaternion data
  76673. * @see https://en.wikipedia.org/wiki/Quaternion
  76674. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76675. */
  76676. export class Quaternion {
  76677. /** defines the first component (0 by default) */
  76678. x: number;
  76679. /** defines the second component (0 by default) */
  76680. y: number;
  76681. /** defines the third component (0 by default) */
  76682. z: number;
  76683. /** defines the fourth component (1.0 by default) */
  76684. w: number;
  76685. /**
  76686. * Creates a new Quaternion from the given floats
  76687. * @param x defines the first component (0 by default)
  76688. * @param y defines the second component (0 by default)
  76689. * @param z defines the third component (0 by default)
  76690. * @param w defines the fourth component (1.0 by default)
  76691. */
  76692. constructor(
  76693. /** defines the first component (0 by default) */
  76694. x?: number,
  76695. /** defines the second component (0 by default) */
  76696. y?: number,
  76697. /** defines the third component (0 by default) */
  76698. z?: number,
  76699. /** defines the fourth component (1.0 by default) */
  76700. w?: number);
  76701. /**
  76702. * Gets a string representation for the current quaternion
  76703. * @returns a string with the Quaternion coordinates
  76704. */
  76705. toString(): string;
  76706. /**
  76707. * Gets the class name of the quaternion
  76708. * @returns the string "Quaternion"
  76709. */
  76710. getClassName(): string;
  76711. /**
  76712. * Gets a hash code for this quaternion
  76713. * @returns the quaternion hash code
  76714. */
  76715. getHashCode(): number;
  76716. /**
  76717. * Copy the quaternion to an array
  76718. * @returns a new array populated with 4 elements from the quaternion coordinates
  76719. */
  76720. asArray(): number[];
  76721. /**
  76722. * Check if two quaternions are equals
  76723. * @param otherQuaternion defines the second operand
  76724. * @return true if the current quaternion and the given one coordinates are strictly equals
  76725. */
  76726. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76727. /**
  76728. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76729. * @param otherQuaternion defines the other quaternion
  76730. * @param epsilon defines the minimal distance to consider equality
  76731. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76732. */
  76733. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76734. /**
  76735. * Clone the current quaternion
  76736. * @returns a new quaternion copied from the current one
  76737. */
  76738. clone(): Quaternion;
  76739. /**
  76740. * Copy a quaternion to the current one
  76741. * @param other defines the other quaternion
  76742. * @returns the updated current quaternion
  76743. */
  76744. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76745. /**
  76746. * Updates the current quaternion with the given float coordinates
  76747. * @param x defines the x coordinate
  76748. * @param y defines the y coordinate
  76749. * @param z defines the z coordinate
  76750. * @param w defines the w coordinate
  76751. * @returns the updated current quaternion
  76752. */
  76753. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76754. /**
  76755. * Updates the current quaternion from the given float coordinates
  76756. * @param x defines the x coordinate
  76757. * @param y defines the y coordinate
  76758. * @param z defines the z coordinate
  76759. * @param w defines the w coordinate
  76760. * @returns the updated current quaternion
  76761. */
  76762. set(x: number, y: number, z: number, w: number): Quaternion;
  76763. /**
  76764. * Adds two quaternions
  76765. * @param other defines the second operand
  76766. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76767. */
  76768. add(other: DeepImmutable<Quaternion>): Quaternion;
  76769. /**
  76770. * Add a quaternion to the current one
  76771. * @param other defines the quaternion to add
  76772. * @returns the current quaternion
  76773. */
  76774. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76775. /**
  76776. * Subtract two quaternions
  76777. * @param other defines the second operand
  76778. * @returns a new quaternion as the subtraction result of the given one from the current one
  76779. */
  76780. subtract(other: Quaternion): Quaternion;
  76781. /**
  76782. * Multiplies the current quaternion by a scale factor
  76783. * @param value defines the scale factor
  76784. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76785. */
  76786. scale(value: number): Quaternion;
  76787. /**
  76788. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76789. * @param scale defines the scale factor
  76790. * @param result defines the Quaternion object where to store the result
  76791. * @returns the unmodified current quaternion
  76792. */
  76793. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76794. /**
  76795. * Multiplies in place the current quaternion by a scale factor
  76796. * @param value defines the scale factor
  76797. * @returns the current modified quaternion
  76798. */
  76799. scaleInPlace(value: number): Quaternion;
  76800. /**
  76801. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76802. * @param scale defines the scale factor
  76803. * @param result defines the Quaternion object where to store the result
  76804. * @returns the unmodified current quaternion
  76805. */
  76806. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76807. /**
  76808. * Multiplies two quaternions
  76809. * @param q1 defines the second operand
  76810. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76811. */
  76812. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76813. /**
  76814. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76815. * @param q1 defines the second operand
  76816. * @param result defines the target quaternion
  76817. * @returns the current quaternion
  76818. */
  76819. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76820. /**
  76821. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76822. * @param q1 defines the second operand
  76823. * @returns the currentupdated quaternion
  76824. */
  76825. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76826. /**
  76827. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76828. * @param ref defines the target quaternion
  76829. * @returns the current quaternion
  76830. */
  76831. conjugateToRef(ref: Quaternion): Quaternion;
  76832. /**
  76833. * Conjugates in place (1-q) the current quaternion
  76834. * @returns the current updated quaternion
  76835. */
  76836. conjugateInPlace(): Quaternion;
  76837. /**
  76838. * Conjugates in place (1-q) the current quaternion
  76839. * @returns a new quaternion
  76840. */
  76841. conjugate(): Quaternion;
  76842. /**
  76843. * Gets length of current quaternion
  76844. * @returns the quaternion length (float)
  76845. */
  76846. length(): number;
  76847. /**
  76848. * Normalize in place the current quaternion
  76849. * @returns the current updated quaternion
  76850. */
  76851. normalize(): Quaternion;
  76852. /**
  76853. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76854. * @param order is a reserved parameter and is ignore for now
  76855. * @returns a new Vector3 containing the Euler angles
  76856. */
  76857. toEulerAngles(order?: string): Vector3;
  76858. /**
  76859. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76860. * @param result defines the vector which will be filled with the Euler angles
  76861. * @param order is a reserved parameter and is ignore for now
  76862. * @returns the current unchanged quaternion
  76863. */
  76864. toEulerAnglesToRef(result: Vector3): Quaternion;
  76865. /**
  76866. * Updates the given rotation matrix with the current quaternion values
  76867. * @param result defines the target matrix
  76868. * @returns the current unchanged quaternion
  76869. */
  76870. toRotationMatrix(result: Matrix): Quaternion;
  76871. /**
  76872. * Updates the current quaternion from the given rotation matrix values
  76873. * @param matrix defines the source matrix
  76874. * @returns the current updated quaternion
  76875. */
  76876. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76877. /**
  76878. * Creates a new quaternion from a rotation matrix
  76879. * @param matrix defines the source matrix
  76880. * @returns a new quaternion created from the given rotation matrix values
  76881. */
  76882. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76883. /**
  76884. * Updates the given quaternion with the given rotation matrix values
  76885. * @param matrix defines the source matrix
  76886. * @param result defines the target quaternion
  76887. */
  76888. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76889. /**
  76890. * Returns the dot product (float) between the quaternions "left" and "right"
  76891. * @param left defines the left operand
  76892. * @param right defines the right operand
  76893. * @returns the dot product
  76894. */
  76895. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76896. /**
  76897. * Checks if the two quaternions are close to each other
  76898. * @param quat0 defines the first quaternion to check
  76899. * @param quat1 defines the second quaternion to check
  76900. * @returns true if the two quaternions are close to each other
  76901. */
  76902. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76903. /**
  76904. * Creates an empty quaternion
  76905. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76906. */
  76907. static Zero(): Quaternion;
  76908. /**
  76909. * Inverse a given quaternion
  76910. * @param q defines the source quaternion
  76911. * @returns a new quaternion as the inverted current quaternion
  76912. */
  76913. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76914. /**
  76915. * Inverse a given quaternion
  76916. * @param q defines the source quaternion
  76917. * @param result the quaternion the result will be stored in
  76918. * @returns the result quaternion
  76919. */
  76920. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76921. /**
  76922. * Creates an identity quaternion
  76923. * @returns the identity quaternion
  76924. */
  76925. static Identity(): Quaternion;
  76926. /**
  76927. * Gets a boolean indicating if the given quaternion is identity
  76928. * @param quaternion defines the quaternion to check
  76929. * @returns true if the quaternion is identity
  76930. */
  76931. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76932. /**
  76933. * Creates a quaternion from a rotation around an axis
  76934. * @param axis defines the axis to use
  76935. * @param angle defines the angle to use
  76936. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76937. */
  76938. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76939. /**
  76940. * Creates a rotation around an axis and stores it into the given quaternion
  76941. * @param axis defines the axis to use
  76942. * @param angle defines the angle to use
  76943. * @param result defines the target quaternion
  76944. * @returns the target quaternion
  76945. */
  76946. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76947. /**
  76948. * Creates a new quaternion from data stored into an array
  76949. * @param array defines the data source
  76950. * @param offset defines the offset in the source array where the data starts
  76951. * @returns a new quaternion
  76952. */
  76953. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76954. /**
  76955. * Create a quaternion from Euler rotation angles
  76956. * @param x Pitch
  76957. * @param y Yaw
  76958. * @param z Roll
  76959. * @returns the new Quaternion
  76960. */
  76961. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76962. /**
  76963. * Updates a quaternion from Euler rotation angles
  76964. * @param x Pitch
  76965. * @param y Yaw
  76966. * @param z Roll
  76967. * @param result the quaternion to store the result
  76968. * @returns the updated quaternion
  76969. */
  76970. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76971. /**
  76972. * Create a quaternion from Euler rotation vector
  76973. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76974. * @returns the new Quaternion
  76975. */
  76976. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76977. /**
  76978. * Updates a quaternion from Euler rotation vector
  76979. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76980. * @param result the quaternion to store the result
  76981. * @returns the updated quaternion
  76982. */
  76983. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76984. /**
  76985. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76986. * @param yaw defines the rotation around Y axis
  76987. * @param pitch defines the rotation around X axis
  76988. * @param roll defines the rotation around Z axis
  76989. * @returns the new quaternion
  76990. */
  76991. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76992. /**
  76993. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76994. * @param yaw defines the rotation around Y axis
  76995. * @param pitch defines the rotation around X axis
  76996. * @param roll defines the rotation around Z axis
  76997. * @param result defines the target quaternion
  76998. */
  76999. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77000. /**
  77001. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77002. * @param alpha defines the rotation around first axis
  77003. * @param beta defines the rotation around second axis
  77004. * @param gamma defines the rotation around third axis
  77005. * @returns the new quaternion
  77006. */
  77007. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77008. /**
  77009. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77010. * @param alpha defines the rotation around first axis
  77011. * @param beta defines the rotation around second axis
  77012. * @param gamma defines the rotation around third axis
  77013. * @param result defines the target quaternion
  77014. */
  77015. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77016. /**
  77017. * 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)
  77018. * @param axis1 defines the first axis
  77019. * @param axis2 defines the second axis
  77020. * @param axis3 defines the third axis
  77021. * @returns the new quaternion
  77022. */
  77023. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77024. /**
  77025. * 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
  77026. * @param axis1 defines the first axis
  77027. * @param axis2 defines the second axis
  77028. * @param axis3 defines the third axis
  77029. * @param ref defines the target quaternion
  77030. */
  77031. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77032. /**
  77033. * Interpolates between two quaternions
  77034. * @param left defines first quaternion
  77035. * @param right defines second quaternion
  77036. * @param amount defines the gradient to use
  77037. * @returns the new interpolated quaternion
  77038. */
  77039. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77040. /**
  77041. * Interpolates between two quaternions and stores it into a target quaternion
  77042. * @param left defines first quaternion
  77043. * @param right defines second quaternion
  77044. * @param amount defines the gradient to use
  77045. * @param result defines the target quaternion
  77046. */
  77047. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77048. /**
  77049. * Interpolate between two quaternions using Hermite interpolation
  77050. * @param value1 defines first quaternion
  77051. * @param tangent1 defines the incoming tangent
  77052. * @param value2 defines second quaternion
  77053. * @param tangent2 defines the outgoing tangent
  77054. * @param amount defines the target quaternion
  77055. * @returns the new interpolated quaternion
  77056. */
  77057. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77058. }
  77059. /**
  77060. * Class used to store matrix data (4x4)
  77061. */
  77062. export class Matrix {
  77063. private static _updateFlagSeed;
  77064. private static _identityReadOnly;
  77065. private _isIdentity;
  77066. private _isIdentityDirty;
  77067. private _isIdentity3x2;
  77068. private _isIdentity3x2Dirty;
  77069. /**
  77070. * Gets the update flag of the matrix which is an unique number for the matrix.
  77071. * It will be incremented every time the matrix data change.
  77072. * You can use it to speed the comparison between two versions of the same matrix.
  77073. */
  77074. updateFlag: number;
  77075. private readonly _m;
  77076. /**
  77077. * Gets the internal data of the matrix
  77078. */
  77079. get m(): DeepImmutable<Float32Array>;
  77080. /** @hidden */
  77081. _markAsUpdated(): void;
  77082. /** @hidden */
  77083. private _updateIdentityStatus;
  77084. /**
  77085. * Creates an empty matrix (filled with zeros)
  77086. */
  77087. constructor();
  77088. /**
  77089. * Check if the current matrix is identity
  77090. * @returns true is the matrix is the identity matrix
  77091. */
  77092. isIdentity(): boolean;
  77093. /**
  77094. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77095. * @returns true is the matrix is the identity matrix
  77096. */
  77097. isIdentityAs3x2(): boolean;
  77098. /**
  77099. * Gets the determinant of the matrix
  77100. * @returns the matrix determinant
  77101. */
  77102. determinant(): number;
  77103. /**
  77104. * Returns the matrix as a Float32Array
  77105. * @returns the matrix underlying array
  77106. */
  77107. toArray(): DeepImmutable<Float32Array>;
  77108. /**
  77109. * Returns the matrix as a Float32Array
  77110. * @returns the matrix underlying array.
  77111. */
  77112. asArray(): DeepImmutable<Float32Array>;
  77113. /**
  77114. * Inverts the current matrix in place
  77115. * @returns the current inverted matrix
  77116. */
  77117. invert(): Matrix;
  77118. /**
  77119. * Sets all the matrix elements to zero
  77120. * @returns the current matrix
  77121. */
  77122. reset(): Matrix;
  77123. /**
  77124. * Adds the current matrix with a second one
  77125. * @param other defines the matrix to add
  77126. * @returns a new matrix as the addition of the current matrix and the given one
  77127. */
  77128. add(other: DeepImmutable<Matrix>): Matrix;
  77129. /**
  77130. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77131. * @param other defines the matrix to add
  77132. * @param result defines the target matrix
  77133. * @returns the current matrix
  77134. */
  77135. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77136. /**
  77137. * Adds in place the given matrix to the current matrix
  77138. * @param other defines the second operand
  77139. * @returns the current updated matrix
  77140. */
  77141. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77142. /**
  77143. * Sets the given matrix to the current inverted Matrix
  77144. * @param other defines the target matrix
  77145. * @returns the unmodified current matrix
  77146. */
  77147. invertToRef(other: Matrix): Matrix;
  77148. /**
  77149. * add a value at the specified position in the current Matrix
  77150. * @param index the index of the value within the matrix. between 0 and 15.
  77151. * @param value the value to be added
  77152. * @returns the current updated matrix
  77153. */
  77154. addAtIndex(index: number, value: number): Matrix;
  77155. /**
  77156. * mutiply the specified position in the current Matrix by a value
  77157. * @param index the index of the value within the matrix. between 0 and 15.
  77158. * @param value the value to be added
  77159. * @returns the current updated matrix
  77160. */
  77161. multiplyAtIndex(index: number, value: number): Matrix;
  77162. /**
  77163. * Inserts the translation vector (using 3 floats) in the current matrix
  77164. * @param x defines the 1st component of the translation
  77165. * @param y defines the 2nd component of the translation
  77166. * @param z defines the 3rd component of the translation
  77167. * @returns the current updated matrix
  77168. */
  77169. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77170. /**
  77171. * Adds the translation vector (using 3 floats) in the current matrix
  77172. * @param x defines the 1st component of the translation
  77173. * @param y defines the 2nd component of the translation
  77174. * @param z defines the 3rd component of the translation
  77175. * @returns the current updated matrix
  77176. */
  77177. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77178. /**
  77179. * Inserts the translation vector in the current matrix
  77180. * @param vector3 defines the translation to insert
  77181. * @returns the current updated matrix
  77182. */
  77183. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77184. /**
  77185. * Gets the translation value of the current matrix
  77186. * @returns a new Vector3 as the extracted translation from the matrix
  77187. */
  77188. getTranslation(): Vector3;
  77189. /**
  77190. * Fill a Vector3 with the extracted translation from the matrix
  77191. * @param result defines the Vector3 where to store the translation
  77192. * @returns the current matrix
  77193. */
  77194. getTranslationToRef(result: Vector3): Matrix;
  77195. /**
  77196. * Remove rotation and scaling part from the matrix
  77197. * @returns the updated matrix
  77198. */
  77199. removeRotationAndScaling(): Matrix;
  77200. /**
  77201. * Multiply two matrices
  77202. * @param other defines the second operand
  77203. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77204. */
  77205. multiply(other: DeepImmutable<Matrix>): Matrix;
  77206. /**
  77207. * Copy the current matrix from the given one
  77208. * @param other defines the source matrix
  77209. * @returns the current updated matrix
  77210. */
  77211. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77212. /**
  77213. * Populates the given array from the starting index with the current matrix values
  77214. * @param array defines the target array
  77215. * @param offset defines the offset in the target array where to start storing values
  77216. * @returns the current matrix
  77217. */
  77218. copyToArray(array: Float32Array, offset?: number): Matrix;
  77219. /**
  77220. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77221. * @param other defines the second operand
  77222. * @param result defines the matrix where to store the multiplication
  77223. * @returns the current matrix
  77224. */
  77225. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77226. /**
  77227. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77228. * @param other defines the second operand
  77229. * @param result defines the array where to store the multiplication
  77230. * @param offset defines the offset in the target array where to start storing values
  77231. * @returns the current matrix
  77232. */
  77233. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77234. /**
  77235. * Check equality between this matrix and a second one
  77236. * @param value defines the second matrix to compare
  77237. * @returns true is the current matrix and the given one values are strictly equal
  77238. */
  77239. equals(value: DeepImmutable<Matrix>): boolean;
  77240. /**
  77241. * Clone the current matrix
  77242. * @returns a new matrix from the current matrix
  77243. */
  77244. clone(): Matrix;
  77245. /**
  77246. * Returns the name of the current matrix class
  77247. * @returns the string "Matrix"
  77248. */
  77249. getClassName(): string;
  77250. /**
  77251. * Gets the hash code of the current matrix
  77252. * @returns the hash code
  77253. */
  77254. getHashCode(): number;
  77255. /**
  77256. * Decomposes the current Matrix into a translation, rotation and scaling components
  77257. * @param scale defines the scale vector3 given as a reference to update
  77258. * @param rotation defines the rotation quaternion given as a reference to update
  77259. * @param translation defines the translation vector3 given as a reference to update
  77260. * @returns true if operation was successful
  77261. */
  77262. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77263. /**
  77264. * Gets specific row of the matrix
  77265. * @param index defines the number of the row to get
  77266. * @returns the index-th row of the current matrix as a new Vector4
  77267. */
  77268. getRow(index: number): Nullable<Vector4>;
  77269. /**
  77270. * Sets the index-th row of the current matrix to the vector4 values
  77271. * @param index defines the number of the row to set
  77272. * @param row defines the target vector4
  77273. * @returns the updated current matrix
  77274. */
  77275. setRow(index: number, row: Vector4): Matrix;
  77276. /**
  77277. * Compute the transpose of the matrix
  77278. * @returns the new transposed matrix
  77279. */
  77280. transpose(): Matrix;
  77281. /**
  77282. * Compute the transpose of the matrix and store it in a given matrix
  77283. * @param result defines the target matrix
  77284. * @returns the current matrix
  77285. */
  77286. transposeToRef(result: Matrix): Matrix;
  77287. /**
  77288. * Sets the index-th row of the current matrix with the given 4 x float values
  77289. * @param index defines the row index
  77290. * @param x defines the x component to set
  77291. * @param y defines the y component to set
  77292. * @param z defines the z component to set
  77293. * @param w defines the w component to set
  77294. * @returns the updated current matrix
  77295. */
  77296. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77297. /**
  77298. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77299. * @param scale defines the scale factor
  77300. * @returns a new matrix
  77301. */
  77302. scale(scale: number): Matrix;
  77303. /**
  77304. * Scale the current matrix values by a factor to a given result matrix
  77305. * @param scale defines the scale factor
  77306. * @param result defines the matrix to store the result
  77307. * @returns the current matrix
  77308. */
  77309. scaleToRef(scale: number, result: Matrix): Matrix;
  77310. /**
  77311. * Scale the current matrix values by a factor and add the result to a given matrix
  77312. * @param scale defines the scale factor
  77313. * @param result defines the Matrix to store the result
  77314. * @returns the current matrix
  77315. */
  77316. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77317. /**
  77318. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77319. * @param ref matrix to store the result
  77320. */
  77321. toNormalMatrix(ref: Matrix): void;
  77322. /**
  77323. * Gets only rotation part of the current matrix
  77324. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77325. */
  77326. getRotationMatrix(): Matrix;
  77327. /**
  77328. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77329. * @param result defines the target matrix to store data to
  77330. * @returns the current matrix
  77331. */
  77332. getRotationMatrixToRef(result: Matrix): Matrix;
  77333. /**
  77334. * Toggles model matrix from being right handed to left handed in place and vice versa
  77335. */
  77336. toggleModelMatrixHandInPlace(): void;
  77337. /**
  77338. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77339. */
  77340. toggleProjectionMatrixHandInPlace(): void;
  77341. /**
  77342. * Creates a matrix from an array
  77343. * @param array defines the source array
  77344. * @param offset defines an offset in the source array
  77345. * @returns a new Matrix set from the starting index of the given array
  77346. */
  77347. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77348. /**
  77349. * Copy the content of an array into a given matrix
  77350. * @param array defines the source array
  77351. * @param offset defines an offset in the source array
  77352. * @param result defines the target matrix
  77353. */
  77354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77355. /**
  77356. * Stores an array into a matrix after having multiplied each component by a given factor
  77357. * @param array defines the source array
  77358. * @param offset defines the offset in the source array
  77359. * @param scale defines the scaling factor
  77360. * @param result defines the target matrix
  77361. */
  77362. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77363. /**
  77364. * Gets an identity matrix that must not be updated
  77365. */
  77366. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77367. /**
  77368. * Stores a list of values (16) inside a given matrix
  77369. * @param initialM11 defines 1st value of 1st row
  77370. * @param initialM12 defines 2nd value of 1st row
  77371. * @param initialM13 defines 3rd value of 1st row
  77372. * @param initialM14 defines 4th value of 1st row
  77373. * @param initialM21 defines 1st value of 2nd row
  77374. * @param initialM22 defines 2nd value of 2nd row
  77375. * @param initialM23 defines 3rd value of 2nd row
  77376. * @param initialM24 defines 4th value of 2nd row
  77377. * @param initialM31 defines 1st value of 3rd row
  77378. * @param initialM32 defines 2nd value of 3rd row
  77379. * @param initialM33 defines 3rd value of 3rd row
  77380. * @param initialM34 defines 4th value of 3rd row
  77381. * @param initialM41 defines 1st value of 4th row
  77382. * @param initialM42 defines 2nd value of 4th row
  77383. * @param initialM43 defines 3rd value of 4th row
  77384. * @param initialM44 defines 4th value of 4th row
  77385. * @param result defines the target matrix
  77386. */
  77387. 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;
  77388. /**
  77389. * Creates new matrix from a list of values (16)
  77390. * @param initialM11 defines 1st value of 1st row
  77391. * @param initialM12 defines 2nd value of 1st row
  77392. * @param initialM13 defines 3rd value of 1st row
  77393. * @param initialM14 defines 4th value of 1st row
  77394. * @param initialM21 defines 1st value of 2nd row
  77395. * @param initialM22 defines 2nd value of 2nd row
  77396. * @param initialM23 defines 3rd value of 2nd row
  77397. * @param initialM24 defines 4th value of 2nd row
  77398. * @param initialM31 defines 1st value of 3rd row
  77399. * @param initialM32 defines 2nd value of 3rd row
  77400. * @param initialM33 defines 3rd value of 3rd row
  77401. * @param initialM34 defines 4th value of 3rd row
  77402. * @param initialM41 defines 1st value of 4th row
  77403. * @param initialM42 defines 2nd value of 4th row
  77404. * @param initialM43 defines 3rd value of 4th row
  77405. * @param initialM44 defines 4th value of 4th row
  77406. * @returns the new matrix
  77407. */
  77408. 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;
  77409. /**
  77410. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77411. * @param scale defines the scale vector3
  77412. * @param rotation defines the rotation quaternion
  77413. * @param translation defines the translation vector3
  77414. * @returns a new matrix
  77415. */
  77416. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77417. /**
  77418. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77419. * @param scale defines the scale vector3
  77420. * @param rotation defines the rotation quaternion
  77421. * @param translation defines the translation vector3
  77422. * @param result defines the target matrix
  77423. */
  77424. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77425. /**
  77426. * Creates a new identity matrix
  77427. * @returns a new identity matrix
  77428. */
  77429. static Identity(): Matrix;
  77430. /**
  77431. * Creates a new identity matrix and stores the result in a given matrix
  77432. * @param result defines the target matrix
  77433. */
  77434. static IdentityToRef(result: Matrix): void;
  77435. /**
  77436. * Creates a new zero matrix
  77437. * @returns a new zero matrix
  77438. */
  77439. static Zero(): Matrix;
  77440. /**
  77441. * Creates a new rotation matrix for "angle" radians around the X axis
  77442. * @param angle defines the angle (in radians) to use
  77443. * @return the new matrix
  77444. */
  77445. static RotationX(angle: number): Matrix;
  77446. /**
  77447. * Creates a new matrix as the invert of a given matrix
  77448. * @param source defines the source matrix
  77449. * @returns the new matrix
  77450. */
  77451. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77452. /**
  77453. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77454. * @param angle defines the angle (in radians) to use
  77455. * @param result defines the target matrix
  77456. */
  77457. static RotationXToRef(angle: number, result: Matrix): void;
  77458. /**
  77459. * Creates a new rotation matrix for "angle" radians around the Y axis
  77460. * @param angle defines the angle (in radians) to use
  77461. * @return the new matrix
  77462. */
  77463. static RotationY(angle: number): Matrix;
  77464. /**
  77465. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77466. * @param angle defines the angle (in radians) to use
  77467. * @param result defines the target matrix
  77468. */
  77469. static RotationYToRef(angle: number, result: Matrix): void;
  77470. /**
  77471. * Creates a new rotation matrix for "angle" radians around the Z axis
  77472. * @param angle defines the angle (in radians) to use
  77473. * @return the new matrix
  77474. */
  77475. static RotationZ(angle: number): Matrix;
  77476. /**
  77477. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77478. * @param angle defines the angle (in radians) to use
  77479. * @param result defines the target matrix
  77480. */
  77481. static RotationZToRef(angle: number, result: Matrix): void;
  77482. /**
  77483. * Creates a new rotation matrix for "angle" radians around the given axis
  77484. * @param axis defines the axis to use
  77485. * @param angle defines the angle (in radians) to use
  77486. * @return the new matrix
  77487. */
  77488. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77489. /**
  77490. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77491. * @param axis defines the axis to use
  77492. * @param angle defines the angle (in radians) to use
  77493. * @param result defines the target matrix
  77494. */
  77495. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77496. /**
  77497. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77498. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77499. * @param from defines the vector to align
  77500. * @param to defines the vector to align to
  77501. * @param result defines the target matrix
  77502. */
  77503. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77504. /**
  77505. * Creates a rotation matrix
  77506. * @param yaw defines the yaw angle in radians (Y axis)
  77507. * @param pitch defines the pitch angle in radians (X axis)
  77508. * @param roll defines the roll angle in radians (X axis)
  77509. * @returns the new rotation matrix
  77510. */
  77511. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77512. /**
  77513. * Creates a rotation matrix and stores it in a given matrix
  77514. * @param yaw defines the yaw angle in radians (Y axis)
  77515. * @param pitch defines the pitch angle in radians (X axis)
  77516. * @param roll defines the roll angle in radians (X axis)
  77517. * @param result defines the target matrix
  77518. */
  77519. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77520. /**
  77521. * Creates a scaling matrix
  77522. * @param x defines the scale factor on X axis
  77523. * @param y defines the scale factor on Y axis
  77524. * @param z defines the scale factor on Z axis
  77525. * @returns the new matrix
  77526. */
  77527. static Scaling(x: number, y: number, z: number): Matrix;
  77528. /**
  77529. * Creates a scaling matrix and stores it in a given matrix
  77530. * @param x defines the scale factor on X axis
  77531. * @param y defines the scale factor on Y axis
  77532. * @param z defines the scale factor on Z axis
  77533. * @param result defines the target matrix
  77534. */
  77535. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77536. /**
  77537. * Creates a translation matrix
  77538. * @param x defines the translation on X axis
  77539. * @param y defines the translation on Y axis
  77540. * @param z defines the translationon Z axis
  77541. * @returns the new matrix
  77542. */
  77543. static Translation(x: number, y: number, z: number): Matrix;
  77544. /**
  77545. * Creates a translation matrix and stores it in a given matrix
  77546. * @param x defines the translation on X axis
  77547. * @param y defines the translation on Y axis
  77548. * @param z defines the translationon Z axis
  77549. * @param result defines the target matrix
  77550. */
  77551. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77552. /**
  77553. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77554. * @param startValue defines the start value
  77555. * @param endValue defines the end value
  77556. * @param gradient defines the gradient factor
  77557. * @returns the new matrix
  77558. */
  77559. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77560. /**
  77561. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77562. * @param startValue defines the start value
  77563. * @param endValue defines the end value
  77564. * @param gradient defines the gradient factor
  77565. * @param result defines the Matrix object where to store data
  77566. */
  77567. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77568. /**
  77569. * Builds a new matrix whose values are computed by:
  77570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77573. * @param startValue defines the first matrix
  77574. * @param endValue defines the second matrix
  77575. * @param gradient defines the gradient between the two matrices
  77576. * @returns the new matrix
  77577. */
  77578. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77579. /**
  77580. * Update a matrix to values which are computed by:
  77581. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77582. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77583. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77584. * @param startValue defines the first matrix
  77585. * @param endValue defines the second matrix
  77586. * @param gradient defines the gradient between the two matrices
  77587. * @param result defines the target matrix
  77588. */
  77589. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77590. /**
  77591. * 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"
  77592. * This function works in left handed mode
  77593. * @param eye defines the final position of the entity
  77594. * @param target defines where the entity should look at
  77595. * @param up defines the up vector for the entity
  77596. * @returns the new matrix
  77597. */
  77598. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77599. /**
  77600. * 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".
  77601. * This function works in left handed mode
  77602. * @param eye defines the final position of the entity
  77603. * @param target defines where the entity should look at
  77604. * @param up defines the up vector for the entity
  77605. * @param result defines the target matrix
  77606. */
  77607. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77608. /**
  77609. * 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"
  77610. * This function works in right handed mode
  77611. * @param eye defines the final position of the entity
  77612. * @param target defines where the entity should look at
  77613. * @param up defines the up vector for the entity
  77614. * @returns the new matrix
  77615. */
  77616. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77617. /**
  77618. * 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".
  77619. * This function works in right handed mode
  77620. * @param eye defines the final position of the entity
  77621. * @param target defines where the entity should look at
  77622. * @param up defines the up vector for the entity
  77623. * @param result defines the target matrix
  77624. */
  77625. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77626. /**
  77627. * Create a left-handed orthographic projection matrix
  77628. * @param width defines the viewport width
  77629. * @param height defines the viewport height
  77630. * @param znear defines the near clip plane
  77631. * @param zfar defines the far clip plane
  77632. * @returns a new matrix as a left-handed orthographic projection matrix
  77633. */
  77634. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77635. /**
  77636. * Store a left-handed orthographic projection to a given matrix
  77637. * @param width defines the viewport width
  77638. * @param height defines the viewport height
  77639. * @param znear defines the near clip plane
  77640. * @param zfar defines the far clip plane
  77641. * @param result defines the target matrix
  77642. */
  77643. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77644. /**
  77645. * Create a left-handed orthographic projection matrix
  77646. * @param left defines the viewport left coordinate
  77647. * @param right defines the viewport right coordinate
  77648. * @param bottom defines the viewport bottom coordinate
  77649. * @param top defines the viewport top coordinate
  77650. * @param znear defines the near clip plane
  77651. * @param zfar defines the far clip plane
  77652. * @returns a new matrix as a left-handed orthographic projection matrix
  77653. */
  77654. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77655. /**
  77656. * Stores a left-handed orthographic projection into a given matrix
  77657. * @param left defines the viewport left coordinate
  77658. * @param right defines the viewport right coordinate
  77659. * @param bottom defines the viewport bottom coordinate
  77660. * @param top defines the viewport top coordinate
  77661. * @param znear defines the near clip plane
  77662. * @param zfar defines the far clip plane
  77663. * @param result defines the target matrix
  77664. */
  77665. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77666. /**
  77667. * Creates a right-handed orthographic projection matrix
  77668. * @param left defines the viewport left coordinate
  77669. * @param right defines the viewport right coordinate
  77670. * @param bottom defines the viewport bottom coordinate
  77671. * @param top defines the viewport top coordinate
  77672. * @param znear defines the near clip plane
  77673. * @param zfar defines the far clip plane
  77674. * @returns a new matrix as a right-handed orthographic projection matrix
  77675. */
  77676. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77677. /**
  77678. * Stores a right-handed orthographic projection into a given matrix
  77679. * @param left defines the viewport left coordinate
  77680. * @param right defines the viewport right coordinate
  77681. * @param bottom defines the viewport bottom coordinate
  77682. * @param top defines the viewport top coordinate
  77683. * @param znear defines the near clip plane
  77684. * @param zfar defines the far clip plane
  77685. * @param result defines the target matrix
  77686. */
  77687. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77688. /**
  77689. * Creates a left-handed perspective projection matrix
  77690. * @param width defines the viewport width
  77691. * @param height defines the viewport height
  77692. * @param znear defines the near clip plane
  77693. * @param zfar defines the far clip plane
  77694. * @returns a new matrix as a left-handed perspective projection matrix
  77695. */
  77696. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77697. /**
  77698. * Creates a left-handed perspective projection matrix
  77699. * @param fov defines the horizontal field of view
  77700. * @param aspect defines the aspect ratio
  77701. * @param znear defines the near clip plane
  77702. * @param zfar defines the far clip plane
  77703. * @returns a new matrix as a left-handed perspective projection matrix
  77704. */
  77705. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77706. /**
  77707. * Stores a left-handed perspective projection into a given matrix
  77708. * @param fov defines the horizontal field of view
  77709. * @param aspect defines the aspect ratio
  77710. * @param znear defines the near clip plane
  77711. * @param zfar defines the far clip plane
  77712. * @param result defines the target matrix
  77713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77714. */
  77715. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77716. /**
  77717. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77718. * @param fov defines the horizontal field of view
  77719. * @param aspect defines the aspect ratio
  77720. * @param znear defines the near clip plane
  77721. * @param zfar not used as infinity is used as far clip
  77722. * @param result defines the target matrix
  77723. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77724. */
  77725. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77726. /**
  77727. * Creates a right-handed perspective projection matrix
  77728. * @param fov defines the horizontal field of view
  77729. * @param aspect defines the aspect ratio
  77730. * @param znear defines the near clip plane
  77731. * @param zfar defines the far clip plane
  77732. * @returns a new matrix as a right-handed perspective projection matrix
  77733. */
  77734. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77735. /**
  77736. * Stores a right-handed perspective projection into a given matrix
  77737. * @param fov defines the horizontal field of view
  77738. * @param aspect defines the aspect ratio
  77739. * @param znear defines the near clip plane
  77740. * @param zfar defines the far clip plane
  77741. * @param result defines the target matrix
  77742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77743. */
  77744. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77745. /**
  77746. * Stores a right-handed perspective projection into a given matrix
  77747. * @param fov defines the horizontal field of view
  77748. * @param aspect defines the aspect ratio
  77749. * @param znear defines the near clip plane
  77750. * @param zfar not used as infinity is used as far clip
  77751. * @param result defines the target matrix
  77752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77753. */
  77754. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77755. /**
  77756. * Stores a perspective projection for WebVR info a given matrix
  77757. * @param fov defines the field of view
  77758. * @param znear defines the near clip plane
  77759. * @param zfar defines the far clip plane
  77760. * @param result defines the target matrix
  77761. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77762. */
  77763. static PerspectiveFovWebVRToRef(fov: {
  77764. upDegrees: number;
  77765. downDegrees: number;
  77766. leftDegrees: number;
  77767. rightDegrees: number;
  77768. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77769. /**
  77770. * Computes a complete transformation matrix
  77771. * @param viewport defines the viewport to use
  77772. * @param world defines the world matrix
  77773. * @param view defines the view matrix
  77774. * @param projection defines the projection matrix
  77775. * @param zmin defines the near clip plane
  77776. * @param zmax defines the far clip plane
  77777. * @returns the transformation matrix
  77778. */
  77779. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77780. /**
  77781. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77782. * @param matrix defines the matrix to use
  77783. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77784. */
  77785. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77786. /**
  77787. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77788. * @param matrix defines the matrix to use
  77789. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77790. */
  77791. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77792. /**
  77793. * Compute the transpose of a given matrix
  77794. * @param matrix defines the matrix to transpose
  77795. * @returns the new matrix
  77796. */
  77797. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77798. /**
  77799. * Compute the transpose of a matrix and store it in a target matrix
  77800. * @param matrix defines the matrix to transpose
  77801. * @param result defines the target matrix
  77802. */
  77803. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77804. /**
  77805. * Computes a reflection matrix from a plane
  77806. * @param plane defines the reflection plane
  77807. * @returns a new matrix
  77808. */
  77809. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77810. /**
  77811. * Computes a reflection matrix from a plane
  77812. * @param plane defines the reflection plane
  77813. * @param result defines the target matrix
  77814. */
  77815. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77816. /**
  77817. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77818. * @param xaxis defines the value of the 1st axis
  77819. * @param yaxis defines the value of the 2nd axis
  77820. * @param zaxis defines the value of the 3rd axis
  77821. * @param result defines the target matrix
  77822. */
  77823. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77824. /**
  77825. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77826. * @param quat defines the quaternion to use
  77827. * @param result defines the target matrix
  77828. */
  77829. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77830. }
  77831. /**
  77832. * @hidden
  77833. */
  77834. export class TmpVectors {
  77835. static Vector2: Vector2[];
  77836. static Vector3: Vector3[];
  77837. static Vector4: Vector4[];
  77838. static Quaternion: Quaternion[];
  77839. static Matrix: Matrix[];
  77840. }
  77841. }
  77842. declare module BABYLON {
  77843. /**
  77844. * Defines potential orientation for back face culling
  77845. */
  77846. export enum Orientation {
  77847. /**
  77848. * Clockwise
  77849. */
  77850. CW = 0,
  77851. /** Counter clockwise */
  77852. CCW = 1
  77853. }
  77854. /** Class used to represent a Bezier curve */
  77855. export class BezierCurve {
  77856. /**
  77857. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77858. * @param t defines the time
  77859. * @param x1 defines the left coordinate on X axis
  77860. * @param y1 defines the left coordinate on Y axis
  77861. * @param x2 defines the right coordinate on X axis
  77862. * @param y2 defines the right coordinate on Y axis
  77863. * @returns the interpolated value
  77864. */
  77865. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77866. }
  77867. /**
  77868. * Defines angle representation
  77869. */
  77870. export class Angle {
  77871. private _radians;
  77872. /**
  77873. * Creates an Angle object of "radians" radians (float).
  77874. * @param radians the angle in radians
  77875. */
  77876. constructor(radians: number);
  77877. /**
  77878. * Get value in degrees
  77879. * @returns the Angle value in degrees (float)
  77880. */
  77881. degrees(): number;
  77882. /**
  77883. * Get value in radians
  77884. * @returns the Angle value in radians (float)
  77885. */
  77886. radians(): number;
  77887. /**
  77888. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77889. * @param a defines first vector
  77890. * @param b defines second vector
  77891. * @returns a new Angle
  77892. */
  77893. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77894. /**
  77895. * Gets a new Angle object from the given float in radians
  77896. * @param radians defines the angle value in radians
  77897. * @returns a new Angle
  77898. */
  77899. static FromRadians(radians: number): Angle;
  77900. /**
  77901. * Gets a new Angle object from the given float in degrees
  77902. * @param degrees defines the angle value in degrees
  77903. * @returns a new Angle
  77904. */
  77905. static FromDegrees(degrees: number): Angle;
  77906. }
  77907. /**
  77908. * This represents an arc in a 2d space.
  77909. */
  77910. export class Arc2 {
  77911. /** Defines the start point of the arc */
  77912. startPoint: Vector2;
  77913. /** Defines the mid point of the arc */
  77914. midPoint: Vector2;
  77915. /** Defines the end point of the arc */
  77916. endPoint: Vector2;
  77917. /**
  77918. * Defines the center point of the arc.
  77919. */
  77920. centerPoint: Vector2;
  77921. /**
  77922. * Defines the radius of the arc.
  77923. */
  77924. radius: number;
  77925. /**
  77926. * Defines the angle of the arc (from mid point to end point).
  77927. */
  77928. angle: Angle;
  77929. /**
  77930. * Defines the start angle of the arc (from start point to middle point).
  77931. */
  77932. startAngle: Angle;
  77933. /**
  77934. * Defines the orientation of the arc (clock wise/counter clock wise).
  77935. */
  77936. orientation: Orientation;
  77937. /**
  77938. * Creates an Arc object from the three given points : start, middle and end.
  77939. * @param startPoint Defines the start point of the arc
  77940. * @param midPoint Defines the midlle point of the arc
  77941. * @param endPoint Defines the end point of the arc
  77942. */
  77943. constructor(
  77944. /** Defines the start point of the arc */
  77945. startPoint: Vector2,
  77946. /** Defines the mid point of the arc */
  77947. midPoint: Vector2,
  77948. /** Defines the end point of the arc */
  77949. endPoint: Vector2);
  77950. }
  77951. /**
  77952. * Represents a 2D path made up of multiple 2D points
  77953. */
  77954. export class Path2 {
  77955. private _points;
  77956. private _length;
  77957. /**
  77958. * If the path start and end point are the same
  77959. */
  77960. closed: boolean;
  77961. /**
  77962. * Creates a Path2 object from the starting 2D coordinates x and y.
  77963. * @param x the starting points x value
  77964. * @param y the starting points y value
  77965. */
  77966. constructor(x: number, y: number);
  77967. /**
  77968. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77969. * @param x the added points x value
  77970. * @param y the added points y value
  77971. * @returns the updated Path2.
  77972. */
  77973. addLineTo(x: number, y: number): Path2;
  77974. /**
  77975. * 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.
  77976. * @param midX middle point x value
  77977. * @param midY middle point y value
  77978. * @param endX end point x value
  77979. * @param endY end point y value
  77980. * @param numberOfSegments (default: 36)
  77981. * @returns the updated Path2.
  77982. */
  77983. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77984. /**
  77985. * Closes the Path2.
  77986. * @returns the Path2.
  77987. */
  77988. close(): Path2;
  77989. /**
  77990. * Gets the sum of the distance between each sequential point in the path
  77991. * @returns the Path2 total length (float).
  77992. */
  77993. length(): number;
  77994. /**
  77995. * Gets the points which construct the path
  77996. * @returns the Path2 internal array of points.
  77997. */
  77998. getPoints(): Vector2[];
  77999. /**
  78000. * Retreives the point at the distance aways from the starting point
  78001. * @param normalizedLengthPosition the length along the path to retreive the point from
  78002. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78003. */
  78004. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78005. /**
  78006. * Creates a new path starting from an x and y position
  78007. * @param x starting x value
  78008. * @param y starting y value
  78009. * @returns a new Path2 starting at the coordinates (x, y).
  78010. */
  78011. static StartingAt(x: number, y: number): Path2;
  78012. }
  78013. /**
  78014. * Represents a 3D path made up of multiple 3D points
  78015. */
  78016. export class Path3D {
  78017. /**
  78018. * an array of Vector3, the curve axis of the Path3D
  78019. */
  78020. path: Vector3[];
  78021. private _curve;
  78022. private _distances;
  78023. private _tangents;
  78024. private _normals;
  78025. private _binormals;
  78026. private _raw;
  78027. private _alignTangentsWithPath;
  78028. private readonly _pointAtData;
  78029. /**
  78030. * new Path3D(path, normal, raw)
  78031. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78032. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78033. * @param path an array of Vector3, the curve axis of the Path3D
  78034. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78035. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78036. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78037. */
  78038. constructor(
  78039. /**
  78040. * an array of Vector3, the curve axis of the Path3D
  78041. */
  78042. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78043. /**
  78044. * Returns the Path3D array of successive Vector3 designing its curve.
  78045. * @returns the Path3D array of successive Vector3 designing its curve.
  78046. */
  78047. getCurve(): Vector3[];
  78048. /**
  78049. * Returns the Path3D array of successive Vector3 designing its curve.
  78050. * @returns the Path3D array of successive Vector3 designing its curve.
  78051. */
  78052. getPoints(): Vector3[];
  78053. /**
  78054. * @returns the computed length (float) of the path.
  78055. */
  78056. length(): number;
  78057. /**
  78058. * Returns an array populated with tangent vectors on each Path3D curve point.
  78059. * @returns an array populated with tangent vectors on each Path3D curve point.
  78060. */
  78061. getTangents(): Vector3[];
  78062. /**
  78063. * Returns an array populated with normal vectors on each Path3D curve point.
  78064. * @returns an array populated with normal vectors on each Path3D curve point.
  78065. */
  78066. getNormals(): Vector3[];
  78067. /**
  78068. * Returns an array populated with binormal vectors on each Path3D curve point.
  78069. * @returns an array populated with binormal vectors on each Path3D curve point.
  78070. */
  78071. getBinormals(): Vector3[];
  78072. /**
  78073. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78074. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78075. */
  78076. getDistances(): number[];
  78077. /**
  78078. * Returns an interpolated point along this path
  78079. * @param position the position of the point along this path, from 0.0 to 1.0
  78080. * @returns a new Vector3 as the point
  78081. */
  78082. getPointAt(position: number): Vector3;
  78083. /**
  78084. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78085. * @param position the position of the point along this path, from 0.0 to 1.0
  78086. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78087. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78088. */
  78089. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78090. /**
  78091. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78092. * @param position the position of the point along this path, from 0.0 to 1.0
  78093. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78094. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78095. */
  78096. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78097. /**
  78098. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78099. * @param position the position of the point along this path, from 0.0 to 1.0
  78100. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78101. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78102. */
  78103. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78104. /**
  78105. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78106. * @param position the position of the point along this path, from 0.0 to 1.0
  78107. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78108. */
  78109. getDistanceAt(position: number): number;
  78110. /**
  78111. * Returns the array index of the previous point of an interpolated point along this path
  78112. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78113. * @returns the array index
  78114. */
  78115. getPreviousPointIndexAt(position: number): number;
  78116. /**
  78117. * 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)
  78118. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78119. * @returns the sub position
  78120. */
  78121. getSubPositionAt(position: number): number;
  78122. /**
  78123. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78124. * @param target the vector of which to get the closest position to
  78125. * @returns the position of the closest virtual point on this path to the target vector
  78126. */
  78127. getClosestPositionTo(target: Vector3): number;
  78128. /**
  78129. * Returns a sub path (slice) of this path
  78130. * @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
  78131. * @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
  78132. * @returns a sub path (slice) of this path
  78133. */
  78134. slice(start?: number, end?: number): Path3D;
  78135. /**
  78136. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78137. * @param path path which all values are copied into the curves points
  78138. * @param firstNormal which should be projected onto the curve
  78139. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78140. * @returns the same object updated.
  78141. */
  78142. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78143. private _compute;
  78144. private _getFirstNonNullVector;
  78145. private _getLastNonNullVector;
  78146. private _normalVector;
  78147. /**
  78148. * Updates the point at data for an interpolated point along this curve
  78149. * @param position the position of the point along this curve, from 0.0 to 1.0
  78150. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78151. * @returns the (updated) point at data
  78152. */
  78153. private _updatePointAtData;
  78154. /**
  78155. * Updates the point at data from the specified parameters
  78156. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78157. * @param point the interpolated point
  78158. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78159. */
  78160. private _setPointAtData;
  78161. /**
  78162. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78163. */
  78164. private _updateInterpolationMatrix;
  78165. }
  78166. /**
  78167. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78168. * A Curve3 is designed from a series of successive Vector3.
  78169. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78170. */
  78171. export class Curve3 {
  78172. private _points;
  78173. private _length;
  78174. /**
  78175. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78176. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78177. * @param v1 (Vector3) the control point
  78178. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78179. * @param nbPoints (integer) the wanted number of points in the curve
  78180. * @returns the created Curve3
  78181. */
  78182. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78183. /**
  78184. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78185. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78186. * @param v1 (Vector3) the first control point
  78187. * @param v2 (Vector3) the second control point
  78188. * @param v3 (Vector3) the end point of the Cubic Bezier
  78189. * @param nbPoints (integer) the wanted number of points in the curve
  78190. * @returns the created Curve3
  78191. */
  78192. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78193. /**
  78194. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78195. * @param p1 (Vector3) the origin point of the Hermite Spline
  78196. * @param t1 (Vector3) the tangent vector at the origin point
  78197. * @param p2 (Vector3) the end point of the Hermite Spline
  78198. * @param t2 (Vector3) the tangent vector at the end point
  78199. * @param nbPoints (integer) the wanted number of points in the curve
  78200. * @returns the created Curve3
  78201. */
  78202. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78203. /**
  78204. * Returns a Curve3 object along a CatmullRom Spline curve :
  78205. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78206. * @param nbPoints (integer) the wanted number of points between each curve control points
  78207. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78208. * @returns the created Curve3
  78209. */
  78210. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78211. /**
  78212. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78213. * A Curve3 is designed from a series of successive Vector3.
  78214. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78215. * @param points points which make up the curve
  78216. */
  78217. constructor(points: Vector3[]);
  78218. /**
  78219. * @returns the Curve3 stored array of successive Vector3
  78220. */
  78221. getPoints(): Vector3[];
  78222. /**
  78223. * @returns the computed length (float) of the curve.
  78224. */
  78225. length(): number;
  78226. /**
  78227. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78228. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78229. * curveA and curveB keep unchanged.
  78230. * @param curve the curve to continue from this curve
  78231. * @returns the newly constructed curve
  78232. */
  78233. continue(curve: DeepImmutable<Curve3>): Curve3;
  78234. private _computeLength;
  78235. }
  78236. }
  78237. declare module BABYLON {
  78238. /**
  78239. * This represents the main contract an easing function should follow.
  78240. * Easing functions are used throughout the animation system.
  78241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78242. */
  78243. export interface IEasingFunction {
  78244. /**
  78245. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78246. * of the easing function.
  78247. * The link below provides some of the most common examples of easing functions.
  78248. * @see https://easings.net/
  78249. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78250. * @returns the corresponding value on the curve defined by the easing function
  78251. */
  78252. ease(gradient: number): number;
  78253. }
  78254. /**
  78255. * Base class used for every default easing function.
  78256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78257. */
  78258. export class EasingFunction implements IEasingFunction {
  78259. /**
  78260. * Interpolation follows the mathematical formula associated with the easing function.
  78261. */
  78262. static readonly EASINGMODE_EASEIN: number;
  78263. /**
  78264. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78265. */
  78266. static readonly EASINGMODE_EASEOUT: number;
  78267. /**
  78268. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78269. */
  78270. static readonly EASINGMODE_EASEINOUT: number;
  78271. private _easingMode;
  78272. /**
  78273. * Sets the easing mode of the current function.
  78274. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78275. */
  78276. setEasingMode(easingMode: number): void;
  78277. /**
  78278. * Gets the current easing mode.
  78279. * @returns the easing mode
  78280. */
  78281. getEasingMode(): number;
  78282. /**
  78283. * @hidden
  78284. */
  78285. easeInCore(gradient: number): number;
  78286. /**
  78287. * Given an input gradient between 0 and 1, this returns the corresponding value
  78288. * of the easing function.
  78289. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78290. * @returns the corresponding value on the curve defined by the easing function
  78291. */
  78292. ease(gradient: number): number;
  78293. }
  78294. /**
  78295. * Easing function with a circle shape (see link below).
  78296. * @see https://easings.net/#easeInCirc
  78297. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78298. */
  78299. export class CircleEase extends EasingFunction implements IEasingFunction {
  78300. /** @hidden */
  78301. easeInCore(gradient: number): number;
  78302. }
  78303. /**
  78304. * Easing function with a ease back shape (see link below).
  78305. * @see https://easings.net/#easeInBack
  78306. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78307. */
  78308. export class BackEase extends EasingFunction implements IEasingFunction {
  78309. /** Defines the amplitude of the function */
  78310. amplitude: number;
  78311. /**
  78312. * Instantiates a back ease easing
  78313. * @see https://easings.net/#easeInBack
  78314. * @param amplitude Defines the amplitude of the function
  78315. */
  78316. constructor(
  78317. /** Defines the amplitude of the function */
  78318. amplitude?: number);
  78319. /** @hidden */
  78320. easeInCore(gradient: number): number;
  78321. }
  78322. /**
  78323. * Easing function with a bouncing shape (see link below).
  78324. * @see https://easings.net/#easeInBounce
  78325. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78326. */
  78327. export class BounceEase extends EasingFunction implements IEasingFunction {
  78328. /** Defines the number of bounces */
  78329. bounces: number;
  78330. /** Defines the amplitude of the bounce */
  78331. bounciness: number;
  78332. /**
  78333. * Instantiates a bounce easing
  78334. * @see https://easings.net/#easeInBounce
  78335. * @param bounces Defines the number of bounces
  78336. * @param bounciness Defines the amplitude of the bounce
  78337. */
  78338. constructor(
  78339. /** Defines the number of bounces */
  78340. bounces?: number,
  78341. /** Defines the amplitude of the bounce */
  78342. bounciness?: number);
  78343. /** @hidden */
  78344. easeInCore(gradient: number): number;
  78345. }
  78346. /**
  78347. * Easing function with a power of 3 shape (see link below).
  78348. * @see https://easings.net/#easeInCubic
  78349. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78350. */
  78351. export class CubicEase extends EasingFunction implements IEasingFunction {
  78352. /** @hidden */
  78353. easeInCore(gradient: number): number;
  78354. }
  78355. /**
  78356. * Easing function with an elastic shape (see link below).
  78357. * @see https://easings.net/#easeInElastic
  78358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78359. */
  78360. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78361. /** Defines the number of oscillations*/
  78362. oscillations: number;
  78363. /** Defines the amplitude of the oscillations*/
  78364. springiness: number;
  78365. /**
  78366. * Instantiates an elastic easing function
  78367. * @see https://easings.net/#easeInElastic
  78368. * @param oscillations Defines the number of oscillations
  78369. * @param springiness Defines the amplitude of the oscillations
  78370. */
  78371. constructor(
  78372. /** Defines the number of oscillations*/
  78373. oscillations?: number,
  78374. /** Defines the amplitude of the oscillations*/
  78375. springiness?: number);
  78376. /** @hidden */
  78377. easeInCore(gradient: number): number;
  78378. }
  78379. /**
  78380. * Easing function with an exponential shape (see link below).
  78381. * @see https://easings.net/#easeInExpo
  78382. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78383. */
  78384. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78385. /** Defines the exponent of the function */
  78386. exponent: number;
  78387. /**
  78388. * Instantiates an exponential easing function
  78389. * @see https://easings.net/#easeInExpo
  78390. * @param exponent Defines the exponent of the function
  78391. */
  78392. constructor(
  78393. /** Defines the exponent of the function */
  78394. exponent?: number);
  78395. /** @hidden */
  78396. easeInCore(gradient: number): number;
  78397. }
  78398. /**
  78399. * Easing function with a power shape (see link below).
  78400. * @see https://easings.net/#easeInQuad
  78401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78402. */
  78403. export class PowerEase extends EasingFunction implements IEasingFunction {
  78404. /** Defines the power of the function */
  78405. power: number;
  78406. /**
  78407. * Instantiates an power base easing function
  78408. * @see https://easings.net/#easeInQuad
  78409. * @param power Defines the power of the function
  78410. */
  78411. constructor(
  78412. /** Defines the power of the function */
  78413. power?: number);
  78414. /** @hidden */
  78415. easeInCore(gradient: number): number;
  78416. }
  78417. /**
  78418. * Easing function with a power of 2 shape (see link below).
  78419. * @see https://easings.net/#easeInQuad
  78420. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78421. */
  78422. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78423. /** @hidden */
  78424. easeInCore(gradient: number): number;
  78425. }
  78426. /**
  78427. * Easing function with a power of 4 shape (see link below).
  78428. * @see https://easings.net/#easeInQuart
  78429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78430. */
  78431. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78432. /** @hidden */
  78433. easeInCore(gradient: number): number;
  78434. }
  78435. /**
  78436. * Easing function with a power of 5 shape (see link below).
  78437. * @see https://easings.net/#easeInQuint
  78438. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78439. */
  78440. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78441. /** @hidden */
  78442. easeInCore(gradient: number): number;
  78443. }
  78444. /**
  78445. * Easing function with a sin shape (see link below).
  78446. * @see https://easings.net/#easeInSine
  78447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78448. */
  78449. export class SineEase extends EasingFunction implements IEasingFunction {
  78450. /** @hidden */
  78451. easeInCore(gradient: number): number;
  78452. }
  78453. /**
  78454. * Easing function with a bezier shape (see link below).
  78455. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78456. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78457. */
  78458. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78459. /** Defines the x component of the start tangent in the bezier curve */
  78460. x1: number;
  78461. /** Defines the y component of the start tangent in the bezier curve */
  78462. y1: number;
  78463. /** Defines the x component of the end tangent in the bezier curve */
  78464. x2: number;
  78465. /** Defines the y component of the end tangent in the bezier curve */
  78466. y2: number;
  78467. /**
  78468. * Instantiates a bezier function
  78469. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78470. * @param x1 Defines the x component of the start tangent in the bezier curve
  78471. * @param y1 Defines the y component of the start tangent in the bezier curve
  78472. * @param x2 Defines the x component of the end tangent in the bezier curve
  78473. * @param y2 Defines the y component of the end tangent in the bezier curve
  78474. */
  78475. constructor(
  78476. /** Defines the x component of the start tangent in the bezier curve */
  78477. x1?: number,
  78478. /** Defines the y component of the start tangent in the bezier curve */
  78479. y1?: number,
  78480. /** Defines the x component of the end tangent in the bezier curve */
  78481. x2?: number,
  78482. /** Defines the y component of the end tangent in the bezier curve */
  78483. y2?: number);
  78484. /** @hidden */
  78485. easeInCore(gradient: number): number;
  78486. }
  78487. }
  78488. declare module BABYLON {
  78489. /**
  78490. * Class used to hold a RBG color
  78491. */
  78492. export class Color3 {
  78493. /**
  78494. * Defines the red component (between 0 and 1, default is 0)
  78495. */
  78496. r: number;
  78497. /**
  78498. * Defines the green component (between 0 and 1, default is 0)
  78499. */
  78500. g: number;
  78501. /**
  78502. * Defines the blue component (between 0 and 1, default is 0)
  78503. */
  78504. b: number;
  78505. /**
  78506. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78507. * @param r defines the red component (between 0 and 1, default is 0)
  78508. * @param g defines the green component (between 0 and 1, default is 0)
  78509. * @param b defines the blue component (between 0 and 1, default is 0)
  78510. */
  78511. constructor(
  78512. /**
  78513. * Defines the red component (between 0 and 1, default is 0)
  78514. */
  78515. r?: number,
  78516. /**
  78517. * Defines the green component (between 0 and 1, default is 0)
  78518. */
  78519. g?: number,
  78520. /**
  78521. * Defines the blue component (between 0 and 1, default is 0)
  78522. */
  78523. b?: number);
  78524. /**
  78525. * Creates a string with the Color3 current values
  78526. * @returns the string representation of the Color3 object
  78527. */
  78528. toString(): string;
  78529. /**
  78530. * Returns the string "Color3"
  78531. * @returns "Color3"
  78532. */
  78533. getClassName(): string;
  78534. /**
  78535. * Compute the Color3 hash code
  78536. * @returns an unique number that can be used to hash Color3 objects
  78537. */
  78538. getHashCode(): number;
  78539. /**
  78540. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78541. * @param array defines the array where to store the r,g,b components
  78542. * @param index defines an optional index in the target array to define where to start storing values
  78543. * @returns the current Color3 object
  78544. */
  78545. toArray(array: FloatArray, index?: number): Color3;
  78546. /**
  78547. * Returns a new Color4 object from the current Color3 and the given alpha
  78548. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78549. * @returns a new Color4 object
  78550. */
  78551. toColor4(alpha?: number): Color4;
  78552. /**
  78553. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78554. * @returns the new array
  78555. */
  78556. asArray(): number[];
  78557. /**
  78558. * Returns the luminance value
  78559. * @returns a float value
  78560. */
  78561. toLuminance(): number;
  78562. /**
  78563. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78564. * @param otherColor defines the second operand
  78565. * @returns the new Color3 object
  78566. */
  78567. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78568. /**
  78569. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78570. * @param otherColor defines the second operand
  78571. * @param result defines the Color3 object where to store the result
  78572. * @returns the current Color3
  78573. */
  78574. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78575. /**
  78576. * Determines equality between Color3 objects
  78577. * @param otherColor defines the second operand
  78578. * @returns true if the rgb values are equal to the given ones
  78579. */
  78580. equals(otherColor: DeepImmutable<Color3>): boolean;
  78581. /**
  78582. * Determines equality between the current Color3 object and a set of r,b,g values
  78583. * @param r defines the red component to check
  78584. * @param g defines the green component to check
  78585. * @param b defines the blue component to check
  78586. * @returns true if the rgb values are equal to the given ones
  78587. */
  78588. equalsFloats(r: number, g: number, b: number): boolean;
  78589. /**
  78590. * Multiplies in place each rgb value by scale
  78591. * @param scale defines the scaling factor
  78592. * @returns the updated Color3
  78593. */
  78594. scale(scale: number): Color3;
  78595. /**
  78596. * Multiplies the rgb values by scale and stores the result into "result"
  78597. * @param scale defines the scaling factor
  78598. * @param result defines the Color3 object where to store the result
  78599. * @returns the unmodified current Color3
  78600. */
  78601. scaleToRef(scale: number, result: Color3): Color3;
  78602. /**
  78603. * Scale the current Color3 values by a factor and add the result to a given Color3
  78604. * @param scale defines the scale factor
  78605. * @param result defines color to store the result into
  78606. * @returns the unmodified current Color3
  78607. */
  78608. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78609. /**
  78610. * Clamps the rgb values by the min and max values and stores the result into "result"
  78611. * @param min defines minimum clamping value (default is 0)
  78612. * @param max defines maximum clamping value (default is 1)
  78613. * @param result defines color to store the result into
  78614. * @returns the original Color3
  78615. */
  78616. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78617. /**
  78618. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78619. * @param otherColor defines the second operand
  78620. * @returns the new Color3
  78621. */
  78622. add(otherColor: DeepImmutable<Color3>): Color3;
  78623. /**
  78624. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78625. * @param otherColor defines the second operand
  78626. * @param result defines Color3 object to store the result into
  78627. * @returns the unmodified current Color3
  78628. */
  78629. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78630. /**
  78631. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78632. * @param otherColor defines the second operand
  78633. * @returns the new Color3
  78634. */
  78635. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78636. /**
  78637. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78638. * @param otherColor defines the second operand
  78639. * @param result defines Color3 object to store the result into
  78640. * @returns the unmodified current Color3
  78641. */
  78642. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78643. /**
  78644. * Copy the current object
  78645. * @returns a new Color3 copied the current one
  78646. */
  78647. clone(): Color3;
  78648. /**
  78649. * Copies the rgb values from the source in the current Color3
  78650. * @param source defines the source Color3 object
  78651. * @returns the updated Color3 object
  78652. */
  78653. copyFrom(source: DeepImmutable<Color3>): Color3;
  78654. /**
  78655. * Updates the Color3 rgb values from the given floats
  78656. * @param r defines the red component to read from
  78657. * @param g defines the green component to read from
  78658. * @param b defines the blue component to read from
  78659. * @returns the current Color3 object
  78660. */
  78661. copyFromFloats(r: number, g: number, b: number): Color3;
  78662. /**
  78663. * Updates the Color3 rgb values from the given floats
  78664. * @param r defines the red component to read from
  78665. * @param g defines the green component to read from
  78666. * @param b defines the blue component to read from
  78667. * @returns the current Color3 object
  78668. */
  78669. set(r: number, g: number, b: number): Color3;
  78670. /**
  78671. * Compute the Color3 hexadecimal code as a string
  78672. * @returns a string containing the hexadecimal representation of the Color3 object
  78673. */
  78674. toHexString(): string;
  78675. /**
  78676. * Computes a new Color3 converted from the current one to linear space
  78677. * @returns a new Color3 object
  78678. */
  78679. toLinearSpace(): Color3;
  78680. /**
  78681. * Converts current color in rgb space to HSV values
  78682. * @returns a new color3 representing the HSV values
  78683. */
  78684. toHSV(): Color3;
  78685. /**
  78686. * Converts current color in rgb space to HSV values
  78687. * @param result defines the Color3 where to store the HSV values
  78688. */
  78689. toHSVToRef(result: Color3): void;
  78690. /**
  78691. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78692. * @param convertedColor defines the Color3 object where to store the linear space version
  78693. * @returns the unmodified Color3
  78694. */
  78695. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78696. /**
  78697. * Computes a new Color3 converted from the current one to gamma space
  78698. * @returns a new Color3 object
  78699. */
  78700. toGammaSpace(): Color3;
  78701. /**
  78702. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78703. * @param convertedColor defines the Color3 object where to store the gamma space version
  78704. * @returns the unmodified Color3
  78705. */
  78706. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78707. private static _BlackReadOnly;
  78708. /**
  78709. * Convert Hue, saturation and value to a Color3 (RGB)
  78710. * @param hue defines the hue
  78711. * @param saturation defines the saturation
  78712. * @param value defines the value
  78713. * @param result defines the Color3 where to store the RGB values
  78714. */
  78715. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78716. /**
  78717. * Creates a new Color3 from the string containing valid hexadecimal values
  78718. * @param hex defines a string containing valid hexadecimal values
  78719. * @returns a new Color3 object
  78720. */
  78721. static FromHexString(hex: string): Color3;
  78722. /**
  78723. * Creates a new Color3 from the starting index of the given array
  78724. * @param array defines the source array
  78725. * @param offset defines an offset in the source array
  78726. * @returns a new Color3 object
  78727. */
  78728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78729. /**
  78730. * Creates a new Color3 from integer values (< 256)
  78731. * @param r defines the red component to read from (value between 0 and 255)
  78732. * @param g defines the green component to read from (value between 0 and 255)
  78733. * @param b defines the blue component to read from (value between 0 and 255)
  78734. * @returns a new Color3 object
  78735. */
  78736. static FromInts(r: number, g: number, b: number): Color3;
  78737. /**
  78738. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78739. * @param start defines the start Color3 value
  78740. * @param end defines the end Color3 value
  78741. * @param amount defines the gradient value between start and end
  78742. * @returns a new Color3 object
  78743. */
  78744. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78745. /**
  78746. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78747. * @param left defines the start value
  78748. * @param right defines the end value
  78749. * @param amount defines the gradient factor
  78750. * @param result defines the Color3 object where to store the result
  78751. */
  78752. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78753. /**
  78754. * Returns a Color3 value containing a red color
  78755. * @returns a new Color3 object
  78756. */
  78757. static Red(): Color3;
  78758. /**
  78759. * Returns a Color3 value containing a green color
  78760. * @returns a new Color3 object
  78761. */
  78762. static Green(): Color3;
  78763. /**
  78764. * Returns a Color3 value containing a blue color
  78765. * @returns a new Color3 object
  78766. */
  78767. static Blue(): Color3;
  78768. /**
  78769. * Returns a Color3 value containing a black color
  78770. * @returns a new Color3 object
  78771. */
  78772. static Black(): Color3;
  78773. /**
  78774. * Gets a Color3 value containing a black color that must not be updated
  78775. */
  78776. static get BlackReadOnly(): DeepImmutable<Color3>;
  78777. /**
  78778. * Returns a Color3 value containing a white color
  78779. * @returns a new Color3 object
  78780. */
  78781. static White(): Color3;
  78782. /**
  78783. * Returns a Color3 value containing a purple color
  78784. * @returns a new Color3 object
  78785. */
  78786. static Purple(): Color3;
  78787. /**
  78788. * Returns a Color3 value containing a magenta color
  78789. * @returns a new Color3 object
  78790. */
  78791. static Magenta(): Color3;
  78792. /**
  78793. * Returns a Color3 value containing a yellow color
  78794. * @returns a new Color3 object
  78795. */
  78796. static Yellow(): Color3;
  78797. /**
  78798. * Returns a Color3 value containing a gray color
  78799. * @returns a new Color3 object
  78800. */
  78801. static Gray(): Color3;
  78802. /**
  78803. * Returns a Color3 value containing a teal color
  78804. * @returns a new Color3 object
  78805. */
  78806. static Teal(): Color3;
  78807. /**
  78808. * Returns a Color3 value containing a random color
  78809. * @returns a new Color3 object
  78810. */
  78811. static Random(): Color3;
  78812. }
  78813. /**
  78814. * Class used to hold a RBGA color
  78815. */
  78816. export class Color4 {
  78817. /**
  78818. * Defines the red component (between 0 and 1, default is 0)
  78819. */
  78820. r: number;
  78821. /**
  78822. * Defines the green component (between 0 and 1, default is 0)
  78823. */
  78824. g: number;
  78825. /**
  78826. * Defines the blue component (between 0 and 1, default is 0)
  78827. */
  78828. b: number;
  78829. /**
  78830. * Defines the alpha component (between 0 and 1, default is 1)
  78831. */
  78832. a: number;
  78833. /**
  78834. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78835. * @param r defines the red component (between 0 and 1, default is 0)
  78836. * @param g defines the green component (between 0 and 1, default is 0)
  78837. * @param b defines the blue component (between 0 and 1, default is 0)
  78838. * @param a defines the alpha component (between 0 and 1, default is 1)
  78839. */
  78840. constructor(
  78841. /**
  78842. * Defines the red component (between 0 and 1, default is 0)
  78843. */
  78844. r?: number,
  78845. /**
  78846. * Defines the green component (between 0 and 1, default is 0)
  78847. */
  78848. g?: number,
  78849. /**
  78850. * Defines the blue component (between 0 and 1, default is 0)
  78851. */
  78852. b?: number,
  78853. /**
  78854. * Defines the alpha component (between 0 and 1, default is 1)
  78855. */
  78856. a?: number);
  78857. /**
  78858. * Adds in place the given Color4 values to the current Color4 object
  78859. * @param right defines the second operand
  78860. * @returns the current updated Color4 object
  78861. */
  78862. addInPlace(right: DeepImmutable<Color4>): Color4;
  78863. /**
  78864. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78865. * @returns the new array
  78866. */
  78867. asArray(): number[];
  78868. /**
  78869. * Stores from the starting index in the given array the Color4 successive values
  78870. * @param array defines the array where to store the r,g,b components
  78871. * @param index defines an optional index in the target array to define where to start storing values
  78872. * @returns the current Color4 object
  78873. */
  78874. toArray(array: number[], index?: number): Color4;
  78875. /**
  78876. * Determines equality between Color4 objects
  78877. * @param otherColor defines the second operand
  78878. * @returns true if the rgba values are equal to the given ones
  78879. */
  78880. equals(otherColor: DeepImmutable<Color4>): boolean;
  78881. /**
  78882. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78883. * @param right defines the second operand
  78884. * @returns a new Color4 object
  78885. */
  78886. add(right: DeepImmutable<Color4>): Color4;
  78887. /**
  78888. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78889. * @param right defines the second operand
  78890. * @returns a new Color4 object
  78891. */
  78892. subtract(right: DeepImmutable<Color4>): Color4;
  78893. /**
  78894. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78895. * @param right defines the second operand
  78896. * @param result defines the Color4 object where to store the result
  78897. * @returns the current Color4 object
  78898. */
  78899. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78900. /**
  78901. * Creates a new Color4 with the current Color4 values multiplied by scale
  78902. * @param scale defines the scaling factor to apply
  78903. * @returns a new Color4 object
  78904. */
  78905. scale(scale: number): Color4;
  78906. /**
  78907. * Multiplies the current Color4 values by scale and stores the result in "result"
  78908. * @param scale defines the scaling factor to apply
  78909. * @param result defines the Color4 object where to store the result
  78910. * @returns the current unmodified Color4
  78911. */
  78912. scaleToRef(scale: number, result: Color4): Color4;
  78913. /**
  78914. * Scale the current Color4 values by a factor and add the result to a given Color4
  78915. * @param scale defines the scale factor
  78916. * @param result defines the Color4 object where to store the result
  78917. * @returns the unmodified current Color4
  78918. */
  78919. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78920. /**
  78921. * Clamps the rgb values by the min and max values and stores the result into "result"
  78922. * @param min defines minimum clamping value (default is 0)
  78923. * @param max defines maximum clamping value (default is 1)
  78924. * @param result defines color to store the result into.
  78925. * @returns the cuurent Color4
  78926. */
  78927. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78928. /**
  78929. * Multipy an Color4 value by another and return a new Color4 object
  78930. * @param color defines the Color4 value to multiply by
  78931. * @returns a new Color4 object
  78932. */
  78933. multiply(color: Color4): Color4;
  78934. /**
  78935. * Multipy a Color4 value by another and push the result in a reference value
  78936. * @param color defines the Color4 value to multiply by
  78937. * @param result defines the Color4 to fill the result in
  78938. * @returns the result Color4
  78939. */
  78940. multiplyToRef(color: Color4, result: Color4): Color4;
  78941. /**
  78942. * Creates a string with the Color4 current values
  78943. * @returns the string representation of the Color4 object
  78944. */
  78945. toString(): string;
  78946. /**
  78947. * Returns the string "Color4"
  78948. * @returns "Color4"
  78949. */
  78950. getClassName(): string;
  78951. /**
  78952. * Compute the Color4 hash code
  78953. * @returns an unique number that can be used to hash Color4 objects
  78954. */
  78955. getHashCode(): number;
  78956. /**
  78957. * Creates a new Color4 copied from the current one
  78958. * @returns a new Color4 object
  78959. */
  78960. clone(): Color4;
  78961. /**
  78962. * Copies the given Color4 values into the current one
  78963. * @param source defines the source Color4 object
  78964. * @returns the current updated Color4 object
  78965. */
  78966. copyFrom(source: Color4): Color4;
  78967. /**
  78968. * Copies the given float values into the current one
  78969. * @param r defines the red component to read from
  78970. * @param g defines the green component to read from
  78971. * @param b defines the blue component to read from
  78972. * @param a defines the alpha component to read from
  78973. * @returns the current updated Color4 object
  78974. */
  78975. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78976. /**
  78977. * Copies the given float values into the current one
  78978. * @param r defines the red component to read from
  78979. * @param g defines the green component to read from
  78980. * @param b defines the blue component to read from
  78981. * @param a defines the alpha component to read from
  78982. * @returns the current updated Color4 object
  78983. */
  78984. set(r: number, g: number, b: number, a: number): Color4;
  78985. /**
  78986. * Compute the Color4 hexadecimal code as a string
  78987. * @returns a string containing the hexadecimal representation of the Color4 object
  78988. */
  78989. toHexString(): string;
  78990. /**
  78991. * Computes a new Color4 converted from the current one to linear space
  78992. * @returns a new Color4 object
  78993. */
  78994. toLinearSpace(): Color4;
  78995. /**
  78996. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78997. * @param convertedColor defines the Color4 object where to store the linear space version
  78998. * @returns the unmodified Color4
  78999. */
  79000. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79001. /**
  79002. * Computes a new Color4 converted from the current one to gamma space
  79003. * @returns a new Color4 object
  79004. */
  79005. toGammaSpace(): Color4;
  79006. /**
  79007. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79008. * @param convertedColor defines the Color4 object where to store the gamma space version
  79009. * @returns the unmodified Color4
  79010. */
  79011. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79012. /**
  79013. * Creates a new Color4 from the string containing valid hexadecimal values
  79014. * @param hex defines a string containing valid hexadecimal values
  79015. * @returns a new Color4 object
  79016. */
  79017. static FromHexString(hex: string): Color4;
  79018. /**
  79019. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79020. * @param left defines the start value
  79021. * @param right defines the end value
  79022. * @param amount defines the gradient factor
  79023. * @returns a new Color4 object
  79024. */
  79025. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79026. /**
  79027. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79028. * @param left defines the start value
  79029. * @param right defines the end value
  79030. * @param amount defines the gradient factor
  79031. * @param result defines the Color4 object where to store data
  79032. */
  79033. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79034. /**
  79035. * Creates a new Color4 from a Color3 and an alpha value
  79036. * @param color3 defines the source Color3 to read from
  79037. * @param alpha defines the alpha component (1.0 by default)
  79038. * @returns a new Color4 object
  79039. */
  79040. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79041. /**
  79042. * Creates a new Color4 from the starting index element of the given array
  79043. * @param array defines the source array to read from
  79044. * @param offset defines the offset in the source array
  79045. * @returns a new Color4 object
  79046. */
  79047. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79048. /**
  79049. * Creates a new Color3 from integer values (< 256)
  79050. * @param r defines the red component to read from (value between 0 and 255)
  79051. * @param g defines the green component to read from (value between 0 and 255)
  79052. * @param b defines the blue component to read from (value between 0 and 255)
  79053. * @param a defines the alpha component to read from (value between 0 and 255)
  79054. * @returns a new Color3 object
  79055. */
  79056. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79057. /**
  79058. * Check the content of a given array and convert it to an array containing RGBA data
  79059. * If the original array was already containing count * 4 values then it is returned directly
  79060. * @param colors defines the array to check
  79061. * @param count defines the number of RGBA data to expect
  79062. * @returns an array containing count * 4 values (RGBA)
  79063. */
  79064. static CheckColors4(colors: number[], count: number): number[];
  79065. }
  79066. /**
  79067. * @hidden
  79068. */
  79069. export class TmpColors {
  79070. static Color3: Color3[];
  79071. static Color4: Color4[];
  79072. }
  79073. }
  79074. declare module BABYLON {
  79075. /**
  79076. * Defines an interface which represents an animation key frame
  79077. */
  79078. export interface IAnimationKey {
  79079. /**
  79080. * Frame of the key frame
  79081. */
  79082. frame: number;
  79083. /**
  79084. * Value at the specifies key frame
  79085. */
  79086. value: any;
  79087. /**
  79088. * The input tangent for the cubic hermite spline
  79089. */
  79090. inTangent?: any;
  79091. /**
  79092. * The output tangent for the cubic hermite spline
  79093. */
  79094. outTangent?: any;
  79095. /**
  79096. * The animation interpolation type
  79097. */
  79098. interpolation?: AnimationKeyInterpolation;
  79099. }
  79100. /**
  79101. * Enum for the animation key frame interpolation type
  79102. */
  79103. export enum AnimationKeyInterpolation {
  79104. /**
  79105. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79106. */
  79107. STEP = 1
  79108. }
  79109. }
  79110. declare module BABYLON {
  79111. /**
  79112. * Represents the range of an animation
  79113. */
  79114. export class AnimationRange {
  79115. /**The name of the animation range**/
  79116. name: string;
  79117. /**The starting frame of the animation */
  79118. from: number;
  79119. /**The ending frame of the animation*/
  79120. to: number;
  79121. /**
  79122. * Initializes the range of an animation
  79123. * @param name The name of the animation range
  79124. * @param from The starting frame of the animation
  79125. * @param to The ending frame of the animation
  79126. */
  79127. constructor(
  79128. /**The name of the animation range**/
  79129. name: string,
  79130. /**The starting frame of the animation */
  79131. from: number,
  79132. /**The ending frame of the animation*/
  79133. to: number);
  79134. /**
  79135. * Makes a copy of the animation range
  79136. * @returns A copy of the animation range
  79137. */
  79138. clone(): AnimationRange;
  79139. }
  79140. }
  79141. declare module BABYLON {
  79142. /**
  79143. * Composed of a frame, and an action function
  79144. */
  79145. export class AnimationEvent {
  79146. /** The frame for which the event is triggered **/
  79147. frame: number;
  79148. /** The event to perform when triggered **/
  79149. action: (currentFrame: number) => void;
  79150. /** Specifies if the event should be triggered only once**/
  79151. onlyOnce?: boolean | undefined;
  79152. /**
  79153. * Specifies if the animation event is done
  79154. */
  79155. isDone: boolean;
  79156. /**
  79157. * Initializes the animation event
  79158. * @param frame The frame for which the event is triggered
  79159. * @param action The event to perform when triggered
  79160. * @param onlyOnce Specifies if the event should be triggered only once
  79161. */
  79162. constructor(
  79163. /** The frame for which the event is triggered **/
  79164. frame: number,
  79165. /** The event to perform when triggered **/
  79166. action: (currentFrame: number) => void,
  79167. /** Specifies if the event should be triggered only once**/
  79168. onlyOnce?: boolean | undefined);
  79169. /** @hidden */
  79170. _clone(): AnimationEvent;
  79171. }
  79172. }
  79173. declare module BABYLON {
  79174. /**
  79175. * Interface used to define a behavior
  79176. */
  79177. export interface Behavior<T> {
  79178. /** gets or sets behavior's name */
  79179. name: string;
  79180. /**
  79181. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79182. */
  79183. init(): void;
  79184. /**
  79185. * Called when the behavior is attached to a target
  79186. * @param target defines the target where the behavior is attached to
  79187. */
  79188. attach(target: T): void;
  79189. /**
  79190. * Called when the behavior is detached from its target
  79191. */
  79192. detach(): void;
  79193. }
  79194. /**
  79195. * Interface implemented by classes supporting behaviors
  79196. */
  79197. export interface IBehaviorAware<T> {
  79198. /**
  79199. * Attach a behavior
  79200. * @param behavior defines the behavior to attach
  79201. * @returns the current host
  79202. */
  79203. addBehavior(behavior: Behavior<T>): T;
  79204. /**
  79205. * Remove a behavior from the current object
  79206. * @param behavior defines the behavior to detach
  79207. * @returns the current host
  79208. */
  79209. removeBehavior(behavior: Behavior<T>): T;
  79210. /**
  79211. * Gets a behavior using its name to search
  79212. * @param name defines the name to search
  79213. * @returns the behavior or null if not found
  79214. */
  79215. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79216. }
  79217. }
  79218. declare module BABYLON {
  79219. /**
  79220. * Defines an array and its length.
  79221. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79222. */
  79223. export interface ISmartArrayLike<T> {
  79224. /**
  79225. * The data of the array.
  79226. */
  79227. data: Array<T>;
  79228. /**
  79229. * The active length of the array.
  79230. */
  79231. length: number;
  79232. }
  79233. /**
  79234. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79235. */
  79236. export class SmartArray<T> implements ISmartArrayLike<T> {
  79237. /**
  79238. * The full set of data from the array.
  79239. */
  79240. data: Array<T>;
  79241. /**
  79242. * The active length of the array.
  79243. */
  79244. length: number;
  79245. protected _id: number;
  79246. /**
  79247. * Instantiates a Smart Array.
  79248. * @param capacity defines the default capacity of the array.
  79249. */
  79250. constructor(capacity: number);
  79251. /**
  79252. * Pushes a value at the end of the active data.
  79253. * @param value defines the object to push in the array.
  79254. */
  79255. push(value: T): void;
  79256. /**
  79257. * Iterates over the active data and apply the lambda to them.
  79258. * @param func defines the action to apply on each value.
  79259. */
  79260. forEach(func: (content: T) => void): void;
  79261. /**
  79262. * Sorts the full sets of data.
  79263. * @param compareFn defines the comparison function to apply.
  79264. */
  79265. sort(compareFn: (a: T, b: T) => number): void;
  79266. /**
  79267. * Resets the active data to an empty array.
  79268. */
  79269. reset(): void;
  79270. /**
  79271. * Releases all the data from the array as well as the array.
  79272. */
  79273. dispose(): void;
  79274. /**
  79275. * Concats the active data with a given array.
  79276. * @param array defines the data to concatenate with.
  79277. */
  79278. concat(array: any): void;
  79279. /**
  79280. * Returns the position of a value in the active data.
  79281. * @param value defines the value to find the index for
  79282. * @returns the index if found in the active data otherwise -1
  79283. */
  79284. indexOf(value: T): number;
  79285. /**
  79286. * Returns whether an element is part of the active data.
  79287. * @param value defines the value to look for
  79288. * @returns true if found in the active data otherwise false
  79289. */
  79290. contains(value: T): boolean;
  79291. private static _GlobalId;
  79292. }
  79293. /**
  79294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79295. * The data in this array can only be present once
  79296. */
  79297. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79298. private _duplicateId;
  79299. /**
  79300. * Pushes a value at the end of the active data.
  79301. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79302. * @param value defines the object to push in the array.
  79303. */
  79304. push(value: T): void;
  79305. /**
  79306. * Pushes a value at the end of the active data.
  79307. * If the data is already present, it won t be added again
  79308. * @param value defines the object to push in the array.
  79309. * @returns true if added false if it was already present
  79310. */
  79311. pushNoDuplicate(value: T): boolean;
  79312. /**
  79313. * Resets the active data to an empty array.
  79314. */
  79315. reset(): void;
  79316. /**
  79317. * Concats the active data with a given array.
  79318. * This ensures no dupplicate will be present in the result.
  79319. * @param array defines the data to concatenate with.
  79320. */
  79321. concatWithNoDuplicate(array: any): void;
  79322. }
  79323. }
  79324. declare module BABYLON {
  79325. /**
  79326. * @ignore
  79327. * This is a list of all the different input types that are available in the application.
  79328. * Fo instance: ArcRotateCameraGamepadInput...
  79329. */
  79330. export var CameraInputTypes: {};
  79331. /**
  79332. * This is the contract to implement in order to create a new input class.
  79333. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79334. */
  79335. export interface ICameraInput<TCamera extends Camera> {
  79336. /**
  79337. * Defines the camera the input is attached to.
  79338. */
  79339. camera: Nullable<TCamera>;
  79340. /**
  79341. * Gets the class name of the current intput.
  79342. * @returns the class name
  79343. */
  79344. getClassName(): string;
  79345. /**
  79346. * Get the friendly name associated with the input class.
  79347. * @returns the input friendly name
  79348. */
  79349. getSimpleName(): string;
  79350. /**
  79351. * Attach the input controls to a specific dom element to get the input from.
  79352. * @param element Defines the element the controls should be listened from
  79353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79354. */
  79355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79356. /**
  79357. * Detach the current controls from the specified dom element.
  79358. * @param element Defines the element to stop listening the inputs from
  79359. */
  79360. detachControl(element: Nullable<HTMLElement>): void;
  79361. /**
  79362. * Update the current camera state depending on the inputs that have been used this frame.
  79363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79364. */
  79365. checkInputs?: () => void;
  79366. }
  79367. /**
  79368. * Represents a map of input types to input instance or input index to input instance.
  79369. */
  79370. export interface CameraInputsMap<TCamera extends Camera> {
  79371. /**
  79372. * Accessor to the input by input type.
  79373. */
  79374. [name: string]: ICameraInput<TCamera>;
  79375. /**
  79376. * Accessor to the input by input index.
  79377. */
  79378. [idx: number]: ICameraInput<TCamera>;
  79379. }
  79380. /**
  79381. * This represents the input manager used within a camera.
  79382. * It helps dealing with all the different kind of input attached to a camera.
  79383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79384. */
  79385. export class CameraInputsManager<TCamera extends Camera> {
  79386. /**
  79387. * Defines the list of inputs attahed to the camera.
  79388. */
  79389. attached: CameraInputsMap<TCamera>;
  79390. /**
  79391. * Defines the dom element the camera is collecting inputs from.
  79392. * This is null if the controls have not been attached.
  79393. */
  79394. attachedElement: Nullable<HTMLElement>;
  79395. /**
  79396. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79397. */
  79398. noPreventDefault: boolean;
  79399. /**
  79400. * Defined the camera the input manager belongs to.
  79401. */
  79402. camera: TCamera;
  79403. /**
  79404. * Update the current camera state depending on the inputs that have been used this frame.
  79405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79406. */
  79407. checkInputs: () => void;
  79408. /**
  79409. * Instantiate a new Camera Input Manager.
  79410. * @param camera Defines the camera the input manager blongs to
  79411. */
  79412. constructor(camera: TCamera);
  79413. /**
  79414. * Add an input method to a camera
  79415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79416. * @param input camera input method
  79417. */
  79418. add(input: ICameraInput<TCamera>): void;
  79419. /**
  79420. * Remove a specific input method from a camera
  79421. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79422. * @param inputToRemove camera input method
  79423. */
  79424. remove(inputToRemove: ICameraInput<TCamera>): void;
  79425. /**
  79426. * Remove a specific input type from a camera
  79427. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79428. * @param inputType the type of the input to remove
  79429. */
  79430. removeByType(inputType: string): void;
  79431. private _addCheckInputs;
  79432. /**
  79433. * Attach the input controls to the currently attached dom element to listen the events from.
  79434. * @param input Defines the input to attach
  79435. */
  79436. attachInput(input: ICameraInput<TCamera>): void;
  79437. /**
  79438. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79439. * @param element Defines the dom element to collect the events from
  79440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79441. */
  79442. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79443. /**
  79444. * Detach the current manager inputs controls from a specific dom element.
  79445. * @param element Defines the dom element to collect the events from
  79446. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79447. */
  79448. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79449. /**
  79450. * Rebuild the dynamic inputCheck function from the current list of
  79451. * defined inputs in the manager.
  79452. */
  79453. rebuildInputCheck(): void;
  79454. /**
  79455. * Remove all attached input methods from a camera
  79456. */
  79457. clear(): void;
  79458. /**
  79459. * Serialize the current input manager attached to a camera.
  79460. * This ensures than once parsed,
  79461. * the input associated to the camera will be identical to the current ones
  79462. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79463. */
  79464. serialize(serializedCamera: any): void;
  79465. /**
  79466. * Parses an input manager serialized JSON to restore the previous list of inputs
  79467. * and states associated to a camera.
  79468. * @param parsedCamera Defines the JSON to parse
  79469. */
  79470. parse(parsedCamera: any): void;
  79471. }
  79472. }
  79473. declare module BABYLON {
  79474. /**
  79475. * Class used to store data that will be store in GPU memory
  79476. */
  79477. export class Buffer {
  79478. private _engine;
  79479. private _buffer;
  79480. /** @hidden */
  79481. _data: Nullable<DataArray>;
  79482. private _updatable;
  79483. private _instanced;
  79484. private _divisor;
  79485. /**
  79486. * Gets the byte stride.
  79487. */
  79488. readonly byteStride: number;
  79489. /**
  79490. * Constructor
  79491. * @param engine the engine
  79492. * @param data the data to use for this buffer
  79493. * @param updatable whether the data is updatable
  79494. * @param stride the stride (optional)
  79495. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79496. * @param instanced whether the buffer is instanced (optional)
  79497. * @param useBytes set to true if the stride in in bytes (optional)
  79498. * @param divisor sets an optional divisor for instances (1 by default)
  79499. */
  79500. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79501. /**
  79502. * Create a new VertexBuffer based on the current buffer
  79503. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79504. * @param offset defines offset in the buffer (0 by default)
  79505. * @param size defines the size in floats of attributes (position is 3 for instance)
  79506. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79507. * @param instanced defines if the vertex buffer contains indexed data
  79508. * @param useBytes defines if the offset and stride are in bytes *
  79509. * @param divisor sets an optional divisor for instances (1 by default)
  79510. * @returns the new vertex buffer
  79511. */
  79512. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79513. /**
  79514. * Gets a boolean indicating if the Buffer is updatable?
  79515. * @returns true if the buffer is updatable
  79516. */
  79517. isUpdatable(): boolean;
  79518. /**
  79519. * Gets current buffer's data
  79520. * @returns a DataArray or null
  79521. */
  79522. getData(): Nullable<DataArray>;
  79523. /**
  79524. * Gets underlying native buffer
  79525. * @returns underlying native buffer
  79526. */
  79527. getBuffer(): Nullable<DataBuffer>;
  79528. /**
  79529. * Gets the stride in float32 units (i.e. byte stride / 4).
  79530. * May not be an integer if the byte stride is not divisible by 4.
  79531. * @returns the stride in float32 units
  79532. * @deprecated Please use byteStride instead.
  79533. */
  79534. getStrideSize(): number;
  79535. /**
  79536. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79537. * @param data defines the data to store
  79538. */
  79539. create(data?: Nullable<DataArray>): void;
  79540. /** @hidden */
  79541. _rebuild(): void;
  79542. /**
  79543. * Update current buffer data
  79544. * @param data defines the data to store
  79545. */
  79546. update(data: DataArray): void;
  79547. /**
  79548. * Updates the data directly.
  79549. * @param data the new data
  79550. * @param offset the new offset
  79551. * @param vertexCount the vertex count (optional)
  79552. * @param useBytes set to true if the offset is in bytes
  79553. */
  79554. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79555. /**
  79556. * Release all resources
  79557. */
  79558. dispose(): void;
  79559. }
  79560. /**
  79561. * Specialized buffer used to store vertex data
  79562. */
  79563. export class VertexBuffer {
  79564. /** @hidden */
  79565. _buffer: Buffer;
  79566. private _kind;
  79567. private _size;
  79568. private _ownsBuffer;
  79569. private _instanced;
  79570. private _instanceDivisor;
  79571. /**
  79572. * The byte type.
  79573. */
  79574. static readonly BYTE: number;
  79575. /**
  79576. * The unsigned byte type.
  79577. */
  79578. static readonly UNSIGNED_BYTE: number;
  79579. /**
  79580. * The short type.
  79581. */
  79582. static readonly SHORT: number;
  79583. /**
  79584. * The unsigned short type.
  79585. */
  79586. static readonly UNSIGNED_SHORT: number;
  79587. /**
  79588. * The integer type.
  79589. */
  79590. static readonly INT: number;
  79591. /**
  79592. * The unsigned integer type.
  79593. */
  79594. static readonly UNSIGNED_INT: number;
  79595. /**
  79596. * The float type.
  79597. */
  79598. static readonly FLOAT: number;
  79599. /**
  79600. * Gets or sets the instance divisor when in instanced mode
  79601. */
  79602. get instanceDivisor(): number;
  79603. set instanceDivisor(value: number);
  79604. /**
  79605. * Gets the byte stride.
  79606. */
  79607. readonly byteStride: number;
  79608. /**
  79609. * Gets the byte offset.
  79610. */
  79611. readonly byteOffset: number;
  79612. /**
  79613. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79614. */
  79615. readonly normalized: boolean;
  79616. /**
  79617. * Gets the data type of each component in the array.
  79618. */
  79619. readonly type: number;
  79620. /**
  79621. * Constructor
  79622. * @param engine the engine
  79623. * @param data the data to use for this vertex buffer
  79624. * @param kind the vertex buffer kind
  79625. * @param updatable whether the data is updatable
  79626. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79627. * @param stride the stride (optional)
  79628. * @param instanced whether the buffer is instanced (optional)
  79629. * @param offset the offset of the data (optional)
  79630. * @param size the number of components (optional)
  79631. * @param type the type of the component (optional)
  79632. * @param normalized whether the data contains normalized data (optional)
  79633. * @param useBytes set to true if stride and offset are in bytes (optional)
  79634. * @param divisor defines the instance divisor to use (1 by default)
  79635. */
  79636. 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);
  79637. /** @hidden */
  79638. _rebuild(): void;
  79639. /**
  79640. * Returns the kind of the VertexBuffer (string)
  79641. * @returns a string
  79642. */
  79643. getKind(): string;
  79644. /**
  79645. * Gets a boolean indicating if the VertexBuffer is updatable?
  79646. * @returns true if the buffer is updatable
  79647. */
  79648. isUpdatable(): boolean;
  79649. /**
  79650. * Gets current buffer's data
  79651. * @returns a DataArray or null
  79652. */
  79653. getData(): Nullable<DataArray>;
  79654. /**
  79655. * Gets underlying native buffer
  79656. * @returns underlying native buffer
  79657. */
  79658. getBuffer(): Nullable<DataBuffer>;
  79659. /**
  79660. * Gets the stride in float32 units (i.e. byte stride / 4).
  79661. * May not be an integer if the byte stride is not divisible by 4.
  79662. * @returns the stride in float32 units
  79663. * @deprecated Please use byteStride instead.
  79664. */
  79665. getStrideSize(): number;
  79666. /**
  79667. * Returns the offset as a multiple of the type byte length.
  79668. * @returns the offset in bytes
  79669. * @deprecated Please use byteOffset instead.
  79670. */
  79671. getOffset(): number;
  79672. /**
  79673. * Returns the number of components per vertex attribute (integer)
  79674. * @returns the size in float
  79675. */
  79676. getSize(): number;
  79677. /**
  79678. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79679. * @returns true if this buffer is instanced
  79680. */
  79681. getIsInstanced(): boolean;
  79682. /**
  79683. * Returns the instancing divisor, zero for non-instanced (integer).
  79684. * @returns a number
  79685. */
  79686. getInstanceDivisor(): number;
  79687. /**
  79688. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79689. * @param data defines the data to store
  79690. */
  79691. create(data?: DataArray): void;
  79692. /**
  79693. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79694. * This function will create a new buffer if the current one is not updatable
  79695. * @param data defines the data to store
  79696. */
  79697. update(data: DataArray): void;
  79698. /**
  79699. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79700. * Returns the directly updated WebGLBuffer.
  79701. * @param data the new data
  79702. * @param offset the new offset
  79703. * @param useBytes set to true if the offset is in bytes
  79704. */
  79705. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79706. /**
  79707. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79708. */
  79709. dispose(): void;
  79710. /**
  79711. * Enumerates each value of this vertex buffer as numbers.
  79712. * @param count the number of values to enumerate
  79713. * @param callback the callback function called for each value
  79714. */
  79715. forEach(count: number, callback: (value: number, index: number) => void): void;
  79716. /**
  79717. * Positions
  79718. */
  79719. static readonly PositionKind: string;
  79720. /**
  79721. * Normals
  79722. */
  79723. static readonly NormalKind: string;
  79724. /**
  79725. * Tangents
  79726. */
  79727. static readonly TangentKind: string;
  79728. /**
  79729. * Texture coordinates
  79730. */
  79731. static readonly UVKind: string;
  79732. /**
  79733. * Texture coordinates 2
  79734. */
  79735. static readonly UV2Kind: string;
  79736. /**
  79737. * Texture coordinates 3
  79738. */
  79739. static readonly UV3Kind: string;
  79740. /**
  79741. * Texture coordinates 4
  79742. */
  79743. static readonly UV4Kind: string;
  79744. /**
  79745. * Texture coordinates 5
  79746. */
  79747. static readonly UV5Kind: string;
  79748. /**
  79749. * Texture coordinates 6
  79750. */
  79751. static readonly UV6Kind: string;
  79752. /**
  79753. * Colors
  79754. */
  79755. static readonly ColorKind: string;
  79756. /**
  79757. * Matrix indices (for bones)
  79758. */
  79759. static readonly MatricesIndicesKind: string;
  79760. /**
  79761. * Matrix weights (for bones)
  79762. */
  79763. static readonly MatricesWeightsKind: string;
  79764. /**
  79765. * Additional matrix indices (for bones)
  79766. */
  79767. static readonly MatricesIndicesExtraKind: string;
  79768. /**
  79769. * Additional matrix weights (for bones)
  79770. */
  79771. static readonly MatricesWeightsExtraKind: string;
  79772. /**
  79773. * Deduces the stride given a kind.
  79774. * @param kind The kind string to deduce
  79775. * @returns The deduced stride
  79776. */
  79777. static DeduceStride(kind: string): number;
  79778. /**
  79779. * Gets the byte length of the given type.
  79780. * @param type the type
  79781. * @returns the number of bytes
  79782. */
  79783. static GetTypeByteLength(type: number): number;
  79784. /**
  79785. * Enumerates each value of the given parameters as numbers.
  79786. * @param data the data to enumerate
  79787. * @param byteOffset the byte offset of the data
  79788. * @param byteStride the byte stride of the data
  79789. * @param componentCount the number of components per element
  79790. * @param componentType the type of the component
  79791. * @param count the number of values to enumerate
  79792. * @param normalized whether the data is normalized
  79793. * @param callback the callback function called for each value
  79794. */
  79795. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79796. private static _GetFloatValue;
  79797. }
  79798. }
  79799. declare module BABYLON {
  79800. /**
  79801. * @hidden
  79802. */
  79803. export class IntersectionInfo {
  79804. bu: Nullable<number>;
  79805. bv: Nullable<number>;
  79806. distance: number;
  79807. faceId: number;
  79808. subMeshId: number;
  79809. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79810. }
  79811. }
  79812. declare module BABYLON {
  79813. /**
  79814. * Represens a plane by the equation ax + by + cz + d = 0
  79815. */
  79816. export class Plane {
  79817. private static _TmpMatrix;
  79818. /**
  79819. * Normal of the plane (a,b,c)
  79820. */
  79821. normal: Vector3;
  79822. /**
  79823. * d component of the plane
  79824. */
  79825. d: number;
  79826. /**
  79827. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79828. * @param a a component of the plane
  79829. * @param b b component of the plane
  79830. * @param c c component of the plane
  79831. * @param d d component of the plane
  79832. */
  79833. constructor(a: number, b: number, c: number, d: number);
  79834. /**
  79835. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79836. */
  79837. asArray(): number[];
  79838. /**
  79839. * @returns a new plane copied from the current Plane.
  79840. */
  79841. clone(): Plane;
  79842. /**
  79843. * @returns the string "Plane".
  79844. */
  79845. getClassName(): string;
  79846. /**
  79847. * @returns the Plane hash code.
  79848. */
  79849. getHashCode(): number;
  79850. /**
  79851. * Normalize the current Plane in place.
  79852. * @returns the updated Plane.
  79853. */
  79854. normalize(): Plane;
  79855. /**
  79856. * Applies a transformation the plane and returns the result
  79857. * @param transformation the transformation matrix to be applied to the plane
  79858. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79859. */
  79860. transform(transformation: DeepImmutable<Matrix>): Plane;
  79861. /**
  79862. * Calcualtte the dot product between the point and the plane normal
  79863. * @param point point to calculate the dot product with
  79864. * @returns the dot product (float) of the point coordinates and the plane normal.
  79865. */
  79866. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79867. /**
  79868. * Updates the current Plane from the plane defined by the three given points.
  79869. * @param point1 one of the points used to contruct the plane
  79870. * @param point2 one of the points used to contruct the plane
  79871. * @param point3 one of the points used to contruct the plane
  79872. * @returns the updated Plane.
  79873. */
  79874. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79875. /**
  79876. * Checks if the plane is facing a given direction
  79877. * @param direction the direction to check if the plane is facing
  79878. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79879. * @returns True is the vector "direction" is the same side than the plane normal.
  79880. */
  79881. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79882. /**
  79883. * Calculates the distance to a point
  79884. * @param point point to calculate distance to
  79885. * @returns the signed distance (float) from the given point to the Plane.
  79886. */
  79887. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79888. /**
  79889. * Creates a plane from an array
  79890. * @param array the array to create a plane from
  79891. * @returns a new Plane from the given array.
  79892. */
  79893. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79894. /**
  79895. * Creates a plane from three points
  79896. * @param point1 point used to create the plane
  79897. * @param point2 point used to create the plane
  79898. * @param point3 point used to create the plane
  79899. * @returns a new Plane defined by the three given points.
  79900. */
  79901. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79902. /**
  79903. * Creates a plane from an origin point and a normal
  79904. * @param origin origin of the plane to be constructed
  79905. * @param normal normal of the plane to be constructed
  79906. * @returns a new Plane the normal vector to this plane at the given origin point.
  79907. * Note : the vector "normal" is updated because normalized.
  79908. */
  79909. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79910. /**
  79911. * Calculates the distance from a plane and a point
  79912. * @param origin origin of the plane to be constructed
  79913. * @param normal normal of the plane to be constructed
  79914. * @param point point to calculate distance to
  79915. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79916. */
  79917. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79918. }
  79919. }
  79920. declare module BABYLON {
  79921. /**
  79922. * Class used to store bounding sphere information
  79923. */
  79924. export class BoundingSphere {
  79925. /**
  79926. * Gets the center of the bounding sphere in local space
  79927. */
  79928. readonly center: Vector3;
  79929. /**
  79930. * Radius of the bounding sphere in local space
  79931. */
  79932. radius: number;
  79933. /**
  79934. * Gets the center of the bounding sphere in world space
  79935. */
  79936. readonly centerWorld: Vector3;
  79937. /**
  79938. * Radius of the bounding sphere in world space
  79939. */
  79940. radiusWorld: number;
  79941. /**
  79942. * Gets the minimum vector in local space
  79943. */
  79944. readonly minimum: Vector3;
  79945. /**
  79946. * Gets the maximum vector in local space
  79947. */
  79948. readonly maximum: Vector3;
  79949. private _worldMatrix;
  79950. private static readonly TmpVector3;
  79951. /**
  79952. * Creates a new bounding sphere
  79953. * @param min defines the minimum vector (in local space)
  79954. * @param max defines the maximum vector (in local space)
  79955. * @param worldMatrix defines the new world matrix
  79956. */
  79957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79958. /**
  79959. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79960. * @param min defines the new minimum vector (in local space)
  79961. * @param max defines the new maximum vector (in local space)
  79962. * @param worldMatrix defines the new world matrix
  79963. */
  79964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79965. /**
  79966. * Scale the current bounding sphere by applying a scale factor
  79967. * @param factor defines the scale factor to apply
  79968. * @returns the current bounding box
  79969. */
  79970. scale(factor: number): BoundingSphere;
  79971. /**
  79972. * Gets the world matrix of the bounding box
  79973. * @returns a matrix
  79974. */
  79975. getWorldMatrix(): DeepImmutable<Matrix>;
  79976. /** @hidden */
  79977. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79978. /**
  79979. * Tests if the bounding sphere is intersecting the frustum planes
  79980. * @param frustumPlanes defines the frustum planes to test
  79981. * @returns true if there is an intersection
  79982. */
  79983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79984. /**
  79985. * Tests if the bounding sphere center is in between the frustum planes.
  79986. * Used for optimistic fast inclusion.
  79987. * @param frustumPlanes defines the frustum planes to test
  79988. * @returns true if the sphere center is in between the frustum planes
  79989. */
  79990. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79991. /**
  79992. * Tests if a point is inside the bounding sphere
  79993. * @param point defines the point to test
  79994. * @returns true if the point is inside the bounding sphere
  79995. */
  79996. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79997. /**
  79998. * Checks if two sphere intersct
  79999. * @param sphere0 sphere 0
  80000. * @param sphere1 sphere 1
  80001. * @returns true if the speres intersect
  80002. */
  80003. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80004. }
  80005. }
  80006. declare module BABYLON {
  80007. /**
  80008. * Class used to store bounding box information
  80009. */
  80010. export class BoundingBox implements ICullable {
  80011. /**
  80012. * Gets the 8 vectors representing the bounding box in local space
  80013. */
  80014. readonly vectors: Vector3[];
  80015. /**
  80016. * Gets the center of the bounding box in local space
  80017. */
  80018. readonly center: Vector3;
  80019. /**
  80020. * Gets the center of the bounding box in world space
  80021. */
  80022. readonly centerWorld: Vector3;
  80023. /**
  80024. * Gets the extend size in local space
  80025. */
  80026. readonly extendSize: Vector3;
  80027. /**
  80028. * Gets the extend size in world space
  80029. */
  80030. readonly extendSizeWorld: Vector3;
  80031. /**
  80032. * Gets the OBB (object bounding box) directions
  80033. */
  80034. readonly directions: Vector3[];
  80035. /**
  80036. * Gets the 8 vectors representing the bounding box in world space
  80037. */
  80038. readonly vectorsWorld: Vector3[];
  80039. /**
  80040. * Gets the minimum vector in world space
  80041. */
  80042. readonly minimumWorld: Vector3;
  80043. /**
  80044. * Gets the maximum vector in world space
  80045. */
  80046. readonly maximumWorld: Vector3;
  80047. /**
  80048. * Gets the minimum vector in local space
  80049. */
  80050. readonly minimum: Vector3;
  80051. /**
  80052. * Gets the maximum vector in local space
  80053. */
  80054. readonly maximum: Vector3;
  80055. private _worldMatrix;
  80056. private static readonly TmpVector3;
  80057. /**
  80058. * @hidden
  80059. */
  80060. _tag: number;
  80061. /**
  80062. * Creates a new bounding box
  80063. * @param min defines the minimum vector (in local space)
  80064. * @param max defines the maximum vector (in local space)
  80065. * @param worldMatrix defines the new world matrix
  80066. */
  80067. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80068. /**
  80069. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80070. * @param min defines the new minimum vector (in local space)
  80071. * @param max defines the new maximum vector (in local space)
  80072. * @param worldMatrix defines the new world matrix
  80073. */
  80074. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80075. /**
  80076. * Scale the current bounding box by applying a scale factor
  80077. * @param factor defines the scale factor to apply
  80078. * @returns the current bounding box
  80079. */
  80080. scale(factor: number): BoundingBox;
  80081. /**
  80082. * Gets the world matrix of the bounding box
  80083. * @returns a matrix
  80084. */
  80085. getWorldMatrix(): DeepImmutable<Matrix>;
  80086. /** @hidden */
  80087. _update(world: DeepImmutable<Matrix>): void;
  80088. /**
  80089. * Tests if the bounding box is intersecting the frustum planes
  80090. * @param frustumPlanes defines the frustum planes to test
  80091. * @returns true if there is an intersection
  80092. */
  80093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80094. /**
  80095. * Tests if the bounding box is entirely inside the frustum planes
  80096. * @param frustumPlanes defines the frustum planes to test
  80097. * @returns true if there is an inclusion
  80098. */
  80099. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80100. /**
  80101. * Tests if a point is inside the bounding box
  80102. * @param point defines the point to test
  80103. * @returns true if the point is inside the bounding box
  80104. */
  80105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80106. /**
  80107. * Tests if the bounding box intersects with a bounding sphere
  80108. * @param sphere defines the sphere to test
  80109. * @returns true if there is an intersection
  80110. */
  80111. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80112. /**
  80113. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80114. * @param min defines the min vector to use
  80115. * @param max defines the max vector to use
  80116. * @returns true if there is an intersection
  80117. */
  80118. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80119. /**
  80120. * Tests if two bounding boxes are intersections
  80121. * @param box0 defines the first box to test
  80122. * @param box1 defines the second box to test
  80123. * @returns true if there is an intersection
  80124. */
  80125. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80126. /**
  80127. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80128. * @param minPoint defines the minimum vector of the bounding box
  80129. * @param maxPoint defines the maximum vector of the bounding box
  80130. * @param sphereCenter defines the sphere center
  80131. * @param sphereRadius defines the sphere radius
  80132. * @returns true if there is an intersection
  80133. */
  80134. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80135. /**
  80136. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80137. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80138. * @param frustumPlanes defines the frustum planes to test
  80139. * @return true if there is an inclusion
  80140. */
  80141. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80142. /**
  80143. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80144. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80145. * @param frustumPlanes defines the frustum planes to test
  80146. * @return true if there is an intersection
  80147. */
  80148. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80149. }
  80150. }
  80151. declare module BABYLON {
  80152. /** @hidden */
  80153. export class Collider {
  80154. /** Define if a collision was found */
  80155. collisionFound: boolean;
  80156. /**
  80157. * Define last intersection point in local space
  80158. */
  80159. intersectionPoint: Vector3;
  80160. /**
  80161. * Define last collided mesh
  80162. */
  80163. collidedMesh: Nullable<AbstractMesh>;
  80164. private _collisionPoint;
  80165. private _planeIntersectionPoint;
  80166. private _tempVector;
  80167. private _tempVector2;
  80168. private _tempVector3;
  80169. private _tempVector4;
  80170. private _edge;
  80171. private _baseToVertex;
  80172. private _destinationPoint;
  80173. private _slidePlaneNormal;
  80174. private _displacementVector;
  80175. /** @hidden */
  80176. _radius: Vector3;
  80177. /** @hidden */
  80178. _retry: number;
  80179. private _velocity;
  80180. private _basePoint;
  80181. private _epsilon;
  80182. /** @hidden */
  80183. _velocityWorldLength: number;
  80184. /** @hidden */
  80185. _basePointWorld: Vector3;
  80186. private _velocityWorld;
  80187. private _normalizedVelocity;
  80188. /** @hidden */
  80189. _initialVelocity: Vector3;
  80190. /** @hidden */
  80191. _initialPosition: Vector3;
  80192. private _nearestDistance;
  80193. private _collisionMask;
  80194. get collisionMask(): number;
  80195. set collisionMask(mask: number);
  80196. /**
  80197. * Gets the plane normal used to compute the sliding response (in local space)
  80198. */
  80199. get slidePlaneNormal(): Vector3;
  80200. /** @hidden */
  80201. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80202. /** @hidden */
  80203. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80204. /** @hidden */
  80205. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80206. /** @hidden */
  80207. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80208. /** @hidden */
  80209. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80210. /** @hidden */
  80211. _getResponse(pos: Vector3, vel: Vector3): void;
  80212. }
  80213. }
  80214. declare module BABYLON {
  80215. /**
  80216. * Interface for cullable objects
  80217. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80218. */
  80219. export interface ICullable {
  80220. /**
  80221. * Checks if the object or part of the object is in the frustum
  80222. * @param frustumPlanes Camera near/planes
  80223. * @returns true if the object is in frustum otherwise false
  80224. */
  80225. isInFrustum(frustumPlanes: Plane[]): boolean;
  80226. /**
  80227. * Checks if a cullable object (mesh...) is in the camera frustum
  80228. * Unlike isInFrustum this cheks the full bounding box
  80229. * @param frustumPlanes Camera near/planes
  80230. * @returns true if the object is in frustum otherwise false
  80231. */
  80232. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80233. }
  80234. /**
  80235. * Info for a bounding data of a mesh
  80236. */
  80237. export class BoundingInfo implements ICullable {
  80238. /**
  80239. * Bounding box for the mesh
  80240. */
  80241. readonly boundingBox: BoundingBox;
  80242. /**
  80243. * Bounding sphere for the mesh
  80244. */
  80245. readonly boundingSphere: BoundingSphere;
  80246. private _isLocked;
  80247. private static readonly TmpVector3;
  80248. /**
  80249. * Constructs bounding info
  80250. * @param minimum min vector of the bounding box/sphere
  80251. * @param maximum max vector of the bounding box/sphere
  80252. * @param worldMatrix defines the new world matrix
  80253. */
  80254. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80255. /**
  80256. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80257. * @param min defines the new minimum vector (in local space)
  80258. * @param max defines the new maximum vector (in local space)
  80259. * @param worldMatrix defines the new world matrix
  80260. */
  80261. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80262. /**
  80263. * min vector of the bounding box/sphere
  80264. */
  80265. get minimum(): Vector3;
  80266. /**
  80267. * max vector of the bounding box/sphere
  80268. */
  80269. get maximum(): Vector3;
  80270. /**
  80271. * If the info is locked and won't be updated to avoid perf overhead
  80272. */
  80273. get isLocked(): boolean;
  80274. set isLocked(value: boolean);
  80275. /**
  80276. * Updates the bounding sphere and box
  80277. * @param world world matrix to be used to update
  80278. */
  80279. update(world: DeepImmutable<Matrix>): void;
  80280. /**
  80281. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80282. * @param center New center of the bounding info
  80283. * @param extend New extend of the bounding info
  80284. * @returns the current bounding info
  80285. */
  80286. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80287. /**
  80288. * Scale the current bounding info by applying a scale factor
  80289. * @param factor defines the scale factor to apply
  80290. * @returns the current bounding info
  80291. */
  80292. scale(factor: number): BoundingInfo;
  80293. /**
  80294. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80295. * @param frustumPlanes defines the frustum to test
  80296. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80297. * @returns true if the bounding info is in the frustum planes
  80298. */
  80299. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80300. /**
  80301. * Gets the world distance between the min and max points of the bounding box
  80302. */
  80303. get diagonalLength(): number;
  80304. /**
  80305. * Checks if a cullable object (mesh...) is in the camera frustum
  80306. * Unlike isInFrustum this cheks the full bounding box
  80307. * @param frustumPlanes Camera near/planes
  80308. * @returns true if the object is in frustum otherwise false
  80309. */
  80310. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80311. /** @hidden */
  80312. _checkCollision(collider: Collider): boolean;
  80313. /**
  80314. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80315. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80316. * @param point the point to check intersection with
  80317. * @returns if the point intersects
  80318. */
  80319. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80320. /**
  80321. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80322. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80323. * @param boundingInfo the bounding info to check intersection with
  80324. * @param precise if the intersection should be done using OBB
  80325. * @returns if the bounding info intersects
  80326. */
  80327. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80328. }
  80329. }
  80330. declare module BABYLON {
  80331. /**
  80332. * Extracts minimum and maximum values from a list of indexed positions
  80333. * @param positions defines the positions to use
  80334. * @param indices defines the indices to the positions
  80335. * @param indexStart defines the start index
  80336. * @param indexCount defines the end index
  80337. * @param bias defines bias value to add to the result
  80338. * @return minimum and maximum values
  80339. */
  80340. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80341. minimum: Vector3;
  80342. maximum: Vector3;
  80343. };
  80344. /**
  80345. * Extracts minimum and maximum values from a list of positions
  80346. * @param positions defines the positions to use
  80347. * @param start defines the start index in the positions array
  80348. * @param count defines the number of positions to handle
  80349. * @param bias defines bias value to add to the result
  80350. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80351. * @return minimum and maximum values
  80352. */
  80353. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80354. minimum: Vector3;
  80355. maximum: Vector3;
  80356. };
  80357. }
  80358. declare module BABYLON {
  80359. /** @hidden */
  80360. export class WebGLDataBuffer extends DataBuffer {
  80361. private _buffer;
  80362. constructor(resource: WebGLBuffer);
  80363. get underlyingResource(): any;
  80364. }
  80365. }
  80366. declare module BABYLON {
  80367. /** @hidden */
  80368. export class WebGLPipelineContext implements IPipelineContext {
  80369. engine: ThinEngine;
  80370. program: Nullable<WebGLProgram>;
  80371. context?: WebGLRenderingContext;
  80372. vertexShader?: WebGLShader;
  80373. fragmentShader?: WebGLShader;
  80374. isParallelCompiled: boolean;
  80375. onCompiled?: () => void;
  80376. transformFeedback?: WebGLTransformFeedback | null;
  80377. vertexCompilationError: Nullable<string>;
  80378. fragmentCompilationError: Nullable<string>;
  80379. programLinkError: Nullable<string>;
  80380. programValidationError: Nullable<string>;
  80381. get isAsync(): boolean;
  80382. get isReady(): boolean;
  80383. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. interface ThinEngine {
  80388. /**
  80389. * Create an uniform buffer
  80390. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80391. * @param elements defines the content of the uniform buffer
  80392. * @returns the webGL uniform buffer
  80393. */
  80394. createUniformBuffer(elements: FloatArray): DataBuffer;
  80395. /**
  80396. * Create a dynamic uniform buffer
  80397. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80398. * @param elements defines the content of the uniform buffer
  80399. * @returns the webGL uniform buffer
  80400. */
  80401. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80402. /**
  80403. * Update an existing uniform buffer
  80404. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80405. * @param uniformBuffer defines the target uniform buffer
  80406. * @param elements defines the content to update
  80407. * @param offset defines the offset in the uniform buffer where update should start
  80408. * @param count defines the size of the data to update
  80409. */
  80410. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80411. /**
  80412. * Bind an uniform buffer to the current webGL context
  80413. * @param buffer defines the buffer to bind
  80414. */
  80415. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80416. /**
  80417. * Bind a buffer to the current webGL context at a given location
  80418. * @param buffer defines the buffer to bind
  80419. * @param location defines the index where to bind the buffer
  80420. */
  80421. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80422. /**
  80423. * Bind a specific block at a given index in a specific shader program
  80424. * @param pipelineContext defines the pipeline context to use
  80425. * @param blockName defines the block name
  80426. * @param index defines the index where to bind the block
  80427. */
  80428. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80429. }
  80430. }
  80431. declare module BABYLON {
  80432. /**
  80433. * Uniform buffer objects.
  80434. *
  80435. * Handles blocks of uniform on the GPU.
  80436. *
  80437. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80438. *
  80439. * For more information, please refer to :
  80440. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80441. */
  80442. export class UniformBuffer {
  80443. private _engine;
  80444. private _buffer;
  80445. private _data;
  80446. private _bufferData;
  80447. private _dynamic?;
  80448. private _uniformLocations;
  80449. private _uniformSizes;
  80450. private _uniformLocationPointer;
  80451. private _needSync;
  80452. private _noUBO;
  80453. private _currentEffect;
  80454. /** @hidden */
  80455. _alreadyBound: boolean;
  80456. private static _MAX_UNIFORM_SIZE;
  80457. private static _tempBuffer;
  80458. /**
  80459. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80460. * This is dynamic to allow compat with webgl 1 and 2.
  80461. * You will need to pass the name of the uniform as well as the value.
  80462. */
  80463. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80464. /**
  80465. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80466. * This is dynamic to allow compat with webgl 1 and 2.
  80467. * You will need to pass the name of the uniform as well as the value.
  80468. */
  80469. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80470. /**
  80471. * Lambda to Update a single float in a uniform buffer.
  80472. * This is dynamic to allow compat with webgl 1 and 2.
  80473. * You will need to pass the name of the uniform as well as the value.
  80474. */
  80475. updateFloat: (name: string, x: number) => void;
  80476. /**
  80477. * Lambda to Update a vec2 of float in a uniform buffer.
  80478. * This is dynamic to allow compat with webgl 1 and 2.
  80479. * You will need to pass the name of the uniform as well as the value.
  80480. */
  80481. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80482. /**
  80483. * Lambda to Update a vec3 of float in a uniform buffer.
  80484. * This is dynamic to allow compat with webgl 1 and 2.
  80485. * You will need to pass the name of the uniform as well as the value.
  80486. */
  80487. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80488. /**
  80489. * Lambda to Update a vec4 of float in a uniform buffer.
  80490. * This is dynamic to allow compat with webgl 1 and 2.
  80491. * You will need to pass the name of the uniform as well as the value.
  80492. */
  80493. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80494. /**
  80495. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80496. * This is dynamic to allow compat with webgl 1 and 2.
  80497. * You will need to pass the name of the uniform as well as the value.
  80498. */
  80499. updateMatrix: (name: string, mat: Matrix) => void;
  80500. /**
  80501. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80502. * This is dynamic to allow compat with webgl 1 and 2.
  80503. * You will need to pass the name of the uniform as well as the value.
  80504. */
  80505. updateVector3: (name: string, vector: Vector3) => void;
  80506. /**
  80507. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80508. * This is dynamic to allow compat with webgl 1 and 2.
  80509. * You will need to pass the name of the uniform as well as the value.
  80510. */
  80511. updateVector4: (name: string, vector: Vector4) => void;
  80512. /**
  80513. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80514. * This is dynamic to allow compat with webgl 1 and 2.
  80515. * You will need to pass the name of the uniform as well as the value.
  80516. */
  80517. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80518. /**
  80519. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80520. * This is dynamic to allow compat with webgl 1 and 2.
  80521. * You will need to pass the name of the uniform as well as the value.
  80522. */
  80523. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80524. /**
  80525. * Instantiates a new Uniform buffer objects.
  80526. *
  80527. * Handles blocks of uniform on the GPU.
  80528. *
  80529. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80530. *
  80531. * For more information, please refer to :
  80532. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80533. * @param engine Define the engine the buffer is associated with
  80534. * @param data Define the data contained in the buffer
  80535. * @param dynamic Define if the buffer is updatable
  80536. */
  80537. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80538. /**
  80539. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80540. * or just falling back on setUniformXXX calls.
  80541. */
  80542. get useUbo(): boolean;
  80543. /**
  80544. * Indicates if the WebGL underlying uniform buffer is in sync
  80545. * with the javascript cache data.
  80546. */
  80547. get isSync(): boolean;
  80548. /**
  80549. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80550. * Also, a dynamic UniformBuffer will disable cache verification and always
  80551. * update the underlying WebGL uniform buffer to the GPU.
  80552. * @returns if Dynamic, otherwise false
  80553. */
  80554. isDynamic(): boolean;
  80555. /**
  80556. * The data cache on JS side.
  80557. * @returns the underlying data as a float array
  80558. */
  80559. getData(): Float32Array;
  80560. /**
  80561. * The underlying WebGL Uniform buffer.
  80562. * @returns the webgl buffer
  80563. */
  80564. getBuffer(): Nullable<DataBuffer>;
  80565. /**
  80566. * std140 layout specifies how to align data within an UBO structure.
  80567. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80568. * for specs.
  80569. */
  80570. private _fillAlignment;
  80571. /**
  80572. * Adds an uniform in the buffer.
  80573. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80574. * for the layout to be correct !
  80575. * @param name Name of the uniform, as used in the uniform block in the shader.
  80576. * @param size Data size, or data directly.
  80577. */
  80578. addUniform(name: string, size: number | number[]): void;
  80579. /**
  80580. * Adds a Matrix 4x4 to the uniform buffer.
  80581. * @param name Name of the uniform, as used in the uniform block in the shader.
  80582. * @param mat A 4x4 matrix.
  80583. */
  80584. addMatrix(name: string, mat: Matrix): void;
  80585. /**
  80586. * Adds a vec2 to the uniform buffer.
  80587. * @param name Name of the uniform, as used in the uniform block in the shader.
  80588. * @param x Define the x component value of the vec2
  80589. * @param y Define the y component value of the vec2
  80590. */
  80591. addFloat2(name: string, x: number, y: number): void;
  80592. /**
  80593. * Adds a vec3 to the uniform buffer.
  80594. * @param name Name of the uniform, as used in the uniform block in the shader.
  80595. * @param x Define the x component value of the vec3
  80596. * @param y Define the y component value of the vec3
  80597. * @param z Define the z component value of the vec3
  80598. */
  80599. addFloat3(name: string, x: number, y: number, z: number): void;
  80600. /**
  80601. * Adds a vec3 to the uniform buffer.
  80602. * @param name Name of the uniform, as used in the uniform block in the shader.
  80603. * @param color Define the vec3 from a Color
  80604. */
  80605. addColor3(name: string, color: Color3): void;
  80606. /**
  80607. * Adds a vec4 to the uniform buffer.
  80608. * @param name Name of the uniform, as used in the uniform block in the shader.
  80609. * @param color Define the rgb components from a Color
  80610. * @param alpha Define the a component of the vec4
  80611. */
  80612. addColor4(name: string, color: Color3, alpha: number): void;
  80613. /**
  80614. * Adds a vec3 to the uniform buffer.
  80615. * @param name Name of the uniform, as used in the uniform block in the shader.
  80616. * @param vector Define the vec3 components from a Vector
  80617. */
  80618. addVector3(name: string, vector: Vector3): void;
  80619. /**
  80620. * Adds a Matrix 3x3 to the uniform buffer.
  80621. * @param name Name of the uniform, as used in the uniform block in the shader.
  80622. */
  80623. addMatrix3x3(name: string): void;
  80624. /**
  80625. * Adds a Matrix 2x2 to the uniform buffer.
  80626. * @param name Name of the uniform, as used in the uniform block in the shader.
  80627. */
  80628. addMatrix2x2(name: string): void;
  80629. /**
  80630. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80631. */
  80632. create(): void;
  80633. /** @hidden */
  80634. _rebuild(): void;
  80635. /**
  80636. * Updates the WebGL Uniform Buffer on the GPU.
  80637. * If the `dynamic` flag is set to true, no cache comparison is done.
  80638. * Otherwise, the buffer will be updated only if the cache differs.
  80639. */
  80640. update(): void;
  80641. /**
  80642. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80643. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80644. * @param data Define the flattened data
  80645. * @param size Define the size of the data.
  80646. */
  80647. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80648. private _valueCache;
  80649. private _cacheMatrix;
  80650. private _updateMatrix3x3ForUniform;
  80651. private _updateMatrix3x3ForEffect;
  80652. private _updateMatrix2x2ForEffect;
  80653. private _updateMatrix2x2ForUniform;
  80654. private _updateFloatForEffect;
  80655. private _updateFloatForUniform;
  80656. private _updateFloat2ForEffect;
  80657. private _updateFloat2ForUniform;
  80658. private _updateFloat3ForEffect;
  80659. private _updateFloat3ForUniform;
  80660. private _updateFloat4ForEffect;
  80661. private _updateFloat4ForUniform;
  80662. private _updateMatrixForEffect;
  80663. private _updateMatrixForUniform;
  80664. private _updateVector3ForEffect;
  80665. private _updateVector3ForUniform;
  80666. private _updateVector4ForEffect;
  80667. private _updateVector4ForUniform;
  80668. private _updateColor3ForEffect;
  80669. private _updateColor3ForUniform;
  80670. private _updateColor4ForEffect;
  80671. private _updateColor4ForUniform;
  80672. /**
  80673. * Sets a sampler uniform on the effect.
  80674. * @param name Define the name of the sampler.
  80675. * @param texture Define the texture to set in the sampler
  80676. */
  80677. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80678. /**
  80679. * Directly updates the value of the uniform in the cache AND on the GPU.
  80680. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80681. * @param data Define the flattened data
  80682. */
  80683. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80684. /**
  80685. * Binds this uniform buffer to an effect.
  80686. * @param effect Define the effect to bind the buffer to
  80687. * @param name Name of the uniform block in the shader.
  80688. */
  80689. bindToEffect(effect: Effect, name: string): void;
  80690. /**
  80691. * Disposes the uniform buffer.
  80692. */
  80693. dispose(): void;
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /**
  80698. * Enum that determines the text-wrapping mode to use.
  80699. */
  80700. export enum InspectableType {
  80701. /**
  80702. * Checkbox for booleans
  80703. */
  80704. Checkbox = 0,
  80705. /**
  80706. * Sliders for numbers
  80707. */
  80708. Slider = 1,
  80709. /**
  80710. * Vector3
  80711. */
  80712. Vector3 = 2,
  80713. /**
  80714. * Quaternions
  80715. */
  80716. Quaternion = 3,
  80717. /**
  80718. * Color3
  80719. */
  80720. Color3 = 4,
  80721. /**
  80722. * String
  80723. */
  80724. String = 5
  80725. }
  80726. /**
  80727. * Interface used to define custom inspectable properties.
  80728. * This interface is used by the inspector to display custom property grids
  80729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80730. */
  80731. export interface IInspectable {
  80732. /**
  80733. * Gets the label to display
  80734. */
  80735. label: string;
  80736. /**
  80737. * Gets the name of the property to edit
  80738. */
  80739. propertyName: string;
  80740. /**
  80741. * Gets the type of the editor to use
  80742. */
  80743. type: InspectableType;
  80744. /**
  80745. * Gets the minimum value of the property when using in "slider" mode
  80746. */
  80747. min?: number;
  80748. /**
  80749. * Gets the maximum value of the property when using in "slider" mode
  80750. */
  80751. max?: number;
  80752. /**
  80753. * Gets the setp to use when using in "slider" mode
  80754. */
  80755. step?: number;
  80756. }
  80757. }
  80758. declare module BABYLON {
  80759. /**
  80760. * Class used to provide helper for timing
  80761. */
  80762. export class TimingTools {
  80763. /**
  80764. * Polyfill for setImmediate
  80765. * @param action defines the action to execute after the current execution block
  80766. */
  80767. static SetImmediate(action: () => void): void;
  80768. }
  80769. }
  80770. declare module BABYLON {
  80771. /**
  80772. * Class used to enable instatition of objects by class name
  80773. */
  80774. export class InstantiationTools {
  80775. /**
  80776. * Use this object to register external classes like custom textures or material
  80777. * to allow the laoders to instantiate them
  80778. */
  80779. static RegisteredExternalClasses: {
  80780. [key: string]: Object;
  80781. };
  80782. /**
  80783. * Tries to instantiate a new object from a given class name
  80784. * @param className defines the class name to instantiate
  80785. * @returns the new object or null if the system was not able to do the instantiation
  80786. */
  80787. static Instantiate(className: string): any;
  80788. }
  80789. }
  80790. declare module BABYLON {
  80791. /**
  80792. * Define options used to create a depth texture
  80793. */
  80794. export class DepthTextureCreationOptions {
  80795. /** Specifies whether or not a stencil should be allocated in the texture */
  80796. generateStencil?: boolean;
  80797. /** Specifies whether or not bilinear filtering is enable on the texture */
  80798. bilinearFiltering?: boolean;
  80799. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80800. comparisonFunction?: number;
  80801. /** Specifies if the created texture is a cube texture */
  80802. isCube?: boolean;
  80803. }
  80804. }
  80805. declare module BABYLON {
  80806. interface ThinEngine {
  80807. /**
  80808. * Creates a depth stencil cube texture.
  80809. * This is only available in WebGL 2.
  80810. * @param size The size of face edge in the cube texture.
  80811. * @param options The options defining the cube texture.
  80812. * @returns The cube texture
  80813. */
  80814. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80815. /**
  80816. * Creates a cube texture
  80817. * @param rootUrl defines the url where the files to load is located
  80818. * @param scene defines the current scene
  80819. * @param files defines the list of files to load (1 per face)
  80820. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80821. * @param onLoad defines an optional callback raised when the texture is loaded
  80822. * @param onError defines an optional callback raised if there is an issue to load the texture
  80823. * @param format defines the format of the data
  80824. * @param forcedExtension defines the extension to use to pick the right loader
  80825. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80826. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80827. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80828. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80829. * @returns the cube texture as an InternalTexture
  80830. */
  80831. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  80832. /**
  80833. * Creates a cube texture
  80834. * @param rootUrl defines the url where the files to load is located
  80835. * @param scene defines the current scene
  80836. * @param files defines the list of files to load (1 per face)
  80837. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80838. * @param onLoad defines an optional callback raised when the texture is loaded
  80839. * @param onError defines an optional callback raised if there is an issue to load the texture
  80840. * @param format defines the format of the data
  80841. * @param forcedExtension defines the extension to use to pick the right loader
  80842. * @returns the cube texture as an InternalTexture
  80843. */
  80844. 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;
  80845. /**
  80846. * Creates a cube texture
  80847. * @param rootUrl defines the url where the files to load is located
  80848. * @param scene defines the current scene
  80849. * @param files defines the list of files to load (1 per face)
  80850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80851. * @param onLoad defines an optional callback raised when the texture is loaded
  80852. * @param onError defines an optional callback raised if there is an issue to load the texture
  80853. * @param format defines the format of the data
  80854. * @param forcedExtension defines the extension to use to pick the right loader
  80855. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80856. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80857. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80858. * @returns the cube texture as an InternalTexture
  80859. */
  80860. 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;
  80861. /** @hidden */
  80862. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80863. /** @hidden */
  80864. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80865. /** @hidden */
  80866. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80867. /** @hidden */
  80868. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80869. /**
  80870. * @hidden
  80871. */
  80872. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80873. }
  80874. }
  80875. declare module BABYLON {
  80876. /**
  80877. * Class for creating a cube texture
  80878. */
  80879. export class CubeTexture extends BaseTexture {
  80880. private _delayedOnLoad;
  80881. /**
  80882. * Observable triggered once the texture has been loaded.
  80883. */
  80884. onLoadObservable: Observable<CubeTexture>;
  80885. /**
  80886. * The url of the texture
  80887. */
  80888. url: string;
  80889. /**
  80890. * Gets or sets the center of the bounding box associated with the cube texture.
  80891. * It must define where the camera used to render the texture was set
  80892. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80893. */
  80894. boundingBoxPosition: Vector3;
  80895. private _boundingBoxSize;
  80896. /**
  80897. * Gets or sets the size of the bounding box associated with the cube texture
  80898. * When defined, the cubemap will switch to local mode
  80899. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80900. * @example https://www.babylonjs-playground.com/#RNASML
  80901. */
  80902. set boundingBoxSize(value: Vector3);
  80903. /**
  80904. * Returns the bounding box size
  80905. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80906. */
  80907. get boundingBoxSize(): Vector3;
  80908. protected _rotationY: number;
  80909. /**
  80910. * Sets texture matrix rotation angle around Y axis in radians.
  80911. */
  80912. set rotationY(value: number);
  80913. /**
  80914. * Gets texture matrix rotation angle around Y axis radians.
  80915. */
  80916. get rotationY(): number;
  80917. /**
  80918. * Are mip maps generated for this texture or not.
  80919. */
  80920. get noMipmap(): boolean;
  80921. private _noMipmap;
  80922. private _files;
  80923. protected _forcedExtension: Nullable<string>;
  80924. private _extensions;
  80925. private _textureMatrix;
  80926. private _format;
  80927. private _createPolynomials;
  80928. /** @hidden */
  80929. _prefiltered: boolean;
  80930. /**
  80931. * Creates a cube texture from an array of image urls
  80932. * @param files defines an array of image urls
  80933. * @param scene defines the hosting scene
  80934. * @param noMipmap specifies if mip maps are not used
  80935. * @returns a cube texture
  80936. */
  80937. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80938. /**
  80939. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80940. * @param url defines the url of the prefiltered texture
  80941. * @param scene defines the scene the texture is attached to
  80942. * @param forcedExtension defines the extension of the file if different from the url
  80943. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80944. * @return the prefiltered texture
  80945. */
  80946. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80947. /**
  80948. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80949. * as prefiltered data.
  80950. * @param rootUrl defines the url of the texture or the root name of the six images
  80951. * @param scene defines the scene the texture is attached to
  80952. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80953. * @param noMipmap defines if mipmaps should be created or not
  80954. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80955. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80956. * @param onError defines a callback triggered in case of error during load
  80957. * @param format defines the internal format to use for the texture once loaded
  80958. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80959. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80960. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80961. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80962. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80963. * @return the cube texture
  80964. */
  80965. 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);
  80966. /**
  80967. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80968. */
  80969. get isPrefiltered(): boolean;
  80970. /**
  80971. * Get the current class name of the texture useful for serialization or dynamic coding.
  80972. * @returns "CubeTexture"
  80973. */
  80974. getClassName(): string;
  80975. /**
  80976. * Update the url (and optional buffer) of this texture if url was null during construction.
  80977. * @param url the url of the texture
  80978. * @param forcedExtension defines the extension to use
  80979. * @param onLoad callback called when the texture is loaded (defaults to null)
  80980. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80981. */
  80982. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80983. /**
  80984. * Delays loading of the cube texture
  80985. * @param forcedExtension defines the extension to use
  80986. */
  80987. delayLoad(forcedExtension?: string): void;
  80988. /**
  80989. * Returns the reflection texture matrix
  80990. * @returns the reflection texture matrix
  80991. */
  80992. getReflectionTextureMatrix(): Matrix;
  80993. /**
  80994. * Sets the reflection texture matrix
  80995. * @param value Reflection texture matrix
  80996. */
  80997. setReflectionTextureMatrix(value: Matrix): void;
  80998. /**
  80999. * Parses text to create a cube texture
  81000. * @param parsedTexture define the serialized text to read from
  81001. * @param scene defines the hosting scene
  81002. * @param rootUrl defines the root url of the cube texture
  81003. * @returns a cube texture
  81004. */
  81005. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81006. /**
  81007. * Makes a clone, or deep copy, of the cube texture
  81008. * @returns a new cube texture
  81009. */
  81010. clone(): CubeTexture;
  81011. }
  81012. }
  81013. declare module BABYLON {
  81014. /**
  81015. * Manages the defines for the Material
  81016. */
  81017. export class MaterialDefines {
  81018. /** @hidden */
  81019. protected _keys: string[];
  81020. private _isDirty;
  81021. /** @hidden */
  81022. _renderId: number;
  81023. /** @hidden */
  81024. _areLightsDirty: boolean;
  81025. /** @hidden */
  81026. _areLightsDisposed: boolean;
  81027. /** @hidden */
  81028. _areAttributesDirty: boolean;
  81029. /** @hidden */
  81030. _areTexturesDirty: boolean;
  81031. /** @hidden */
  81032. _areFresnelDirty: boolean;
  81033. /** @hidden */
  81034. _areMiscDirty: boolean;
  81035. /** @hidden */
  81036. _areImageProcessingDirty: boolean;
  81037. /** @hidden */
  81038. _normals: boolean;
  81039. /** @hidden */
  81040. _uvs: boolean;
  81041. /** @hidden */
  81042. _needNormals: boolean;
  81043. /** @hidden */
  81044. _needUVs: boolean;
  81045. [id: string]: any;
  81046. /**
  81047. * Specifies if the material needs to be re-calculated
  81048. */
  81049. get isDirty(): boolean;
  81050. /**
  81051. * Marks the material to indicate that it has been re-calculated
  81052. */
  81053. markAsProcessed(): void;
  81054. /**
  81055. * Marks the material to indicate that it needs to be re-calculated
  81056. */
  81057. markAsUnprocessed(): void;
  81058. /**
  81059. * Marks the material to indicate all of its defines need to be re-calculated
  81060. */
  81061. markAllAsDirty(): void;
  81062. /**
  81063. * Marks the material to indicate that image processing needs to be re-calculated
  81064. */
  81065. markAsImageProcessingDirty(): void;
  81066. /**
  81067. * Marks the material to indicate the lights need to be re-calculated
  81068. * @param disposed Defines whether the light is dirty due to dispose or not
  81069. */
  81070. markAsLightDirty(disposed?: boolean): void;
  81071. /**
  81072. * Marks the attribute state as changed
  81073. */
  81074. markAsAttributesDirty(): void;
  81075. /**
  81076. * Marks the texture state as changed
  81077. */
  81078. markAsTexturesDirty(): void;
  81079. /**
  81080. * Marks the fresnel state as changed
  81081. */
  81082. markAsFresnelDirty(): void;
  81083. /**
  81084. * Marks the misc state as changed
  81085. */
  81086. markAsMiscDirty(): void;
  81087. /**
  81088. * Rebuilds the material defines
  81089. */
  81090. rebuild(): void;
  81091. /**
  81092. * Specifies if two material defines are equal
  81093. * @param other - A material define instance to compare to
  81094. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81095. */
  81096. isEqual(other: MaterialDefines): boolean;
  81097. /**
  81098. * Clones this instance's defines to another instance
  81099. * @param other - material defines to clone values to
  81100. */
  81101. cloneTo(other: MaterialDefines): void;
  81102. /**
  81103. * Resets the material define values
  81104. */
  81105. reset(): void;
  81106. /**
  81107. * Converts the material define values to a string
  81108. * @returns - String of material define information
  81109. */
  81110. toString(): string;
  81111. }
  81112. }
  81113. declare module BABYLON {
  81114. /**
  81115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81117. * 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;
  81118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81119. */
  81120. export class ColorCurves {
  81121. private _dirty;
  81122. private _tempColor;
  81123. private _globalCurve;
  81124. private _highlightsCurve;
  81125. private _midtonesCurve;
  81126. private _shadowsCurve;
  81127. private _positiveCurve;
  81128. private _negativeCurve;
  81129. private _globalHue;
  81130. private _globalDensity;
  81131. private _globalSaturation;
  81132. private _globalExposure;
  81133. /**
  81134. * Gets the global Hue value.
  81135. * 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).
  81136. */
  81137. get globalHue(): number;
  81138. /**
  81139. * Sets the global Hue value.
  81140. * 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).
  81141. */
  81142. set globalHue(value: number);
  81143. /**
  81144. * Gets the global Density value.
  81145. * 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.
  81146. * Values less than zero provide a filter of opposite hue.
  81147. */
  81148. get globalDensity(): number;
  81149. /**
  81150. * Sets the global Density value.
  81151. * 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.
  81152. * Values less than zero provide a filter of opposite hue.
  81153. */
  81154. set globalDensity(value: number);
  81155. /**
  81156. * Gets the global Saturation value.
  81157. * 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.
  81158. */
  81159. get globalSaturation(): number;
  81160. /**
  81161. * Sets the global Saturation value.
  81162. * 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.
  81163. */
  81164. set globalSaturation(value: number);
  81165. /**
  81166. * Gets the global Exposure value.
  81167. * 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.
  81168. */
  81169. get globalExposure(): number;
  81170. /**
  81171. * Sets the global Exposure value.
  81172. * 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.
  81173. */
  81174. set globalExposure(value: number);
  81175. private _highlightsHue;
  81176. private _highlightsDensity;
  81177. private _highlightsSaturation;
  81178. private _highlightsExposure;
  81179. /**
  81180. * Gets the highlights Hue value.
  81181. * 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).
  81182. */
  81183. get highlightsHue(): number;
  81184. /**
  81185. * Sets the highlights Hue value.
  81186. * 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).
  81187. */
  81188. set highlightsHue(value: number);
  81189. /**
  81190. * Gets the highlights Density value.
  81191. * 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.
  81192. * Values less than zero provide a filter of opposite hue.
  81193. */
  81194. get highlightsDensity(): number;
  81195. /**
  81196. * Sets the highlights Density value.
  81197. * 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.
  81198. * Values less than zero provide a filter of opposite hue.
  81199. */
  81200. set highlightsDensity(value: number);
  81201. /**
  81202. * Gets the highlights Saturation value.
  81203. * 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.
  81204. */
  81205. get highlightsSaturation(): number;
  81206. /**
  81207. * Sets the highlights Saturation value.
  81208. * 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.
  81209. */
  81210. set highlightsSaturation(value: number);
  81211. /**
  81212. * Gets the highlights Exposure value.
  81213. * 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.
  81214. */
  81215. get highlightsExposure(): number;
  81216. /**
  81217. * Sets the highlights Exposure value.
  81218. * 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.
  81219. */
  81220. set highlightsExposure(value: number);
  81221. private _midtonesHue;
  81222. private _midtonesDensity;
  81223. private _midtonesSaturation;
  81224. private _midtonesExposure;
  81225. /**
  81226. * Gets the midtones Hue value.
  81227. * 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).
  81228. */
  81229. get midtonesHue(): number;
  81230. /**
  81231. * Sets the midtones Hue value.
  81232. * 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).
  81233. */
  81234. set midtonesHue(value: number);
  81235. /**
  81236. * Gets the midtones Density value.
  81237. * 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.
  81238. * Values less than zero provide a filter of opposite hue.
  81239. */
  81240. get midtonesDensity(): number;
  81241. /**
  81242. * Sets the midtones Density value.
  81243. * 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.
  81244. * Values less than zero provide a filter of opposite hue.
  81245. */
  81246. set midtonesDensity(value: number);
  81247. /**
  81248. * Gets the midtones Saturation value.
  81249. * 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.
  81250. */
  81251. get midtonesSaturation(): number;
  81252. /**
  81253. * Sets the midtones Saturation value.
  81254. * 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.
  81255. */
  81256. set midtonesSaturation(value: number);
  81257. /**
  81258. * Gets the midtones Exposure value.
  81259. * 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.
  81260. */
  81261. get midtonesExposure(): number;
  81262. /**
  81263. * Sets the midtones Exposure value.
  81264. * 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.
  81265. */
  81266. set midtonesExposure(value: number);
  81267. private _shadowsHue;
  81268. private _shadowsDensity;
  81269. private _shadowsSaturation;
  81270. private _shadowsExposure;
  81271. /**
  81272. * Gets the shadows Hue value.
  81273. * 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).
  81274. */
  81275. get shadowsHue(): number;
  81276. /**
  81277. * Sets the shadows Hue value.
  81278. * 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).
  81279. */
  81280. set shadowsHue(value: number);
  81281. /**
  81282. * Gets the shadows Density value.
  81283. * 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.
  81284. * Values less than zero provide a filter of opposite hue.
  81285. */
  81286. get shadowsDensity(): number;
  81287. /**
  81288. * Sets the shadows Density value.
  81289. * 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.
  81290. * Values less than zero provide a filter of opposite hue.
  81291. */
  81292. set shadowsDensity(value: number);
  81293. /**
  81294. * Gets the shadows Saturation value.
  81295. * 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.
  81296. */
  81297. get shadowsSaturation(): number;
  81298. /**
  81299. * Sets the shadows Saturation value.
  81300. * 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.
  81301. */
  81302. set shadowsSaturation(value: number);
  81303. /**
  81304. * Gets the shadows Exposure value.
  81305. * 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.
  81306. */
  81307. get shadowsExposure(): number;
  81308. /**
  81309. * Sets the shadows Exposure value.
  81310. * 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.
  81311. */
  81312. set shadowsExposure(value: number);
  81313. /**
  81314. * Returns the class name
  81315. * @returns The class name
  81316. */
  81317. getClassName(): string;
  81318. /**
  81319. * Binds the color curves to the shader.
  81320. * @param colorCurves The color curve to bind
  81321. * @param effect The effect to bind to
  81322. * @param positiveUniform The positive uniform shader parameter
  81323. * @param neutralUniform The neutral uniform shader parameter
  81324. * @param negativeUniform The negative uniform shader parameter
  81325. */
  81326. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81327. /**
  81328. * Prepare the list of uniforms associated with the ColorCurves effects.
  81329. * @param uniformsList The list of uniforms used in the effect
  81330. */
  81331. static PrepareUniforms(uniformsList: string[]): void;
  81332. /**
  81333. * Returns color grading data based on a hue, density, saturation and exposure value.
  81334. * @param filterHue The hue of the color filter.
  81335. * @param filterDensity The density of the color filter.
  81336. * @param saturation The saturation.
  81337. * @param exposure The exposure.
  81338. * @param result The result data container.
  81339. */
  81340. private getColorGradingDataToRef;
  81341. /**
  81342. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81343. * @param value The input slider value in range [-100,100].
  81344. * @returns Adjusted value.
  81345. */
  81346. private static applyColorGradingSliderNonlinear;
  81347. /**
  81348. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81349. * @param hue The hue (H) input.
  81350. * @param saturation The saturation (S) input.
  81351. * @param brightness The brightness (B) input.
  81352. * @result An RGBA color represented as Vector4.
  81353. */
  81354. private static fromHSBToRef;
  81355. /**
  81356. * Returns a value clamped between min and max
  81357. * @param value The value to clamp
  81358. * @param min The minimum of value
  81359. * @param max The maximum of value
  81360. * @returns The clamped value.
  81361. */
  81362. private static clamp;
  81363. /**
  81364. * Clones the current color curve instance.
  81365. * @return The cloned curves
  81366. */
  81367. clone(): ColorCurves;
  81368. /**
  81369. * Serializes the current color curve instance to a json representation.
  81370. * @return a JSON representation
  81371. */
  81372. serialize(): any;
  81373. /**
  81374. * Parses the color curve from a json representation.
  81375. * @param source the JSON source to parse
  81376. * @return The parsed curves
  81377. */
  81378. static Parse(source: any): ColorCurves;
  81379. }
  81380. }
  81381. declare module BABYLON {
  81382. /**
  81383. * Interface to follow in your material defines to integrate easily the
  81384. * Image proccessing functions.
  81385. * @hidden
  81386. */
  81387. export interface IImageProcessingConfigurationDefines {
  81388. IMAGEPROCESSING: boolean;
  81389. VIGNETTE: boolean;
  81390. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81391. VIGNETTEBLENDMODEOPAQUE: boolean;
  81392. TONEMAPPING: boolean;
  81393. TONEMAPPING_ACES: boolean;
  81394. CONTRAST: boolean;
  81395. EXPOSURE: boolean;
  81396. COLORCURVES: boolean;
  81397. COLORGRADING: boolean;
  81398. COLORGRADING3D: boolean;
  81399. SAMPLER3DGREENDEPTH: boolean;
  81400. SAMPLER3DBGRMAP: boolean;
  81401. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81402. }
  81403. /**
  81404. * @hidden
  81405. */
  81406. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81407. IMAGEPROCESSING: boolean;
  81408. VIGNETTE: boolean;
  81409. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81410. VIGNETTEBLENDMODEOPAQUE: boolean;
  81411. TONEMAPPING: boolean;
  81412. TONEMAPPING_ACES: boolean;
  81413. CONTRAST: boolean;
  81414. COLORCURVES: boolean;
  81415. COLORGRADING: boolean;
  81416. COLORGRADING3D: boolean;
  81417. SAMPLER3DGREENDEPTH: boolean;
  81418. SAMPLER3DBGRMAP: boolean;
  81419. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81420. EXPOSURE: boolean;
  81421. constructor();
  81422. }
  81423. /**
  81424. * This groups together the common properties used for image processing either in direct forward pass
  81425. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81426. * or not.
  81427. */
  81428. export class ImageProcessingConfiguration {
  81429. /**
  81430. * Default tone mapping applied in BabylonJS.
  81431. */
  81432. static readonly TONEMAPPING_STANDARD: number;
  81433. /**
  81434. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81435. * to other engines rendering to increase portability.
  81436. */
  81437. static readonly TONEMAPPING_ACES: number;
  81438. /**
  81439. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81440. */
  81441. colorCurves: Nullable<ColorCurves>;
  81442. private _colorCurvesEnabled;
  81443. /**
  81444. * Gets wether the color curves effect is enabled.
  81445. */
  81446. get colorCurvesEnabled(): boolean;
  81447. /**
  81448. * Sets wether the color curves effect is enabled.
  81449. */
  81450. set colorCurvesEnabled(value: boolean);
  81451. private _colorGradingTexture;
  81452. /**
  81453. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81454. */
  81455. get colorGradingTexture(): Nullable<BaseTexture>;
  81456. /**
  81457. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81458. */
  81459. set colorGradingTexture(value: Nullable<BaseTexture>);
  81460. private _colorGradingEnabled;
  81461. /**
  81462. * Gets wether the color grading effect is enabled.
  81463. */
  81464. get colorGradingEnabled(): boolean;
  81465. /**
  81466. * Sets wether the color grading effect is enabled.
  81467. */
  81468. set colorGradingEnabled(value: boolean);
  81469. private _colorGradingWithGreenDepth;
  81470. /**
  81471. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81472. */
  81473. get colorGradingWithGreenDepth(): boolean;
  81474. /**
  81475. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81476. */
  81477. set colorGradingWithGreenDepth(value: boolean);
  81478. private _colorGradingBGR;
  81479. /**
  81480. * Gets wether the color grading texture contains BGR values.
  81481. */
  81482. get colorGradingBGR(): boolean;
  81483. /**
  81484. * Sets wether the color grading texture contains BGR values.
  81485. */
  81486. set colorGradingBGR(value: boolean);
  81487. /** @hidden */
  81488. _exposure: number;
  81489. /**
  81490. * Gets the Exposure used in the effect.
  81491. */
  81492. get exposure(): number;
  81493. /**
  81494. * Sets the Exposure used in the effect.
  81495. */
  81496. set exposure(value: number);
  81497. private _toneMappingEnabled;
  81498. /**
  81499. * Gets wether the tone mapping effect is enabled.
  81500. */
  81501. get toneMappingEnabled(): boolean;
  81502. /**
  81503. * Sets wether the tone mapping effect is enabled.
  81504. */
  81505. set toneMappingEnabled(value: boolean);
  81506. private _toneMappingType;
  81507. /**
  81508. * Gets the type of tone mapping effect.
  81509. */
  81510. get toneMappingType(): number;
  81511. /**
  81512. * Sets the type of tone mapping effect used in BabylonJS.
  81513. */
  81514. set toneMappingType(value: number);
  81515. protected _contrast: number;
  81516. /**
  81517. * Gets the contrast used in the effect.
  81518. */
  81519. get contrast(): number;
  81520. /**
  81521. * Sets the contrast used in the effect.
  81522. */
  81523. set contrast(value: number);
  81524. /**
  81525. * Vignette stretch size.
  81526. */
  81527. vignetteStretch: number;
  81528. /**
  81529. * Vignette centre X Offset.
  81530. */
  81531. vignetteCentreX: number;
  81532. /**
  81533. * Vignette centre Y Offset.
  81534. */
  81535. vignetteCentreY: number;
  81536. /**
  81537. * Vignette weight or intensity of the vignette effect.
  81538. */
  81539. vignetteWeight: number;
  81540. /**
  81541. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81542. * if vignetteEnabled is set to true.
  81543. */
  81544. vignetteColor: Color4;
  81545. /**
  81546. * Camera field of view used by the Vignette effect.
  81547. */
  81548. vignetteCameraFov: number;
  81549. private _vignetteBlendMode;
  81550. /**
  81551. * Gets the vignette blend mode allowing different kind of effect.
  81552. */
  81553. get vignetteBlendMode(): number;
  81554. /**
  81555. * Sets the vignette blend mode allowing different kind of effect.
  81556. */
  81557. set vignetteBlendMode(value: number);
  81558. private _vignetteEnabled;
  81559. /**
  81560. * Gets wether the vignette effect is enabled.
  81561. */
  81562. get vignetteEnabled(): boolean;
  81563. /**
  81564. * Sets wether the vignette effect is enabled.
  81565. */
  81566. set vignetteEnabled(value: boolean);
  81567. private _applyByPostProcess;
  81568. /**
  81569. * Gets wether the image processing is applied through a post process or not.
  81570. */
  81571. get applyByPostProcess(): boolean;
  81572. /**
  81573. * Sets wether the image processing is applied through a post process or not.
  81574. */
  81575. set applyByPostProcess(value: boolean);
  81576. private _isEnabled;
  81577. /**
  81578. * Gets wether the image processing is enabled or not.
  81579. */
  81580. get isEnabled(): boolean;
  81581. /**
  81582. * Sets wether the image processing is enabled or not.
  81583. */
  81584. set isEnabled(value: boolean);
  81585. /**
  81586. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81587. */
  81588. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81589. /**
  81590. * Method called each time the image processing information changes requires to recompile the effect.
  81591. */
  81592. protected _updateParameters(): void;
  81593. /**
  81594. * Gets the current class name.
  81595. * @return "ImageProcessingConfiguration"
  81596. */
  81597. getClassName(): string;
  81598. /**
  81599. * Prepare the list of uniforms associated with the Image Processing effects.
  81600. * @param uniforms The list of uniforms used in the effect
  81601. * @param defines the list of defines currently in use
  81602. */
  81603. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81604. /**
  81605. * Prepare the list of samplers associated with the Image Processing effects.
  81606. * @param samplersList The list of uniforms used in the effect
  81607. * @param defines the list of defines currently in use
  81608. */
  81609. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81610. /**
  81611. * Prepare the list of defines associated to the shader.
  81612. * @param defines the list of defines to complete
  81613. * @param forPostProcess Define if we are currently in post process mode or not
  81614. */
  81615. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81616. /**
  81617. * Returns true if all the image processing information are ready.
  81618. * @returns True if ready, otherwise, false
  81619. */
  81620. isReady(): boolean;
  81621. /**
  81622. * Binds the image processing to the shader.
  81623. * @param effect The effect to bind to
  81624. * @param overrideAspectRatio Override the aspect ratio of the effect
  81625. */
  81626. bind(effect: Effect, overrideAspectRatio?: number): void;
  81627. /**
  81628. * Clones the current image processing instance.
  81629. * @return The cloned image processing
  81630. */
  81631. clone(): ImageProcessingConfiguration;
  81632. /**
  81633. * Serializes the current image processing instance to a json representation.
  81634. * @return a JSON representation
  81635. */
  81636. serialize(): any;
  81637. /**
  81638. * Parses the image processing from a json representation.
  81639. * @param source the JSON source to parse
  81640. * @return The parsed image processing
  81641. */
  81642. static Parse(source: any): ImageProcessingConfiguration;
  81643. private static _VIGNETTEMODE_MULTIPLY;
  81644. private static _VIGNETTEMODE_OPAQUE;
  81645. /**
  81646. * Used to apply the vignette as a mix with the pixel color.
  81647. */
  81648. static get VIGNETTEMODE_MULTIPLY(): number;
  81649. /**
  81650. * Used to apply the vignette as a replacement of the pixel color.
  81651. */
  81652. static get VIGNETTEMODE_OPAQUE(): number;
  81653. }
  81654. }
  81655. declare module BABYLON {
  81656. /** @hidden */
  81657. export var postprocessVertexShader: {
  81658. name: string;
  81659. shader: string;
  81660. };
  81661. }
  81662. declare module BABYLON {
  81663. interface ThinEngine {
  81664. /**
  81665. * Creates a new render target texture
  81666. * @param size defines the size of the texture
  81667. * @param options defines the options used to create the texture
  81668. * @returns a new render target texture stored in an InternalTexture
  81669. */
  81670. createRenderTargetTexture(size: number | {
  81671. width: number;
  81672. height: number;
  81673. layers?: number;
  81674. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81675. /**
  81676. * Creates a depth stencil texture.
  81677. * This is only available in WebGL 2 or with the depth texture extension available.
  81678. * @param size The size of face edge in the texture.
  81679. * @param options The options defining the texture.
  81680. * @returns The texture
  81681. */
  81682. createDepthStencilTexture(size: number | {
  81683. width: number;
  81684. height: number;
  81685. layers?: number;
  81686. }, options: DepthTextureCreationOptions): InternalTexture;
  81687. /** @hidden */
  81688. _createDepthStencilTexture(size: number | {
  81689. width: number;
  81690. height: number;
  81691. layers?: number;
  81692. }, options: DepthTextureCreationOptions): InternalTexture;
  81693. }
  81694. }
  81695. declare module BABYLON {
  81696. /** Defines supported spaces */
  81697. export enum Space {
  81698. /** Local (object) space */
  81699. LOCAL = 0,
  81700. /** World space */
  81701. WORLD = 1,
  81702. /** Bone space */
  81703. BONE = 2
  81704. }
  81705. /** Defines the 3 main axes */
  81706. export class Axis {
  81707. /** X axis */
  81708. static X: Vector3;
  81709. /** Y axis */
  81710. static Y: Vector3;
  81711. /** Z axis */
  81712. static Z: Vector3;
  81713. }
  81714. }
  81715. declare module BABYLON {
  81716. /**
  81717. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81718. * This is the base of the follow, arc rotate cameras and Free camera
  81719. * @see http://doc.babylonjs.com/features/cameras
  81720. */
  81721. export class TargetCamera extends Camera {
  81722. private static _RigCamTransformMatrix;
  81723. private static _TargetTransformMatrix;
  81724. private static _TargetFocalPoint;
  81725. /**
  81726. * Define the current direction the camera is moving to
  81727. */
  81728. cameraDirection: Vector3;
  81729. /**
  81730. * Define the current rotation the camera is rotating to
  81731. */
  81732. cameraRotation: Vector2;
  81733. /**
  81734. * When set, the up vector of the camera will be updated by the rotation of the camera
  81735. */
  81736. updateUpVectorFromRotation: boolean;
  81737. private _tmpQuaternion;
  81738. /**
  81739. * Define the current rotation of the camera
  81740. */
  81741. rotation: Vector3;
  81742. /**
  81743. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81744. */
  81745. rotationQuaternion: Quaternion;
  81746. /**
  81747. * Define the current speed of the camera
  81748. */
  81749. speed: number;
  81750. /**
  81751. * Add constraint to the camera to prevent it to move freely in all directions and
  81752. * around all axis.
  81753. */
  81754. noRotationConstraint: boolean;
  81755. /**
  81756. * Define the current target of the camera as an object or a position.
  81757. */
  81758. lockedTarget: any;
  81759. /** @hidden */
  81760. _currentTarget: Vector3;
  81761. /** @hidden */
  81762. _initialFocalDistance: number;
  81763. /** @hidden */
  81764. _viewMatrix: Matrix;
  81765. /** @hidden */
  81766. _camMatrix: Matrix;
  81767. /** @hidden */
  81768. _cameraTransformMatrix: Matrix;
  81769. /** @hidden */
  81770. _cameraRotationMatrix: Matrix;
  81771. /** @hidden */
  81772. _referencePoint: Vector3;
  81773. /** @hidden */
  81774. _transformedReferencePoint: Vector3;
  81775. protected _globalCurrentTarget: Vector3;
  81776. protected _globalCurrentUpVector: Vector3;
  81777. /** @hidden */
  81778. _reset: () => void;
  81779. private _defaultUp;
  81780. /**
  81781. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81782. * This is the base of the follow, arc rotate cameras and Free camera
  81783. * @see http://doc.babylonjs.com/features/cameras
  81784. * @param name Defines the name of the camera in the scene
  81785. * @param position Defines the start position of the camera in the scene
  81786. * @param scene Defines the scene the camera belongs to
  81787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81788. */
  81789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81790. /**
  81791. * Gets the position in front of the camera at a given distance.
  81792. * @param distance The distance from the camera we want the position to be
  81793. * @returns the position
  81794. */
  81795. getFrontPosition(distance: number): Vector3;
  81796. /** @hidden */
  81797. _getLockedTargetPosition(): Nullable<Vector3>;
  81798. private _storedPosition;
  81799. private _storedRotation;
  81800. private _storedRotationQuaternion;
  81801. /**
  81802. * Store current camera state of the camera (fov, position, rotation, etc..)
  81803. * @returns the camera
  81804. */
  81805. storeState(): Camera;
  81806. /**
  81807. * Restored camera state. You must call storeState() first
  81808. * @returns whether it was successful or not
  81809. * @hidden
  81810. */
  81811. _restoreStateValues(): boolean;
  81812. /** @hidden */
  81813. _initCache(): void;
  81814. /** @hidden */
  81815. _updateCache(ignoreParentClass?: boolean): void;
  81816. /** @hidden */
  81817. _isSynchronizedViewMatrix(): boolean;
  81818. /** @hidden */
  81819. _computeLocalCameraSpeed(): number;
  81820. /**
  81821. * Defines the target the camera should look at.
  81822. * @param target Defines the new target as a Vector or a mesh
  81823. */
  81824. setTarget(target: Vector3): void;
  81825. /**
  81826. * Return the current target position of the camera. This value is expressed in local space.
  81827. * @returns the target position
  81828. */
  81829. getTarget(): Vector3;
  81830. /** @hidden */
  81831. _decideIfNeedsToMove(): boolean;
  81832. /** @hidden */
  81833. _updatePosition(): void;
  81834. /** @hidden */
  81835. _checkInputs(): void;
  81836. protected _updateCameraRotationMatrix(): void;
  81837. /**
  81838. * 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)
  81839. * @returns the current camera
  81840. */
  81841. private _rotateUpVectorWithCameraRotationMatrix;
  81842. private _cachedRotationZ;
  81843. private _cachedQuaternionRotationZ;
  81844. /** @hidden */
  81845. _getViewMatrix(): Matrix;
  81846. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81847. /**
  81848. * @hidden
  81849. */
  81850. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81851. /**
  81852. * @hidden
  81853. */
  81854. _updateRigCameras(): void;
  81855. private _getRigCamPositionAndTarget;
  81856. /**
  81857. * Gets the current object class name.
  81858. * @return the class name
  81859. */
  81860. getClassName(): string;
  81861. }
  81862. }
  81863. declare module BABYLON {
  81864. /**
  81865. * Gather the list of keyboard event types as constants.
  81866. */
  81867. export class KeyboardEventTypes {
  81868. /**
  81869. * The keydown event is fired when a key becomes active (pressed).
  81870. */
  81871. static readonly KEYDOWN: number;
  81872. /**
  81873. * The keyup event is fired when a key has been released.
  81874. */
  81875. static readonly KEYUP: number;
  81876. }
  81877. /**
  81878. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81879. */
  81880. export class KeyboardInfo {
  81881. /**
  81882. * Defines the type of event (KeyboardEventTypes)
  81883. */
  81884. type: number;
  81885. /**
  81886. * Defines the related dom event
  81887. */
  81888. event: KeyboardEvent;
  81889. /**
  81890. * Instantiates a new keyboard info.
  81891. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81892. * @param type Defines the type of event (KeyboardEventTypes)
  81893. * @param event Defines the related dom event
  81894. */
  81895. constructor(
  81896. /**
  81897. * Defines the type of event (KeyboardEventTypes)
  81898. */
  81899. type: number,
  81900. /**
  81901. * Defines the related dom event
  81902. */
  81903. event: KeyboardEvent);
  81904. }
  81905. /**
  81906. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81907. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81908. */
  81909. export class KeyboardInfoPre extends KeyboardInfo {
  81910. /**
  81911. * Defines the type of event (KeyboardEventTypes)
  81912. */
  81913. type: number;
  81914. /**
  81915. * Defines the related dom event
  81916. */
  81917. event: KeyboardEvent;
  81918. /**
  81919. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81920. */
  81921. skipOnPointerObservable: boolean;
  81922. /**
  81923. * Instantiates a new keyboard pre info.
  81924. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81925. * @param type Defines the type of event (KeyboardEventTypes)
  81926. * @param event Defines the related dom event
  81927. */
  81928. constructor(
  81929. /**
  81930. * Defines the type of event (KeyboardEventTypes)
  81931. */
  81932. type: number,
  81933. /**
  81934. * Defines the related dom event
  81935. */
  81936. event: KeyboardEvent);
  81937. }
  81938. }
  81939. declare module BABYLON {
  81940. /**
  81941. * Manage the keyboard inputs to control the movement of a free camera.
  81942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81943. */
  81944. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81945. /**
  81946. * Defines the camera the input is attached to.
  81947. */
  81948. camera: FreeCamera;
  81949. /**
  81950. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81951. */
  81952. keysUp: number[];
  81953. /**
  81954. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81955. */
  81956. keysDown: number[];
  81957. /**
  81958. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81959. */
  81960. keysLeft: number[];
  81961. /**
  81962. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81963. */
  81964. keysRight: number[];
  81965. private _keys;
  81966. private _onCanvasBlurObserver;
  81967. private _onKeyboardObserver;
  81968. private _engine;
  81969. private _scene;
  81970. /**
  81971. * Attach the input controls to a specific dom element to get the input from.
  81972. * @param element Defines the element the controls should be listened from
  81973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81974. */
  81975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81976. /**
  81977. * Detach the current controls from the specified dom element.
  81978. * @param element Defines the element to stop listening the inputs from
  81979. */
  81980. detachControl(element: Nullable<HTMLElement>): void;
  81981. /**
  81982. * Update the current camera state depending on the inputs that have been used this frame.
  81983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81984. */
  81985. checkInputs(): void;
  81986. /**
  81987. * Gets the class name of the current intput.
  81988. * @returns the class name
  81989. */
  81990. getClassName(): string;
  81991. /** @hidden */
  81992. _onLostFocus(): void;
  81993. /**
  81994. * Get the friendly name associated with the input class.
  81995. * @returns the input friendly name
  81996. */
  81997. getSimpleName(): string;
  81998. }
  81999. }
  82000. declare module BABYLON {
  82001. /**
  82002. * Interface describing all the common properties and methods a shadow light needs to implement.
  82003. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82004. * as well as binding the different shadow properties to the effects.
  82005. */
  82006. export interface IShadowLight extends Light {
  82007. /**
  82008. * The light id in the scene (used in scene.findLighById for instance)
  82009. */
  82010. id: string;
  82011. /**
  82012. * The position the shdow will be casted from.
  82013. */
  82014. position: Vector3;
  82015. /**
  82016. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82017. */
  82018. direction: Vector3;
  82019. /**
  82020. * The transformed position. Position of the light in world space taking parenting in account.
  82021. */
  82022. transformedPosition: Vector3;
  82023. /**
  82024. * The transformed direction. Direction of the light in world space taking parenting in account.
  82025. */
  82026. transformedDirection: Vector3;
  82027. /**
  82028. * The friendly name of the light in the scene.
  82029. */
  82030. name: string;
  82031. /**
  82032. * Defines the shadow projection clipping minimum z value.
  82033. */
  82034. shadowMinZ: number;
  82035. /**
  82036. * Defines the shadow projection clipping maximum z value.
  82037. */
  82038. shadowMaxZ: number;
  82039. /**
  82040. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82041. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82042. */
  82043. computeTransformedInformation(): boolean;
  82044. /**
  82045. * Gets the scene the light belongs to.
  82046. * @returns The scene
  82047. */
  82048. getScene(): Scene;
  82049. /**
  82050. * Callback defining a custom Projection Matrix Builder.
  82051. * This can be used to override the default projection matrix computation.
  82052. */
  82053. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82054. /**
  82055. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82056. * @param matrix The materix to updated with the projection information
  82057. * @param viewMatrix The transform matrix of the light
  82058. * @param renderList The list of mesh to render in the map
  82059. * @returns The current light
  82060. */
  82061. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82062. /**
  82063. * Gets the current depth scale used in ESM.
  82064. * @returns The scale
  82065. */
  82066. getDepthScale(): number;
  82067. /**
  82068. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82069. * @returns true if a cube texture needs to be use
  82070. */
  82071. needCube(): boolean;
  82072. /**
  82073. * Detects if the projection matrix requires to be recomputed this frame.
  82074. * @returns true if it requires to be recomputed otherwise, false.
  82075. */
  82076. needProjectionMatrixCompute(): boolean;
  82077. /**
  82078. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82079. */
  82080. forceProjectionMatrixCompute(): void;
  82081. /**
  82082. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82083. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82084. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82085. */
  82086. getShadowDirection(faceIndex?: number): Vector3;
  82087. /**
  82088. * Gets the minZ used for shadow according to both the scene and the light.
  82089. * @param activeCamera The camera we are returning the min for
  82090. * @returns the depth min z
  82091. */
  82092. getDepthMinZ(activeCamera: Camera): number;
  82093. /**
  82094. * Gets the maxZ used for shadow according to both the scene and the light.
  82095. * @param activeCamera The camera we are returning the max for
  82096. * @returns the depth max z
  82097. */
  82098. getDepthMaxZ(activeCamera: Camera): number;
  82099. }
  82100. /**
  82101. * Base implementation IShadowLight
  82102. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82103. */
  82104. export abstract class ShadowLight extends Light implements IShadowLight {
  82105. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82106. protected _position: Vector3;
  82107. protected _setPosition(value: Vector3): void;
  82108. /**
  82109. * Sets the position the shadow will be casted from. Also use as the light position for both
  82110. * point and spot lights.
  82111. */
  82112. get position(): Vector3;
  82113. /**
  82114. * Sets the position the shadow will be casted from. Also use as the light position for both
  82115. * point and spot lights.
  82116. */
  82117. set position(value: Vector3);
  82118. protected _direction: Vector3;
  82119. protected _setDirection(value: Vector3): void;
  82120. /**
  82121. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82122. * Also use as the light direction on spot and directional lights.
  82123. */
  82124. get direction(): Vector3;
  82125. /**
  82126. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82127. * Also use as the light direction on spot and directional lights.
  82128. */
  82129. set direction(value: Vector3);
  82130. protected _shadowMinZ: number;
  82131. /**
  82132. * Gets the shadow projection clipping minimum z value.
  82133. */
  82134. get shadowMinZ(): number;
  82135. /**
  82136. * Sets the shadow projection clipping minimum z value.
  82137. */
  82138. set shadowMinZ(value: number);
  82139. protected _shadowMaxZ: number;
  82140. /**
  82141. * Sets the shadow projection clipping maximum z value.
  82142. */
  82143. get shadowMaxZ(): number;
  82144. /**
  82145. * Gets the shadow projection clipping maximum z value.
  82146. */
  82147. set shadowMaxZ(value: number);
  82148. /**
  82149. * Callback defining a custom Projection Matrix Builder.
  82150. * This can be used to override the default projection matrix computation.
  82151. */
  82152. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82153. /**
  82154. * The transformed position. Position of the light in world space taking parenting in account.
  82155. */
  82156. transformedPosition: Vector3;
  82157. /**
  82158. * The transformed direction. Direction of the light in world space taking parenting in account.
  82159. */
  82160. transformedDirection: Vector3;
  82161. private _needProjectionMatrixCompute;
  82162. /**
  82163. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82164. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82165. */
  82166. computeTransformedInformation(): boolean;
  82167. /**
  82168. * Return the depth scale used for the shadow map.
  82169. * @returns the depth scale.
  82170. */
  82171. getDepthScale(): number;
  82172. /**
  82173. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82174. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82175. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82176. */
  82177. getShadowDirection(faceIndex?: number): Vector3;
  82178. /**
  82179. * Returns the ShadowLight absolute position in the World.
  82180. * @returns the position vector in world space
  82181. */
  82182. getAbsolutePosition(): Vector3;
  82183. /**
  82184. * Sets the ShadowLight direction toward the passed target.
  82185. * @param target The point to target in local space
  82186. * @returns the updated ShadowLight direction
  82187. */
  82188. setDirectionToTarget(target: Vector3): Vector3;
  82189. /**
  82190. * Returns the light rotation in euler definition.
  82191. * @returns the x y z rotation in local space.
  82192. */
  82193. getRotation(): Vector3;
  82194. /**
  82195. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82196. * @returns true if a cube texture needs to be use
  82197. */
  82198. needCube(): boolean;
  82199. /**
  82200. * Detects if the projection matrix requires to be recomputed this frame.
  82201. * @returns true if it requires to be recomputed otherwise, false.
  82202. */
  82203. needProjectionMatrixCompute(): boolean;
  82204. /**
  82205. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82206. */
  82207. forceProjectionMatrixCompute(): void;
  82208. /** @hidden */
  82209. _initCache(): void;
  82210. /** @hidden */
  82211. _isSynchronized(): boolean;
  82212. /**
  82213. * Computes the world matrix of the node
  82214. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82215. * @returns the world matrix
  82216. */
  82217. computeWorldMatrix(force?: boolean): Matrix;
  82218. /**
  82219. * Gets the minZ used for shadow according to both the scene and the light.
  82220. * @param activeCamera The camera we are returning the min for
  82221. * @returns the depth min z
  82222. */
  82223. getDepthMinZ(activeCamera: Camera): number;
  82224. /**
  82225. * Gets the maxZ used for shadow according to both the scene and the light.
  82226. * @param activeCamera The camera we are returning the max for
  82227. * @returns the depth max z
  82228. */
  82229. getDepthMaxZ(activeCamera: Camera): number;
  82230. /**
  82231. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82232. * @param matrix The materix to updated with the projection information
  82233. * @param viewMatrix The transform matrix of the light
  82234. * @param renderList The list of mesh to render in the map
  82235. * @returns The current light
  82236. */
  82237. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82238. }
  82239. }
  82240. declare module BABYLON {
  82241. /**
  82242. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82243. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82244. */
  82245. export class EffectFallbacks implements IEffectFallbacks {
  82246. private _defines;
  82247. private _currentRank;
  82248. private _maxRank;
  82249. private _mesh;
  82250. /**
  82251. * Removes the fallback from the bound mesh.
  82252. */
  82253. unBindMesh(): void;
  82254. /**
  82255. * Adds a fallback on the specified property.
  82256. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82257. * @param define The name of the define in the shader
  82258. */
  82259. addFallback(rank: number, define: string): void;
  82260. /**
  82261. * Sets the mesh to use CPU skinning when needing to fallback.
  82262. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82263. * @param mesh The mesh to use the fallbacks.
  82264. */
  82265. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82266. /**
  82267. * Checks to see if more fallbacks are still availible.
  82268. */
  82269. get hasMoreFallbacks(): boolean;
  82270. /**
  82271. * Removes the defines that should be removed when falling back.
  82272. * @param currentDefines defines the current define statements for the shader.
  82273. * @param effect defines the current effect we try to compile
  82274. * @returns The resulting defines with defines of the current rank removed.
  82275. */
  82276. reduce(currentDefines: string, effect: Effect): string;
  82277. }
  82278. }
  82279. declare module BABYLON {
  82280. /**
  82281. * "Static Class" containing the most commonly used helper while dealing with material for
  82282. * rendering purpose.
  82283. *
  82284. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82285. *
  82286. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82287. */
  82288. export class MaterialHelper {
  82289. /**
  82290. * Bind the current view position to an effect.
  82291. * @param effect The effect to be bound
  82292. * @param scene The scene the eyes position is used from
  82293. */
  82294. static BindEyePosition(effect: Effect, scene: Scene): void;
  82295. /**
  82296. * Helps preparing the defines values about the UVs in used in the effect.
  82297. * UVs are shared as much as we can accross channels in the shaders.
  82298. * @param texture The texture we are preparing the UVs for
  82299. * @param defines The defines to update
  82300. * @param key The channel key "diffuse", "specular"... used in the shader
  82301. */
  82302. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82303. /**
  82304. * Binds a texture matrix value to its corrsponding uniform
  82305. * @param texture The texture to bind the matrix for
  82306. * @param uniformBuffer The uniform buffer receivin the data
  82307. * @param key The channel key "diffuse", "specular"... used in the shader
  82308. */
  82309. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82310. /**
  82311. * Gets the current status of the fog (should it be enabled?)
  82312. * @param mesh defines the mesh to evaluate for fog support
  82313. * @param scene defines the hosting scene
  82314. * @returns true if fog must be enabled
  82315. */
  82316. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82317. /**
  82318. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82319. * @param mesh defines the current mesh
  82320. * @param scene defines the current scene
  82321. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82322. * @param pointsCloud defines if point cloud rendering has to be turned on
  82323. * @param fogEnabled defines if fog has to be turned on
  82324. * @param alphaTest defines if alpha testing has to be turned on
  82325. * @param defines defines the current list of defines
  82326. */
  82327. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82328. /**
  82329. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82330. * @param scene defines the current scene
  82331. * @param engine defines the current engine
  82332. * @param defines specifies the list of active defines
  82333. * @param useInstances defines if instances have to be turned on
  82334. * @param useClipPlane defines if clip plane have to be turned on
  82335. */
  82336. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82337. /**
  82338. * Prepares the defines for bones
  82339. * @param mesh The mesh containing the geometry data we will draw
  82340. * @param defines The defines to update
  82341. */
  82342. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82343. /**
  82344. * Prepares the defines for morph targets
  82345. * @param mesh The mesh containing the geometry data we will draw
  82346. * @param defines The defines to update
  82347. */
  82348. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82349. /**
  82350. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82351. * @param mesh The mesh containing the geometry data we will draw
  82352. * @param defines The defines to update
  82353. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82354. * @param useBones Precise whether bones should be used or not (override mesh info)
  82355. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82356. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82357. * @returns false if defines are considered not dirty and have not been checked
  82358. */
  82359. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82360. /**
  82361. * Prepares the defines related to multiview
  82362. * @param scene The scene we are intending to draw
  82363. * @param defines The defines to update
  82364. */
  82365. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82366. /**
  82367. * Prepares the defines related to the light information passed in parameter
  82368. * @param scene The scene we are intending to draw
  82369. * @param mesh The mesh the effect is compiling for
  82370. * @param light The light the effect is compiling for
  82371. * @param lightIndex The index of the light
  82372. * @param defines The defines to update
  82373. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82374. * @param state Defines the current state regarding what is needed (normals, etc...)
  82375. */
  82376. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82377. needNormals: boolean;
  82378. needRebuild: boolean;
  82379. shadowEnabled: boolean;
  82380. specularEnabled: boolean;
  82381. lightmapMode: boolean;
  82382. }): void;
  82383. /**
  82384. * Prepares the defines related to the light information passed in parameter
  82385. * @param scene The scene we are intending to draw
  82386. * @param mesh The mesh the effect is compiling for
  82387. * @param defines The defines to update
  82388. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82389. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82390. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82391. * @returns true if normals will be required for the rest of the effect
  82392. */
  82393. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82394. /**
  82395. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82396. * @param lightIndex defines the light index
  82397. * @param uniformsList The uniform list
  82398. * @param samplersList The sampler list
  82399. * @param projectedLightTexture defines if projected texture must be used
  82400. * @param uniformBuffersList defines an optional list of uniform buffers
  82401. */
  82402. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82403. /**
  82404. * Prepares the uniforms and samplers list to be used in the effect
  82405. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82406. * @param samplersList The sampler list
  82407. * @param defines The defines helping in the list generation
  82408. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82409. */
  82410. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82411. /**
  82412. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82413. * @param defines The defines to update while falling back
  82414. * @param fallbacks The authorized effect fallbacks
  82415. * @param maxSimultaneousLights The maximum number of lights allowed
  82416. * @param rank the current rank of the Effect
  82417. * @returns The newly affected rank
  82418. */
  82419. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82420. private static _TmpMorphInfluencers;
  82421. /**
  82422. * Prepares the list of attributes required for morph targets according to the effect defines.
  82423. * @param attribs The current list of supported attribs
  82424. * @param mesh The mesh to prepare the morph targets attributes for
  82425. * @param influencers The number of influencers
  82426. */
  82427. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82428. /**
  82429. * Prepares the list of attributes required for morph targets according to the effect defines.
  82430. * @param attribs The current list of supported attribs
  82431. * @param mesh The mesh to prepare the morph targets attributes for
  82432. * @param defines The current Defines of the effect
  82433. */
  82434. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82435. /**
  82436. * Prepares the list of attributes required for bones according to the effect defines.
  82437. * @param attribs The current list of supported attribs
  82438. * @param mesh The mesh to prepare the bones attributes for
  82439. * @param defines The current Defines of the effect
  82440. * @param fallbacks The current efffect fallback strategy
  82441. */
  82442. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82443. /**
  82444. * Check and prepare the list of attributes required for instances according to the effect defines.
  82445. * @param attribs The current list of supported attribs
  82446. * @param defines The current MaterialDefines of the effect
  82447. */
  82448. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82449. /**
  82450. * Add the list of attributes required for instances to the attribs array.
  82451. * @param attribs The current list of supported attribs
  82452. */
  82453. static PushAttributesForInstances(attribs: string[]): void;
  82454. /**
  82455. * Binds the light information to the effect.
  82456. * @param light The light containing the generator
  82457. * @param effect The effect we are binding the data to
  82458. * @param lightIndex The light index in the effect used to render
  82459. */
  82460. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82461. /**
  82462. * Binds the lights information from the scene to the effect for the given mesh.
  82463. * @param light Light to bind
  82464. * @param lightIndex Light index
  82465. * @param scene The scene where the light belongs to
  82466. * @param effect The effect we are binding the data to
  82467. * @param useSpecular Defines if specular is supported
  82468. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82469. */
  82470. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82471. /**
  82472. * Binds the lights information from the scene to the effect for the given mesh.
  82473. * @param scene The scene the lights belongs to
  82474. * @param mesh The mesh we are binding the information to render
  82475. * @param effect The effect we are binding the data to
  82476. * @param defines The generated defines for the effect
  82477. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82478. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82479. */
  82480. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82481. private static _tempFogColor;
  82482. /**
  82483. * Binds the fog information from the scene to the effect for the given mesh.
  82484. * @param scene The scene the lights belongs to
  82485. * @param mesh The mesh we are binding the information to render
  82486. * @param effect The effect we are binding the data to
  82487. * @param linearSpace Defines if the fog effect is applied in linear space
  82488. */
  82489. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82490. /**
  82491. * Binds the bones information from the mesh to the effect.
  82492. * @param mesh The mesh we are binding the information to render
  82493. * @param effect The effect we are binding the data to
  82494. */
  82495. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82496. /**
  82497. * Binds the morph targets information from the mesh to the effect.
  82498. * @param abstractMesh The mesh we are binding the information to render
  82499. * @param effect The effect we are binding the data to
  82500. */
  82501. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82502. /**
  82503. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82504. * @param defines The generated defines used in the effect
  82505. * @param effect The effect we are binding the data to
  82506. * @param scene The scene we are willing to render with logarithmic scale for
  82507. */
  82508. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82509. /**
  82510. * Binds the clip plane information from the scene to the effect.
  82511. * @param scene The scene the clip plane information are extracted from
  82512. * @param effect The effect we are binding the data to
  82513. */
  82514. static BindClipPlane(effect: Effect, scene: Scene): void;
  82515. }
  82516. }
  82517. declare module BABYLON {
  82518. /** @hidden */
  82519. export var packingFunctions: {
  82520. name: string;
  82521. shader: string;
  82522. };
  82523. }
  82524. declare module BABYLON {
  82525. /** @hidden */
  82526. export var clipPlaneFragmentDeclaration: {
  82527. name: string;
  82528. shader: string;
  82529. };
  82530. }
  82531. declare module BABYLON {
  82532. /** @hidden */
  82533. export var clipPlaneFragment: {
  82534. name: string;
  82535. shader: string;
  82536. };
  82537. }
  82538. declare module BABYLON {
  82539. /** @hidden */
  82540. export var shadowMapPixelShader: {
  82541. name: string;
  82542. shader: string;
  82543. };
  82544. }
  82545. declare module BABYLON {
  82546. /** @hidden */
  82547. export var bonesDeclaration: {
  82548. name: string;
  82549. shader: string;
  82550. };
  82551. }
  82552. declare module BABYLON {
  82553. /** @hidden */
  82554. export var morphTargetsVertexGlobalDeclaration: {
  82555. name: string;
  82556. shader: string;
  82557. };
  82558. }
  82559. declare module BABYLON {
  82560. /** @hidden */
  82561. export var morphTargetsVertexDeclaration: {
  82562. name: string;
  82563. shader: string;
  82564. };
  82565. }
  82566. declare module BABYLON {
  82567. /** @hidden */
  82568. export var instancesDeclaration: {
  82569. name: string;
  82570. shader: string;
  82571. };
  82572. }
  82573. declare module BABYLON {
  82574. /** @hidden */
  82575. export var helperFunctions: {
  82576. name: string;
  82577. shader: string;
  82578. };
  82579. }
  82580. declare module BABYLON {
  82581. /** @hidden */
  82582. export var clipPlaneVertexDeclaration: {
  82583. name: string;
  82584. shader: string;
  82585. };
  82586. }
  82587. declare module BABYLON {
  82588. /** @hidden */
  82589. export var morphTargetsVertex: {
  82590. name: string;
  82591. shader: string;
  82592. };
  82593. }
  82594. declare module BABYLON {
  82595. /** @hidden */
  82596. export var instancesVertex: {
  82597. name: string;
  82598. shader: string;
  82599. };
  82600. }
  82601. declare module BABYLON {
  82602. /** @hidden */
  82603. export var bonesVertex: {
  82604. name: string;
  82605. shader: string;
  82606. };
  82607. }
  82608. declare module BABYLON {
  82609. /** @hidden */
  82610. export var clipPlaneVertex: {
  82611. name: string;
  82612. shader: string;
  82613. };
  82614. }
  82615. declare module BABYLON {
  82616. /** @hidden */
  82617. export var shadowMapVertexShader: {
  82618. name: string;
  82619. shader: string;
  82620. };
  82621. }
  82622. declare module BABYLON {
  82623. /** @hidden */
  82624. export var depthBoxBlurPixelShader: {
  82625. name: string;
  82626. shader: string;
  82627. };
  82628. }
  82629. declare module BABYLON {
  82630. /**
  82631. * Class representing a ray with position and direction
  82632. */
  82633. export class Ray {
  82634. /** origin point */
  82635. origin: Vector3;
  82636. /** direction */
  82637. direction: Vector3;
  82638. /** length of the ray */
  82639. length: number;
  82640. private static readonly TmpVector3;
  82641. private _tmpRay;
  82642. /**
  82643. * Creates a new ray
  82644. * @param origin origin point
  82645. * @param direction direction
  82646. * @param length length of the ray
  82647. */
  82648. constructor(
  82649. /** origin point */
  82650. origin: Vector3,
  82651. /** direction */
  82652. direction: Vector3,
  82653. /** length of the ray */
  82654. length?: number);
  82655. /**
  82656. * Checks if the ray intersects a box
  82657. * @param minimum bound of the box
  82658. * @param maximum bound of the box
  82659. * @param intersectionTreshold extra extend to be added to the box in all direction
  82660. * @returns if the box was hit
  82661. */
  82662. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82663. /**
  82664. * Checks if the ray intersects a box
  82665. * @param box the bounding box to check
  82666. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82667. * @returns if the box was hit
  82668. */
  82669. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82670. /**
  82671. * If the ray hits a sphere
  82672. * @param sphere the bounding sphere to check
  82673. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82674. * @returns true if it hits the sphere
  82675. */
  82676. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82677. /**
  82678. * If the ray hits a triange
  82679. * @param vertex0 triangle vertex
  82680. * @param vertex1 triangle vertex
  82681. * @param vertex2 triangle vertex
  82682. * @returns intersection information if hit
  82683. */
  82684. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82685. /**
  82686. * Checks if ray intersects a plane
  82687. * @param plane the plane to check
  82688. * @returns the distance away it was hit
  82689. */
  82690. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82691. /**
  82692. * Calculate the intercept of a ray on a given axis
  82693. * @param axis to check 'x' | 'y' | 'z'
  82694. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82695. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82696. */
  82697. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82698. /**
  82699. * Checks if ray intersects a mesh
  82700. * @param mesh the mesh to check
  82701. * @param fastCheck if only the bounding box should checked
  82702. * @returns picking info of the intersecton
  82703. */
  82704. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82705. /**
  82706. * Checks if ray intersects a mesh
  82707. * @param meshes the meshes to check
  82708. * @param fastCheck if only the bounding box should checked
  82709. * @param results array to store result in
  82710. * @returns Array of picking infos
  82711. */
  82712. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82713. private _comparePickingInfo;
  82714. private static smallnum;
  82715. private static rayl;
  82716. /**
  82717. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82718. * @param sega the first point of the segment to test the intersection against
  82719. * @param segb the second point of the segment to test the intersection against
  82720. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82721. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82722. */
  82723. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82724. /**
  82725. * Update the ray from viewport position
  82726. * @param x position
  82727. * @param y y position
  82728. * @param viewportWidth viewport width
  82729. * @param viewportHeight viewport height
  82730. * @param world world matrix
  82731. * @param view view matrix
  82732. * @param projection projection matrix
  82733. * @returns this ray updated
  82734. */
  82735. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82736. /**
  82737. * Creates a ray with origin and direction of 0,0,0
  82738. * @returns the new ray
  82739. */
  82740. static Zero(): Ray;
  82741. /**
  82742. * Creates a new ray from screen space and viewport
  82743. * @param x position
  82744. * @param y y position
  82745. * @param viewportWidth viewport width
  82746. * @param viewportHeight viewport height
  82747. * @param world world matrix
  82748. * @param view view matrix
  82749. * @param projection projection matrix
  82750. * @returns new ray
  82751. */
  82752. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82753. /**
  82754. * 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
  82755. * transformed to the given world matrix.
  82756. * @param origin The origin point
  82757. * @param end The end point
  82758. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82759. * @returns the new ray
  82760. */
  82761. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82762. /**
  82763. * Transforms a ray by a matrix
  82764. * @param ray ray to transform
  82765. * @param matrix matrix to apply
  82766. * @returns the resulting new ray
  82767. */
  82768. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82769. /**
  82770. * Transforms a ray by a matrix
  82771. * @param ray ray to transform
  82772. * @param matrix matrix to apply
  82773. * @param result ray to store result in
  82774. */
  82775. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82776. /**
  82777. * Unproject a ray from screen space to object space
  82778. * @param sourceX defines the screen space x coordinate to use
  82779. * @param sourceY defines the screen space y coordinate to use
  82780. * @param viewportWidth defines the current width of the viewport
  82781. * @param viewportHeight defines the current height of the viewport
  82782. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82783. * @param view defines the view matrix to use
  82784. * @param projection defines the projection matrix to use
  82785. */
  82786. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82787. }
  82788. /**
  82789. * Type used to define predicate used to select faces when a mesh intersection is detected
  82790. */
  82791. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82792. interface Scene {
  82793. /** @hidden */
  82794. _tempPickingRay: Nullable<Ray>;
  82795. /** @hidden */
  82796. _cachedRayForTransform: Ray;
  82797. /** @hidden */
  82798. _pickWithRayInverseMatrix: Matrix;
  82799. /** @hidden */
  82800. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82801. /** @hidden */
  82802. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82803. }
  82804. }
  82805. declare module BABYLON {
  82806. /**
  82807. * Groups all the scene component constants in one place to ease maintenance.
  82808. * @hidden
  82809. */
  82810. export class SceneComponentConstants {
  82811. static readonly NAME_EFFECTLAYER: string;
  82812. static readonly NAME_LAYER: string;
  82813. static readonly NAME_LENSFLARESYSTEM: string;
  82814. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82815. static readonly NAME_PARTICLESYSTEM: string;
  82816. static readonly NAME_GAMEPAD: string;
  82817. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82818. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82819. static readonly NAME_DEPTHRENDERER: string;
  82820. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82821. static readonly NAME_SPRITE: string;
  82822. static readonly NAME_OUTLINERENDERER: string;
  82823. static readonly NAME_PROCEDURALTEXTURE: string;
  82824. static readonly NAME_SHADOWGENERATOR: string;
  82825. static readonly NAME_OCTREE: string;
  82826. static readonly NAME_PHYSICSENGINE: string;
  82827. static readonly NAME_AUDIO: string;
  82828. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82829. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82830. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82831. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82832. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82833. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82834. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82848. static readonly STEP_AFTERRENDER_AUDIO: number;
  82849. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82850. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82851. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82852. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82853. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82854. static readonly STEP_POINTERMOVE_SPRITE: number;
  82855. static readonly STEP_POINTERDOWN_SPRITE: number;
  82856. static readonly STEP_POINTERUP_SPRITE: number;
  82857. }
  82858. /**
  82859. * This represents a scene component.
  82860. *
  82861. * This is used to decouple the dependency the scene is having on the different workloads like
  82862. * layers, post processes...
  82863. */
  82864. export interface ISceneComponent {
  82865. /**
  82866. * The name of the component. Each component must have a unique name.
  82867. */
  82868. name: string;
  82869. /**
  82870. * The scene the component belongs to.
  82871. */
  82872. scene: Scene;
  82873. /**
  82874. * Register the component to one instance of a scene.
  82875. */
  82876. register(): void;
  82877. /**
  82878. * Rebuilds the elements related to this component in case of
  82879. * context lost for instance.
  82880. */
  82881. rebuild(): void;
  82882. /**
  82883. * Disposes the component and the associated ressources.
  82884. */
  82885. dispose(): void;
  82886. }
  82887. /**
  82888. * This represents a SERIALIZABLE scene component.
  82889. *
  82890. * This extends Scene Component to add Serialization methods on top.
  82891. */
  82892. export interface ISceneSerializableComponent extends ISceneComponent {
  82893. /**
  82894. * Adds all the elements from the container to the scene
  82895. * @param container the container holding the elements
  82896. */
  82897. addFromContainer(container: AbstractScene): void;
  82898. /**
  82899. * Removes all the elements in the container from the scene
  82900. * @param container contains the elements to remove
  82901. * @param dispose if the removed element should be disposed (default: false)
  82902. */
  82903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82904. /**
  82905. * Serializes the component data to the specified json object
  82906. * @param serializationObject The object to serialize to
  82907. */
  82908. serialize(serializationObject: any): void;
  82909. }
  82910. /**
  82911. * Strong typing of a Mesh related stage step action
  82912. */
  82913. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82914. /**
  82915. * Strong typing of a Evaluate Sub Mesh related stage step action
  82916. */
  82917. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82918. /**
  82919. * Strong typing of a Active Mesh related stage step action
  82920. */
  82921. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82922. /**
  82923. * Strong typing of a Camera related stage step action
  82924. */
  82925. export type CameraStageAction = (camera: Camera) => void;
  82926. /**
  82927. * Strong typing of a Camera Frame buffer related stage step action
  82928. */
  82929. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82930. /**
  82931. * Strong typing of a Render Target related stage step action
  82932. */
  82933. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82934. /**
  82935. * Strong typing of a RenderingGroup related stage step action
  82936. */
  82937. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82938. /**
  82939. * Strong typing of a Mesh Render related stage step action
  82940. */
  82941. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82942. /**
  82943. * Strong typing of a simple stage step action
  82944. */
  82945. export type SimpleStageAction = () => void;
  82946. /**
  82947. * Strong typing of a render target action.
  82948. */
  82949. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82950. /**
  82951. * Strong typing of a pointer move action.
  82952. */
  82953. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82954. /**
  82955. * Strong typing of a pointer up/down action.
  82956. */
  82957. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82958. /**
  82959. * Representation of a stage in the scene (Basically a list of ordered steps)
  82960. * @hidden
  82961. */
  82962. export class Stage<T extends Function> extends Array<{
  82963. index: number;
  82964. component: ISceneComponent;
  82965. action: T;
  82966. }> {
  82967. /**
  82968. * Hide ctor from the rest of the world.
  82969. * @param items The items to add.
  82970. */
  82971. private constructor();
  82972. /**
  82973. * Creates a new Stage.
  82974. * @returns A new instance of a Stage
  82975. */
  82976. static Create<T extends Function>(): Stage<T>;
  82977. /**
  82978. * Registers a step in an ordered way in the targeted stage.
  82979. * @param index Defines the position to register the step in
  82980. * @param component Defines the component attached to the step
  82981. * @param action Defines the action to launch during the step
  82982. */
  82983. registerStep(index: number, component: ISceneComponent, action: T): void;
  82984. /**
  82985. * Clears all the steps from the stage.
  82986. */
  82987. clear(): void;
  82988. }
  82989. }
  82990. declare module BABYLON {
  82991. interface Scene {
  82992. /** @hidden */
  82993. _pointerOverSprite: Nullable<Sprite>;
  82994. /** @hidden */
  82995. _pickedDownSprite: Nullable<Sprite>;
  82996. /** @hidden */
  82997. _tempSpritePickingRay: Nullable<Ray>;
  82998. /**
  82999. * All of the sprite managers added to this scene
  83000. * @see http://doc.babylonjs.com/babylon101/sprites
  83001. */
  83002. spriteManagers: Array<ISpriteManager>;
  83003. /**
  83004. * An event triggered when sprites rendering is about to start
  83005. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83006. */
  83007. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83008. /**
  83009. * An event triggered when sprites rendering is done
  83010. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83011. */
  83012. onAfterSpritesRenderingObservable: Observable<Scene>;
  83013. /** @hidden */
  83014. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83015. /** Launch a ray to try to pick a sprite in the scene
  83016. * @param x position on screen
  83017. * @param y position on screen
  83018. * @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
  83019. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83020. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83021. * @returns a PickingInfo
  83022. */
  83023. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83024. /** Use the given ray to pick a sprite in the scene
  83025. * @param ray The ray (in world space) to use to pick meshes
  83026. * @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
  83027. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83028. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83029. * @returns a PickingInfo
  83030. */
  83031. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83032. /** @hidden */
  83033. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83034. /** Launch a ray to try to pick sprites in the scene
  83035. * @param x position on screen
  83036. * @param y position on screen
  83037. * @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
  83038. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83039. * @returns a PickingInfo array
  83040. */
  83041. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83042. /** Use the given ray to pick sprites in the scene
  83043. * @param ray The ray (in world space) to use to pick meshes
  83044. * @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
  83045. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83046. * @returns a PickingInfo array
  83047. */
  83048. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83049. /**
  83050. * Force the sprite under the pointer
  83051. * @param sprite defines the sprite to use
  83052. */
  83053. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83054. /**
  83055. * Gets the sprite under the pointer
  83056. * @returns a Sprite or null if no sprite is under the pointer
  83057. */
  83058. getPointerOverSprite(): Nullable<Sprite>;
  83059. }
  83060. /**
  83061. * Defines the sprite scene component responsible to manage sprites
  83062. * in a given scene.
  83063. */
  83064. export class SpriteSceneComponent implements ISceneComponent {
  83065. /**
  83066. * The component name helpfull to identify the component in the list of scene components.
  83067. */
  83068. readonly name: string;
  83069. /**
  83070. * The scene the component belongs to.
  83071. */
  83072. scene: Scene;
  83073. /** @hidden */
  83074. private _spritePredicate;
  83075. /**
  83076. * Creates a new instance of the component for the given scene
  83077. * @param scene Defines the scene to register the component in
  83078. */
  83079. constructor(scene: Scene);
  83080. /**
  83081. * Registers the component in a given scene
  83082. */
  83083. register(): void;
  83084. /**
  83085. * Rebuilds the elements related to this component in case of
  83086. * context lost for instance.
  83087. */
  83088. rebuild(): void;
  83089. /**
  83090. * Disposes the component and the associated ressources.
  83091. */
  83092. dispose(): void;
  83093. private _pickSpriteButKeepRay;
  83094. private _pointerMove;
  83095. private _pointerDown;
  83096. private _pointerUp;
  83097. }
  83098. }
  83099. declare module BABYLON {
  83100. /** @hidden */
  83101. export var fogFragmentDeclaration: {
  83102. name: string;
  83103. shader: string;
  83104. };
  83105. }
  83106. declare module BABYLON {
  83107. /** @hidden */
  83108. export var fogFragment: {
  83109. name: string;
  83110. shader: string;
  83111. };
  83112. }
  83113. declare module BABYLON {
  83114. /** @hidden */
  83115. export var spritesPixelShader: {
  83116. name: string;
  83117. shader: string;
  83118. };
  83119. }
  83120. declare module BABYLON {
  83121. /** @hidden */
  83122. export var fogVertexDeclaration: {
  83123. name: string;
  83124. shader: string;
  83125. };
  83126. }
  83127. declare module BABYLON {
  83128. /** @hidden */
  83129. export var spritesVertexShader: {
  83130. name: string;
  83131. shader: string;
  83132. };
  83133. }
  83134. declare module BABYLON {
  83135. /**
  83136. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83137. */
  83138. export interface ISpriteManager extends IDisposable {
  83139. /**
  83140. * Restricts the camera to viewing objects with the same layerMask.
  83141. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83142. */
  83143. layerMask: number;
  83144. /**
  83145. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83146. */
  83147. isPickable: boolean;
  83148. /**
  83149. * Specifies the rendering group id for this mesh (0 by default)
  83150. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83151. */
  83152. renderingGroupId: number;
  83153. /**
  83154. * Defines the list of sprites managed by the manager.
  83155. */
  83156. sprites: Array<Sprite>;
  83157. /**
  83158. * Tests the intersection of a sprite with a specific ray.
  83159. * @param ray The ray we are sending to test the collision
  83160. * @param camera The camera space we are sending rays in
  83161. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83162. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83163. * @returns picking info or null.
  83164. */
  83165. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83166. /**
  83167. * Intersects the sprites with a ray
  83168. * @param ray defines the ray to intersect with
  83169. * @param camera defines the current active camera
  83170. * @param predicate defines a predicate used to select candidate sprites
  83171. * @returns null if no hit or a PickingInfo array
  83172. */
  83173. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83174. /**
  83175. * Renders the list of sprites on screen.
  83176. */
  83177. render(): void;
  83178. }
  83179. /**
  83180. * Class used to manage multiple sprites on the same spritesheet
  83181. * @see http://doc.babylonjs.com/babylon101/sprites
  83182. */
  83183. export class SpriteManager implements ISpriteManager {
  83184. /** defines the manager's name */
  83185. name: string;
  83186. /** Gets the list of sprites */
  83187. sprites: Sprite[];
  83188. /** Gets or sets the rendering group id (0 by default) */
  83189. renderingGroupId: number;
  83190. /** Gets or sets camera layer mask */
  83191. layerMask: number;
  83192. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83193. fogEnabled: boolean;
  83194. /** Gets or sets a boolean indicating if the sprites are pickable */
  83195. isPickable: boolean;
  83196. /** Defines the default width of a cell in the spritesheet */
  83197. cellWidth: number;
  83198. /** Defines the default height of a cell in the spritesheet */
  83199. cellHeight: number;
  83200. /** Associative array from JSON sprite data file */
  83201. private _cellData;
  83202. /** Array of sprite names from JSON sprite data file */
  83203. private _spriteMap;
  83204. /** True when packed cell data from JSON file is ready*/
  83205. private _packedAndReady;
  83206. /**
  83207. * An event triggered when the manager is disposed.
  83208. */
  83209. onDisposeObservable: Observable<SpriteManager>;
  83210. private _onDisposeObserver;
  83211. /**
  83212. * Callback called when the manager is disposed
  83213. */
  83214. set onDispose(callback: () => void);
  83215. private _capacity;
  83216. private _fromPacked;
  83217. private _spriteTexture;
  83218. private _epsilon;
  83219. private _scene;
  83220. private _vertexData;
  83221. private _buffer;
  83222. private _vertexBuffers;
  83223. private _indexBuffer;
  83224. private _effectBase;
  83225. private _effectFog;
  83226. /**
  83227. * Gets or sets the spritesheet texture
  83228. */
  83229. get texture(): Texture;
  83230. set texture(value: Texture);
  83231. private _blendMode;
  83232. /**
  83233. * Blend mode use to render the particle, it can be any of
  83234. * the static Constants.ALPHA_x properties provided in this class.
  83235. * Default value is Constants.ALPHA_COMBINE
  83236. */
  83237. get blendMode(): number;
  83238. set blendMode(blendMode: number);
  83239. /** Disables writing to the depth buffer when rendering the sprites.
  83240. * It can be handy to disable depth writing when using textures without alpha channel
  83241. * and setting some specific blend modes.
  83242. */
  83243. disableDepthWrite: boolean;
  83244. /**
  83245. * Creates a new sprite manager
  83246. * @param name defines the manager's name
  83247. * @param imgUrl defines the sprite sheet url
  83248. * @param capacity defines the maximum allowed number of sprites
  83249. * @param cellSize defines the size of a sprite cell
  83250. * @param scene defines the hosting scene
  83251. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83252. * @param samplingMode defines the smapling mode to use with spritesheet
  83253. * @param fromPacked set to false; do not alter
  83254. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83255. */
  83256. constructor(
  83257. /** defines the manager's name */
  83258. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83259. private _makePacked;
  83260. private _appendSpriteVertex;
  83261. /**
  83262. * Intersects the sprites with a ray
  83263. * @param ray defines the ray to intersect with
  83264. * @param camera defines the current active camera
  83265. * @param predicate defines a predicate used to select candidate sprites
  83266. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83267. * @returns null if no hit or a PickingInfo
  83268. */
  83269. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83270. /**
  83271. * Intersects the sprites with a ray
  83272. * @param ray defines the ray to intersect with
  83273. * @param camera defines the current active camera
  83274. * @param predicate defines a predicate used to select candidate sprites
  83275. * @returns null if no hit or a PickingInfo array
  83276. */
  83277. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83278. /**
  83279. * Render all child sprites
  83280. */
  83281. render(): void;
  83282. /**
  83283. * Release associated resources
  83284. */
  83285. dispose(): void;
  83286. }
  83287. }
  83288. declare module BABYLON {
  83289. /** Interface used by value gradients (color, factor, ...) */
  83290. export interface IValueGradient {
  83291. /**
  83292. * Gets or sets the gradient value (between 0 and 1)
  83293. */
  83294. gradient: number;
  83295. }
  83296. /** Class used to store color4 gradient */
  83297. export class ColorGradient implements IValueGradient {
  83298. /**
  83299. * Gets or sets the gradient value (between 0 and 1)
  83300. */
  83301. gradient: number;
  83302. /**
  83303. * Gets or sets first associated color
  83304. */
  83305. color1: Color4;
  83306. /**
  83307. * Gets or sets second associated color
  83308. */
  83309. color2?: Color4;
  83310. /**
  83311. * Will get a color picked randomly between color1 and color2.
  83312. * If color2 is undefined then color1 will be used
  83313. * @param result defines the target Color4 to store the result in
  83314. */
  83315. getColorToRef(result: Color4): void;
  83316. }
  83317. /** Class used to store color 3 gradient */
  83318. export class Color3Gradient implements IValueGradient {
  83319. /**
  83320. * Gets or sets the gradient value (between 0 and 1)
  83321. */
  83322. gradient: number;
  83323. /**
  83324. * Gets or sets the associated color
  83325. */
  83326. color: Color3;
  83327. }
  83328. /** Class used to store factor gradient */
  83329. export class FactorGradient implements IValueGradient {
  83330. /**
  83331. * Gets or sets the gradient value (between 0 and 1)
  83332. */
  83333. gradient: number;
  83334. /**
  83335. * Gets or sets first associated factor
  83336. */
  83337. factor1: number;
  83338. /**
  83339. * Gets or sets second associated factor
  83340. */
  83341. factor2?: number;
  83342. /**
  83343. * Will get a number picked randomly between factor1 and factor2.
  83344. * If factor2 is undefined then factor1 will be used
  83345. * @returns the picked number
  83346. */
  83347. getFactor(): number;
  83348. }
  83349. /**
  83350. * Helper used to simplify some generic gradient tasks
  83351. */
  83352. export class GradientHelper {
  83353. /**
  83354. * Gets the current gradient from an array of IValueGradient
  83355. * @param ratio defines the current ratio to get
  83356. * @param gradients defines the array of IValueGradient
  83357. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83358. */
  83359. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83360. }
  83361. }
  83362. declare module BABYLON {
  83363. /**
  83364. * Interface for the size containing width and height
  83365. */
  83366. export interface ISize {
  83367. /**
  83368. * Width
  83369. */
  83370. width: number;
  83371. /**
  83372. * Heighht
  83373. */
  83374. height: number;
  83375. }
  83376. /**
  83377. * Size containing widht and height
  83378. */
  83379. export class Size implements ISize {
  83380. /**
  83381. * Width
  83382. */
  83383. width: number;
  83384. /**
  83385. * Height
  83386. */
  83387. height: number;
  83388. /**
  83389. * Creates a Size object from the given width and height (floats).
  83390. * @param width width of the new size
  83391. * @param height height of the new size
  83392. */
  83393. constructor(width: number, height: number);
  83394. /**
  83395. * Returns a string with the Size width and height
  83396. * @returns a string with the Size width and height
  83397. */
  83398. toString(): string;
  83399. /**
  83400. * "Size"
  83401. * @returns the string "Size"
  83402. */
  83403. getClassName(): string;
  83404. /**
  83405. * Returns the Size hash code.
  83406. * @returns a hash code for a unique width and height
  83407. */
  83408. getHashCode(): number;
  83409. /**
  83410. * Updates the current size from the given one.
  83411. * @param src the given size
  83412. */
  83413. copyFrom(src: Size): void;
  83414. /**
  83415. * Updates in place the current Size from the given floats.
  83416. * @param width width of the new size
  83417. * @param height height of the new size
  83418. * @returns the updated Size.
  83419. */
  83420. copyFromFloats(width: number, height: number): Size;
  83421. /**
  83422. * Updates in place the current Size from the given floats.
  83423. * @param width width to set
  83424. * @param height height to set
  83425. * @returns the updated Size.
  83426. */
  83427. set(width: number, height: number): Size;
  83428. /**
  83429. * Multiplies the width and height by numbers
  83430. * @param w factor to multiple the width by
  83431. * @param h factor to multiple the height by
  83432. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83433. */
  83434. multiplyByFloats(w: number, h: number): Size;
  83435. /**
  83436. * Clones the size
  83437. * @returns a new Size copied from the given one.
  83438. */
  83439. clone(): Size;
  83440. /**
  83441. * True if the current Size and the given one width and height are strictly equal.
  83442. * @param other the other size to compare against
  83443. * @returns True if the current Size and the given one width and height are strictly equal.
  83444. */
  83445. equals(other: Size): boolean;
  83446. /**
  83447. * The surface of the Size : width * height (float).
  83448. */
  83449. get surface(): number;
  83450. /**
  83451. * Create a new size of zero
  83452. * @returns a new Size set to (0.0, 0.0)
  83453. */
  83454. static Zero(): Size;
  83455. /**
  83456. * Sums the width and height of two sizes
  83457. * @param otherSize size to add to this size
  83458. * @returns a new Size set as the addition result of the current Size and the given one.
  83459. */
  83460. add(otherSize: Size): Size;
  83461. /**
  83462. * Subtracts the width and height of two
  83463. * @param otherSize size to subtract to this size
  83464. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83465. */
  83466. subtract(otherSize: Size): Size;
  83467. /**
  83468. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83469. * @param start starting size to lerp between
  83470. * @param end end size to lerp between
  83471. * @param amount amount to lerp between the start and end values
  83472. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83473. */
  83474. static Lerp(start: Size, end: Size, amount: number): Size;
  83475. }
  83476. }
  83477. declare module BABYLON {
  83478. interface ThinEngine {
  83479. /**
  83480. * Creates a dynamic texture
  83481. * @param width defines the width of the texture
  83482. * @param height defines the height of the texture
  83483. * @param generateMipMaps defines if the engine should generate the mip levels
  83484. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83485. * @returns the dynamic texture inside an InternalTexture
  83486. */
  83487. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83488. /**
  83489. * Update the content of a dynamic texture
  83490. * @param texture defines the texture to update
  83491. * @param canvas defines the canvas containing the source
  83492. * @param invertY defines if data must be stored with Y axis inverted
  83493. * @param premulAlpha defines if alpha is stored as premultiplied
  83494. * @param format defines the format of the data
  83495. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83496. */
  83497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83498. }
  83499. }
  83500. declare module BABYLON {
  83501. /**
  83502. * Helper class used to generate a canvas to manipulate images
  83503. */
  83504. export class CanvasGenerator {
  83505. /**
  83506. * Create a new canvas (or offscreen canvas depending on the context)
  83507. * @param width defines the expected width
  83508. * @param height defines the expected height
  83509. * @return a new canvas or offscreen canvas
  83510. */
  83511. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83512. }
  83513. }
  83514. declare module BABYLON {
  83515. /**
  83516. * A class extending Texture allowing drawing on a texture
  83517. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83518. */
  83519. export class DynamicTexture extends Texture {
  83520. private _generateMipMaps;
  83521. private _canvas;
  83522. private _context;
  83523. private _engine;
  83524. /**
  83525. * Creates a DynamicTexture
  83526. * @param name defines the name of the texture
  83527. * @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
  83528. * @param scene defines the scene where you want the texture
  83529. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83530. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83531. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83532. */
  83533. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83534. /**
  83535. * Get the current class name of the texture useful for serialization or dynamic coding.
  83536. * @returns "DynamicTexture"
  83537. */
  83538. getClassName(): string;
  83539. /**
  83540. * Gets the current state of canRescale
  83541. */
  83542. get canRescale(): boolean;
  83543. private _recreate;
  83544. /**
  83545. * Scales the texture
  83546. * @param ratio the scale factor to apply to both width and height
  83547. */
  83548. scale(ratio: number): void;
  83549. /**
  83550. * Resizes the texture
  83551. * @param width the new width
  83552. * @param height the new height
  83553. */
  83554. scaleTo(width: number, height: number): void;
  83555. /**
  83556. * Gets the context of the canvas used by the texture
  83557. * @returns the canvas context of the dynamic texture
  83558. */
  83559. getContext(): CanvasRenderingContext2D;
  83560. /**
  83561. * Clears the texture
  83562. */
  83563. clear(): void;
  83564. /**
  83565. * Updates the texture
  83566. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83567. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83568. */
  83569. update(invertY?: boolean, premulAlpha?: boolean): void;
  83570. /**
  83571. * Draws text onto the texture
  83572. * @param text defines the text to be drawn
  83573. * @param x defines the placement of the text from the left
  83574. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83575. * @param font defines the font to be used with font-style, font-size, font-name
  83576. * @param color defines the color used for the text
  83577. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83578. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83579. * @param update defines whether texture is immediately update (default is true)
  83580. */
  83581. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83582. /**
  83583. * Clones the texture
  83584. * @returns the clone of the texture.
  83585. */
  83586. clone(): DynamicTexture;
  83587. /**
  83588. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83589. * @returns a serialized dynamic texture object
  83590. */
  83591. serialize(): any;
  83592. /** @hidden */
  83593. _rebuild(): void;
  83594. }
  83595. }
  83596. declare module BABYLON {
  83597. interface Engine {
  83598. /**
  83599. * Creates a raw texture
  83600. * @param data defines the data to store in the texture
  83601. * @param width defines the width of the texture
  83602. * @param height defines the height of the texture
  83603. * @param format defines the format of the data
  83604. * @param generateMipMaps defines if the engine should generate the mip levels
  83605. * @param invertY defines if data must be stored with Y axis inverted
  83606. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83607. * @param compression defines the compression used (null by default)
  83608. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83609. * @returns the raw texture inside an InternalTexture
  83610. */
  83611. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83612. /**
  83613. * Update a raw texture
  83614. * @param texture defines the texture to update
  83615. * @param data defines the data to store in the texture
  83616. * @param format defines the format of the data
  83617. * @param invertY defines if data must be stored with Y axis inverted
  83618. */
  83619. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83620. /**
  83621. * Update a raw texture
  83622. * @param texture defines the texture to update
  83623. * @param data defines the data to store in the texture
  83624. * @param format defines the format of the data
  83625. * @param invertY defines if data must be stored with Y axis inverted
  83626. * @param compression defines the compression used (null by default)
  83627. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83628. */
  83629. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83630. /**
  83631. * Creates a new raw cube texture
  83632. * @param data defines the array of data to use to create each face
  83633. * @param size defines the size of the textures
  83634. * @param format defines the format of the data
  83635. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83636. * @param generateMipMaps defines if the engine should generate the mip levels
  83637. * @param invertY defines if data must be stored with Y axis inverted
  83638. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83639. * @param compression defines the compression used (null by default)
  83640. * @returns the cube texture as an InternalTexture
  83641. */
  83642. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83643. /**
  83644. * Update a raw cube texture
  83645. * @param texture defines the texture to udpdate
  83646. * @param data defines the data to store
  83647. * @param format defines the data format
  83648. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83649. * @param invertY defines if data must be stored with Y axis inverted
  83650. */
  83651. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83652. /**
  83653. * Update a raw cube texture
  83654. * @param texture defines the texture to udpdate
  83655. * @param data defines the data to store
  83656. * @param format defines the data format
  83657. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83658. * @param invertY defines if data must be stored with Y axis inverted
  83659. * @param compression defines the compression used (null by default)
  83660. */
  83661. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83662. /**
  83663. * Update a raw cube texture
  83664. * @param texture defines the texture to udpdate
  83665. * @param data defines the data to store
  83666. * @param format defines the data format
  83667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83668. * @param invertY defines if data must be stored with Y axis inverted
  83669. * @param compression defines the compression used (null by default)
  83670. * @param level defines which level of the texture to update
  83671. */
  83672. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83673. /**
  83674. * Creates a new raw cube texture from a specified url
  83675. * @param url defines the url where the data is located
  83676. * @param scene defines the current scene
  83677. * @param size defines the size of the textures
  83678. * @param format defines the format of the data
  83679. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83680. * @param noMipmap defines if the engine should avoid generating the mip levels
  83681. * @param callback defines a callback used to extract texture data from loaded data
  83682. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83683. * @param onLoad defines a callback called when texture is loaded
  83684. * @param onError defines a callback called if there is an error
  83685. * @returns the cube texture as an InternalTexture
  83686. */
  83687. 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;
  83688. /**
  83689. * Creates a new raw cube texture from a specified url
  83690. * @param url defines the url where the data is located
  83691. * @param scene defines the current scene
  83692. * @param size defines the size of the textures
  83693. * @param format defines the format of the data
  83694. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83695. * @param noMipmap defines if the engine should avoid generating the mip levels
  83696. * @param callback defines a callback used to extract texture data from loaded data
  83697. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83698. * @param onLoad defines a callback called when texture is loaded
  83699. * @param onError defines a callback called if there is an error
  83700. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83701. * @param invertY defines if data must be stored with Y axis inverted
  83702. * @returns the cube texture as an InternalTexture
  83703. */
  83704. 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;
  83705. /**
  83706. * Creates a new raw 3D texture
  83707. * @param data defines the data used to create the texture
  83708. * @param width defines the width of the texture
  83709. * @param height defines the height of the texture
  83710. * @param depth defines the depth of the texture
  83711. * @param format defines the format of the texture
  83712. * @param generateMipMaps defines if the engine must generate mip levels
  83713. * @param invertY defines if data must be stored with Y axis inverted
  83714. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83715. * @param compression defines the compressed used (can be null)
  83716. * @param textureType defines the compressed used (can be null)
  83717. * @returns a new raw 3D texture (stored in an InternalTexture)
  83718. */
  83719. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83720. /**
  83721. * Update a raw 3D texture
  83722. * @param texture defines the texture to update
  83723. * @param data defines the data to store
  83724. * @param format defines the data format
  83725. * @param invertY defines if data must be stored with Y axis inverted
  83726. */
  83727. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83728. /**
  83729. * Update a raw 3D texture
  83730. * @param texture defines the texture to update
  83731. * @param data defines the data to store
  83732. * @param format defines the data format
  83733. * @param invertY defines if data must be stored with Y axis inverted
  83734. * @param compression defines the used compression (can be null)
  83735. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83736. */
  83737. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83738. /**
  83739. * Creates a new raw 2D array texture
  83740. * @param data defines the data used to create the texture
  83741. * @param width defines the width of the texture
  83742. * @param height defines the height of the texture
  83743. * @param depth defines the number of layers of the texture
  83744. * @param format defines the format of the texture
  83745. * @param generateMipMaps defines if the engine must generate mip levels
  83746. * @param invertY defines if data must be stored with Y axis inverted
  83747. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83748. * @param compression defines the compressed used (can be null)
  83749. * @param textureType defines the compressed used (can be null)
  83750. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83751. */
  83752. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83753. /**
  83754. * Update a raw 2D array texture
  83755. * @param texture defines the texture to update
  83756. * @param data defines the data to store
  83757. * @param format defines the data format
  83758. * @param invertY defines if data must be stored with Y axis inverted
  83759. */
  83760. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83761. /**
  83762. * Update a raw 2D array texture
  83763. * @param texture defines the texture to update
  83764. * @param data defines the data to store
  83765. * @param format defines the data format
  83766. * @param invertY defines if data must be stored with Y axis inverted
  83767. * @param compression defines the used compression (can be null)
  83768. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83769. */
  83770. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83771. }
  83772. }
  83773. declare module BABYLON {
  83774. /**
  83775. * Raw texture can help creating a texture directly from an array of data.
  83776. * This can be super useful if you either get the data from an uncompressed source or
  83777. * if you wish to create your texture pixel by pixel.
  83778. */
  83779. export class RawTexture extends Texture {
  83780. /**
  83781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83782. */
  83783. format: number;
  83784. private _engine;
  83785. /**
  83786. * Instantiates a new RawTexture.
  83787. * Raw texture can help creating a texture directly from an array of data.
  83788. * This can be super useful if you either get the data from an uncompressed source or
  83789. * if you wish to create your texture pixel by pixel.
  83790. * @param data define the array of data to use to create the texture
  83791. * @param width define the width of the texture
  83792. * @param height define the height of the texture
  83793. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83794. * @param scene define the scene the texture belongs to
  83795. * @param generateMipMaps define whether mip maps should be generated or not
  83796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83798. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83799. */
  83800. constructor(data: ArrayBufferView, width: number, height: number,
  83801. /**
  83802. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83803. */
  83804. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83805. /**
  83806. * Updates the texture underlying data.
  83807. * @param data Define the new data of the texture
  83808. */
  83809. update(data: ArrayBufferView): void;
  83810. /**
  83811. * Creates a luminance texture from some data.
  83812. * @param data Define the texture data
  83813. * @param width Define the width of the texture
  83814. * @param height Define the height of the texture
  83815. * @param scene Define the scene the texture belongs to
  83816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83819. * @returns the luminance texture
  83820. */
  83821. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83822. /**
  83823. * Creates a luminance alpha texture from some data.
  83824. * @param data Define the texture data
  83825. * @param width Define the width of the texture
  83826. * @param height Define the height of the texture
  83827. * @param scene Define the scene the texture belongs to
  83828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83831. * @returns the luminance alpha texture
  83832. */
  83833. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83834. /**
  83835. * Creates an alpha texture from some data.
  83836. * @param data Define the texture data
  83837. * @param width Define the width of the texture
  83838. * @param height Define the height of the texture
  83839. * @param scene Define the scene the texture belongs to
  83840. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83841. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83842. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83843. * @returns the alpha texture
  83844. */
  83845. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83846. /**
  83847. * Creates a RGB texture from some data.
  83848. * @param data Define the texture data
  83849. * @param width Define the width of the texture
  83850. * @param height Define the height of the texture
  83851. * @param scene Define the scene the texture belongs to
  83852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83856. * @returns the RGB alpha texture
  83857. */
  83858. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83859. /**
  83860. * Creates a RGBA texture from some data.
  83861. * @param data Define the texture data
  83862. * @param width Define the width of the texture
  83863. * @param height Define the height of the texture
  83864. * @param scene Define the scene the texture belongs to
  83865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83869. * @returns the RGBA texture
  83870. */
  83871. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83872. /**
  83873. * Creates a R texture from some data.
  83874. * @param data Define the texture data
  83875. * @param width Define the width of the texture
  83876. * @param height Define the height of the texture
  83877. * @param scene Define the scene the texture belongs to
  83878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83882. * @returns the R texture
  83883. */
  83884. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83885. }
  83886. }
  83887. declare module BABYLON {
  83888. interface AbstractScene {
  83889. /**
  83890. * The list of procedural textures added to the scene
  83891. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83892. */
  83893. proceduralTextures: Array<ProceduralTexture>;
  83894. }
  83895. /**
  83896. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83897. * in a given scene.
  83898. */
  83899. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83900. /**
  83901. * The component name helpfull to identify the component in the list of scene components.
  83902. */
  83903. readonly name: string;
  83904. /**
  83905. * The scene the component belongs to.
  83906. */
  83907. scene: Scene;
  83908. /**
  83909. * Creates a new instance of the component for the given scene
  83910. * @param scene Defines the scene to register the component in
  83911. */
  83912. constructor(scene: Scene);
  83913. /**
  83914. * Registers the component in a given scene
  83915. */
  83916. register(): void;
  83917. /**
  83918. * Rebuilds the elements related to this component in case of
  83919. * context lost for instance.
  83920. */
  83921. rebuild(): void;
  83922. /**
  83923. * Disposes the component and the associated ressources.
  83924. */
  83925. dispose(): void;
  83926. private _beforeClear;
  83927. }
  83928. }
  83929. declare module BABYLON {
  83930. interface ThinEngine {
  83931. /**
  83932. * Creates a new render target cube texture
  83933. * @param size defines the size of the texture
  83934. * @param options defines the options used to create the texture
  83935. * @returns a new render target cube texture stored in an InternalTexture
  83936. */
  83937. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83938. }
  83939. }
  83940. declare module BABYLON {
  83941. /** @hidden */
  83942. export var proceduralVertexShader: {
  83943. name: string;
  83944. shader: string;
  83945. };
  83946. }
  83947. declare module BABYLON {
  83948. /**
  83949. * 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.
  83950. * This is the base class of any Procedural texture and contains most of the shareable code.
  83951. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83952. */
  83953. export class ProceduralTexture extends Texture {
  83954. isCube: boolean;
  83955. /**
  83956. * Define if the texture is enabled or not (disabled texture will not render)
  83957. */
  83958. isEnabled: boolean;
  83959. /**
  83960. * Define if the texture must be cleared before rendering (default is true)
  83961. */
  83962. autoClear: boolean;
  83963. /**
  83964. * Callback called when the texture is generated
  83965. */
  83966. onGenerated: () => void;
  83967. /**
  83968. * Event raised when the texture is generated
  83969. */
  83970. onGeneratedObservable: Observable<ProceduralTexture>;
  83971. /** @hidden */
  83972. _generateMipMaps: boolean;
  83973. /** @hidden **/
  83974. _effect: Effect;
  83975. /** @hidden */
  83976. _textures: {
  83977. [key: string]: Texture;
  83978. };
  83979. private _size;
  83980. private _currentRefreshId;
  83981. private _frameId;
  83982. private _refreshRate;
  83983. private _vertexBuffers;
  83984. private _indexBuffer;
  83985. private _uniforms;
  83986. private _samplers;
  83987. private _fragment;
  83988. private _floats;
  83989. private _ints;
  83990. private _floatsArrays;
  83991. private _colors3;
  83992. private _colors4;
  83993. private _vectors2;
  83994. private _vectors3;
  83995. private _matrices;
  83996. private _fallbackTexture;
  83997. private _fallbackTextureUsed;
  83998. private _engine;
  83999. private _cachedDefines;
  84000. private _contentUpdateId;
  84001. private _contentData;
  84002. /**
  84003. * Instantiates a new procedural texture.
  84004. * 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.
  84005. * This is the base class of any Procedural texture and contains most of the shareable code.
  84006. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84007. * @param name Define the name of the texture
  84008. * @param size Define the size of the texture to create
  84009. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84010. * @param scene Define the scene the texture belongs to
  84011. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84012. * @param generateMipMaps Define if the texture should creates mip maps or not
  84013. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84014. */
  84015. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84016. /**
  84017. * The effect that is created when initializing the post process.
  84018. * @returns The created effect corresponding the the postprocess.
  84019. */
  84020. getEffect(): Effect;
  84021. /**
  84022. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84023. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84024. */
  84025. getContent(): Nullable<ArrayBufferView>;
  84026. private _createIndexBuffer;
  84027. /** @hidden */
  84028. _rebuild(): void;
  84029. /**
  84030. * Resets the texture in order to recreate its associated resources.
  84031. * This can be called in case of context loss
  84032. */
  84033. reset(): void;
  84034. protected _getDefines(): string;
  84035. /**
  84036. * Is the texture ready to be used ? (rendered at least once)
  84037. * @returns true if ready, otherwise, false.
  84038. */
  84039. isReady(): boolean;
  84040. /**
  84041. * Resets the refresh counter of the texture and start bak from scratch.
  84042. * Could be useful to regenerate the texture if it is setup to render only once.
  84043. */
  84044. resetRefreshCounter(): void;
  84045. /**
  84046. * Set the fragment shader to use in order to render the texture.
  84047. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84048. */
  84049. setFragment(fragment: any): void;
  84050. /**
  84051. * Define the refresh rate of the texture or the rendering frequency.
  84052. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84053. */
  84054. get refreshRate(): number;
  84055. set refreshRate(value: number);
  84056. /** @hidden */
  84057. _shouldRender(): boolean;
  84058. /**
  84059. * Get the size the texture is rendering at.
  84060. * @returns the size (texture is always squared)
  84061. */
  84062. getRenderSize(): number;
  84063. /**
  84064. * Resize the texture to new value.
  84065. * @param size Define the new size the texture should have
  84066. * @param generateMipMaps Define whether the new texture should create mip maps
  84067. */
  84068. resize(size: number, generateMipMaps: boolean): void;
  84069. private _checkUniform;
  84070. /**
  84071. * Set a texture in the shader program used to render.
  84072. * @param name Define the name of the uniform samplers as defined in the shader
  84073. * @param texture Define the texture to bind to this sampler
  84074. * @return the texture itself allowing "fluent" like uniform updates
  84075. */
  84076. setTexture(name: string, texture: Texture): ProceduralTexture;
  84077. /**
  84078. * Set a float in the shader.
  84079. * @param name Define the name of the uniform as defined in the shader
  84080. * @param value Define the value to give to the uniform
  84081. * @return the texture itself allowing "fluent" like uniform updates
  84082. */
  84083. setFloat(name: string, value: number): ProceduralTexture;
  84084. /**
  84085. * Set a int in the shader.
  84086. * @param name Define the name of the uniform as defined in the shader
  84087. * @param value Define the value to give to the uniform
  84088. * @return the texture itself allowing "fluent" like uniform updates
  84089. */
  84090. setInt(name: string, value: number): ProceduralTexture;
  84091. /**
  84092. * Set an array of floats in the shader.
  84093. * @param name Define the name of the uniform as defined in the shader
  84094. * @param value Define the value to give to the uniform
  84095. * @return the texture itself allowing "fluent" like uniform updates
  84096. */
  84097. setFloats(name: string, value: number[]): ProceduralTexture;
  84098. /**
  84099. * Set a vec3 in the shader from a Color3.
  84100. * @param name Define the name of the uniform as defined in the shader
  84101. * @param value Define the value to give to the uniform
  84102. * @return the texture itself allowing "fluent" like uniform updates
  84103. */
  84104. setColor3(name: string, value: Color3): ProceduralTexture;
  84105. /**
  84106. * Set a vec4 in the shader from a Color4.
  84107. * @param name Define the name of the uniform as defined in the shader
  84108. * @param value Define the value to give to the uniform
  84109. * @return the texture itself allowing "fluent" like uniform updates
  84110. */
  84111. setColor4(name: string, value: Color4): ProceduralTexture;
  84112. /**
  84113. * Set a vec2 in the shader from a Vector2.
  84114. * @param name Define the name of the uniform as defined in the shader
  84115. * @param value Define the value to give to the uniform
  84116. * @return the texture itself allowing "fluent" like uniform updates
  84117. */
  84118. setVector2(name: string, value: Vector2): ProceduralTexture;
  84119. /**
  84120. * Set a vec3 in the shader from a Vector3.
  84121. * @param name Define the name of the uniform as defined in the shader
  84122. * @param value Define the value to give to the uniform
  84123. * @return the texture itself allowing "fluent" like uniform updates
  84124. */
  84125. setVector3(name: string, value: Vector3): ProceduralTexture;
  84126. /**
  84127. * Set a mat4 in the shader from a MAtrix.
  84128. * @param name Define the name of the uniform as defined in the shader
  84129. * @param value Define the value to give to the uniform
  84130. * @return the texture itself allowing "fluent" like uniform updates
  84131. */
  84132. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84133. /**
  84134. * Render the texture to its associated render target.
  84135. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84136. */
  84137. render(useCameraPostProcess?: boolean): void;
  84138. /**
  84139. * Clone the texture.
  84140. * @returns the cloned texture
  84141. */
  84142. clone(): ProceduralTexture;
  84143. /**
  84144. * Dispose the texture and release its asoociated resources.
  84145. */
  84146. dispose(): void;
  84147. }
  84148. }
  84149. declare module BABYLON {
  84150. /**
  84151. * This represents the base class for particle system in Babylon.
  84152. * 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.
  84153. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84154. * @example https://doc.babylonjs.com/babylon101/particles
  84155. */
  84156. export class BaseParticleSystem {
  84157. /**
  84158. * Source color is added to the destination color without alpha affecting the result
  84159. */
  84160. static BLENDMODE_ONEONE: number;
  84161. /**
  84162. * Blend current color and particle color using particle’s alpha
  84163. */
  84164. static BLENDMODE_STANDARD: number;
  84165. /**
  84166. * Add current color and particle color multiplied by particle’s alpha
  84167. */
  84168. static BLENDMODE_ADD: number;
  84169. /**
  84170. * Multiply current color with particle color
  84171. */
  84172. static BLENDMODE_MULTIPLY: number;
  84173. /**
  84174. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84175. */
  84176. static BLENDMODE_MULTIPLYADD: number;
  84177. /**
  84178. * List of animations used by the particle system.
  84179. */
  84180. animations: Animation[];
  84181. /**
  84182. * The id of the Particle system.
  84183. */
  84184. id: string;
  84185. /**
  84186. * The friendly name of the Particle system.
  84187. */
  84188. name: string;
  84189. /**
  84190. * The rendering group used by the Particle system to chose when to render.
  84191. */
  84192. renderingGroupId: number;
  84193. /**
  84194. * The emitter represents the Mesh or position we are attaching the particle system to.
  84195. */
  84196. emitter: Nullable<AbstractMesh | Vector3>;
  84197. /**
  84198. * The maximum number of particles to emit per frame
  84199. */
  84200. emitRate: number;
  84201. /**
  84202. * If you want to launch only a few particles at once, that can be done, as well.
  84203. */
  84204. manualEmitCount: number;
  84205. /**
  84206. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84207. */
  84208. updateSpeed: number;
  84209. /**
  84210. * The amount of time the particle system is running (depends of the overall update speed).
  84211. */
  84212. targetStopDuration: number;
  84213. /**
  84214. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84215. */
  84216. disposeOnStop: boolean;
  84217. /**
  84218. * Minimum power of emitting particles.
  84219. */
  84220. minEmitPower: number;
  84221. /**
  84222. * Maximum power of emitting particles.
  84223. */
  84224. maxEmitPower: number;
  84225. /**
  84226. * Minimum life time of emitting particles.
  84227. */
  84228. minLifeTime: number;
  84229. /**
  84230. * Maximum life time of emitting particles.
  84231. */
  84232. maxLifeTime: number;
  84233. /**
  84234. * Minimum Size of emitting particles.
  84235. */
  84236. minSize: number;
  84237. /**
  84238. * Maximum Size of emitting particles.
  84239. */
  84240. maxSize: number;
  84241. /**
  84242. * Minimum scale of emitting particles on X axis.
  84243. */
  84244. minScaleX: number;
  84245. /**
  84246. * Maximum scale of emitting particles on X axis.
  84247. */
  84248. maxScaleX: number;
  84249. /**
  84250. * Minimum scale of emitting particles on Y axis.
  84251. */
  84252. minScaleY: number;
  84253. /**
  84254. * Maximum scale of emitting particles on Y axis.
  84255. */
  84256. maxScaleY: number;
  84257. /**
  84258. * Gets or sets the minimal initial rotation in radians.
  84259. */
  84260. minInitialRotation: number;
  84261. /**
  84262. * Gets or sets the maximal initial rotation in radians.
  84263. */
  84264. maxInitialRotation: number;
  84265. /**
  84266. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84267. */
  84268. minAngularSpeed: number;
  84269. /**
  84270. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84271. */
  84272. maxAngularSpeed: number;
  84273. /**
  84274. * The texture used to render each particle. (this can be a spritesheet)
  84275. */
  84276. particleTexture: Nullable<Texture>;
  84277. /**
  84278. * The layer mask we are rendering the particles through.
  84279. */
  84280. layerMask: number;
  84281. /**
  84282. * This can help using your own shader to render the particle system.
  84283. * The according effect will be created
  84284. */
  84285. customShader: any;
  84286. /**
  84287. * By default particle system starts as soon as they are created. This prevents the
  84288. * automatic start to happen and let you decide when to start emitting particles.
  84289. */
  84290. preventAutoStart: boolean;
  84291. private _noiseTexture;
  84292. /**
  84293. * Gets or sets a texture used to add random noise to particle positions
  84294. */
  84295. get noiseTexture(): Nullable<ProceduralTexture>;
  84296. set noiseTexture(value: Nullable<ProceduralTexture>);
  84297. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84298. noiseStrength: Vector3;
  84299. /**
  84300. * Callback triggered when the particle animation is ending.
  84301. */
  84302. onAnimationEnd: Nullable<() => void>;
  84303. /**
  84304. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84305. */
  84306. blendMode: number;
  84307. /**
  84308. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84309. * to override the particles.
  84310. */
  84311. forceDepthWrite: boolean;
  84312. /** 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 */
  84313. preWarmCycles: number;
  84314. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84315. preWarmStepOffset: number;
  84316. /**
  84317. * 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)
  84318. */
  84319. spriteCellChangeSpeed: number;
  84320. /**
  84321. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84322. */
  84323. startSpriteCellID: number;
  84324. /**
  84325. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84326. */
  84327. endSpriteCellID: number;
  84328. /**
  84329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84330. */
  84331. spriteCellWidth: number;
  84332. /**
  84333. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84334. */
  84335. spriteCellHeight: number;
  84336. /**
  84337. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84338. */
  84339. spriteRandomStartCell: boolean;
  84340. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84341. translationPivot: Vector2;
  84342. /** @hidden */
  84343. protected _isAnimationSheetEnabled: boolean;
  84344. /**
  84345. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84346. */
  84347. beginAnimationOnStart: boolean;
  84348. /**
  84349. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84350. */
  84351. beginAnimationFrom: number;
  84352. /**
  84353. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84354. */
  84355. beginAnimationTo: number;
  84356. /**
  84357. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84358. */
  84359. beginAnimationLoop: boolean;
  84360. /**
  84361. * Gets or sets a world offset applied to all particles
  84362. */
  84363. worldOffset: Vector3;
  84364. /**
  84365. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84366. */
  84367. get isAnimationSheetEnabled(): boolean;
  84368. set isAnimationSheetEnabled(value: boolean);
  84369. /**
  84370. * Get hosting scene
  84371. * @returns the scene
  84372. */
  84373. getScene(): Scene;
  84374. /**
  84375. * You can use gravity if you want to give an orientation to your particles.
  84376. */
  84377. gravity: Vector3;
  84378. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84379. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84380. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84381. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84382. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84383. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84384. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84385. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84386. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84387. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84388. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84389. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84390. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84391. /**
  84392. * Defines the delay in milliseconds before starting the system (0 by default)
  84393. */
  84394. startDelay: number;
  84395. /**
  84396. * Gets the current list of drag gradients.
  84397. * You must use addDragGradient and removeDragGradient to udpate this list
  84398. * @returns the list of drag gradients
  84399. */
  84400. getDragGradients(): Nullable<Array<FactorGradient>>;
  84401. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84402. limitVelocityDamping: number;
  84403. /**
  84404. * Gets the current list of limit velocity gradients.
  84405. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84406. * @returns the list of limit velocity gradients
  84407. */
  84408. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84409. /**
  84410. * Gets the current list of color gradients.
  84411. * You must use addColorGradient and removeColorGradient to udpate this list
  84412. * @returns the list of color gradients
  84413. */
  84414. getColorGradients(): Nullable<Array<ColorGradient>>;
  84415. /**
  84416. * Gets the current list of size gradients.
  84417. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84418. * @returns the list of size gradients
  84419. */
  84420. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84421. /**
  84422. * Gets the current list of color remap gradients.
  84423. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84424. * @returns the list of color remap gradients
  84425. */
  84426. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84427. /**
  84428. * Gets the current list of alpha remap gradients.
  84429. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84430. * @returns the list of alpha remap gradients
  84431. */
  84432. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84433. /**
  84434. * Gets the current list of life time gradients.
  84435. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84436. * @returns the list of life time gradients
  84437. */
  84438. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84439. /**
  84440. * Gets the current list of angular speed gradients.
  84441. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84442. * @returns the list of angular speed gradients
  84443. */
  84444. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84445. /**
  84446. * Gets the current list of velocity gradients.
  84447. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84448. * @returns the list of velocity gradients
  84449. */
  84450. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84451. /**
  84452. * Gets the current list of start size gradients.
  84453. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84454. * @returns the list of start size gradients
  84455. */
  84456. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84457. /**
  84458. * Gets the current list of emit rate gradients.
  84459. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84460. * @returns the list of emit rate gradients
  84461. */
  84462. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84463. /**
  84464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84465. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84466. */
  84467. get direction1(): Vector3;
  84468. set direction1(value: Vector3);
  84469. /**
  84470. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84471. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84472. */
  84473. get direction2(): Vector3;
  84474. set direction2(value: Vector3);
  84475. /**
  84476. * 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.
  84477. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84478. */
  84479. get minEmitBox(): Vector3;
  84480. set minEmitBox(value: Vector3);
  84481. /**
  84482. * 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.
  84483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84484. */
  84485. get maxEmitBox(): Vector3;
  84486. set maxEmitBox(value: Vector3);
  84487. /**
  84488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84489. */
  84490. color1: Color4;
  84491. /**
  84492. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84493. */
  84494. color2: Color4;
  84495. /**
  84496. * Color the particle will have at the end of its lifetime
  84497. */
  84498. colorDead: Color4;
  84499. /**
  84500. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84501. */
  84502. textureMask: Color4;
  84503. /**
  84504. * The particle emitter type defines the emitter used by the particle system.
  84505. * It can be for example box, sphere, or cone...
  84506. */
  84507. particleEmitterType: IParticleEmitterType;
  84508. /** @hidden */
  84509. _isSubEmitter: boolean;
  84510. /**
  84511. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84512. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84513. */
  84514. billboardMode: number;
  84515. protected _isBillboardBased: boolean;
  84516. /**
  84517. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84518. */
  84519. get isBillboardBased(): boolean;
  84520. set isBillboardBased(value: boolean);
  84521. /**
  84522. * The scene the particle system belongs to.
  84523. */
  84524. protected _scene: Scene;
  84525. /**
  84526. * Local cache of defines for image processing.
  84527. */
  84528. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84529. /**
  84530. * Default configuration related to image processing available in the standard Material.
  84531. */
  84532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84533. /**
  84534. * Gets the image processing configuration used either in this material.
  84535. */
  84536. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84537. /**
  84538. * Sets the Default image processing configuration used either in the this material.
  84539. *
  84540. * If sets to null, the scene one is in use.
  84541. */
  84542. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84543. /**
  84544. * Attaches a new image processing configuration to the Standard Material.
  84545. * @param configuration
  84546. */
  84547. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84548. /** @hidden */
  84549. protected _reset(): void;
  84550. /** @hidden */
  84551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84552. /**
  84553. * Instantiates a particle system.
  84554. * 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.
  84555. * @param name The name of the particle system
  84556. */
  84557. constructor(name: string);
  84558. /**
  84559. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84562. * @returns the emitter
  84563. */
  84564. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84565. /**
  84566. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84567. * @param radius The radius of the hemisphere to emit from
  84568. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84569. * @returns the emitter
  84570. */
  84571. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84572. /**
  84573. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84574. * @param radius The radius of the sphere to emit from
  84575. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84576. * @returns the emitter
  84577. */
  84578. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84579. /**
  84580. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84581. * @param radius The radius of the sphere to emit from
  84582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84584. * @returns the emitter
  84585. */
  84586. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84587. /**
  84588. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84589. * @param radius The radius of the emission cylinder
  84590. * @param height The height of the emission cylinder
  84591. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84592. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84593. * @returns the emitter
  84594. */
  84595. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84596. /**
  84597. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84598. * @param radius The radius of the cylinder to emit from
  84599. * @param height The height of the emission cylinder
  84600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84603. * @returns the emitter
  84604. */
  84605. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84606. /**
  84607. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84608. * @param radius The radius of the cone to emit from
  84609. * @param angle The base angle of the cone
  84610. * @returns the emitter
  84611. */
  84612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84613. /**
  84614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84619. * @returns the emitter
  84620. */
  84621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84622. }
  84623. }
  84624. declare module BABYLON {
  84625. /**
  84626. * Type of sub emitter
  84627. */
  84628. export enum SubEmitterType {
  84629. /**
  84630. * Attached to the particle over it's lifetime
  84631. */
  84632. ATTACHED = 0,
  84633. /**
  84634. * Created when the particle dies
  84635. */
  84636. END = 1
  84637. }
  84638. /**
  84639. * Sub emitter class used to emit particles from an existing particle
  84640. */
  84641. export class SubEmitter {
  84642. /**
  84643. * the particle system to be used by the sub emitter
  84644. */
  84645. particleSystem: ParticleSystem;
  84646. /**
  84647. * Type of the submitter (Default: END)
  84648. */
  84649. type: SubEmitterType;
  84650. /**
  84651. * 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)
  84652. * Note: This only is supported when using an emitter of type Mesh
  84653. */
  84654. inheritDirection: boolean;
  84655. /**
  84656. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84657. */
  84658. inheritedVelocityAmount: number;
  84659. /**
  84660. * Creates a sub emitter
  84661. * @param particleSystem the particle system to be used by the sub emitter
  84662. */
  84663. constructor(
  84664. /**
  84665. * the particle system to be used by the sub emitter
  84666. */
  84667. particleSystem: ParticleSystem);
  84668. /**
  84669. * Clones the sub emitter
  84670. * @returns the cloned sub emitter
  84671. */
  84672. clone(): SubEmitter;
  84673. /**
  84674. * Serialize current object to a JSON object
  84675. * @returns the serialized object
  84676. */
  84677. serialize(): any;
  84678. /** @hidden */
  84679. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84680. /**
  84681. * Creates a new SubEmitter from a serialized JSON version
  84682. * @param serializationObject defines the JSON object to read from
  84683. * @param scene defines the hosting scene
  84684. * @param rootUrl defines the rootUrl for data loading
  84685. * @returns a new SubEmitter
  84686. */
  84687. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84688. /** Release associated resources */
  84689. dispose(): void;
  84690. }
  84691. }
  84692. declare module BABYLON {
  84693. /** @hidden */
  84694. export var imageProcessingDeclaration: {
  84695. name: string;
  84696. shader: string;
  84697. };
  84698. }
  84699. declare module BABYLON {
  84700. /** @hidden */
  84701. export var imageProcessingFunctions: {
  84702. name: string;
  84703. shader: string;
  84704. };
  84705. }
  84706. declare module BABYLON {
  84707. /** @hidden */
  84708. export var particlesPixelShader: {
  84709. name: string;
  84710. shader: string;
  84711. };
  84712. }
  84713. declare module BABYLON {
  84714. /** @hidden */
  84715. export var particlesVertexShader: {
  84716. name: string;
  84717. shader: string;
  84718. };
  84719. }
  84720. declare module BABYLON {
  84721. /**
  84722. * This represents a particle system in Babylon.
  84723. * 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.
  84724. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84725. * @example https://doc.babylonjs.com/babylon101/particles
  84726. */
  84727. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84728. /**
  84729. * Billboard mode will only apply to Y axis
  84730. */
  84731. static readonly BILLBOARDMODE_Y: number;
  84732. /**
  84733. * Billboard mode will apply to all axes
  84734. */
  84735. static readonly BILLBOARDMODE_ALL: number;
  84736. /**
  84737. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84738. */
  84739. static readonly BILLBOARDMODE_STRETCHED: number;
  84740. /**
  84741. * This function can be defined to provide custom update for active particles.
  84742. * This function will be called instead of regular update (age, position, color, etc.).
  84743. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84744. */
  84745. updateFunction: (particles: Particle[]) => void;
  84746. private _emitterWorldMatrix;
  84747. /**
  84748. * This function can be defined to specify initial direction for every new particle.
  84749. * It by default use the emitterType defined function
  84750. */
  84751. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84752. /**
  84753. * This function can be defined to specify initial position for every new particle.
  84754. * It by default use the emitterType defined function
  84755. */
  84756. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84757. /**
  84758. * @hidden
  84759. */
  84760. _inheritedVelocityOffset: Vector3;
  84761. /**
  84762. * An event triggered when the system is disposed
  84763. */
  84764. onDisposeObservable: Observable<ParticleSystem>;
  84765. private _onDisposeObserver;
  84766. /**
  84767. * Sets a callback that will be triggered when the system is disposed
  84768. */
  84769. set onDispose(callback: () => void);
  84770. private _particles;
  84771. private _epsilon;
  84772. private _capacity;
  84773. private _stockParticles;
  84774. private _newPartsExcess;
  84775. private _vertexData;
  84776. private _vertexBuffer;
  84777. private _vertexBuffers;
  84778. private _spriteBuffer;
  84779. private _indexBuffer;
  84780. private _effect;
  84781. private _customEffect;
  84782. private _cachedDefines;
  84783. private _scaledColorStep;
  84784. private _colorDiff;
  84785. private _scaledDirection;
  84786. private _scaledGravity;
  84787. private _currentRenderId;
  84788. private _alive;
  84789. private _useInstancing;
  84790. private _started;
  84791. private _stopped;
  84792. private _actualFrame;
  84793. private _scaledUpdateSpeed;
  84794. private _vertexBufferSize;
  84795. /** @hidden */
  84796. _currentEmitRateGradient: Nullable<FactorGradient>;
  84797. /** @hidden */
  84798. _currentEmitRate1: number;
  84799. /** @hidden */
  84800. _currentEmitRate2: number;
  84801. /** @hidden */
  84802. _currentStartSizeGradient: Nullable<FactorGradient>;
  84803. /** @hidden */
  84804. _currentStartSize1: number;
  84805. /** @hidden */
  84806. _currentStartSize2: number;
  84807. private readonly _rawTextureWidth;
  84808. private _rampGradientsTexture;
  84809. private _useRampGradients;
  84810. /** Gets or sets a boolean indicating that ramp gradients must be used
  84811. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84812. */
  84813. get useRampGradients(): boolean;
  84814. set useRampGradients(value: boolean);
  84815. /**
  84816. * 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.
  84817. * 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: [])
  84818. */
  84819. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84820. private _subEmitters;
  84821. /**
  84822. * @hidden
  84823. * If the particle systems emitter should be disposed when the particle system is disposed
  84824. */
  84825. _disposeEmitterOnDispose: boolean;
  84826. /**
  84827. * The current active Sub-systems, this property is used by the root particle system only.
  84828. */
  84829. activeSubSystems: Array<ParticleSystem>;
  84830. private _rootParticleSystem;
  84831. /**
  84832. * Gets the current list of active particles
  84833. */
  84834. get particles(): Particle[];
  84835. /**
  84836. * Returns the string "ParticleSystem"
  84837. * @returns a string containing the class name
  84838. */
  84839. getClassName(): string;
  84840. /**
  84841. * Instantiates a particle system.
  84842. * 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.
  84843. * @param name The name of the particle system
  84844. * @param capacity The max number of particles alive at the same time
  84845. * @param scene The scene the particle system belongs to
  84846. * @param customEffect a custom effect used to change the way particles are rendered by default
  84847. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84848. * @param epsilon Offset used to render the particles
  84849. */
  84850. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84851. private _addFactorGradient;
  84852. private _removeFactorGradient;
  84853. /**
  84854. * Adds a new life time gradient
  84855. * @param gradient defines the gradient to use (between 0 and 1)
  84856. * @param factor defines the life time factor to affect to the specified gradient
  84857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84858. * @returns the current particle system
  84859. */
  84860. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84861. /**
  84862. * Remove a specific life time gradient
  84863. * @param gradient defines the gradient to remove
  84864. * @returns the current particle system
  84865. */
  84866. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84867. /**
  84868. * Adds a new size gradient
  84869. * @param gradient defines the gradient to use (between 0 and 1)
  84870. * @param factor defines the size factor to affect to the specified gradient
  84871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84872. * @returns the current particle system
  84873. */
  84874. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84875. /**
  84876. * Remove a specific size gradient
  84877. * @param gradient defines the gradient to remove
  84878. * @returns the current particle system
  84879. */
  84880. removeSizeGradient(gradient: number): IParticleSystem;
  84881. /**
  84882. * Adds a new color remap gradient
  84883. * @param gradient defines the gradient to use (between 0 and 1)
  84884. * @param min defines the color remap minimal range
  84885. * @param max defines the color remap maximal range
  84886. * @returns the current particle system
  84887. */
  84888. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84889. /**
  84890. * Remove a specific color remap gradient
  84891. * @param gradient defines the gradient to remove
  84892. * @returns the current particle system
  84893. */
  84894. removeColorRemapGradient(gradient: number): IParticleSystem;
  84895. /**
  84896. * Adds a new alpha remap gradient
  84897. * @param gradient defines the gradient to use (between 0 and 1)
  84898. * @param min defines the alpha remap minimal range
  84899. * @param max defines the alpha remap maximal range
  84900. * @returns the current particle system
  84901. */
  84902. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84903. /**
  84904. * Remove a specific alpha remap gradient
  84905. * @param gradient defines the gradient to remove
  84906. * @returns the current particle system
  84907. */
  84908. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84909. /**
  84910. * Adds a new angular speed gradient
  84911. * @param gradient defines the gradient to use (between 0 and 1)
  84912. * @param factor defines the angular speed to affect to the specified gradient
  84913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84914. * @returns the current particle system
  84915. */
  84916. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84917. /**
  84918. * Remove a specific angular speed gradient
  84919. * @param gradient defines the gradient to remove
  84920. * @returns the current particle system
  84921. */
  84922. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84923. /**
  84924. * Adds a new velocity gradient
  84925. * @param gradient defines the gradient to use (between 0 and 1)
  84926. * @param factor defines the velocity to affect to the specified gradient
  84927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84928. * @returns the current particle system
  84929. */
  84930. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84931. /**
  84932. * Remove a specific velocity gradient
  84933. * @param gradient defines the gradient to remove
  84934. * @returns the current particle system
  84935. */
  84936. removeVelocityGradient(gradient: number): IParticleSystem;
  84937. /**
  84938. * Adds a new limit velocity gradient
  84939. * @param gradient defines the gradient to use (between 0 and 1)
  84940. * @param factor defines the limit velocity value to affect to the specified gradient
  84941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84942. * @returns the current particle system
  84943. */
  84944. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84945. /**
  84946. * Remove a specific limit velocity gradient
  84947. * @param gradient defines the gradient to remove
  84948. * @returns the current particle system
  84949. */
  84950. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84951. /**
  84952. * Adds a new drag gradient
  84953. * @param gradient defines the gradient to use (between 0 and 1)
  84954. * @param factor defines the drag value to affect to the specified gradient
  84955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84956. * @returns the current particle system
  84957. */
  84958. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84959. /**
  84960. * Remove a specific drag gradient
  84961. * @param gradient defines the gradient to remove
  84962. * @returns the current particle system
  84963. */
  84964. removeDragGradient(gradient: number): IParticleSystem;
  84965. /**
  84966. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84967. * @param gradient defines the gradient to use (between 0 and 1)
  84968. * @param factor defines the emit rate value to affect to the specified gradient
  84969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84970. * @returns the current particle system
  84971. */
  84972. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84973. /**
  84974. * Remove a specific emit rate gradient
  84975. * @param gradient defines the gradient to remove
  84976. * @returns the current particle system
  84977. */
  84978. removeEmitRateGradient(gradient: number): IParticleSystem;
  84979. /**
  84980. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84981. * @param gradient defines the gradient to use (between 0 and 1)
  84982. * @param factor defines the start size value to affect to the specified gradient
  84983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84984. * @returns the current particle system
  84985. */
  84986. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84987. /**
  84988. * Remove a specific start size gradient
  84989. * @param gradient defines the gradient to remove
  84990. * @returns the current particle system
  84991. */
  84992. removeStartSizeGradient(gradient: number): IParticleSystem;
  84993. private _createRampGradientTexture;
  84994. /**
  84995. * Gets the current list of ramp gradients.
  84996. * You must use addRampGradient and removeRampGradient to udpate this list
  84997. * @returns the list of ramp gradients
  84998. */
  84999. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85000. /**
  85001. * Adds a new ramp gradient used to remap particle colors
  85002. * @param gradient defines the gradient to use (between 0 and 1)
  85003. * @param color defines the color to affect to the specified gradient
  85004. * @returns the current particle system
  85005. */
  85006. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85007. /**
  85008. * Remove a specific ramp gradient
  85009. * @param gradient defines the gradient to remove
  85010. * @returns the current particle system
  85011. */
  85012. removeRampGradient(gradient: number): ParticleSystem;
  85013. /**
  85014. * Adds a new color gradient
  85015. * @param gradient defines the gradient to use (between 0 and 1)
  85016. * @param color1 defines the color to affect to the specified gradient
  85017. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85018. * @returns this particle system
  85019. */
  85020. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85021. /**
  85022. * Remove a specific color gradient
  85023. * @param gradient defines the gradient to remove
  85024. * @returns this particle system
  85025. */
  85026. removeColorGradient(gradient: number): IParticleSystem;
  85027. private _fetchR;
  85028. protected _reset(): void;
  85029. private _resetEffect;
  85030. private _createVertexBuffers;
  85031. private _createIndexBuffer;
  85032. /**
  85033. * Gets the maximum number of particles active at the same time.
  85034. * @returns The max number of active particles.
  85035. */
  85036. getCapacity(): number;
  85037. /**
  85038. * Gets whether there are still active particles in the system.
  85039. * @returns True if it is alive, otherwise false.
  85040. */
  85041. isAlive(): boolean;
  85042. /**
  85043. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85044. * @returns True if it has been started, otherwise false.
  85045. */
  85046. isStarted(): boolean;
  85047. private _prepareSubEmitterInternalArray;
  85048. /**
  85049. * Starts the particle system and begins to emit
  85050. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85051. */
  85052. start(delay?: number): void;
  85053. /**
  85054. * Stops the particle system.
  85055. * @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.
  85056. */
  85057. stop(stopSubEmitters?: boolean): void;
  85058. /**
  85059. * Remove all active particles
  85060. */
  85061. reset(): void;
  85062. /**
  85063. * @hidden (for internal use only)
  85064. */
  85065. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85066. /**
  85067. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85068. * Its lifetime will start back at 0.
  85069. */
  85070. recycleParticle: (particle: Particle) => void;
  85071. private _stopSubEmitters;
  85072. private _createParticle;
  85073. private _removeFromRoot;
  85074. private _emitFromParticle;
  85075. private _update;
  85076. /** @hidden */
  85077. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85078. /** @hidden */
  85079. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85080. /** @hidden */
  85081. private _getEffect;
  85082. /**
  85083. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85084. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85085. */
  85086. animate(preWarmOnly?: boolean): void;
  85087. private _appendParticleVertices;
  85088. /**
  85089. * Rebuilds the particle system.
  85090. */
  85091. rebuild(): void;
  85092. /**
  85093. * Is this system ready to be used/rendered
  85094. * @return true if the system is ready
  85095. */
  85096. isReady(): boolean;
  85097. private _render;
  85098. /**
  85099. * Renders the particle system in its current state.
  85100. * @returns the current number of particles
  85101. */
  85102. render(): number;
  85103. /**
  85104. * Disposes the particle system and free the associated resources
  85105. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85106. */
  85107. dispose(disposeTexture?: boolean): void;
  85108. /**
  85109. * Clones the particle system.
  85110. * @param name The name of the cloned object
  85111. * @param newEmitter The new emitter to use
  85112. * @returns the cloned particle system
  85113. */
  85114. clone(name: string, newEmitter: any): ParticleSystem;
  85115. /**
  85116. * Serializes the particle system to a JSON object.
  85117. * @returns the JSON object
  85118. */
  85119. serialize(): any;
  85120. /** @hidden */
  85121. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85122. /** @hidden */
  85123. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85124. /**
  85125. * Parses a JSON object to create a particle system.
  85126. * @param parsedParticleSystem The JSON object to parse
  85127. * @param scene The scene to create the particle system in
  85128. * @param rootUrl The root url to use to load external dependencies like texture
  85129. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85130. * @returns the Parsed particle system
  85131. */
  85132. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85133. }
  85134. }
  85135. declare module BABYLON {
  85136. /**
  85137. * A particle represents one of the element emitted by a particle system.
  85138. * This is mainly define by its coordinates, direction, velocity and age.
  85139. */
  85140. export class Particle {
  85141. /**
  85142. * The particle system the particle belongs to.
  85143. */
  85144. particleSystem: ParticleSystem;
  85145. private static _Count;
  85146. /**
  85147. * Unique ID of the particle
  85148. */
  85149. id: number;
  85150. /**
  85151. * The world position of the particle in the scene.
  85152. */
  85153. position: Vector3;
  85154. /**
  85155. * The world direction of the particle in the scene.
  85156. */
  85157. direction: Vector3;
  85158. /**
  85159. * The color of the particle.
  85160. */
  85161. color: Color4;
  85162. /**
  85163. * The color change of the particle per step.
  85164. */
  85165. colorStep: Color4;
  85166. /**
  85167. * Defines how long will the life of the particle be.
  85168. */
  85169. lifeTime: number;
  85170. /**
  85171. * The current age of the particle.
  85172. */
  85173. age: number;
  85174. /**
  85175. * The current size of the particle.
  85176. */
  85177. size: number;
  85178. /**
  85179. * The current scale of the particle.
  85180. */
  85181. scale: Vector2;
  85182. /**
  85183. * The current angle of the particle.
  85184. */
  85185. angle: number;
  85186. /**
  85187. * Defines how fast is the angle changing.
  85188. */
  85189. angularSpeed: number;
  85190. /**
  85191. * Defines the cell index used by the particle to be rendered from a sprite.
  85192. */
  85193. cellIndex: number;
  85194. /**
  85195. * The information required to support color remapping
  85196. */
  85197. remapData: Vector4;
  85198. /** @hidden */
  85199. _randomCellOffset?: number;
  85200. /** @hidden */
  85201. _initialDirection: Nullable<Vector3>;
  85202. /** @hidden */
  85203. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85204. /** @hidden */
  85205. _initialStartSpriteCellID: number;
  85206. /** @hidden */
  85207. _initialEndSpriteCellID: number;
  85208. /** @hidden */
  85209. _currentColorGradient: Nullable<ColorGradient>;
  85210. /** @hidden */
  85211. _currentColor1: Color4;
  85212. /** @hidden */
  85213. _currentColor2: Color4;
  85214. /** @hidden */
  85215. _currentSizeGradient: Nullable<FactorGradient>;
  85216. /** @hidden */
  85217. _currentSize1: number;
  85218. /** @hidden */
  85219. _currentSize2: number;
  85220. /** @hidden */
  85221. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85222. /** @hidden */
  85223. _currentAngularSpeed1: number;
  85224. /** @hidden */
  85225. _currentAngularSpeed2: number;
  85226. /** @hidden */
  85227. _currentVelocityGradient: Nullable<FactorGradient>;
  85228. /** @hidden */
  85229. _currentVelocity1: number;
  85230. /** @hidden */
  85231. _currentVelocity2: number;
  85232. /** @hidden */
  85233. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85234. /** @hidden */
  85235. _currentLimitVelocity1: number;
  85236. /** @hidden */
  85237. _currentLimitVelocity2: number;
  85238. /** @hidden */
  85239. _currentDragGradient: Nullable<FactorGradient>;
  85240. /** @hidden */
  85241. _currentDrag1: number;
  85242. /** @hidden */
  85243. _currentDrag2: number;
  85244. /** @hidden */
  85245. _randomNoiseCoordinates1: Vector3;
  85246. /** @hidden */
  85247. _randomNoiseCoordinates2: Vector3;
  85248. /**
  85249. * Creates a new instance Particle
  85250. * @param particleSystem the particle system the particle belongs to
  85251. */
  85252. constructor(
  85253. /**
  85254. * The particle system the particle belongs to.
  85255. */
  85256. particleSystem: ParticleSystem);
  85257. private updateCellInfoFromSystem;
  85258. /**
  85259. * Defines how the sprite cell index is updated for the particle
  85260. */
  85261. updateCellIndex(): void;
  85262. /** @hidden */
  85263. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85264. /** @hidden */
  85265. _inheritParticleInfoToSubEmitters(): void;
  85266. /** @hidden */
  85267. _reset(): void;
  85268. /**
  85269. * Copy the properties of particle to another one.
  85270. * @param other the particle to copy the information to.
  85271. */
  85272. copyTo(other: Particle): void;
  85273. }
  85274. }
  85275. declare module BABYLON {
  85276. /**
  85277. * Particle emitter represents a volume emitting particles.
  85278. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85279. */
  85280. export interface IParticleEmitterType {
  85281. /**
  85282. * Called by the particle System when the direction is computed for the created particle.
  85283. * @param worldMatrix is the world matrix of the particle system
  85284. * @param directionToUpdate is the direction vector to update with the result
  85285. * @param particle is the particle we are computed the direction for
  85286. */
  85287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85288. /**
  85289. * Called by the particle System when the position is computed for the created particle.
  85290. * @param worldMatrix is the world matrix of the particle system
  85291. * @param positionToUpdate is the position vector to update with the result
  85292. * @param particle is the particle we are computed the position for
  85293. */
  85294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85295. /**
  85296. * Clones the current emitter and returns a copy of it
  85297. * @returns the new emitter
  85298. */
  85299. clone(): IParticleEmitterType;
  85300. /**
  85301. * Called by the GPUParticleSystem to setup the update shader
  85302. * @param effect defines the update shader
  85303. */
  85304. applyToShader(effect: Effect): void;
  85305. /**
  85306. * Returns a string to use to update the GPU particles update shader
  85307. * @returns the effect defines string
  85308. */
  85309. getEffectDefines(): string;
  85310. /**
  85311. * Returns a string representing the class name
  85312. * @returns a string containing the class name
  85313. */
  85314. getClassName(): string;
  85315. /**
  85316. * Serializes the particle system to a JSON object.
  85317. * @returns the JSON object
  85318. */
  85319. serialize(): any;
  85320. /**
  85321. * Parse properties from a JSON object
  85322. * @param serializationObject defines the JSON object
  85323. * @param scene defines the hosting scene
  85324. */
  85325. parse(serializationObject: any, scene: Scene): void;
  85326. }
  85327. }
  85328. declare module BABYLON {
  85329. /**
  85330. * Particle emitter emitting particles from the inside of a box.
  85331. * It emits the particles randomly between 2 given directions.
  85332. */
  85333. export class BoxParticleEmitter implements IParticleEmitterType {
  85334. /**
  85335. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85336. */
  85337. direction1: Vector3;
  85338. /**
  85339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85340. */
  85341. direction2: Vector3;
  85342. /**
  85343. * 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.
  85344. */
  85345. minEmitBox: Vector3;
  85346. /**
  85347. * 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.
  85348. */
  85349. maxEmitBox: Vector3;
  85350. /**
  85351. * Creates a new instance BoxParticleEmitter
  85352. */
  85353. constructor();
  85354. /**
  85355. * Called by the particle System when the direction is computed for the created particle.
  85356. * @param worldMatrix is the world matrix of the particle system
  85357. * @param directionToUpdate is the direction vector to update with the result
  85358. * @param particle is the particle we are computed the direction for
  85359. */
  85360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85361. /**
  85362. * Called by the particle System when the position is computed for the created particle.
  85363. * @param worldMatrix is the world matrix of the particle system
  85364. * @param positionToUpdate is the position vector to update with the result
  85365. * @param particle is the particle we are computed the position for
  85366. */
  85367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85368. /**
  85369. * Clones the current emitter and returns a copy of it
  85370. * @returns the new emitter
  85371. */
  85372. clone(): BoxParticleEmitter;
  85373. /**
  85374. * Called by the GPUParticleSystem to setup the update shader
  85375. * @param effect defines the update shader
  85376. */
  85377. applyToShader(effect: Effect): void;
  85378. /**
  85379. * Returns a string to use to update the GPU particles update shader
  85380. * @returns a string containng the defines string
  85381. */
  85382. getEffectDefines(): string;
  85383. /**
  85384. * Returns the string "BoxParticleEmitter"
  85385. * @returns a string containing the class name
  85386. */
  85387. getClassName(): string;
  85388. /**
  85389. * Serializes the particle system to a JSON object.
  85390. * @returns the JSON object
  85391. */
  85392. serialize(): any;
  85393. /**
  85394. * Parse properties from a JSON object
  85395. * @param serializationObject defines the JSON object
  85396. */
  85397. parse(serializationObject: any): void;
  85398. }
  85399. }
  85400. declare module BABYLON {
  85401. /**
  85402. * Particle emitter emitting particles from the inside of a cone.
  85403. * It emits the particles alongside the cone volume from the base to the particle.
  85404. * The emission direction might be randomized.
  85405. */
  85406. export class ConeParticleEmitter implements IParticleEmitterType {
  85407. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85408. directionRandomizer: number;
  85409. private _radius;
  85410. private _angle;
  85411. private _height;
  85412. /**
  85413. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85414. */
  85415. radiusRange: number;
  85416. /**
  85417. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85418. */
  85419. heightRange: number;
  85420. /**
  85421. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85422. */
  85423. emitFromSpawnPointOnly: boolean;
  85424. /**
  85425. * Gets or sets the radius of the emission cone
  85426. */
  85427. get radius(): number;
  85428. set radius(value: number);
  85429. /**
  85430. * Gets or sets the angle of the emission cone
  85431. */
  85432. get angle(): number;
  85433. set angle(value: number);
  85434. private _buildHeight;
  85435. /**
  85436. * Creates a new instance ConeParticleEmitter
  85437. * @param radius the radius of the emission cone (1 by default)
  85438. * @param angle the cone base angle (PI by default)
  85439. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85440. */
  85441. constructor(radius?: number, angle?: number,
  85442. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85443. directionRandomizer?: number);
  85444. /**
  85445. * Called by the particle System when the direction is computed for the created particle.
  85446. * @param worldMatrix is the world matrix of the particle system
  85447. * @param directionToUpdate is the direction vector to update with the result
  85448. * @param particle is the particle we are computed the direction for
  85449. */
  85450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85451. /**
  85452. * Called by the particle System when the position is computed for the created particle.
  85453. * @param worldMatrix is the world matrix of the particle system
  85454. * @param positionToUpdate is the position vector to update with the result
  85455. * @param particle is the particle we are computed the position for
  85456. */
  85457. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85458. /**
  85459. * Clones the current emitter and returns a copy of it
  85460. * @returns the new emitter
  85461. */
  85462. clone(): ConeParticleEmitter;
  85463. /**
  85464. * Called by the GPUParticleSystem to setup the update shader
  85465. * @param effect defines the update shader
  85466. */
  85467. applyToShader(effect: Effect): void;
  85468. /**
  85469. * Returns a string to use to update the GPU particles update shader
  85470. * @returns a string containng the defines string
  85471. */
  85472. getEffectDefines(): string;
  85473. /**
  85474. * Returns the string "ConeParticleEmitter"
  85475. * @returns a string containing the class name
  85476. */
  85477. getClassName(): string;
  85478. /**
  85479. * Serializes the particle system to a JSON object.
  85480. * @returns the JSON object
  85481. */
  85482. serialize(): any;
  85483. /**
  85484. * Parse properties from a JSON object
  85485. * @param serializationObject defines the JSON object
  85486. */
  85487. parse(serializationObject: any): void;
  85488. }
  85489. }
  85490. declare module BABYLON {
  85491. /**
  85492. * Particle emitter emitting particles from the inside of a cylinder.
  85493. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85494. */
  85495. export class CylinderParticleEmitter implements IParticleEmitterType {
  85496. /**
  85497. * The radius of the emission cylinder.
  85498. */
  85499. radius: number;
  85500. /**
  85501. * The height of the emission cylinder.
  85502. */
  85503. height: number;
  85504. /**
  85505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85506. */
  85507. radiusRange: number;
  85508. /**
  85509. * How much to randomize the particle direction [0-1].
  85510. */
  85511. directionRandomizer: number;
  85512. /**
  85513. * Creates a new instance CylinderParticleEmitter
  85514. * @param radius the radius of the emission cylinder (1 by default)
  85515. * @param height the height of the emission cylinder (1 by default)
  85516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85517. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85518. */
  85519. constructor(
  85520. /**
  85521. * The radius of the emission cylinder.
  85522. */
  85523. radius?: number,
  85524. /**
  85525. * The height of the emission cylinder.
  85526. */
  85527. height?: number,
  85528. /**
  85529. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85530. */
  85531. radiusRange?: number,
  85532. /**
  85533. * How much to randomize the particle direction [0-1].
  85534. */
  85535. directionRandomizer?: number);
  85536. /**
  85537. * Called by the particle System when the direction is computed for the created particle.
  85538. * @param worldMatrix is the world matrix of the particle system
  85539. * @param directionToUpdate is the direction vector to update with the result
  85540. * @param particle is the particle we are computed the direction for
  85541. */
  85542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85543. /**
  85544. * Called by the particle System when the position is computed for the created particle.
  85545. * @param worldMatrix is the world matrix of the particle system
  85546. * @param positionToUpdate is the position vector to update with the result
  85547. * @param particle is the particle we are computed the position for
  85548. */
  85549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85550. /**
  85551. * Clones the current emitter and returns a copy of it
  85552. * @returns the new emitter
  85553. */
  85554. clone(): CylinderParticleEmitter;
  85555. /**
  85556. * Called by the GPUParticleSystem to setup the update shader
  85557. * @param effect defines the update shader
  85558. */
  85559. applyToShader(effect: Effect): void;
  85560. /**
  85561. * Returns a string to use to update the GPU particles update shader
  85562. * @returns a string containng the defines string
  85563. */
  85564. getEffectDefines(): string;
  85565. /**
  85566. * Returns the string "CylinderParticleEmitter"
  85567. * @returns a string containing the class name
  85568. */
  85569. getClassName(): string;
  85570. /**
  85571. * Serializes the particle system to a JSON object.
  85572. * @returns the JSON object
  85573. */
  85574. serialize(): any;
  85575. /**
  85576. * Parse properties from a JSON object
  85577. * @param serializationObject defines the JSON object
  85578. */
  85579. parse(serializationObject: any): void;
  85580. }
  85581. /**
  85582. * Particle emitter emitting particles from the inside of a cylinder.
  85583. * It emits the particles randomly between two vectors.
  85584. */
  85585. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85586. /**
  85587. * The min limit of the emission direction.
  85588. */
  85589. direction1: Vector3;
  85590. /**
  85591. * The max limit of the emission direction.
  85592. */
  85593. direction2: Vector3;
  85594. /**
  85595. * Creates a new instance CylinderDirectedParticleEmitter
  85596. * @param radius the radius of the emission cylinder (1 by default)
  85597. * @param height the height of the emission cylinder (1 by default)
  85598. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85599. * @param direction1 the min limit of the emission direction (up vector by default)
  85600. * @param direction2 the max limit of the emission direction (up vector by default)
  85601. */
  85602. constructor(radius?: number, height?: number, radiusRange?: number,
  85603. /**
  85604. * The min limit of the emission direction.
  85605. */
  85606. direction1?: Vector3,
  85607. /**
  85608. * The max limit of the emission direction.
  85609. */
  85610. direction2?: Vector3);
  85611. /**
  85612. * Called by the particle System when the direction is computed for the created particle.
  85613. * @param worldMatrix is the world matrix of the particle system
  85614. * @param directionToUpdate is the direction vector to update with the result
  85615. * @param particle is the particle we are computed the direction for
  85616. */
  85617. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85618. /**
  85619. * Clones the current emitter and returns a copy of it
  85620. * @returns the new emitter
  85621. */
  85622. clone(): CylinderDirectedParticleEmitter;
  85623. /**
  85624. * Called by the GPUParticleSystem to setup the update shader
  85625. * @param effect defines the update shader
  85626. */
  85627. applyToShader(effect: Effect): void;
  85628. /**
  85629. * Returns a string to use to update the GPU particles update shader
  85630. * @returns a string containng the defines string
  85631. */
  85632. getEffectDefines(): string;
  85633. /**
  85634. * Returns the string "CylinderDirectedParticleEmitter"
  85635. * @returns a string containing the class name
  85636. */
  85637. getClassName(): string;
  85638. /**
  85639. * Serializes the particle system to a JSON object.
  85640. * @returns the JSON object
  85641. */
  85642. serialize(): any;
  85643. /**
  85644. * Parse properties from a JSON object
  85645. * @param serializationObject defines the JSON object
  85646. */
  85647. parse(serializationObject: any): void;
  85648. }
  85649. }
  85650. declare module BABYLON {
  85651. /**
  85652. * Particle emitter emitting particles from the inside of a hemisphere.
  85653. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85654. */
  85655. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85656. /**
  85657. * The radius of the emission hemisphere.
  85658. */
  85659. radius: number;
  85660. /**
  85661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85662. */
  85663. radiusRange: number;
  85664. /**
  85665. * How much to randomize the particle direction [0-1].
  85666. */
  85667. directionRandomizer: number;
  85668. /**
  85669. * Creates a new instance HemisphericParticleEmitter
  85670. * @param radius the radius of the emission hemisphere (1 by default)
  85671. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85672. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85673. */
  85674. constructor(
  85675. /**
  85676. * The radius of the emission hemisphere.
  85677. */
  85678. radius?: number,
  85679. /**
  85680. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85681. */
  85682. radiusRange?: number,
  85683. /**
  85684. * How much to randomize the particle direction [0-1].
  85685. */
  85686. directionRandomizer?: number);
  85687. /**
  85688. * Called by the particle System when the direction is computed for the created particle.
  85689. * @param worldMatrix is the world matrix of the particle system
  85690. * @param directionToUpdate is the direction vector to update with the result
  85691. * @param particle is the particle we are computed the direction for
  85692. */
  85693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85694. /**
  85695. * Called by the particle System when the position is computed for the created particle.
  85696. * @param worldMatrix is the world matrix of the particle system
  85697. * @param positionToUpdate is the position vector to update with the result
  85698. * @param particle is the particle we are computed the position for
  85699. */
  85700. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85701. /**
  85702. * Clones the current emitter and returns a copy of it
  85703. * @returns the new emitter
  85704. */
  85705. clone(): HemisphericParticleEmitter;
  85706. /**
  85707. * Called by the GPUParticleSystem to setup the update shader
  85708. * @param effect defines the update shader
  85709. */
  85710. applyToShader(effect: Effect): void;
  85711. /**
  85712. * Returns a string to use to update the GPU particles update shader
  85713. * @returns a string containng the defines string
  85714. */
  85715. getEffectDefines(): string;
  85716. /**
  85717. * Returns the string "HemisphericParticleEmitter"
  85718. * @returns a string containing the class name
  85719. */
  85720. getClassName(): string;
  85721. /**
  85722. * Serializes the particle system to a JSON object.
  85723. * @returns the JSON object
  85724. */
  85725. serialize(): any;
  85726. /**
  85727. * Parse properties from a JSON object
  85728. * @param serializationObject defines the JSON object
  85729. */
  85730. parse(serializationObject: any): void;
  85731. }
  85732. }
  85733. declare module BABYLON {
  85734. /**
  85735. * Particle emitter emitting particles from a point.
  85736. * It emits the particles randomly between 2 given directions.
  85737. */
  85738. export class PointParticleEmitter implements IParticleEmitterType {
  85739. /**
  85740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85741. */
  85742. direction1: Vector3;
  85743. /**
  85744. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85745. */
  85746. direction2: Vector3;
  85747. /**
  85748. * Creates a new instance PointParticleEmitter
  85749. */
  85750. constructor();
  85751. /**
  85752. * Called by the particle System when the direction is computed for the created particle.
  85753. * @param worldMatrix is the world matrix of the particle system
  85754. * @param directionToUpdate is the direction vector to update with the result
  85755. * @param particle is the particle we are computed the direction for
  85756. */
  85757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85758. /**
  85759. * Called by the particle System when the position is computed for the created particle.
  85760. * @param worldMatrix is the world matrix of the particle system
  85761. * @param positionToUpdate is the position vector to update with the result
  85762. * @param particle is the particle we are computed the position for
  85763. */
  85764. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85765. /**
  85766. * Clones the current emitter and returns a copy of it
  85767. * @returns the new emitter
  85768. */
  85769. clone(): PointParticleEmitter;
  85770. /**
  85771. * Called by the GPUParticleSystem to setup the update shader
  85772. * @param effect defines the update shader
  85773. */
  85774. applyToShader(effect: Effect): void;
  85775. /**
  85776. * Returns a string to use to update the GPU particles update shader
  85777. * @returns a string containng the defines string
  85778. */
  85779. getEffectDefines(): string;
  85780. /**
  85781. * Returns the string "PointParticleEmitter"
  85782. * @returns a string containing the class name
  85783. */
  85784. getClassName(): string;
  85785. /**
  85786. * Serializes the particle system to a JSON object.
  85787. * @returns the JSON object
  85788. */
  85789. serialize(): any;
  85790. /**
  85791. * Parse properties from a JSON object
  85792. * @param serializationObject defines the JSON object
  85793. */
  85794. parse(serializationObject: any): void;
  85795. }
  85796. }
  85797. declare module BABYLON {
  85798. /**
  85799. * Particle emitter emitting particles from the inside of a sphere.
  85800. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85801. */
  85802. export class SphereParticleEmitter implements IParticleEmitterType {
  85803. /**
  85804. * The radius of the emission sphere.
  85805. */
  85806. radius: number;
  85807. /**
  85808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85809. */
  85810. radiusRange: number;
  85811. /**
  85812. * How much to randomize the particle direction [0-1].
  85813. */
  85814. directionRandomizer: number;
  85815. /**
  85816. * Creates a new instance SphereParticleEmitter
  85817. * @param radius the radius of the emission sphere (1 by default)
  85818. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85819. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85820. */
  85821. constructor(
  85822. /**
  85823. * The radius of the emission sphere.
  85824. */
  85825. radius?: number,
  85826. /**
  85827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85828. */
  85829. radiusRange?: number,
  85830. /**
  85831. * How much to randomize the particle direction [0-1].
  85832. */
  85833. directionRandomizer?: number);
  85834. /**
  85835. * Called by the particle System when the direction is computed for the created particle.
  85836. * @param worldMatrix is the world matrix of the particle system
  85837. * @param directionToUpdate is the direction vector to update with the result
  85838. * @param particle is the particle we are computed the direction for
  85839. */
  85840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85841. /**
  85842. * Called by the particle System when the position is computed for the created particle.
  85843. * @param worldMatrix is the world matrix of the particle system
  85844. * @param positionToUpdate is the position vector to update with the result
  85845. * @param particle is the particle we are computed the position for
  85846. */
  85847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85848. /**
  85849. * Clones the current emitter and returns a copy of it
  85850. * @returns the new emitter
  85851. */
  85852. clone(): SphereParticleEmitter;
  85853. /**
  85854. * Called by the GPUParticleSystem to setup the update shader
  85855. * @param effect defines the update shader
  85856. */
  85857. applyToShader(effect: Effect): void;
  85858. /**
  85859. * Returns a string to use to update the GPU particles update shader
  85860. * @returns a string containng the defines string
  85861. */
  85862. getEffectDefines(): string;
  85863. /**
  85864. * Returns the string "SphereParticleEmitter"
  85865. * @returns a string containing the class name
  85866. */
  85867. getClassName(): string;
  85868. /**
  85869. * Serializes the particle system to a JSON object.
  85870. * @returns the JSON object
  85871. */
  85872. serialize(): any;
  85873. /**
  85874. * Parse properties from a JSON object
  85875. * @param serializationObject defines the JSON object
  85876. */
  85877. parse(serializationObject: any): void;
  85878. }
  85879. /**
  85880. * Particle emitter emitting particles from the inside of a sphere.
  85881. * It emits the particles randomly between two vectors.
  85882. */
  85883. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85884. /**
  85885. * The min limit of the emission direction.
  85886. */
  85887. direction1: Vector3;
  85888. /**
  85889. * The max limit of the emission direction.
  85890. */
  85891. direction2: Vector3;
  85892. /**
  85893. * Creates a new instance SphereDirectedParticleEmitter
  85894. * @param radius the radius of the emission sphere (1 by default)
  85895. * @param direction1 the min limit of the emission direction (up vector by default)
  85896. * @param direction2 the max limit of the emission direction (up vector by default)
  85897. */
  85898. constructor(radius?: number,
  85899. /**
  85900. * The min limit of the emission direction.
  85901. */
  85902. direction1?: Vector3,
  85903. /**
  85904. * The max limit of the emission direction.
  85905. */
  85906. direction2?: Vector3);
  85907. /**
  85908. * Called by the particle System when the direction is computed for the created particle.
  85909. * @param worldMatrix is the world matrix of the particle system
  85910. * @param directionToUpdate is the direction vector to update with the result
  85911. * @param particle is the particle we are computed the direction for
  85912. */
  85913. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85914. /**
  85915. * Clones the current emitter and returns a copy of it
  85916. * @returns the new emitter
  85917. */
  85918. clone(): SphereDirectedParticleEmitter;
  85919. /**
  85920. * Called by the GPUParticleSystem to setup the update shader
  85921. * @param effect defines the update shader
  85922. */
  85923. applyToShader(effect: Effect): void;
  85924. /**
  85925. * Returns a string to use to update the GPU particles update shader
  85926. * @returns a string containng the defines string
  85927. */
  85928. getEffectDefines(): string;
  85929. /**
  85930. * Returns the string "SphereDirectedParticleEmitter"
  85931. * @returns a string containing the class name
  85932. */
  85933. getClassName(): string;
  85934. /**
  85935. * Serializes the particle system to a JSON object.
  85936. * @returns the JSON object
  85937. */
  85938. serialize(): any;
  85939. /**
  85940. * Parse properties from a JSON object
  85941. * @param serializationObject defines the JSON object
  85942. */
  85943. parse(serializationObject: any): void;
  85944. }
  85945. }
  85946. declare module BABYLON {
  85947. /**
  85948. * Particle emitter emitting particles from a custom list of positions.
  85949. */
  85950. export class CustomParticleEmitter implements IParticleEmitterType {
  85951. /**
  85952. * Gets or sets the position generator that will create the inital position of each particle.
  85953. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85954. */
  85955. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  85956. /**
  85957. * Gets or sets the destination generator that will create the final destination of each particle.
  85958. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85959. */
  85960. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  85961. /**
  85962. * Creates a new instance CustomParticleEmitter
  85963. */
  85964. constructor();
  85965. /**
  85966. * Called by the particle System when the direction is computed for the created particle.
  85967. * @param worldMatrix is the world matrix of the particle system
  85968. * @param directionToUpdate is the direction vector to update with the result
  85969. * @param particle is the particle we are computed the direction for
  85970. */
  85971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85972. /**
  85973. * Called by the particle System when the position is computed for the created particle.
  85974. * @param worldMatrix is the world matrix of the particle system
  85975. * @param positionToUpdate is the position vector to update with the result
  85976. * @param particle is the particle we are computed the position for
  85977. */
  85978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85979. /**
  85980. * Clones the current emitter and returns a copy of it
  85981. * @returns the new emitter
  85982. */
  85983. clone(): CustomParticleEmitter;
  85984. /**
  85985. * Called by the GPUParticleSystem to setup the update shader
  85986. * @param effect defines the update shader
  85987. */
  85988. applyToShader(effect: Effect): void;
  85989. /**
  85990. * Returns a string to use to update the GPU particles update shader
  85991. * @returns a string containng the defines string
  85992. */
  85993. getEffectDefines(): string;
  85994. /**
  85995. * Returns the string "PointParticleEmitter"
  85996. * @returns a string containing the class name
  85997. */
  85998. getClassName(): string;
  85999. /**
  86000. * Serializes the particle system to a JSON object.
  86001. * @returns the JSON object
  86002. */
  86003. serialize(): any;
  86004. /**
  86005. * Parse properties from a JSON object
  86006. * @param serializationObject defines the JSON object
  86007. */
  86008. parse(serializationObject: any): void;
  86009. }
  86010. }
  86011. declare module BABYLON {
  86012. /**
  86013. * Particle emitter emitting particles from the inside of a box.
  86014. * It emits the particles randomly between 2 given directions.
  86015. */
  86016. export class MeshParticleEmitter implements IParticleEmitterType {
  86017. /** Defines the mesh to use as source */
  86018. mesh?: AbstractMesh | undefined;
  86019. private _indices;
  86020. private _positions;
  86021. private _normals;
  86022. private _storedNormal;
  86023. /**
  86024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86025. */
  86026. direction1: Vector3;
  86027. /**
  86028. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86029. */
  86030. direction2: Vector3;
  86031. /**
  86032. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86033. */
  86034. useMeshNormalsForDirection: boolean;
  86035. /**
  86036. * Creates a new instance MeshParticleEmitter
  86037. * @param mesh defines the mesh to use as source
  86038. */
  86039. constructor(
  86040. /** Defines the mesh to use as source */
  86041. mesh?: AbstractMesh | undefined);
  86042. /**
  86043. * Called by the particle System when the direction is computed for the created particle.
  86044. * @param worldMatrix is the world matrix of the particle system
  86045. * @param directionToUpdate is the direction vector to update with the result
  86046. * @param particle is the particle we are computed the direction for
  86047. */
  86048. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86049. /**
  86050. * Called by the particle System when the position is computed for the created particle.
  86051. * @param worldMatrix is the world matrix of the particle system
  86052. * @param positionToUpdate is the position vector to update with the result
  86053. * @param particle is the particle we are computed the position for
  86054. */
  86055. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86056. /**
  86057. * Clones the current emitter and returns a copy of it
  86058. * @returns the new emitter
  86059. */
  86060. clone(): MeshParticleEmitter;
  86061. /**
  86062. * Called by the GPUParticleSystem to setup the update shader
  86063. * @param effect defines the update shader
  86064. */
  86065. applyToShader(effect: Effect): void;
  86066. /**
  86067. * Returns a string to use to update the GPU particles update shader
  86068. * @returns a string containng the defines string
  86069. */
  86070. getEffectDefines(): string;
  86071. /**
  86072. * Returns the string "BoxParticleEmitter"
  86073. * @returns a string containing the class name
  86074. */
  86075. getClassName(): string;
  86076. /**
  86077. * Serializes the particle system to a JSON object.
  86078. * @returns the JSON object
  86079. */
  86080. serialize(): any;
  86081. /**
  86082. * Parse properties from a JSON object
  86083. * @param serializationObject defines the JSON object
  86084. * @param scene defines the hosting scene
  86085. */
  86086. parse(serializationObject: any, scene: Scene): void;
  86087. }
  86088. }
  86089. declare module BABYLON {
  86090. /**
  86091. * Interface representing a particle system in Babylon.js.
  86092. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86093. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86094. */
  86095. export interface IParticleSystem {
  86096. /**
  86097. * List of animations used by the particle system.
  86098. */
  86099. animations: Animation[];
  86100. /**
  86101. * The id of the Particle system.
  86102. */
  86103. id: string;
  86104. /**
  86105. * The name of the Particle system.
  86106. */
  86107. name: string;
  86108. /**
  86109. * The emitter represents the Mesh or position we are attaching the particle system to.
  86110. */
  86111. emitter: Nullable<AbstractMesh | Vector3>;
  86112. /**
  86113. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86114. */
  86115. isBillboardBased: boolean;
  86116. /**
  86117. * The rendering group used by the Particle system to chose when to render.
  86118. */
  86119. renderingGroupId: number;
  86120. /**
  86121. * The layer mask we are rendering the particles through.
  86122. */
  86123. layerMask: number;
  86124. /**
  86125. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86126. */
  86127. updateSpeed: number;
  86128. /**
  86129. * The amount of time the particle system is running (depends of the overall update speed).
  86130. */
  86131. targetStopDuration: number;
  86132. /**
  86133. * The texture used to render each particle. (this can be a spritesheet)
  86134. */
  86135. particleTexture: Nullable<Texture>;
  86136. /**
  86137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86138. */
  86139. blendMode: number;
  86140. /**
  86141. * Minimum life time of emitting particles.
  86142. */
  86143. minLifeTime: number;
  86144. /**
  86145. * Maximum life time of emitting particles.
  86146. */
  86147. maxLifeTime: number;
  86148. /**
  86149. * Minimum Size of emitting particles.
  86150. */
  86151. minSize: number;
  86152. /**
  86153. * Maximum Size of emitting particles.
  86154. */
  86155. maxSize: number;
  86156. /**
  86157. * Minimum scale of emitting particles on X axis.
  86158. */
  86159. minScaleX: number;
  86160. /**
  86161. * Maximum scale of emitting particles on X axis.
  86162. */
  86163. maxScaleX: number;
  86164. /**
  86165. * Minimum scale of emitting particles on Y axis.
  86166. */
  86167. minScaleY: number;
  86168. /**
  86169. * Maximum scale of emitting particles on Y axis.
  86170. */
  86171. maxScaleY: number;
  86172. /**
  86173. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86174. */
  86175. color1: Color4;
  86176. /**
  86177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86178. */
  86179. color2: Color4;
  86180. /**
  86181. * Color the particle will have at the end of its lifetime.
  86182. */
  86183. colorDead: Color4;
  86184. /**
  86185. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86186. */
  86187. emitRate: number;
  86188. /**
  86189. * You can use gravity if you want to give an orientation to your particles.
  86190. */
  86191. gravity: Vector3;
  86192. /**
  86193. * Minimum power of emitting particles.
  86194. */
  86195. minEmitPower: number;
  86196. /**
  86197. * Maximum power of emitting particles.
  86198. */
  86199. maxEmitPower: number;
  86200. /**
  86201. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86202. */
  86203. minAngularSpeed: number;
  86204. /**
  86205. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86206. */
  86207. maxAngularSpeed: number;
  86208. /**
  86209. * Gets or sets the minimal initial rotation in radians.
  86210. */
  86211. minInitialRotation: number;
  86212. /**
  86213. * Gets or sets the maximal initial rotation in radians.
  86214. */
  86215. maxInitialRotation: number;
  86216. /**
  86217. * The particle emitter type defines the emitter used by the particle system.
  86218. * It can be for example box, sphere, or cone...
  86219. */
  86220. particleEmitterType: Nullable<IParticleEmitterType>;
  86221. /**
  86222. * Defines the delay in milliseconds before starting the system (0 by default)
  86223. */
  86224. startDelay: number;
  86225. /**
  86226. * 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
  86227. */
  86228. preWarmCycles: number;
  86229. /**
  86230. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86231. */
  86232. preWarmStepOffset: number;
  86233. /**
  86234. * 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)
  86235. */
  86236. spriteCellChangeSpeed: number;
  86237. /**
  86238. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86239. */
  86240. startSpriteCellID: number;
  86241. /**
  86242. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86243. */
  86244. endSpriteCellID: number;
  86245. /**
  86246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86247. */
  86248. spriteCellWidth: number;
  86249. /**
  86250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86251. */
  86252. spriteCellHeight: number;
  86253. /**
  86254. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86255. */
  86256. spriteRandomStartCell: boolean;
  86257. /**
  86258. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86259. */
  86260. isAnimationSheetEnabled: boolean;
  86261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86262. translationPivot: Vector2;
  86263. /**
  86264. * Gets or sets a texture used to add random noise to particle positions
  86265. */
  86266. noiseTexture: Nullable<BaseTexture>;
  86267. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86268. noiseStrength: Vector3;
  86269. /**
  86270. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86271. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86272. */
  86273. billboardMode: number;
  86274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86275. limitVelocityDamping: number;
  86276. /**
  86277. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86278. */
  86279. beginAnimationOnStart: boolean;
  86280. /**
  86281. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86282. */
  86283. beginAnimationFrom: number;
  86284. /**
  86285. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86286. */
  86287. beginAnimationTo: number;
  86288. /**
  86289. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86290. */
  86291. beginAnimationLoop: boolean;
  86292. /**
  86293. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86294. */
  86295. disposeOnStop: boolean;
  86296. /**
  86297. * Gets the maximum number of particles active at the same time.
  86298. * @returns The max number of active particles.
  86299. */
  86300. getCapacity(): number;
  86301. /**
  86302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86303. * @returns True if it has been started, otherwise false.
  86304. */
  86305. isStarted(): boolean;
  86306. /**
  86307. * Animates the particle system for this frame.
  86308. */
  86309. animate(): void;
  86310. /**
  86311. * Renders the particle system in its current state.
  86312. * @returns the current number of particles
  86313. */
  86314. render(): number;
  86315. /**
  86316. * Dispose the particle system and frees its associated resources.
  86317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86318. */
  86319. dispose(disposeTexture?: boolean): void;
  86320. /**
  86321. * Clones the particle system.
  86322. * @param name The name of the cloned object
  86323. * @param newEmitter The new emitter to use
  86324. * @returns the cloned particle system
  86325. */
  86326. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86327. /**
  86328. * Serializes the particle system to a JSON object.
  86329. * @returns the JSON object
  86330. */
  86331. serialize(): any;
  86332. /**
  86333. * Rebuild the particle system
  86334. */
  86335. rebuild(): void;
  86336. /**
  86337. * Starts the particle system and begins to emit
  86338. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86339. */
  86340. start(delay?: number): void;
  86341. /**
  86342. * Stops the particle system.
  86343. */
  86344. stop(): void;
  86345. /**
  86346. * Remove all active particles
  86347. */
  86348. reset(): void;
  86349. /**
  86350. * Is this system ready to be used/rendered
  86351. * @return true if the system is ready
  86352. */
  86353. isReady(): boolean;
  86354. /**
  86355. * Adds a new color gradient
  86356. * @param gradient defines the gradient to use (between 0 and 1)
  86357. * @param color1 defines the color to affect to the specified gradient
  86358. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86359. * @returns the current particle system
  86360. */
  86361. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86362. /**
  86363. * Remove a specific color gradient
  86364. * @param gradient defines the gradient to remove
  86365. * @returns the current particle system
  86366. */
  86367. removeColorGradient(gradient: number): IParticleSystem;
  86368. /**
  86369. * Adds a new size gradient
  86370. * @param gradient defines the gradient to use (between 0 and 1)
  86371. * @param factor defines the size factor to affect to the specified gradient
  86372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86373. * @returns the current particle system
  86374. */
  86375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86376. /**
  86377. * Remove a specific size gradient
  86378. * @param gradient defines the gradient to remove
  86379. * @returns the current particle system
  86380. */
  86381. removeSizeGradient(gradient: number): IParticleSystem;
  86382. /**
  86383. * Gets the current list of color gradients.
  86384. * You must use addColorGradient and removeColorGradient to udpate this list
  86385. * @returns the list of color gradients
  86386. */
  86387. getColorGradients(): Nullable<Array<ColorGradient>>;
  86388. /**
  86389. * Gets the current list of size gradients.
  86390. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86391. * @returns the list of size gradients
  86392. */
  86393. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86394. /**
  86395. * Gets the current list of angular speed gradients.
  86396. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86397. * @returns the list of angular speed gradients
  86398. */
  86399. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86400. /**
  86401. * Adds a new angular speed gradient
  86402. * @param gradient defines the gradient to use (between 0 and 1)
  86403. * @param factor defines the angular speed to affect to the specified gradient
  86404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86405. * @returns the current particle system
  86406. */
  86407. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86408. /**
  86409. * Remove a specific angular speed gradient
  86410. * @param gradient defines the gradient to remove
  86411. * @returns the current particle system
  86412. */
  86413. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86414. /**
  86415. * Gets the current list of velocity gradients.
  86416. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86417. * @returns the list of velocity gradients
  86418. */
  86419. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86420. /**
  86421. * Adds a new velocity gradient
  86422. * @param gradient defines the gradient to use (between 0 and 1)
  86423. * @param factor defines the velocity to affect to the specified gradient
  86424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86425. * @returns the current particle system
  86426. */
  86427. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86428. /**
  86429. * Remove a specific velocity gradient
  86430. * @param gradient defines the gradient to remove
  86431. * @returns the current particle system
  86432. */
  86433. removeVelocityGradient(gradient: number): IParticleSystem;
  86434. /**
  86435. * Gets the current list of limit velocity gradients.
  86436. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86437. * @returns the list of limit velocity gradients
  86438. */
  86439. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86440. /**
  86441. * Adds a new limit velocity gradient
  86442. * @param gradient defines the gradient to use (between 0 and 1)
  86443. * @param factor defines the limit velocity to affect to the specified gradient
  86444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86445. * @returns the current particle system
  86446. */
  86447. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86448. /**
  86449. * Remove a specific limit velocity gradient
  86450. * @param gradient defines the gradient to remove
  86451. * @returns the current particle system
  86452. */
  86453. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86454. /**
  86455. * Adds a new drag gradient
  86456. * @param gradient defines the gradient to use (between 0 and 1)
  86457. * @param factor defines the drag to affect to the specified gradient
  86458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86459. * @returns the current particle system
  86460. */
  86461. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86462. /**
  86463. * Remove a specific drag gradient
  86464. * @param gradient defines the gradient to remove
  86465. * @returns the current particle system
  86466. */
  86467. removeDragGradient(gradient: number): IParticleSystem;
  86468. /**
  86469. * Gets the current list of drag gradients.
  86470. * You must use addDragGradient and removeDragGradient to udpate this list
  86471. * @returns the list of drag gradients
  86472. */
  86473. getDragGradients(): Nullable<Array<FactorGradient>>;
  86474. /**
  86475. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86476. * @param gradient defines the gradient to use (between 0 and 1)
  86477. * @param factor defines the emit rate to affect to the specified gradient
  86478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86479. * @returns the current particle system
  86480. */
  86481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86482. /**
  86483. * Remove a specific emit rate gradient
  86484. * @param gradient defines the gradient to remove
  86485. * @returns the current particle system
  86486. */
  86487. removeEmitRateGradient(gradient: number): IParticleSystem;
  86488. /**
  86489. * Gets the current list of emit rate gradients.
  86490. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86491. * @returns the list of emit rate gradients
  86492. */
  86493. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86494. /**
  86495. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86496. * @param gradient defines the gradient to use (between 0 and 1)
  86497. * @param factor defines the start size to affect to the specified gradient
  86498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86499. * @returns the current particle system
  86500. */
  86501. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86502. /**
  86503. * Remove a specific start size gradient
  86504. * @param gradient defines the gradient to remove
  86505. * @returns the current particle system
  86506. */
  86507. removeStartSizeGradient(gradient: number): IParticleSystem;
  86508. /**
  86509. * Gets the current list of start size gradients.
  86510. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86511. * @returns the list of start size gradients
  86512. */
  86513. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86514. /**
  86515. * Adds a new life time gradient
  86516. * @param gradient defines the gradient to use (between 0 and 1)
  86517. * @param factor defines the life time factor to affect to the specified gradient
  86518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86519. * @returns the current particle system
  86520. */
  86521. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86522. /**
  86523. * Remove a specific life time gradient
  86524. * @param gradient defines the gradient to remove
  86525. * @returns the current particle system
  86526. */
  86527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86528. /**
  86529. * Gets the current list of life time gradients.
  86530. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86531. * @returns the list of life time gradients
  86532. */
  86533. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86534. /**
  86535. * Gets the current list of color gradients.
  86536. * You must use addColorGradient and removeColorGradient to udpate this list
  86537. * @returns the list of color gradients
  86538. */
  86539. getColorGradients(): Nullable<Array<ColorGradient>>;
  86540. /**
  86541. * Adds a new ramp gradient used to remap particle colors
  86542. * @param gradient defines the gradient to use (between 0 and 1)
  86543. * @param color defines the color to affect to the specified gradient
  86544. * @returns the current particle system
  86545. */
  86546. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86547. /**
  86548. * Gets the current list of ramp gradients.
  86549. * You must use addRampGradient and removeRampGradient to udpate this list
  86550. * @returns the list of ramp gradients
  86551. */
  86552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86553. /** Gets or sets a boolean indicating that ramp gradients must be used
  86554. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86555. */
  86556. useRampGradients: boolean;
  86557. /**
  86558. * Adds a new color remap gradient
  86559. * @param gradient defines the gradient to use (between 0 and 1)
  86560. * @param min defines the color remap minimal range
  86561. * @param max defines the color remap maximal range
  86562. * @returns the current particle system
  86563. */
  86564. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86565. /**
  86566. * Gets the current list of color remap gradients.
  86567. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86568. * @returns the list of color remap gradients
  86569. */
  86570. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86571. /**
  86572. * Adds a new alpha remap gradient
  86573. * @param gradient defines the gradient to use (between 0 and 1)
  86574. * @param min defines the alpha remap minimal range
  86575. * @param max defines the alpha remap maximal range
  86576. * @returns the current particle system
  86577. */
  86578. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86579. /**
  86580. * Gets the current list of alpha remap gradients.
  86581. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86582. * @returns the list of alpha remap gradients
  86583. */
  86584. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86585. /**
  86586. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86589. * @returns the emitter
  86590. */
  86591. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86592. /**
  86593. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86594. * @param radius The radius of the hemisphere to emit from
  86595. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86596. * @returns the emitter
  86597. */
  86598. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86599. /**
  86600. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86601. * @param radius The radius of the sphere to emit from
  86602. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86603. * @returns the emitter
  86604. */
  86605. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86606. /**
  86607. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86608. * @param radius The radius of the sphere to emit from
  86609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86611. * @returns the emitter
  86612. */
  86613. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86614. /**
  86615. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86616. * @param radius The radius of the emission cylinder
  86617. * @param height The height of the emission cylinder
  86618. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86619. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86620. * @returns the emitter
  86621. */
  86622. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86623. /**
  86624. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86625. * @param radius The radius of the cylinder to emit from
  86626. * @param height The height of the emission cylinder
  86627. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86630. * @returns the emitter
  86631. */
  86632. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86633. /**
  86634. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86635. * @param radius The radius of the cone to emit from
  86636. * @param angle The base angle of the cone
  86637. * @returns the emitter
  86638. */
  86639. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86640. /**
  86641. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86644. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86645. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86646. * @returns the emitter
  86647. */
  86648. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86649. /**
  86650. * Get hosting scene
  86651. * @returns the scene
  86652. */
  86653. getScene(): Scene;
  86654. }
  86655. }
  86656. declare module BABYLON {
  86657. /**
  86658. * 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.
  86659. * @see https://doc.babylonjs.com/how_to/transformnode
  86660. */
  86661. export class TransformNode extends Node {
  86662. /**
  86663. * Object will not rotate to face the camera
  86664. */
  86665. static BILLBOARDMODE_NONE: number;
  86666. /**
  86667. * Object will rotate to face the camera but only on the x axis
  86668. */
  86669. static BILLBOARDMODE_X: number;
  86670. /**
  86671. * Object will rotate to face the camera but only on the y axis
  86672. */
  86673. static BILLBOARDMODE_Y: number;
  86674. /**
  86675. * Object will rotate to face the camera but only on the z axis
  86676. */
  86677. static BILLBOARDMODE_Z: number;
  86678. /**
  86679. * Object will rotate to face the camera
  86680. */
  86681. static BILLBOARDMODE_ALL: number;
  86682. /**
  86683. * Object will rotate to face the camera's position instead of orientation
  86684. */
  86685. static BILLBOARDMODE_USE_POSITION: number;
  86686. private _forward;
  86687. private _forwardInverted;
  86688. private _up;
  86689. private _right;
  86690. private _rightInverted;
  86691. private _position;
  86692. private _rotation;
  86693. private _rotationQuaternion;
  86694. protected _scaling: Vector3;
  86695. protected _isDirty: boolean;
  86696. private _transformToBoneReferal;
  86697. private _isAbsoluteSynced;
  86698. private _billboardMode;
  86699. /**
  86700. * Gets or sets the billboard mode. Default is 0.
  86701. *
  86702. * | Value | Type | Description |
  86703. * | --- | --- | --- |
  86704. * | 0 | BILLBOARDMODE_NONE | |
  86705. * | 1 | BILLBOARDMODE_X | |
  86706. * | 2 | BILLBOARDMODE_Y | |
  86707. * | 4 | BILLBOARDMODE_Z | |
  86708. * | 7 | BILLBOARDMODE_ALL | |
  86709. *
  86710. */
  86711. get billboardMode(): number;
  86712. set billboardMode(value: number);
  86713. private _preserveParentRotationForBillboard;
  86714. /**
  86715. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86716. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86717. */
  86718. get preserveParentRotationForBillboard(): boolean;
  86719. set preserveParentRotationForBillboard(value: boolean);
  86720. /**
  86721. * 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
  86722. */
  86723. scalingDeterminant: number;
  86724. private _infiniteDistance;
  86725. /**
  86726. * Gets or sets the distance of the object to max, often used by skybox
  86727. */
  86728. get infiniteDistance(): boolean;
  86729. set infiniteDistance(value: boolean);
  86730. /**
  86731. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86732. * By default the system will update normals to compensate
  86733. */
  86734. ignoreNonUniformScaling: boolean;
  86735. /**
  86736. * 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
  86737. */
  86738. reIntegrateRotationIntoRotationQuaternion: boolean;
  86739. /** @hidden */
  86740. _poseMatrix: Nullable<Matrix>;
  86741. /** @hidden */
  86742. _localMatrix: Matrix;
  86743. private _usePivotMatrix;
  86744. private _absolutePosition;
  86745. private _absoluteScaling;
  86746. private _absoluteRotationQuaternion;
  86747. private _pivotMatrix;
  86748. private _pivotMatrixInverse;
  86749. protected _postMultiplyPivotMatrix: boolean;
  86750. protected _isWorldMatrixFrozen: boolean;
  86751. /** @hidden */
  86752. _indexInSceneTransformNodesArray: number;
  86753. /**
  86754. * An event triggered after the world matrix is updated
  86755. */
  86756. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86757. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86758. /**
  86759. * Gets a string identifying the name of the class
  86760. * @returns "TransformNode" string
  86761. */
  86762. getClassName(): string;
  86763. /**
  86764. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86765. */
  86766. get position(): Vector3;
  86767. set position(newPosition: Vector3);
  86768. /**
  86769. * 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)).
  86770. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86771. */
  86772. get rotation(): Vector3;
  86773. set rotation(newRotation: Vector3);
  86774. /**
  86775. * 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)).
  86776. */
  86777. get scaling(): Vector3;
  86778. set scaling(newScaling: Vector3);
  86779. /**
  86780. * 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).
  86781. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86782. */
  86783. get rotationQuaternion(): Nullable<Quaternion>;
  86784. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86785. /**
  86786. * The forward direction of that transform in world space.
  86787. */
  86788. get forward(): Vector3;
  86789. /**
  86790. * The up direction of that transform in world space.
  86791. */
  86792. get up(): Vector3;
  86793. /**
  86794. * The right direction of that transform in world space.
  86795. */
  86796. get right(): Vector3;
  86797. /**
  86798. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86799. * @param matrix the matrix to copy the pose from
  86800. * @returns this TransformNode.
  86801. */
  86802. updatePoseMatrix(matrix: Matrix): TransformNode;
  86803. /**
  86804. * Returns the mesh Pose matrix.
  86805. * @returns the pose matrix
  86806. */
  86807. getPoseMatrix(): Matrix;
  86808. /** @hidden */
  86809. _isSynchronized(): boolean;
  86810. /** @hidden */
  86811. _initCache(): void;
  86812. /**
  86813. * Flag the transform node as dirty (Forcing it to update everything)
  86814. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86815. * @returns this transform node
  86816. */
  86817. markAsDirty(property: string): TransformNode;
  86818. /**
  86819. * Returns the current mesh absolute position.
  86820. * Returns a Vector3.
  86821. */
  86822. get absolutePosition(): Vector3;
  86823. /**
  86824. * Returns the current mesh absolute scaling.
  86825. * Returns a Vector3.
  86826. */
  86827. get absoluteScaling(): Vector3;
  86828. /**
  86829. * Returns the current mesh absolute rotation.
  86830. * Returns a Quaternion.
  86831. */
  86832. get absoluteRotationQuaternion(): Quaternion;
  86833. /**
  86834. * Sets a new matrix to apply before all other transformation
  86835. * @param matrix defines the transform matrix
  86836. * @returns the current TransformNode
  86837. */
  86838. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86839. /**
  86840. * Sets a new pivot matrix to the current node
  86841. * @param matrix defines the new pivot matrix to use
  86842. * @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
  86843. * @returns the current TransformNode
  86844. */
  86845. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86846. /**
  86847. * Returns the mesh pivot matrix.
  86848. * Default : Identity.
  86849. * @returns the matrix
  86850. */
  86851. getPivotMatrix(): Matrix;
  86852. /**
  86853. * Instantiate (when possible) or clone that node with its hierarchy
  86854. * @param newParent defines the new parent to use for the instance (or clone)
  86855. * @param options defines options to configure how copy is done
  86856. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86857. * @returns an instance (or a clone) of the current node with its hiearchy
  86858. */
  86859. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86860. doNotInstantiate: boolean;
  86861. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86862. /**
  86863. * Prevents the World matrix to be computed any longer
  86864. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86865. * @returns the TransformNode.
  86866. */
  86867. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86868. /**
  86869. * Allows back the World matrix computation.
  86870. * @returns the TransformNode.
  86871. */
  86872. unfreezeWorldMatrix(): this;
  86873. /**
  86874. * True if the World matrix has been frozen.
  86875. */
  86876. get isWorldMatrixFrozen(): boolean;
  86877. /**
  86878. * Retuns the mesh absolute position in the World.
  86879. * @returns a Vector3.
  86880. */
  86881. getAbsolutePosition(): Vector3;
  86882. /**
  86883. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86884. * @param absolutePosition the absolute position to set
  86885. * @returns the TransformNode.
  86886. */
  86887. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86888. /**
  86889. * Sets the mesh position in its local space.
  86890. * @param vector3 the position to set in localspace
  86891. * @returns the TransformNode.
  86892. */
  86893. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86894. /**
  86895. * Returns the mesh position in the local space from the current World matrix values.
  86896. * @returns a new Vector3.
  86897. */
  86898. getPositionExpressedInLocalSpace(): Vector3;
  86899. /**
  86900. * Translates the mesh along the passed Vector3 in its local space.
  86901. * @param vector3 the distance to translate in localspace
  86902. * @returns the TransformNode.
  86903. */
  86904. locallyTranslate(vector3: Vector3): TransformNode;
  86905. private static _lookAtVectorCache;
  86906. /**
  86907. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86908. * @param targetPoint the position (must be in same space as current mesh) to look at
  86909. * @param yawCor optional yaw (y-axis) correction in radians
  86910. * @param pitchCor optional pitch (x-axis) correction in radians
  86911. * @param rollCor optional roll (z-axis) correction in radians
  86912. * @param space the choosen space of the target
  86913. * @returns the TransformNode.
  86914. */
  86915. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86916. /**
  86917. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86918. * This Vector3 is expressed in the World space.
  86919. * @param localAxis axis to rotate
  86920. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86921. */
  86922. getDirection(localAxis: Vector3): Vector3;
  86923. /**
  86924. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86925. * localAxis is expressed in the mesh local space.
  86926. * result is computed in the Wordl space from the mesh World matrix.
  86927. * @param localAxis axis to rotate
  86928. * @param result the resulting transformnode
  86929. * @returns this TransformNode.
  86930. */
  86931. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86932. /**
  86933. * Sets this transform node rotation to the given local axis.
  86934. * @param localAxis the axis in local space
  86935. * @param yawCor optional yaw (y-axis) correction in radians
  86936. * @param pitchCor optional pitch (x-axis) correction in radians
  86937. * @param rollCor optional roll (z-axis) correction in radians
  86938. * @returns this TransformNode
  86939. */
  86940. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86941. /**
  86942. * Sets a new pivot point to the current node
  86943. * @param point defines the new pivot point to use
  86944. * @param space defines if the point is in world or local space (local by default)
  86945. * @returns the current TransformNode
  86946. */
  86947. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86948. /**
  86949. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86950. * @returns the pivot point
  86951. */
  86952. getPivotPoint(): Vector3;
  86953. /**
  86954. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86955. * @param result the vector3 to store the result
  86956. * @returns this TransformNode.
  86957. */
  86958. getPivotPointToRef(result: Vector3): TransformNode;
  86959. /**
  86960. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86961. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86962. */
  86963. getAbsolutePivotPoint(): Vector3;
  86964. /**
  86965. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86966. * @param result vector3 to store the result
  86967. * @returns this TransformNode.
  86968. */
  86969. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86970. /**
  86971. * Defines the passed node as the parent of the current node.
  86972. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86973. * @see https://doc.babylonjs.com/how_to/parenting
  86974. * @param node the node ot set as the parent
  86975. * @returns this TransformNode.
  86976. */
  86977. setParent(node: Nullable<Node>): TransformNode;
  86978. private _nonUniformScaling;
  86979. /**
  86980. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86981. */
  86982. get nonUniformScaling(): boolean;
  86983. /** @hidden */
  86984. _updateNonUniformScalingState(value: boolean): boolean;
  86985. /**
  86986. * Attach the current TransformNode to another TransformNode associated with a bone
  86987. * @param bone Bone affecting the TransformNode
  86988. * @param affectedTransformNode TransformNode associated with the bone
  86989. * @returns this object
  86990. */
  86991. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86992. /**
  86993. * Detach the transform node if its associated with a bone
  86994. * @returns this object
  86995. */
  86996. detachFromBone(): TransformNode;
  86997. private static _rotationAxisCache;
  86998. /**
  86999. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87000. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87001. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87002. * The passed axis is also normalized.
  87003. * @param axis the axis to rotate around
  87004. * @param amount the amount to rotate in radians
  87005. * @param space Space to rotate in (Default: local)
  87006. * @returns the TransformNode.
  87007. */
  87008. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87009. /**
  87010. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87011. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87012. * The passed axis is also normalized. .
  87013. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87014. * @param point the point to rotate around
  87015. * @param axis the axis to rotate around
  87016. * @param amount the amount to rotate in radians
  87017. * @returns the TransformNode
  87018. */
  87019. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87020. /**
  87021. * Translates the mesh along the axis vector for the passed distance in the given space.
  87022. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87023. * @param axis the axis to translate in
  87024. * @param distance the distance to translate
  87025. * @param space Space to rotate in (Default: local)
  87026. * @returns the TransformNode.
  87027. */
  87028. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87029. /**
  87030. * Adds a rotation step to the mesh current rotation.
  87031. * x, y, z are Euler angles expressed in radians.
  87032. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87033. * This means this rotation is made in the mesh local space only.
  87034. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87035. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87036. * ```javascript
  87037. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87038. * ```
  87039. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87040. * 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.
  87041. * @param x Rotation to add
  87042. * @param y Rotation to add
  87043. * @param z Rotation to add
  87044. * @returns the TransformNode.
  87045. */
  87046. addRotation(x: number, y: number, z: number): TransformNode;
  87047. /**
  87048. * @hidden
  87049. */
  87050. protected _getEffectiveParent(): Nullable<Node>;
  87051. /**
  87052. * Computes the world matrix of the node
  87053. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87054. * @returns the world matrix
  87055. */
  87056. computeWorldMatrix(force?: boolean): Matrix;
  87057. /**
  87058. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87059. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87060. */
  87061. resetLocalMatrix(independentOfChildren?: boolean): void;
  87062. protected _afterComputeWorldMatrix(): void;
  87063. /**
  87064. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87065. * @param func callback function to add
  87066. *
  87067. * @returns the TransformNode.
  87068. */
  87069. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87070. /**
  87071. * Removes a registered callback function.
  87072. * @param func callback function to remove
  87073. * @returns the TransformNode.
  87074. */
  87075. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87076. /**
  87077. * Gets the position of the current mesh in camera space
  87078. * @param camera defines the camera to use
  87079. * @returns a position
  87080. */
  87081. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87082. /**
  87083. * Returns the distance from the mesh to the active camera
  87084. * @param camera defines the camera to use
  87085. * @returns the distance
  87086. */
  87087. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87088. /**
  87089. * Clone the current transform node
  87090. * @param name Name of the new clone
  87091. * @param newParent New parent for the clone
  87092. * @param doNotCloneChildren Do not clone children hierarchy
  87093. * @returns the new transform node
  87094. */
  87095. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87096. /**
  87097. * Serializes the objects information.
  87098. * @param currentSerializationObject defines the object to serialize in
  87099. * @returns the serialized object
  87100. */
  87101. serialize(currentSerializationObject?: any): any;
  87102. /**
  87103. * Returns a new TransformNode object parsed from the source provided.
  87104. * @param parsedTransformNode is the source.
  87105. * @param scene the scne the object belongs to
  87106. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87107. * @returns a new TransformNode object parsed from the source provided.
  87108. */
  87109. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87110. /**
  87111. * Get all child-transformNodes of this node
  87112. * @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
  87113. * @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
  87114. * @returns an array of TransformNode
  87115. */
  87116. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87117. /**
  87118. * Releases resources associated with this transform node.
  87119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87121. */
  87122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87123. /**
  87124. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87125. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87126. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87127. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87128. * @returns the current mesh
  87129. */
  87130. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87131. private _syncAbsoluteScalingAndRotation;
  87132. }
  87133. }
  87134. declare module BABYLON {
  87135. /**
  87136. * Class used to override all child animations of a given target
  87137. */
  87138. export class AnimationPropertiesOverride {
  87139. /**
  87140. * Gets or sets a value indicating if animation blending must be used
  87141. */
  87142. enableBlending: boolean;
  87143. /**
  87144. * Gets or sets the blending speed to use when enableBlending is true
  87145. */
  87146. blendingSpeed: number;
  87147. /**
  87148. * Gets or sets the default loop mode to use
  87149. */
  87150. loopMode: number;
  87151. }
  87152. }
  87153. declare module BABYLON {
  87154. /**
  87155. * Class used to store bone information
  87156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87157. */
  87158. export class Bone extends Node {
  87159. /**
  87160. * defines the bone name
  87161. */
  87162. name: string;
  87163. private static _tmpVecs;
  87164. private static _tmpQuat;
  87165. private static _tmpMats;
  87166. /**
  87167. * Gets the list of child bones
  87168. */
  87169. children: Bone[];
  87170. /** Gets the animations associated with this bone */
  87171. animations: Animation[];
  87172. /**
  87173. * Gets or sets bone length
  87174. */
  87175. length: number;
  87176. /**
  87177. * @hidden Internal only
  87178. * Set this value to map this bone to a different index in the transform matrices
  87179. * Set this value to -1 to exclude the bone from the transform matrices
  87180. */
  87181. _index: Nullable<number>;
  87182. private _skeleton;
  87183. private _localMatrix;
  87184. private _restPose;
  87185. private _baseMatrix;
  87186. private _absoluteTransform;
  87187. private _invertedAbsoluteTransform;
  87188. private _parent;
  87189. private _scalingDeterminant;
  87190. private _worldTransform;
  87191. private _localScaling;
  87192. private _localRotation;
  87193. private _localPosition;
  87194. private _needToDecompose;
  87195. private _needToCompose;
  87196. /** @hidden */
  87197. _linkedTransformNode: Nullable<TransformNode>;
  87198. /** @hidden */
  87199. _waitingTransformNodeId: Nullable<string>;
  87200. /** @hidden */
  87201. get _matrix(): Matrix;
  87202. /** @hidden */
  87203. set _matrix(value: Matrix);
  87204. /**
  87205. * Create a new bone
  87206. * @param name defines the bone name
  87207. * @param skeleton defines the parent skeleton
  87208. * @param parentBone defines the parent (can be null if the bone is the root)
  87209. * @param localMatrix defines the local matrix
  87210. * @param restPose defines the rest pose matrix
  87211. * @param baseMatrix defines the base matrix
  87212. * @param index defines index of the bone in the hiearchy
  87213. */
  87214. constructor(
  87215. /**
  87216. * defines the bone name
  87217. */
  87218. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87219. /**
  87220. * Gets the current object class name.
  87221. * @return the class name
  87222. */
  87223. getClassName(): string;
  87224. /**
  87225. * Gets the parent skeleton
  87226. * @returns a skeleton
  87227. */
  87228. getSkeleton(): Skeleton;
  87229. /**
  87230. * Gets parent bone
  87231. * @returns a bone or null if the bone is the root of the bone hierarchy
  87232. */
  87233. getParent(): Nullable<Bone>;
  87234. /**
  87235. * Returns an array containing the root bones
  87236. * @returns an array containing the root bones
  87237. */
  87238. getChildren(): Array<Bone>;
  87239. /**
  87240. * Gets the node index in matrix array generated for rendering
  87241. * @returns the node index
  87242. */
  87243. getIndex(): number;
  87244. /**
  87245. * Sets the parent bone
  87246. * @param parent defines the parent (can be null if the bone is the root)
  87247. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87248. */
  87249. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87250. /**
  87251. * Gets the local matrix
  87252. * @returns a matrix
  87253. */
  87254. getLocalMatrix(): Matrix;
  87255. /**
  87256. * Gets the base matrix (initial matrix which remains unchanged)
  87257. * @returns a matrix
  87258. */
  87259. getBaseMatrix(): Matrix;
  87260. /**
  87261. * Gets the rest pose matrix
  87262. * @returns a matrix
  87263. */
  87264. getRestPose(): Matrix;
  87265. /**
  87266. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87267. */
  87268. getWorldMatrix(): Matrix;
  87269. /**
  87270. * Sets the local matrix to rest pose matrix
  87271. */
  87272. returnToRest(): void;
  87273. /**
  87274. * Gets the inverse of the absolute transform matrix.
  87275. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87276. * @returns a matrix
  87277. */
  87278. getInvertedAbsoluteTransform(): Matrix;
  87279. /**
  87280. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87281. * @returns a matrix
  87282. */
  87283. getAbsoluteTransform(): Matrix;
  87284. /**
  87285. * Links with the given transform node.
  87286. * The local matrix of this bone is copied from the transform node every frame.
  87287. * @param transformNode defines the transform node to link to
  87288. */
  87289. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87290. /**
  87291. * Gets the node used to drive the bone's transformation
  87292. * @returns a transform node or null
  87293. */
  87294. getTransformNode(): Nullable<TransformNode>;
  87295. /** Gets or sets current position (in local space) */
  87296. get position(): Vector3;
  87297. set position(newPosition: Vector3);
  87298. /** Gets or sets current rotation (in local space) */
  87299. get rotation(): Vector3;
  87300. set rotation(newRotation: Vector3);
  87301. /** Gets or sets current rotation quaternion (in local space) */
  87302. get rotationQuaternion(): Quaternion;
  87303. set rotationQuaternion(newRotation: Quaternion);
  87304. /** Gets or sets current scaling (in local space) */
  87305. get scaling(): Vector3;
  87306. set scaling(newScaling: Vector3);
  87307. /**
  87308. * Gets the animation properties override
  87309. */
  87310. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87311. private _decompose;
  87312. private _compose;
  87313. /**
  87314. * Update the base and local matrices
  87315. * @param matrix defines the new base or local matrix
  87316. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87317. * @param updateLocalMatrix defines if the local matrix should be updated
  87318. */
  87319. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87320. /** @hidden */
  87321. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87322. /**
  87323. * Flag the bone as dirty (Forcing it to update everything)
  87324. */
  87325. markAsDirty(): void;
  87326. /** @hidden */
  87327. _markAsDirtyAndCompose(): void;
  87328. private _markAsDirtyAndDecompose;
  87329. /**
  87330. * Translate the bone in local or world space
  87331. * @param vec The amount to translate the bone
  87332. * @param space The space that the translation is in
  87333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87334. */
  87335. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87336. /**
  87337. * Set the postion of the bone in local or world space
  87338. * @param position The position to set the bone
  87339. * @param space The space that the position is in
  87340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87341. */
  87342. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87343. /**
  87344. * Set the absolute position of the bone (world space)
  87345. * @param position The position to set the bone
  87346. * @param mesh The mesh that this bone is attached to
  87347. */
  87348. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87349. /**
  87350. * Scale the bone on the x, y and z axes (in local space)
  87351. * @param x The amount to scale the bone on the x axis
  87352. * @param y The amount to scale the bone on the y axis
  87353. * @param z The amount to scale the bone on the z axis
  87354. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87355. */
  87356. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87357. /**
  87358. * Set the bone scaling in local space
  87359. * @param scale defines the scaling vector
  87360. */
  87361. setScale(scale: Vector3): void;
  87362. /**
  87363. * Gets the current scaling in local space
  87364. * @returns the current scaling vector
  87365. */
  87366. getScale(): Vector3;
  87367. /**
  87368. * Gets the current scaling in local space and stores it in a target vector
  87369. * @param result defines the target vector
  87370. */
  87371. getScaleToRef(result: Vector3): void;
  87372. /**
  87373. * Set the yaw, pitch, and roll of the bone in local or world space
  87374. * @param yaw The rotation of the bone on the y axis
  87375. * @param pitch The rotation of the bone on the x axis
  87376. * @param roll The rotation of the bone on the z axis
  87377. * @param space The space that the axes of rotation are in
  87378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87379. */
  87380. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87381. /**
  87382. * Add a rotation to the bone on an axis in local or world space
  87383. * @param axis The axis to rotate the bone on
  87384. * @param amount The amount to rotate the bone
  87385. * @param space The space that the axis is in
  87386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87387. */
  87388. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87389. /**
  87390. * Set the rotation of the bone to a particular axis angle in local or world space
  87391. * @param axis The axis to rotate the bone on
  87392. * @param angle The angle that the bone should be rotated to
  87393. * @param space The space that the axis is in
  87394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87395. */
  87396. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87397. /**
  87398. * Set the euler rotation of the bone in local of world space
  87399. * @param rotation The euler rotation that the bone should be set to
  87400. * @param space The space that the rotation is in
  87401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87402. */
  87403. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87404. /**
  87405. * Set the quaternion rotation of the bone in local of world space
  87406. * @param quat The quaternion rotation that the bone should be set to
  87407. * @param space The space that the rotation is in
  87408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87409. */
  87410. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87411. /**
  87412. * Set the rotation matrix of the bone in local of world space
  87413. * @param rotMat The rotation matrix that the bone should be set to
  87414. * @param space The space that the rotation is in
  87415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87416. */
  87417. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87418. private _rotateWithMatrix;
  87419. private _getNegativeRotationToRef;
  87420. /**
  87421. * Get the position of the bone in local or world space
  87422. * @param space The space that the returned position is in
  87423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87424. * @returns The position of the bone
  87425. */
  87426. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87427. /**
  87428. * Copy the position of the bone to a vector3 in local or world space
  87429. * @param space The space that the returned position is in
  87430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87431. * @param result The vector3 to copy the position to
  87432. */
  87433. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87434. /**
  87435. * Get the absolute position of the bone (world space)
  87436. * @param mesh The mesh that this bone is attached to
  87437. * @returns The absolute position of the bone
  87438. */
  87439. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87440. /**
  87441. * Copy the absolute position of the bone (world space) to the result param
  87442. * @param mesh The mesh that this bone is attached to
  87443. * @param result The vector3 to copy the absolute position to
  87444. */
  87445. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87446. /**
  87447. * Compute the absolute transforms of this bone and its children
  87448. */
  87449. computeAbsoluteTransforms(): void;
  87450. /**
  87451. * Get the world direction from an axis that is in the local space of the bone
  87452. * @param localAxis The local direction that is used to compute the world direction
  87453. * @param mesh The mesh that this bone is attached to
  87454. * @returns The world direction
  87455. */
  87456. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87457. /**
  87458. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87459. * @param localAxis The local direction that is used to compute the world direction
  87460. * @param mesh The mesh that this bone is attached to
  87461. * @param result The vector3 that the world direction will be copied to
  87462. */
  87463. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87464. /**
  87465. * Get the euler rotation of the bone in local or world space
  87466. * @param space The space that the rotation should be in
  87467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87468. * @returns The euler rotation
  87469. */
  87470. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87471. /**
  87472. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87473. * @param space The space that the rotation should be in
  87474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87475. * @param result The vector3 that the rotation should be copied to
  87476. */
  87477. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87478. /**
  87479. * Get the quaternion rotation of the bone in either local or world space
  87480. * @param space The space that the rotation should be in
  87481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87482. * @returns The quaternion rotation
  87483. */
  87484. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87485. /**
  87486. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87487. * @param space The space that the rotation should be in
  87488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87489. * @param result The quaternion that the rotation should be copied to
  87490. */
  87491. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87492. /**
  87493. * Get the rotation matrix of the bone in local or world space
  87494. * @param space The space that the rotation should be in
  87495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87496. * @returns The rotation matrix
  87497. */
  87498. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87499. /**
  87500. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87501. * @param space The space that the rotation should be in
  87502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87503. * @param result The quaternion that the rotation should be copied to
  87504. */
  87505. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87506. /**
  87507. * Get the world position of a point that is in the local space of the bone
  87508. * @param position The local position
  87509. * @param mesh The mesh that this bone is attached to
  87510. * @returns The world position
  87511. */
  87512. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87513. /**
  87514. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87515. * @param position The local position
  87516. * @param mesh The mesh that this bone is attached to
  87517. * @param result The vector3 that the world position should be copied to
  87518. */
  87519. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87520. /**
  87521. * Get the local position of a point that is in world space
  87522. * @param position The world position
  87523. * @param mesh The mesh that this bone is attached to
  87524. * @returns The local position
  87525. */
  87526. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87527. /**
  87528. * Get the local position of a point that is in world space and copy it to the result param
  87529. * @param position The world position
  87530. * @param mesh The mesh that this bone is attached to
  87531. * @param result The vector3 that the local position should be copied to
  87532. */
  87533. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87534. }
  87535. }
  87536. declare module BABYLON {
  87537. /**
  87538. * Defines a runtime animation
  87539. */
  87540. export class RuntimeAnimation {
  87541. private _events;
  87542. /**
  87543. * The current frame of the runtime animation
  87544. */
  87545. private _currentFrame;
  87546. /**
  87547. * The animation used by the runtime animation
  87548. */
  87549. private _animation;
  87550. /**
  87551. * The target of the runtime animation
  87552. */
  87553. private _target;
  87554. /**
  87555. * The initiating animatable
  87556. */
  87557. private _host;
  87558. /**
  87559. * The original value of the runtime animation
  87560. */
  87561. private _originalValue;
  87562. /**
  87563. * The original blend value of the runtime animation
  87564. */
  87565. private _originalBlendValue;
  87566. /**
  87567. * The offsets cache of the runtime animation
  87568. */
  87569. private _offsetsCache;
  87570. /**
  87571. * The high limits cache of the runtime animation
  87572. */
  87573. private _highLimitsCache;
  87574. /**
  87575. * Specifies if the runtime animation has been stopped
  87576. */
  87577. private _stopped;
  87578. /**
  87579. * The blending factor of the runtime animation
  87580. */
  87581. private _blendingFactor;
  87582. /**
  87583. * The BabylonJS scene
  87584. */
  87585. private _scene;
  87586. /**
  87587. * The current value of the runtime animation
  87588. */
  87589. private _currentValue;
  87590. /** @hidden */
  87591. _animationState: _IAnimationState;
  87592. /**
  87593. * The active target of the runtime animation
  87594. */
  87595. private _activeTargets;
  87596. private _currentActiveTarget;
  87597. private _directTarget;
  87598. /**
  87599. * The target path of the runtime animation
  87600. */
  87601. private _targetPath;
  87602. /**
  87603. * The weight of the runtime animation
  87604. */
  87605. private _weight;
  87606. /**
  87607. * The ratio offset of the runtime animation
  87608. */
  87609. private _ratioOffset;
  87610. /**
  87611. * The previous delay of the runtime animation
  87612. */
  87613. private _previousDelay;
  87614. /**
  87615. * The previous ratio of the runtime animation
  87616. */
  87617. private _previousRatio;
  87618. private _enableBlending;
  87619. private _keys;
  87620. private _minFrame;
  87621. private _maxFrame;
  87622. private _minValue;
  87623. private _maxValue;
  87624. private _targetIsArray;
  87625. /**
  87626. * Gets the current frame of the runtime animation
  87627. */
  87628. get currentFrame(): number;
  87629. /**
  87630. * Gets the weight of the runtime animation
  87631. */
  87632. get weight(): number;
  87633. /**
  87634. * Gets the current value of the runtime animation
  87635. */
  87636. get currentValue(): any;
  87637. /**
  87638. * Gets the target path of the runtime animation
  87639. */
  87640. get targetPath(): string;
  87641. /**
  87642. * Gets the actual target of the runtime animation
  87643. */
  87644. get target(): any;
  87645. /** @hidden */
  87646. _onLoop: () => void;
  87647. /**
  87648. * Create a new RuntimeAnimation object
  87649. * @param target defines the target of the animation
  87650. * @param animation defines the source animation object
  87651. * @param scene defines the hosting scene
  87652. * @param host defines the initiating Animatable
  87653. */
  87654. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87655. private _preparePath;
  87656. /**
  87657. * Gets the animation from the runtime animation
  87658. */
  87659. get animation(): Animation;
  87660. /**
  87661. * Resets the runtime animation to the beginning
  87662. * @param restoreOriginal defines whether to restore the target property to the original value
  87663. */
  87664. reset(restoreOriginal?: boolean): void;
  87665. /**
  87666. * Specifies if the runtime animation is stopped
  87667. * @returns Boolean specifying if the runtime animation is stopped
  87668. */
  87669. isStopped(): boolean;
  87670. /**
  87671. * Disposes of the runtime animation
  87672. */
  87673. dispose(): void;
  87674. /**
  87675. * Apply the interpolated value to the target
  87676. * @param currentValue defines the value computed by the animation
  87677. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87678. */
  87679. setValue(currentValue: any, weight: number): void;
  87680. private _getOriginalValues;
  87681. private _setValue;
  87682. /**
  87683. * Gets the loop pmode of the runtime animation
  87684. * @returns Loop Mode
  87685. */
  87686. private _getCorrectLoopMode;
  87687. /**
  87688. * Move the current animation to a given frame
  87689. * @param frame defines the frame to move to
  87690. */
  87691. goToFrame(frame: number): void;
  87692. /**
  87693. * @hidden Internal use only
  87694. */
  87695. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87696. /**
  87697. * Execute the current animation
  87698. * @param delay defines the delay to add to the current frame
  87699. * @param from defines the lower bound of the animation range
  87700. * @param to defines the upper bound of the animation range
  87701. * @param loop defines if the current animation must loop
  87702. * @param speedRatio defines the current speed ratio
  87703. * @param weight defines the weight of the animation (default is -1 so no weight)
  87704. * @param onLoop optional callback called when animation loops
  87705. * @returns a boolean indicating if the animation is running
  87706. */
  87707. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87708. }
  87709. }
  87710. declare module BABYLON {
  87711. /**
  87712. * Class used to store an actual running animation
  87713. */
  87714. export class Animatable {
  87715. /** defines the target object */
  87716. target: any;
  87717. /** defines the starting frame number (default is 0) */
  87718. fromFrame: number;
  87719. /** defines the ending frame number (default is 100) */
  87720. toFrame: number;
  87721. /** defines if the animation must loop (default is false) */
  87722. loopAnimation: boolean;
  87723. /** defines a callback to call when animation ends if it is not looping */
  87724. onAnimationEnd?: (() => void) | null | undefined;
  87725. /** defines a callback to call when animation loops */
  87726. onAnimationLoop?: (() => void) | null | undefined;
  87727. private _localDelayOffset;
  87728. private _pausedDelay;
  87729. private _runtimeAnimations;
  87730. private _paused;
  87731. private _scene;
  87732. private _speedRatio;
  87733. private _weight;
  87734. private _syncRoot;
  87735. /**
  87736. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87737. * This will only apply for non looping animation (default is true)
  87738. */
  87739. disposeOnEnd: boolean;
  87740. /**
  87741. * Gets a boolean indicating if the animation has started
  87742. */
  87743. animationStarted: boolean;
  87744. /**
  87745. * Observer raised when the animation ends
  87746. */
  87747. onAnimationEndObservable: Observable<Animatable>;
  87748. /**
  87749. * Observer raised when the animation loops
  87750. */
  87751. onAnimationLoopObservable: Observable<Animatable>;
  87752. /**
  87753. * Gets the root Animatable used to synchronize and normalize animations
  87754. */
  87755. get syncRoot(): Nullable<Animatable>;
  87756. /**
  87757. * Gets the current frame of the first RuntimeAnimation
  87758. * Used to synchronize Animatables
  87759. */
  87760. get masterFrame(): number;
  87761. /**
  87762. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87763. */
  87764. get weight(): number;
  87765. set weight(value: number);
  87766. /**
  87767. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87768. */
  87769. get speedRatio(): number;
  87770. set speedRatio(value: number);
  87771. /**
  87772. * Creates a new Animatable
  87773. * @param scene defines the hosting scene
  87774. * @param target defines the target object
  87775. * @param fromFrame defines the starting frame number (default is 0)
  87776. * @param toFrame defines the ending frame number (default is 100)
  87777. * @param loopAnimation defines if the animation must loop (default is false)
  87778. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87779. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87780. * @param animations defines a group of animation to add to the new Animatable
  87781. * @param onAnimationLoop defines a callback to call when animation loops
  87782. */
  87783. constructor(scene: Scene,
  87784. /** defines the target object */
  87785. target: any,
  87786. /** defines the starting frame number (default is 0) */
  87787. fromFrame?: number,
  87788. /** defines the ending frame number (default is 100) */
  87789. toFrame?: number,
  87790. /** defines if the animation must loop (default is false) */
  87791. loopAnimation?: boolean, speedRatio?: number,
  87792. /** defines a callback to call when animation ends if it is not looping */
  87793. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87794. /** defines a callback to call when animation loops */
  87795. onAnimationLoop?: (() => void) | null | undefined);
  87796. /**
  87797. * Synchronize and normalize current Animatable with a source Animatable
  87798. * This is useful when using animation weights and when animations are not of the same length
  87799. * @param root defines the root Animatable to synchronize with
  87800. * @returns the current Animatable
  87801. */
  87802. syncWith(root: Animatable): Animatable;
  87803. /**
  87804. * Gets the list of runtime animations
  87805. * @returns an array of RuntimeAnimation
  87806. */
  87807. getAnimations(): RuntimeAnimation[];
  87808. /**
  87809. * Adds more animations to the current animatable
  87810. * @param target defines the target of the animations
  87811. * @param animations defines the new animations to add
  87812. */
  87813. appendAnimations(target: any, animations: Animation[]): void;
  87814. /**
  87815. * Gets the source animation for a specific property
  87816. * @param property defines the propertyu to look for
  87817. * @returns null or the source animation for the given property
  87818. */
  87819. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87820. /**
  87821. * Gets the runtime animation for a specific property
  87822. * @param property defines the propertyu to look for
  87823. * @returns null or the runtime animation for the given property
  87824. */
  87825. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87826. /**
  87827. * Resets the animatable to its original state
  87828. */
  87829. reset(): void;
  87830. /**
  87831. * Allows the animatable to blend with current running animations
  87832. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87833. * @param blendingSpeed defines the blending speed to use
  87834. */
  87835. enableBlending(blendingSpeed: number): void;
  87836. /**
  87837. * Disable animation blending
  87838. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87839. */
  87840. disableBlending(): void;
  87841. /**
  87842. * Jump directly to a given frame
  87843. * @param frame defines the frame to jump to
  87844. */
  87845. goToFrame(frame: number): void;
  87846. /**
  87847. * Pause the animation
  87848. */
  87849. pause(): void;
  87850. /**
  87851. * Restart the animation
  87852. */
  87853. restart(): void;
  87854. private _raiseOnAnimationEnd;
  87855. /**
  87856. * Stop and delete the current animation
  87857. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87858. * @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)
  87859. */
  87860. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87861. /**
  87862. * Wait asynchronously for the animation to end
  87863. * @returns a promise which will be fullfilled when the animation ends
  87864. */
  87865. waitAsync(): Promise<Animatable>;
  87866. /** @hidden */
  87867. _animate(delay: number): boolean;
  87868. }
  87869. interface Scene {
  87870. /** @hidden */
  87871. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87872. /** @hidden */
  87873. _processLateAnimationBindingsForMatrices(holder: {
  87874. totalWeight: number;
  87875. animations: RuntimeAnimation[];
  87876. originalValue: Matrix;
  87877. }): any;
  87878. /** @hidden */
  87879. _processLateAnimationBindingsForQuaternions(holder: {
  87880. totalWeight: number;
  87881. animations: RuntimeAnimation[];
  87882. originalValue: Quaternion;
  87883. }, refQuaternion: Quaternion): Quaternion;
  87884. /** @hidden */
  87885. _processLateAnimationBindings(): void;
  87886. /**
  87887. * Will start the animation sequence of a given target
  87888. * @param target defines the target
  87889. * @param from defines from which frame should animation start
  87890. * @param to defines until which frame should animation run.
  87891. * @param weight defines the weight to apply to the animation (1.0 by default)
  87892. * @param loop defines if the animation loops
  87893. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87894. * @param onAnimationEnd defines the function to be executed when the animation ends
  87895. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87896. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87897. * @param onAnimationLoop defines the callback to call when an animation loops
  87898. * @returns the animatable object created for this animation
  87899. */
  87900. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87901. /**
  87902. * Will start the animation sequence of a given target
  87903. * @param target defines the target
  87904. * @param from defines from which frame should animation start
  87905. * @param to defines until which frame should animation run.
  87906. * @param loop defines if the animation loops
  87907. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87908. * @param onAnimationEnd defines the function to be executed when the animation ends
  87909. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87910. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87911. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87912. * @param onAnimationLoop defines the callback to call when an animation loops
  87913. * @returns the animatable object created for this animation
  87914. */
  87915. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87916. /**
  87917. * Will start the animation sequence of a given target and its hierarchy
  87918. * @param target defines the target
  87919. * @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.
  87920. * @param from defines from which frame should animation start
  87921. * @param to defines until which frame should animation run.
  87922. * @param loop defines if the animation loops
  87923. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87924. * @param onAnimationEnd defines the function to be executed when the animation ends
  87925. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87926. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87927. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87928. * @param onAnimationLoop defines the callback to call when an animation loops
  87929. * @returns the list of created animatables
  87930. */
  87931. 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[];
  87932. /**
  87933. * Begin a new animation on a given node
  87934. * @param target defines the target where the animation will take place
  87935. * @param animations defines the list of animations to start
  87936. * @param from defines the initial value
  87937. * @param to defines the final value
  87938. * @param loop defines if you want animation to loop (off by default)
  87939. * @param speedRatio defines the speed ratio to apply to all animations
  87940. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87941. * @param onAnimationLoop defines the callback to call when an animation loops
  87942. * @returns the list of created animatables
  87943. */
  87944. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  87945. /**
  87946. * Begin a new animation on a given node and its hierarchy
  87947. * @param target defines the root node where the animation will take place
  87948. * @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.
  87949. * @param animations defines the list of animations to start
  87950. * @param from defines the initial value
  87951. * @param to defines the final value
  87952. * @param loop defines if you want animation to loop (off by default)
  87953. * @param speedRatio defines the speed ratio to apply to all animations
  87954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87955. * @param onAnimationLoop defines the callback to call when an animation loops
  87956. * @returns the list of animatables created for all nodes
  87957. */
  87958. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  87959. /**
  87960. * Gets the animatable associated with a specific target
  87961. * @param target defines the target of the animatable
  87962. * @returns the required animatable if found
  87963. */
  87964. getAnimatableByTarget(target: any): Nullable<Animatable>;
  87965. /**
  87966. * Gets all animatables associated with a given target
  87967. * @param target defines the target to look animatables for
  87968. * @returns an array of Animatables
  87969. */
  87970. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  87971. /**
  87972. * Stops and removes all animations that have been applied to the scene
  87973. */
  87974. stopAllAnimations(): void;
  87975. /**
  87976. * Gets the current delta time used by animation engine
  87977. */
  87978. deltaTime: number;
  87979. }
  87980. interface Bone {
  87981. /**
  87982. * Copy an animation range from another bone
  87983. * @param source defines the source bone
  87984. * @param rangeName defines the range name to copy
  87985. * @param frameOffset defines the frame offset
  87986. * @param rescaleAsRequired defines if rescaling must be applied if required
  87987. * @param skelDimensionsRatio defines the scaling ratio
  87988. * @returns true if operation was successful
  87989. */
  87990. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  87991. }
  87992. }
  87993. declare module BABYLON {
  87994. /**
  87995. * Class used to handle skinning animations
  87996. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87997. */
  87998. export class Skeleton implements IAnimatable {
  87999. /** defines the skeleton name */
  88000. name: string;
  88001. /** defines the skeleton Id */
  88002. id: string;
  88003. /**
  88004. * Defines the list of child bones
  88005. */
  88006. bones: Bone[];
  88007. /**
  88008. * Defines an estimate of the dimension of the skeleton at rest
  88009. */
  88010. dimensionsAtRest: Vector3;
  88011. /**
  88012. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88013. */
  88014. needInitialSkinMatrix: boolean;
  88015. /**
  88016. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88017. */
  88018. overrideMesh: Nullable<AbstractMesh>;
  88019. /**
  88020. * Gets the list of animations attached to this skeleton
  88021. */
  88022. animations: Array<Animation>;
  88023. private _scene;
  88024. private _isDirty;
  88025. private _transformMatrices;
  88026. private _transformMatrixTexture;
  88027. private _meshesWithPoseMatrix;
  88028. private _animatables;
  88029. private _identity;
  88030. private _synchronizedWithMesh;
  88031. private _ranges;
  88032. private _lastAbsoluteTransformsUpdateId;
  88033. private _canUseTextureForBones;
  88034. private _uniqueId;
  88035. /** @hidden */
  88036. _numBonesWithLinkedTransformNode: number;
  88037. /** @hidden */
  88038. _hasWaitingData: Nullable<boolean>;
  88039. /**
  88040. * Specifies if the skeleton should be serialized
  88041. */
  88042. doNotSerialize: boolean;
  88043. private _useTextureToStoreBoneMatrices;
  88044. /**
  88045. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88046. * Please note that this option is not available if the hardware does not support it
  88047. */
  88048. get useTextureToStoreBoneMatrices(): boolean;
  88049. set useTextureToStoreBoneMatrices(value: boolean);
  88050. private _animationPropertiesOverride;
  88051. /**
  88052. * Gets or sets the animation properties override
  88053. */
  88054. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88055. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88056. /**
  88057. * List of inspectable custom properties (used by the Inspector)
  88058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88059. */
  88060. inspectableCustomProperties: IInspectable[];
  88061. /**
  88062. * An observable triggered before computing the skeleton's matrices
  88063. */
  88064. onBeforeComputeObservable: Observable<Skeleton>;
  88065. /**
  88066. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88067. */
  88068. get isUsingTextureForMatrices(): boolean;
  88069. /**
  88070. * Gets the unique ID of this skeleton
  88071. */
  88072. get uniqueId(): number;
  88073. /**
  88074. * Creates a new skeleton
  88075. * @param name defines the skeleton name
  88076. * @param id defines the skeleton Id
  88077. * @param scene defines the hosting scene
  88078. */
  88079. constructor(
  88080. /** defines the skeleton name */
  88081. name: string,
  88082. /** defines the skeleton Id */
  88083. id: string, scene: Scene);
  88084. /**
  88085. * Gets the current object class name.
  88086. * @return the class name
  88087. */
  88088. getClassName(): string;
  88089. /**
  88090. * Returns an array containing the root bones
  88091. * @returns an array containing the root bones
  88092. */
  88093. getChildren(): Array<Bone>;
  88094. /**
  88095. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88096. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88097. * @returns a Float32Array containing matrices data
  88098. */
  88099. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88100. /**
  88101. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88102. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88103. * @returns a raw texture containing the data
  88104. */
  88105. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88106. /**
  88107. * Gets the current hosting scene
  88108. * @returns a scene object
  88109. */
  88110. getScene(): Scene;
  88111. /**
  88112. * Gets a string representing the current skeleton data
  88113. * @param fullDetails defines a boolean indicating if we want a verbose version
  88114. * @returns a string representing the current skeleton data
  88115. */
  88116. toString(fullDetails?: boolean): string;
  88117. /**
  88118. * Get bone's index searching by name
  88119. * @param name defines bone's name to search for
  88120. * @return the indice of the bone. Returns -1 if not found
  88121. */
  88122. getBoneIndexByName(name: string): number;
  88123. /**
  88124. * Creater a new animation range
  88125. * @param name defines the name of the range
  88126. * @param from defines the start key
  88127. * @param to defines the end key
  88128. */
  88129. createAnimationRange(name: string, from: number, to: number): void;
  88130. /**
  88131. * Delete a specific animation range
  88132. * @param name defines the name of the range
  88133. * @param deleteFrames defines if frames must be removed as well
  88134. */
  88135. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88136. /**
  88137. * Gets a specific animation range
  88138. * @param name defines the name of the range to look for
  88139. * @returns the requested animation range or null if not found
  88140. */
  88141. getAnimationRange(name: string): Nullable<AnimationRange>;
  88142. /**
  88143. * Gets the list of all animation ranges defined on this skeleton
  88144. * @returns an array
  88145. */
  88146. getAnimationRanges(): Nullable<AnimationRange>[];
  88147. /**
  88148. * Copy animation range from a source skeleton.
  88149. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88150. * @param source defines the source skeleton
  88151. * @param name defines the name of the range to copy
  88152. * @param rescaleAsRequired defines if rescaling must be applied if required
  88153. * @returns true if operation was successful
  88154. */
  88155. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88156. /**
  88157. * Forces the skeleton to go to rest pose
  88158. */
  88159. returnToRest(): void;
  88160. private _getHighestAnimationFrame;
  88161. /**
  88162. * Begin a specific animation range
  88163. * @param name defines the name of the range to start
  88164. * @param loop defines if looping must be turned on (false by default)
  88165. * @param speedRatio defines the speed ratio to apply (1 by default)
  88166. * @param onAnimationEnd defines a callback which will be called when animation will end
  88167. * @returns a new animatable
  88168. */
  88169. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88170. /** @hidden */
  88171. _markAsDirty(): void;
  88172. /** @hidden */
  88173. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88174. /** @hidden */
  88175. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88176. private _computeTransformMatrices;
  88177. /**
  88178. * Build all resources required to render a skeleton
  88179. */
  88180. prepare(): void;
  88181. /**
  88182. * Gets the list of animatables currently running for this skeleton
  88183. * @returns an array of animatables
  88184. */
  88185. getAnimatables(): IAnimatable[];
  88186. /**
  88187. * Clone the current skeleton
  88188. * @param name defines the name of the new skeleton
  88189. * @param id defines the id of the new skeleton
  88190. * @returns the new skeleton
  88191. */
  88192. clone(name: string, id?: string): Skeleton;
  88193. /**
  88194. * Enable animation blending for this skeleton
  88195. * @param blendingSpeed defines the blending speed to apply
  88196. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88197. */
  88198. enableBlending(blendingSpeed?: number): void;
  88199. /**
  88200. * Releases all resources associated with the current skeleton
  88201. */
  88202. dispose(): void;
  88203. /**
  88204. * Serialize the skeleton in a JSON object
  88205. * @returns a JSON object
  88206. */
  88207. serialize(): any;
  88208. /**
  88209. * Creates a new skeleton from serialized data
  88210. * @param parsedSkeleton defines the serialized data
  88211. * @param scene defines the hosting scene
  88212. * @returns a new skeleton
  88213. */
  88214. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88215. /**
  88216. * Compute all node absolute transforms
  88217. * @param forceUpdate defines if computation must be done even if cache is up to date
  88218. */
  88219. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88220. /**
  88221. * Gets the root pose matrix
  88222. * @returns a matrix
  88223. */
  88224. getPoseMatrix(): Nullable<Matrix>;
  88225. /**
  88226. * Sorts bones per internal index
  88227. */
  88228. sortBones(): void;
  88229. private _sortBones;
  88230. }
  88231. }
  88232. declare module BABYLON {
  88233. /**
  88234. * Creates an instance based on a source mesh.
  88235. */
  88236. export class InstancedMesh extends AbstractMesh {
  88237. private _sourceMesh;
  88238. private _currentLOD;
  88239. /** @hidden */
  88240. _indexInSourceMeshInstanceArray: number;
  88241. constructor(name: string, source: Mesh);
  88242. /**
  88243. * Returns the string "InstancedMesh".
  88244. */
  88245. getClassName(): string;
  88246. /** Gets the list of lights affecting that mesh */
  88247. get lightSources(): Light[];
  88248. _resyncLightSources(): void;
  88249. _resyncLightSource(light: Light): void;
  88250. _removeLightSource(light: Light, dispose: boolean): void;
  88251. /**
  88252. * If the source mesh receives shadows
  88253. */
  88254. get receiveShadows(): boolean;
  88255. /**
  88256. * The material of the source mesh
  88257. */
  88258. get material(): Nullable<Material>;
  88259. /**
  88260. * Visibility of the source mesh
  88261. */
  88262. get visibility(): number;
  88263. /**
  88264. * Skeleton of the source mesh
  88265. */
  88266. get skeleton(): Nullable<Skeleton>;
  88267. /**
  88268. * Rendering ground id of the source mesh
  88269. */
  88270. get renderingGroupId(): number;
  88271. set renderingGroupId(value: number);
  88272. /**
  88273. * Returns the total number of vertices (integer).
  88274. */
  88275. getTotalVertices(): number;
  88276. /**
  88277. * Returns a positive integer : the total number of indices in this mesh geometry.
  88278. * @returns the numner of indices or zero if the mesh has no geometry.
  88279. */
  88280. getTotalIndices(): number;
  88281. /**
  88282. * The source mesh of the instance
  88283. */
  88284. get sourceMesh(): Mesh;
  88285. /**
  88286. * Is this node ready to be used/rendered
  88287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88288. * @return {boolean} is it ready
  88289. */
  88290. isReady(completeCheck?: boolean): boolean;
  88291. /**
  88292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88293. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88294. * @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.
  88295. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88296. */
  88297. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88298. /**
  88299. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88300. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88301. * The `data` are either a numeric array either a Float32Array.
  88302. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88303. * 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).
  88304. * Note that a new underlying VertexBuffer object is created each call.
  88305. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88306. *
  88307. * Possible `kind` values :
  88308. * - VertexBuffer.PositionKind
  88309. * - VertexBuffer.UVKind
  88310. * - VertexBuffer.UV2Kind
  88311. * - VertexBuffer.UV3Kind
  88312. * - VertexBuffer.UV4Kind
  88313. * - VertexBuffer.UV5Kind
  88314. * - VertexBuffer.UV6Kind
  88315. * - VertexBuffer.ColorKind
  88316. * - VertexBuffer.MatricesIndicesKind
  88317. * - VertexBuffer.MatricesIndicesExtraKind
  88318. * - VertexBuffer.MatricesWeightsKind
  88319. * - VertexBuffer.MatricesWeightsExtraKind
  88320. *
  88321. * Returns the Mesh.
  88322. */
  88323. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88324. /**
  88325. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88326. * If the mesh has no geometry, it is simply returned as it is.
  88327. * The `data` are either a numeric array either a Float32Array.
  88328. * No new underlying VertexBuffer object is created.
  88329. * 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.
  88330. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88331. *
  88332. * Possible `kind` values :
  88333. * - VertexBuffer.PositionKind
  88334. * - VertexBuffer.UVKind
  88335. * - VertexBuffer.UV2Kind
  88336. * - VertexBuffer.UV3Kind
  88337. * - VertexBuffer.UV4Kind
  88338. * - VertexBuffer.UV5Kind
  88339. * - VertexBuffer.UV6Kind
  88340. * - VertexBuffer.ColorKind
  88341. * - VertexBuffer.MatricesIndicesKind
  88342. * - VertexBuffer.MatricesIndicesExtraKind
  88343. * - VertexBuffer.MatricesWeightsKind
  88344. * - VertexBuffer.MatricesWeightsExtraKind
  88345. *
  88346. * Returns the Mesh.
  88347. */
  88348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88349. /**
  88350. * Sets the mesh indices.
  88351. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88352. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88353. * This method creates a new index buffer each call.
  88354. * Returns the Mesh.
  88355. */
  88356. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88357. /**
  88358. * Boolean : True if the mesh owns the requested kind of data.
  88359. */
  88360. isVerticesDataPresent(kind: string): boolean;
  88361. /**
  88362. * Returns an array of indices (IndicesArray).
  88363. */
  88364. getIndices(): Nullable<IndicesArray>;
  88365. get _positions(): Nullable<Vector3[]>;
  88366. /**
  88367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88368. * This means the mesh underlying bounding box and sphere are recomputed.
  88369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88370. * @returns the current mesh
  88371. */
  88372. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88373. /** @hidden */
  88374. _preActivate(): InstancedMesh;
  88375. /** @hidden */
  88376. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88377. /** @hidden */
  88378. _postActivate(): void;
  88379. getWorldMatrix(): Matrix;
  88380. get isAnInstance(): boolean;
  88381. /**
  88382. * Returns the current associated LOD AbstractMesh.
  88383. */
  88384. getLOD(camera: Camera): AbstractMesh;
  88385. /** @hidden */
  88386. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88387. /** @hidden */
  88388. _syncSubMeshes(): InstancedMesh;
  88389. /** @hidden */
  88390. _generatePointsArray(): boolean;
  88391. /**
  88392. * Creates a new InstancedMesh from the current mesh.
  88393. * - name (string) : the cloned mesh name
  88394. * - newParent (optional Node) : the optional Node to parent the clone to.
  88395. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88396. *
  88397. * Returns the clone.
  88398. */
  88399. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88400. /**
  88401. * Disposes the InstancedMesh.
  88402. * Returns nothing.
  88403. */
  88404. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88405. }
  88406. interface Mesh {
  88407. /**
  88408. * Register a custom buffer that will be instanced
  88409. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88410. * @param kind defines the buffer kind
  88411. * @param stride defines the stride in floats
  88412. */
  88413. registerInstancedBuffer(kind: string, stride: number): void;
  88414. /** @hidden */
  88415. _userInstancedBuffersStorage: {
  88416. data: {
  88417. [key: string]: Float32Array;
  88418. };
  88419. sizes: {
  88420. [key: string]: number;
  88421. };
  88422. vertexBuffers: {
  88423. [key: string]: Nullable<VertexBuffer>;
  88424. };
  88425. strides: {
  88426. [key: string]: number;
  88427. };
  88428. };
  88429. }
  88430. interface AbstractMesh {
  88431. /**
  88432. * Object used to store instanced buffers defined by user
  88433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88434. */
  88435. instancedBuffers: {
  88436. [key: string]: any;
  88437. };
  88438. }
  88439. }
  88440. declare module BABYLON {
  88441. /**
  88442. * Defines the options associated with the creation of a shader material.
  88443. */
  88444. export interface IShaderMaterialOptions {
  88445. /**
  88446. * Does the material work in alpha blend mode
  88447. */
  88448. needAlphaBlending: boolean;
  88449. /**
  88450. * Does the material work in alpha test mode
  88451. */
  88452. needAlphaTesting: boolean;
  88453. /**
  88454. * The list of attribute names used in the shader
  88455. */
  88456. attributes: string[];
  88457. /**
  88458. * The list of unifrom names used in the shader
  88459. */
  88460. uniforms: string[];
  88461. /**
  88462. * The list of UBO names used in the shader
  88463. */
  88464. uniformBuffers: string[];
  88465. /**
  88466. * The list of sampler names used in the shader
  88467. */
  88468. samplers: string[];
  88469. /**
  88470. * The list of defines used in the shader
  88471. */
  88472. defines: string[];
  88473. }
  88474. /**
  88475. * 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.
  88476. *
  88477. * This returned material effects how the mesh will look based on the code in the shaders.
  88478. *
  88479. * @see http://doc.babylonjs.com/how_to/shader_material
  88480. */
  88481. export class ShaderMaterial extends Material {
  88482. private _shaderPath;
  88483. private _options;
  88484. private _textures;
  88485. private _textureArrays;
  88486. private _floats;
  88487. private _ints;
  88488. private _floatsArrays;
  88489. private _colors3;
  88490. private _colors3Arrays;
  88491. private _colors4;
  88492. private _colors4Arrays;
  88493. private _vectors2;
  88494. private _vectors3;
  88495. private _vectors4;
  88496. private _matrices;
  88497. private _matrixArrays;
  88498. private _matrices3x3;
  88499. private _matrices2x2;
  88500. private _vectors2Arrays;
  88501. private _vectors3Arrays;
  88502. private _vectors4Arrays;
  88503. private _cachedWorldViewMatrix;
  88504. private _cachedWorldViewProjectionMatrix;
  88505. private _renderId;
  88506. private _multiview;
  88507. /**
  88508. * Instantiate a new shader material.
  88509. * 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.
  88510. * This returned material effects how the mesh will look based on the code in the shaders.
  88511. * @see http://doc.babylonjs.com/how_to/shader_material
  88512. * @param name Define the name of the material in the scene
  88513. * @param scene Define the scene the material belongs to
  88514. * @param shaderPath Defines the route to the shader code in one of three ways:
  88515. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88516. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88517. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88518. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88519. * @param options Define the options used to create the shader
  88520. */
  88521. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88522. /**
  88523. * Gets the shader path used to define the shader code
  88524. * It can be modified to trigger a new compilation
  88525. */
  88526. get shaderPath(): any;
  88527. /**
  88528. * Sets the shader path used to define the shader code
  88529. * It can be modified to trigger a new compilation
  88530. */
  88531. set shaderPath(shaderPath: any);
  88532. /**
  88533. * Gets the options used to compile the shader.
  88534. * They can be modified to trigger a new compilation
  88535. */
  88536. get options(): IShaderMaterialOptions;
  88537. /**
  88538. * Gets the current class name of the material e.g. "ShaderMaterial"
  88539. * Mainly use in serialization.
  88540. * @returns the class name
  88541. */
  88542. getClassName(): string;
  88543. /**
  88544. * Specifies if the material will require alpha blending
  88545. * @returns a boolean specifying if alpha blending is needed
  88546. */
  88547. needAlphaBlending(): boolean;
  88548. /**
  88549. * Specifies if this material should be rendered in alpha test mode
  88550. * @returns a boolean specifying if an alpha test is needed.
  88551. */
  88552. needAlphaTesting(): boolean;
  88553. private _checkUniform;
  88554. /**
  88555. * Set a texture in the shader.
  88556. * @param name Define the name of the uniform samplers as defined in the shader
  88557. * @param texture Define the texture to bind to this sampler
  88558. * @return the material itself allowing "fluent" like uniform updates
  88559. */
  88560. setTexture(name: string, texture: Texture): ShaderMaterial;
  88561. /**
  88562. * Set a texture array in the shader.
  88563. * @param name Define the name of the uniform sampler array as defined in the shader
  88564. * @param textures Define the list of textures to bind to this sampler
  88565. * @return the material itself allowing "fluent" like uniform updates
  88566. */
  88567. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88568. /**
  88569. * Set a float in the shader.
  88570. * @param name Define the name of the uniform as defined in the shader
  88571. * @param value Define the value to give to the uniform
  88572. * @return the material itself allowing "fluent" like uniform updates
  88573. */
  88574. setFloat(name: string, value: number): ShaderMaterial;
  88575. /**
  88576. * Set a int in the shader.
  88577. * @param name Define the name of the uniform as defined in the shader
  88578. * @param value Define the value to give to the uniform
  88579. * @return the material itself allowing "fluent" like uniform updates
  88580. */
  88581. setInt(name: string, value: number): ShaderMaterial;
  88582. /**
  88583. * Set an array of floats in the shader.
  88584. * @param name Define the name of the uniform as defined in the shader
  88585. * @param value Define the value to give to the uniform
  88586. * @return the material itself allowing "fluent" like uniform updates
  88587. */
  88588. setFloats(name: string, value: number[]): ShaderMaterial;
  88589. /**
  88590. * Set a vec3 in the shader from a Color3.
  88591. * @param name Define the name of the uniform as defined in the shader
  88592. * @param value Define the value to give to the uniform
  88593. * @return the material itself allowing "fluent" like uniform updates
  88594. */
  88595. setColor3(name: string, value: Color3): ShaderMaterial;
  88596. /**
  88597. * Set a vec3 array in the shader from a Color3 array.
  88598. * @param name Define the name of the uniform as defined in the shader
  88599. * @param value Define the value to give to the uniform
  88600. * @return the material itself allowing "fluent" like uniform updates
  88601. */
  88602. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88603. /**
  88604. * Set a vec4 in the shader from a Color4.
  88605. * @param name Define the name of the uniform as defined in the shader
  88606. * @param value Define the value to give to the uniform
  88607. * @return the material itself allowing "fluent" like uniform updates
  88608. */
  88609. setColor4(name: string, value: Color4): ShaderMaterial;
  88610. /**
  88611. * Set a vec4 array in the shader from a Color4 array.
  88612. * @param name Define the name of the uniform as defined in the shader
  88613. * @param value Define the value to give to the uniform
  88614. * @return the material itself allowing "fluent" like uniform updates
  88615. */
  88616. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88617. /**
  88618. * Set a vec2 in the shader from a Vector2.
  88619. * @param name Define the name of the uniform as defined in the shader
  88620. * @param value Define the value to give to the uniform
  88621. * @return the material itself allowing "fluent" like uniform updates
  88622. */
  88623. setVector2(name: string, value: Vector2): ShaderMaterial;
  88624. /**
  88625. * Set a vec3 in the shader from a Vector3.
  88626. * @param name Define the name of the uniform as defined in the shader
  88627. * @param value Define the value to give to the uniform
  88628. * @return the material itself allowing "fluent" like uniform updates
  88629. */
  88630. setVector3(name: string, value: Vector3): ShaderMaterial;
  88631. /**
  88632. * Set a vec4 in the shader from a Vector4.
  88633. * @param name Define the name of the uniform as defined in the shader
  88634. * @param value Define the value to give to the uniform
  88635. * @return the material itself allowing "fluent" like uniform updates
  88636. */
  88637. setVector4(name: string, value: Vector4): ShaderMaterial;
  88638. /**
  88639. * Set a mat4 in the shader from a Matrix.
  88640. * @param name Define the name of the uniform as defined in the shader
  88641. * @param value Define the value to give to the uniform
  88642. * @return the material itself allowing "fluent" like uniform updates
  88643. */
  88644. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88645. /**
  88646. * Set a float32Array in the shader from a matrix array.
  88647. * @param name Define the name of the uniform as defined in the shader
  88648. * @param value Define the value to give to the uniform
  88649. * @return the material itself allowing "fluent" like uniform updates
  88650. */
  88651. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88652. /**
  88653. * Set a mat3 in the shader from a Float32Array.
  88654. * @param name Define the name of the uniform as defined in the shader
  88655. * @param value Define the value to give to the uniform
  88656. * @return the material itself allowing "fluent" like uniform updates
  88657. */
  88658. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88659. /**
  88660. * Set a mat2 in the shader from a Float32Array.
  88661. * @param name Define the name of the uniform as defined in the shader
  88662. * @param value Define the value to give to the uniform
  88663. * @return the material itself allowing "fluent" like uniform updates
  88664. */
  88665. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88666. /**
  88667. * Set a vec2 array in the shader from a number array.
  88668. * @param name Define the name of the uniform as defined in the shader
  88669. * @param value Define the value to give to the uniform
  88670. * @return the material itself allowing "fluent" like uniform updates
  88671. */
  88672. setArray2(name: string, value: number[]): ShaderMaterial;
  88673. /**
  88674. * Set a vec3 array in the shader from a number array.
  88675. * @param name Define the name of the uniform as defined in the shader
  88676. * @param value Define the value to give to the uniform
  88677. * @return the material itself allowing "fluent" like uniform updates
  88678. */
  88679. setArray3(name: string, value: number[]): ShaderMaterial;
  88680. /**
  88681. * Set a vec4 array in the shader from a number array.
  88682. * @param name Define the name of the uniform as defined in the shader
  88683. * @param value Define the value to give to the uniform
  88684. * @return the material itself allowing "fluent" like uniform updates
  88685. */
  88686. setArray4(name: string, value: number[]): ShaderMaterial;
  88687. private _checkCache;
  88688. /**
  88689. * Specifies that the submesh is ready to be used
  88690. * @param mesh defines the mesh to check
  88691. * @param subMesh defines which submesh to check
  88692. * @param useInstances specifies that instances should be used
  88693. * @returns a boolean indicating that the submesh is ready or not
  88694. */
  88695. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88696. /**
  88697. * Checks if the material is ready to render the requested mesh
  88698. * @param mesh Define the mesh to render
  88699. * @param useInstances Define whether or not the material is used with instances
  88700. * @returns true if ready, otherwise false
  88701. */
  88702. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88703. /**
  88704. * Binds the world matrix to the material
  88705. * @param world defines the world transformation matrix
  88706. */
  88707. bindOnlyWorldMatrix(world: Matrix): void;
  88708. /**
  88709. * Binds the material to the mesh
  88710. * @param world defines the world transformation matrix
  88711. * @param mesh defines the mesh to bind the material to
  88712. */
  88713. bind(world: Matrix, mesh?: Mesh): void;
  88714. /**
  88715. * Gets the active textures from the material
  88716. * @returns an array of textures
  88717. */
  88718. getActiveTextures(): BaseTexture[];
  88719. /**
  88720. * Specifies if the material uses a texture
  88721. * @param texture defines the texture to check against the material
  88722. * @returns a boolean specifying if the material uses the texture
  88723. */
  88724. hasTexture(texture: BaseTexture): boolean;
  88725. /**
  88726. * Makes a duplicate of the material, and gives it a new name
  88727. * @param name defines the new name for the duplicated material
  88728. * @returns the cloned material
  88729. */
  88730. clone(name: string): ShaderMaterial;
  88731. /**
  88732. * Disposes the material
  88733. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88734. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88735. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88736. */
  88737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88738. /**
  88739. * Serializes this material in a JSON representation
  88740. * @returns the serialized material object
  88741. */
  88742. serialize(): any;
  88743. /**
  88744. * Creates a shader material from parsed shader material data
  88745. * @param source defines the JSON represnetation of the material
  88746. * @param scene defines the hosting scene
  88747. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88748. * @returns a new material
  88749. */
  88750. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88751. }
  88752. }
  88753. declare module BABYLON {
  88754. /** @hidden */
  88755. export var colorPixelShader: {
  88756. name: string;
  88757. shader: string;
  88758. };
  88759. }
  88760. declare module BABYLON {
  88761. /** @hidden */
  88762. export var colorVertexShader: {
  88763. name: string;
  88764. shader: string;
  88765. };
  88766. }
  88767. declare module BABYLON {
  88768. /**
  88769. * Line mesh
  88770. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88771. */
  88772. export class LinesMesh extends Mesh {
  88773. /**
  88774. * If vertex color should be applied to the mesh
  88775. */
  88776. readonly useVertexColor?: boolean | undefined;
  88777. /**
  88778. * If vertex alpha should be applied to the mesh
  88779. */
  88780. readonly useVertexAlpha?: boolean | undefined;
  88781. /**
  88782. * Color of the line (Default: White)
  88783. */
  88784. color: Color3;
  88785. /**
  88786. * Alpha of the line (Default: 1)
  88787. */
  88788. alpha: number;
  88789. /**
  88790. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88791. * This margin is expressed in world space coordinates, so its value may vary.
  88792. * Default value is 0.1
  88793. */
  88794. intersectionThreshold: number;
  88795. private _colorShader;
  88796. private color4;
  88797. /**
  88798. * Creates a new LinesMesh
  88799. * @param name defines the name
  88800. * @param scene defines the hosting scene
  88801. * @param parent defines the parent mesh if any
  88802. * @param source defines the optional source LinesMesh used to clone data from
  88803. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88804. * When false, achieved by calling a clone(), also passing False.
  88805. * This will make creation of children, recursive.
  88806. * @param useVertexColor defines if this LinesMesh supports vertex color
  88807. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88808. */
  88809. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88810. /**
  88811. * If vertex color should be applied to the mesh
  88812. */
  88813. useVertexColor?: boolean | undefined,
  88814. /**
  88815. * If vertex alpha should be applied to the mesh
  88816. */
  88817. useVertexAlpha?: boolean | undefined);
  88818. private _addClipPlaneDefine;
  88819. private _removeClipPlaneDefine;
  88820. isReady(): boolean;
  88821. /**
  88822. * Returns the string "LineMesh"
  88823. */
  88824. getClassName(): string;
  88825. /**
  88826. * @hidden
  88827. */
  88828. get material(): Material;
  88829. /**
  88830. * @hidden
  88831. */
  88832. set material(value: Material);
  88833. /**
  88834. * @hidden
  88835. */
  88836. get checkCollisions(): boolean;
  88837. /** @hidden */
  88838. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88839. /** @hidden */
  88840. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88841. /**
  88842. * Disposes of the line mesh
  88843. * @param doNotRecurse If children should be disposed
  88844. */
  88845. dispose(doNotRecurse?: boolean): void;
  88846. /**
  88847. * Returns a new LineMesh object cloned from the current one.
  88848. */
  88849. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88850. /**
  88851. * Creates a new InstancedLinesMesh object from the mesh model.
  88852. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88853. * @param name defines the name of the new instance
  88854. * @returns a new InstancedLinesMesh
  88855. */
  88856. createInstance(name: string): InstancedLinesMesh;
  88857. }
  88858. /**
  88859. * Creates an instance based on a source LinesMesh
  88860. */
  88861. export class InstancedLinesMesh extends InstancedMesh {
  88862. /**
  88863. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88864. * This margin is expressed in world space coordinates, so its value may vary.
  88865. * Initilized with the intersectionThreshold value of the source LinesMesh
  88866. */
  88867. intersectionThreshold: number;
  88868. constructor(name: string, source: LinesMesh);
  88869. /**
  88870. * Returns the string "InstancedLinesMesh".
  88871. */
  88872. getClassName(): string;
  88873. }
  88874. }
  88875. declare module BABYLON {
  88876. /** @hidden */
  88877. export var linePixelShader: {
  88878. name: string;
  88879. shader: string;
  88880. };
  88881. }
  88882. declare module BABYLON {
  88883. /** @hidden */
  88884. export var lineVertexShader: {
  88885. name: string;
  88886. shader: string;
  88887. };
  88888. }
  88889. declare module BABYLON {
  88890. interface AbstractMesh {
  88891. /**
  88892. * Gets the edgesRenderer associated with the mesh
  88893. */
  88894. edgesRenderer: Nullable<EdgesRenderer>;
  88895. }
  88896. interface LinesMesh {
  88897. /**
  88898. * Enables the edge rendering mode on the mesh.
  88899. * This mode makes the mesh edges visible
  88900. * @param epsilon defines the maximal distance between two angles to detect a face
  88901. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88902. * @returns the currentAbstractMesh
  88903. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88904. */
  88905. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88906. }
  88907. interface InstancedLinesMesh {
  88908. /**
  88909. * Enables the edge rendering mode on the mesh.
  88910. * This mode makes the mesh edges visible
  88911. * @param epsilon defines the maximal distance between two angles to detect a face
  88912. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88913. * @returns the current InstancedLinesMesh
  88914. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88915. */
  88916. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88917. }
  88918. /**
  88919. * Defines the minimum contract an Edges renderer should follow.
  88920. */
  88921. export interface IEdgesRenderer extends IDisposable {
  88922. /**
  88923. * Gets or sets a boolean indicating if the edgesRenderer is active
  88924. */
  88925. isEnabled: boolean;
  88926. /**
  88927. * Renders the edges of the attached mesh,
  88928. */
  88929. render(): void;
  88930. /**
  88931. * Checks wether or not the edges renderer is ready to render.
  88932. * @return true if ready, otherwise false.
  88933. */
  88934. isReady(): boolean;
  88935. }
  88936. /**
  88937. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88938. */
  88939. export class EdgesRenderer implements IEdgesRenderer {
  88940. /**
  88941. * Define the size of the edges with an orthographic camera
  88942. */
  88943. edgesWidthScalerForOrthographic: number;
  88944. /**
  88945. * Define the size of the edges with a perspective camera
  88946. */
  88947. edgesWidthScalerForPerspective: number;
  88948. protected _source: AbstractMesh;
  88949. protected _linesPositions: number[];
  88950. protected _linesNormals: number[];
  88951. protected _linesIndices: number[];
  88952. protected _epsilon: number;
  88953. protected _indicesCount: number;
  88954. protected _lineShader: ShaderMaterial;
  88955. protected _ib: DataBuffer;
  88956. protected _buffers: {
  88957. [key: string]: Nullable<VertexBuffer>;
  88958. };
  88959. protected _checkVerticesInsteadOfIndices: boolean;
  88960. private _meshRebuildObserver;
  88961. private _meshDisposeObserver;
  88962. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88963. isEnabled: boolean;
  88964. /**
  88965. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88966. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88967. * @param source Mesh used to create edges
  88968. * @param epsilon sum of angles in adjacency to check for edge
  88969. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88970. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88971. */
  88972. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88973. protected _prepareRessources(): void;
  88974. /** @hidden */
  88975. _rebuild(): void;
  88976. /**
  88977. * Releases the required resources for the edges renderer
  88978. */
  88979. dispose(): void;
  88980. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88981. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88982. /**
  88983. * Checks if the pair of p0 and p1 is en edge
  88984. * @param faceIndex
  88985. * @param edge
  88986. * @param faceNormals
  88987. * @param p0
  88988. * @param p1
  88989. * @private
  88990. */
  88991. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88992. /**
  88993. * push line into the position, normal and index buffer
  88994. * @protected
  88995. */
  88996. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88997. /**
  88998. * Generates lines edges from adjacencjes
  88999. * @private
  89000. */
  89001. _generateEdgesLines(): void;
  89002. /**
  89003. * Checks wether or not the edges renderer is ready to render.
  89004. * @return true if ready, otherwise false.
  89005. */
  89006. isReady(): boolean;
  89007. /**
  89008. * Renders the edges of the attached mesh,
  89009. */
  89010. render(): void;
  89011. }
  89012. /**
  89013. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89014. */
  89015. export class LineEdgesRenderer extends EdgesRenderer {
  89016. /**
  89017. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89018. * @param source LineMesh used to generate edges
  89019. * @param epsilon not important (specified angle for edge detection)
  89020. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89021. */
  89022. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89023. /**
  89024. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89025. */
  89026. _generateEdgesLines(): void;
  89027. }
  89028. }
  89029. declare module BABYLON {
  89030. /**
  89031. * This represents the object necessary to create a rendering group.
  89032. * This is exclusively used and created by the rendering manager.
  89033. * To modify the behavior, you use the available helpers in your scene or meshes.
  89034. * @hidden
  89035. */
  89036. export class RenderingGroup {
  89037. index: number;
  89038. private static _zeroVector;
  89039. private _scene;
  89040. private _opaqueSubMeshes;
  89041. private _transparentSubMeshes;
  89042. private _alphaTestSubMeshes;
  89043. private _depthOnlySubMeshes;
  89044. private _particleSystems;
  89045. private _spriteManagers;
  89046. private _opaqueSortCompareFn;
  89047. private _alphaTestSortCompareFn;
  89048. private _transparentSortCompareFn;
  89049. private _renderOpaque;
  89050. private _renderAlphaTest;
  89051. private _renderTransparent;
  89052. /** @hidden */
  89053. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89054. onBeforeTransparentRendering: () => void;
  89055. /**
  89056. * Set the opaque sort comparison function.
  89057. * If null the sub meshes will be render in the order they were created
  89058. */
  89059. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89060. /**
  89061. * Set the alpha test sort comparison function.
  89062. * If null the sub meshes will be render in the order they were created
  89063. */
  89064. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89065. /**
  89066. * Set the transparent sort comparison function.
  89067. * If null the sub meshes will be render in the order they were created
  89068. */
  89069. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89070. /**
  89071. * Creates a new rendering group.
  89072. * @param index The rendering group index
  89073. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89074. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89075. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89076. */
  89077. 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>);
  89078. /**
  89079. * Render all the sub meshes contained in the group.
  89080. * @param customRenderFunction Used to override the default render behaviour of the group.
  89081. * @returns true if rendered some submeshes.
  89082. */
  89083. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89084. /**
  89085. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89086. * @param subMeshes The submeshes to render
  89087. */
  89088. private renderOpaqueSorted;
  89089. /**
  89090. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89091. * @param subMeshes The submeshes to render
  89092. */
  89093. private renderAlphaTestSorted;
  89094. /**
  89095. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89096. * @param subMeshes The submeshes to render
  89097. */
  89098. private renderTransparentSorted;
  89099. /**
  89100. * Renders the submeshes in a specified order.
  89101. * @param subMeshes The submeshes to sort before render
  89102. * @param sortCompareFn The comparison function use to sort
  89103. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89104. * @param transparent Specifies to activate blending if true
  89105. */
  89106. private static renderSorted;
  89107. /**
  89108. * Renders the submeshes in the order they were dispatched (no sort applied).
  89109. * @param subMeshes The submeshes to render
  89110. */
  89111. private static renderUnsorted;
  89112. /**
  89113. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89114. * are rendered back to front if in the same alpha index.
  89115. *
  89116. * @param a The first submesh
  89117. * @param b The second submesh
  89118. * @returns The result of the comparison
  89119. */
  89120. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89121. /**
  89122. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89123. * are rendered back to front.
  89124. *
  89125. * @param a The first submesh
  89126. * @param b The second submesh
  89127. * @returns The result of the comparison
  89128. */
  89129. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89130. /**
  89131. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89132. * are rendered front to back (prevent overdraw).
  89133. *
  89134. * @param a The first submesh
  89135. * @param b The second submesh
  89136. * @returns The result of the comparison
  89137. */
  89138. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89139. /**
  89140. * Resets the different lists of submeshes to prepare a new frame.
  89141. */
  89142. prepare(): void;
  89143. dispose(): void;
  89144. /**
  89145. * Inserts the submesh in its correct queue depending on its material.
  89146. * @param subMesh The submesh to dispatch
  89147. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89148. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89149. */
  89150. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89151. dispatchSprites(spriteManager: ISpriteManager): void;
  89152. dispatchParticles(particleSystem: IParticleSystem): void;
  89153. private _renderParticles;
  89154. private _renderSprites;
  89155. }
  89156. }
  89157. declare module BABYLON {
  89158. /**
  89159. * Interface describing the different options available in the rendering manager
  89160. * regarding Auto Clear between groups.
  89161. */
  89162. export interface IRenderingManagerAutoClearSetup {
  89163. /**
  89164. * Defines whether or not autoclear is enable.
  89165. */
  89166. autoClear: boolean;
  89167. /**
  89168. * Defines whether or not to autoclear the depth buffer.
  89169. */
  89170. depth: boolean;
  89171. /**
  89172. * Defines whether or not to autoclear the stencil buffer.
  89173. */
  89174. stencil: boolean;
  89175. }
  89176. /**
  89177. * This class is used by the onRenderingGroupObservable
  89178. */
  89179. export class RenderingGroupInfo {
  89180. /**
  89181. * The Scene that being rendered
  89182. */
  89183. scene: Scene;
  89184. /**
  89185. * The camera currently used for the rendering pass
  89186. */
  89187. camera: Nullable<Camera>;
  89188. /**
  89189. * The ID of the renderingGroup being processed
  89190. */
  89191. renderingGroupId: number;
  89192. }
  89193. /**
  89194. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89195. * It is enable to manage the different groups as well as the different necessary sort functions.
  89196. * This should not be used directly aside of the few static configurations
  89197. */
  89198. export class RenderingManager {
  89199. /**
  89200. * The max id used for rendering groups (not included)
  89201. */
  89202. static MAX_RENDERINGGROUPS: number;
  89203. /**
  89204. * The min id used for rendering groups (included)
  89205. */
  89206. static MIN_RENDERINGGROUPS: number;
  89207. /**
  89208. * Used to globally prevent autoclearing scenes.
  89209. */
  89210. static AUTOCLEAR: boolean;
  89211. /**
  89212. * @hidden
  89213. */
  89214. _useSceneAutoClearSetup: boolean;
  89215. private _scene;
  89216. private _renderingGroups;
  89217. private _depthStencilBufferAlreadyCleaned;
  89218. private _autoClearDepthStencil;
  89219. private _customOpaqueSortCompareFn;
  89220. private _customAlphaTestSortCompareFn;
  89221. private _customTransparentSortCompareFn;
  89222. private _renderingGroupInfo;
  89223. /**
  89224. * Instantiates a new rendering group for a particular scene
  89225. * @param scene Defines the scene the groups belongs to
  89226. */
  89227. constructor(scene: Scene);
  89228. private _clearDepthStencilBuffer;
  89229. /**
  89230. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89231. * @hidden
  89232. */
  89233. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89234. /**
  89235. * Resets the different information of the group to prepare a new frame
  89236. * @hidden
  89237. */
  89238. reset(): void;
  89239. /**
  89240. * Dispose and release the group and its associated resources.
  89241. * @hidden
  89242. */
  89243. dispose(): void;
  89244. /**
  89245. * Clear the info related to rendering groups preventing retention points during dispose.
  89246. */
  89247. freeRenderingGroups(): void;
  89248. private _prepareRenderingGroup;
  89249. /**
  89250. * Add a sprite manager to the rendering manager in order to render it this frame.
  89251. * @param spriteManager Define the sprite manager to render
  89252. */
  89253. dispatchSprites(spriteManager: ISpriteManager): void;
  89254. /**
  89255. * Add a particle system to the rendering manager in order to render it this frame.
  89256. * @param particleSystem Define the particle system to render
  89257. */
  89258. dispatchParticles(particleSystem: IParticleSystem): void;
  89259. /**
  89260. * Add a submesh to the manager in order to render it this frame
  89261. * @param subMesh The submesh to dispatch
  89262. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89263. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89264. */
  89265. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89266. /**
  89267. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89268. * This allowed control for front to back rendering or reversly depending of the special needs.
  89269. *
  89270. * @param renderingGroupId The rendering group id corresponding to its index
  89271. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89272. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89273. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89274. */
  89275. 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;
  89276. /**
  89277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89278. *
  89279. * @param renderingGroupId The rendering group id corresponding to its index
  89280. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89281. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89282. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89283. */
  89284. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89285. /**
  89286. * Gets the current auto clear configuration for one rendering group of the rendering
  89287. * manager.
  89288. * @param index the rendering group index to get the information for
  89289. * @returns The auto clear setup for the requested rendering group
  89290. */
  89291. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89292. }
  89293. }
  89294. declare module BABYLON {
  89295. /**
  89296. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89297. */
  89298. export interface ICustomShaderOptions {
  89299. /**
  89300. * Gets or sets the custom shader name to use
  89301. */
  89302. shaderName: string;
  89303. /**
  89304. * The list of attribute names used in the shader
  89305. */
  89306. attributes?: string[];
  89307. /**
  89308. * The list of unifrom names used in the shader
  89309. */
  89310. uniforms?: string[];
  89311. /**
  89312. * The list of sampler names used in the shader
  89313. */
  89314. samplers?: string[];
  89315. /**
  89316. * The list of defines used in the shader
  89317. */
  89318. defines?: string[];
  89319. }
  89320. /**
  89321. * Interface to implement to create a shadow generator compatible with BJS.
  89322. */
  89323. export interface IShadowGenerator {
  89324. /**
  89325. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89326. * @returns The render target texture if present otherwise, null
  89327. */
  89328. getShadowMap(): Nullable<RenderTargetTexture>;
  89329. /**
  89330. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89331. * @param subMesh The submesh we want to render in the shadow map
  89332. * @param useInstances Defines wether will draw in the map using instances
  89333. * @returns true if ready otherwise, false
  89334. */
  89335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89336. /**
  89337. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89338. * @param defines Defines of the material we want to update
  89339. * @param lightIndex Index of the light in the enabled light list of the material
  89340. */
  89341. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89342. /**
  89343. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89344. * defined in the generator but impacting the effect).
  89345. * It implies the unifroms available on the materials are the standard BJS ones.
  89346. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89347. * @param effect The effect we are binfing the information for
  89348. */
  89349. bindShadowLight(lightIndex: string, effect: Effect): void;
  89350. /**
  89351. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89352. * (eq to shadow prjection matrix * light transform matrix)
  89353. * @returns The transform matrix used to create the shadow map
  89354. */
  89355. getTransformMatrix(): Matrix;
  89356. /**
  89357. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89358. * Cube and 2D textures for instance.
  89359. */
  89360. recreateShadowMap(): void;
  89361. /**
  89362. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89363. * @param onCompiled Callback triggered at the and of the effects compilation
  89364. * @param options Sets of optional options forcing the compilation with different modes
  89365. */
  89366. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89367. useInstances: boolean;
  89368. }>): void;
  89369. /**
  89370. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89371. * @param options Sets of optional options forcing the compilation with different modes
  89372. * @returns A promise that resolves when the compilation completes
  89373. */
  89374. forceCompilationAsync(options?: Partial<{
  89375. useInstances: boolean;
  89376. }>): Promise<void>;
  89377. /**
  89378. * Serializes the shadow generator setup to a json object.
  89379. * @returns The serialized JSON object
  89380. */
  89381. serialize(): any;
  89382. /**
  89383. * Disposes the Shadow map and related Textures and effects.
  89384. */
  89385. dispose(): void;
  89386. }
  89387. /**
  89388. * Default implementation IShadowGenerator.
  89389. * This is the main object responsible of generating shadows in the framework.
  89390. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89391. */
  89392. export class ShadowGenerator implements IShadowGenerator {
  89393. /**
  89394. * Name of the shadow generator class
  89395. */
  89396. static CLASSNAME: string;
  89397. /**
  89398. * Shadow generator mode None: no filtering applied.
  89399. */
  89400. static readonly FILTER_NONE: number;
  89401. /**
  89402. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89404. */
  89405. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89406. /**
  89407. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89408. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89409. */
  89410. static readonly FILTER_POISSONSAMPLING: number;
  89411. /**
  89412. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89413. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89414. */
  89415. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89416. /**
  89417. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89418. * edge artifacts on steep falloff.
  89419. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89420. */
  89421. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89422. /**
  89423. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89424. * edge artifacts on steep falloff.
  89425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89426. */
  89427. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89428. /**
  89429. * Shadow generator mode PCF: Percentage Closer Filtering
  89430. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89431. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89432. */
  89433. static readonly FILTER_PCF: number;
  89434. /**
  89435. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89436. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89437. * Contact Hardening
  89438. */
  89439. static readonly FILTER_PCSS: number;
  89440. /**
  89441. * Reserved for PCF and PCSS
  89442. * Highest Quality.
  89443. *
  89444. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89445. *
  89446. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89447. */
  89448. static readonly QUALITY_HIGH: number;
  89449. /**
  89450. * Reserved for PCF and PCSS
  89451. * Good tradeoff for quality/perf cross devices
  89452. *
  89453. * Execute PCF on a 3*3 kernel.
  89454. *
  89455. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89456. */
  89457. static readonly QUALITY_MEDIUM: number;
  89458. /**
  89459. * Reserved for PCF and PCSS
  89460. * The lowest quality but the fastest.
  89461. *
  89462. * Execute PCF on a 1*1 kernel.
  89463. *
  89464. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89465. */
  89466. static readonly QUALITY_LOW: number;
  89467. /** Gets or sets the custom shader name to use */
  89468. customShaderOptions: ICustomShaderOptions;
  89469. /**
  89470. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89471. */
  89472. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89473. /**
  89474. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89475. */
  89476. onAfterShadowMapRenderObservable: Observable<Effect>;
  89477. /**
  89478. * Observable triggered before a mesh is rendered in the shadow map.
  89479. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89480. */
  89481. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89482. /**
  89483. * Observable triggered after a mesh is rendered in the shadow map.
  89484. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89485. */
  89486. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89487. protected _bias: number;
  89488. /**
  89489. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89490. */
  89491. get bias(): number;
  89492. /**
  89493. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89494. */
  89495. set bias(bias: number);
  89496. protected _normalBias: number;
  89497. /**
  89498. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89499. */
  89500. get normalBias(): number;
  89501. /**
  89502. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89503. */
  89504. set normalBias(normalBias: number);
  89505. protected _blurBoxOffset: number;
  89506. /**
  89507. * Gets the blur box offset: offset applied during the blur pass.
  89508. * Only useful if useKernelBlur = false
  89509. */
  89510. get blurBoxOffset(): number;
  89511. /**
  89512. * Sets the blur box offset: offset applied during the blur pass.
  89513. * Only useful if useKernelBlur = false
  89514. */
  89515. set blurBoxOffset(value: number);
  89516. protected _blurScale: number;
  89517. /**
  89518. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89519. * 2 means half of the size.
  89520. */
  89521. get blurScale(): number;
  89522. /**
  89523. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89524. * 2 means half of the size.
  89525. */
  89526. set blurScale(value: number);
  89527. protected _blurKernel: number;
  89528. /**
  89529. * Gets the blur kernel: kernel size of the blur pass.
  89530. * Only useful if useKernelBlur = true
  89531. */
  89532. get blurKernel(): number;
  89533. /**
  89534. * Sets the blur kernel: kernel size of the blur pass.
  89535. * Only useful if useKernelBlur = true
  89536. */
  89537. set blurKernel(value: number);
  89538. protected _useKernelBlur: boolean;
  89539. /**
  89540. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89541. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89542. */
  89543. get useKernelBlur(): boolean;
  89544. /**
  89545. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89546. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89547. */
  89548. set useKernelBlur(value: boolean);
  89549. protected _depthScale: number;
  89550. /**
  89551. * Gets the depth scale used in ESM mode.
  89552. */
  89553. get depthScale(): number;
  89554. /**
  89555. * Sets the depth scale used in ESM mode.
  89556. * This can override the scale stored on the light.
  89557. */
  89558. set depthScale(value: number);
  89559. protected _validateFilter(filter: number): number;
  89560. protected _filter: number;
  89561. /**
  89562. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89563. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89564. */
  89565. get filter(): number;
  89566. /**
  89567. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89568. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89569. */
  89570. set filter(value: number);
  89571. /**
  89572. * Gets if the current filter is set to Poisson Sampling.
  89573. */
  89574. get usePoissonSampling(): boolean;
  89575. /**
  89576. * Sets the current filter to Poisson Sampling.
  89577. */
  89578. set usePoissonSampling(value: boolean);
  89579. /**
  89580. * Gets if the current filter is set to ESM.
  89581. */
  89582. get useExponentialShadowMap(): boolean;
  89583. /**
  89584. * Sets the current filter is to ESM.
  89585. */
  89586. set useExponentialShadowMap(value: boolean);
  89587. /**
  89588. * Gets if the current filter is set to filtered ESM.
  89589. */
  89590. get useBlurExponentialShadowMap(): boolean;
  89591. /**
  89592. * Gets if the current filter is set to filtered ESM.
  89593. */
  89594. set useBlurExponentialShadowMap(value: boolean);
  89595. /**
  89596. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89597. * exponential to prevent steep falloff artifacts).
  89598. */
  89599. get useCloseExponentialShadowMap(): boolean;
  89600. /**
  89601. * Sets the current filter to "close ESM" (using the inverse of the
  89602. * exponential to prevent steep falloff artifacts).
  89603. */
  89604. set useCloseExponentialShadowMap(value: boolean);
  89605. /**
  89606. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89607. * exponential to prevent steep falloff artifacts).
  89608. */
  89609. get useBlurCloseExponentialShadowMap(): boolean;
  89610. /**
  89611. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89612. * exponential to prevent steep falloff artifacts).
  89613. */
  89614. set useBlurCloseExponentialShadowMap(value: boolean);
  89615. /**
  89616. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89617. */
  89618. get usePercentageCloserFiltering(): boolean;
  89619. /**
  89620. * Sets the current filter to "PCF" (percentage closer filtering).
  89621. */
  89622. set usePercentageCloserFiltering(value: boolean);
  89623. protected _filteringQuality: number;
  89624. /**
  89625. * Gets the PCF or PCSS Quality.
  89626. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89627. */
  89628. get filteringQuality(): number;
  89629. /**
  89630. * Sets the PCF or PCSS Quality.
  89631. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89632. */
  89633. set filteringQuality(filteringQuality: number);
  89634. /**
  89635. * Gets if the current filter is set to "PCSS" (contact hardening).
  89636. */
  89637. get useContactHardeningShadow(): boolean;
  89638. /**
  89639. * Sets the current filter to "PCSS" (contact hardening).
  89640. */
  89641. set useContactHardeningShadow(value: boolean);
  89642. protected _contactHardeningLightSizeUVRatio: number;
  89643. /**
  89644. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89645. * Using a ratio helps keeping shape stability independently of the map size.
  89646. *
  89647. * It does not account for the light projection as it was having too much
  89648. * instability during the light setup or during light position changes.
  89649. *
  89650. * Only valid if useContactHardeningShadow is true.
  89651. */
  89652. get contactHardeningLightSizeUVRatio(): number;
  89653. /**
  89654. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89655. * Using a ratio helps keeping shape stability independently of the map size.
  89656. *
  89657. * It does not account for the light projection as it was having too much
  89658. * instability during the light setup or during light position changes.
  89659. *
  89660. * Only valid if useContactHardeningShadow is true.
  89661. */
  89662. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89663. protected _darkness: number;
  89664. /** Gets or sets the actual darkness of a shadow */
  89665. get darkness(): number;
  89666. set darkness(value: number);
  89667. /**
  89668. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89669. * 0 means strongest and 1 would means no shadow.
  89670. * @returns the darkness.
  89671. */
  89672. getDarkness(): number;
  89673. /**
  89674. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89675. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89676. * @returns the shadow generator allowing fluent coding.
  89677. */
  89678. setDarkness(darkness: number): ShadowGenerator;
  89679. protected _transparencyShadow: boolean;
  89680. /** Gets or sets the ability to have transparent shadow */
  89681. get transparencyShadow(): boolean;
  89682. set transparencyShadow(value: boolean);
  89683. /**
  89684. * Sets the ability to have transparent shadow (boolean).
  89685. * @param transparent True if transparent else False
  89686. * @returns the shadow generator allowing fluent coding
  89687. */
  89688. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89689. protected _shadowMap: Nullable<RenderTargetTexture>;
  89690. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89691. /**
  89692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89693. * @returns The render target texture if present otherwise, null
  89694. */
  89695. getShadowMap(): Nullable<RenderTargetTexture>;
  89696. /**
  89697. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89698. * @returns The render target texture if the shadow map is present otherwise, null
  89699. */
  89700. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89701. /**
  89702. * Gets the class name of that object
  89703. * @returns "ShadowGenerator"
  89704. */
  89705. getClassName(): string;
  89706. /**
  89707. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89708. * @param mesh Mesh to add
  89709. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89710. * @returns the Shadow Generator itself
  89711. */
  89712. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89713. /**
  89714. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89715. * @param mesh Mesh to remove
  89716. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89717. * @returns the Shadow Generator itself
  89718. */
  89719. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89720. /**
  89721. * Controls the extent to which the shadows fade out at the edge of the frustum
  89722. */
  89723. frustumEdgeFalloff: number;
  89724. protected _light: IShadowLight;
  89725. /**
  89726. * Returns the associated light object.
  89727. * @returns the light generating the shadow
  89728. */
  89729. getLight(): IShadowLight;
  89730. /**
  89731. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89732. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89733. * It might on the other hand introduce peter panning.
  89734. */
  89735. forceBackFacesOnly: boolean;
  89736. protected _scene: Scene;
  89737. protected _lightDirection: Vector3;
  89738. protected _effect: Effect;
  89739. protected _viewMatrix: Matrix;
  89740. protected _projectionMatrix: Matrix;
  89741. protected _transformMatrix: Matrix;
  89742. protected _cachedPosition: Vector3;
  89743. protected _cachedDirection: Vector3;
  89744. protected _cachedDefines: string;
  89745. protected _currentRenderID: number;
  89746. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89747. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89748. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89749. protected _blurPostProcesses: PostProcess[];
  89750. protected _mapSize: number;
  89751. protected _currentFaceIndex: number;
  89752. protected _currentFaceIndexCache: number;
  89753. protected _textureType: number;
  89754. protected _defaultTextureMatrix: Matrix;
  89755. protected _storedUniqueId: Nullable<number>;
  89756. /** @hidden */
  89757. static _SceneComponentInitialization: (scene: Scene) => void;
  89758. /**
  89759. * Creates a ShadowGenerator object.
  89760. * A ShadowGenerator is the required tool to use the shadows.
  89761. * Each light casting shadows needs to use its own ShadowGenerator.
  89762. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89763. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89764. * @param light The light object generating the shadows.
  89765. * @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.
  89766. */
  89767. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89768. protected _initializeGenerator(): void;
  89769. protected _createTargetRenderTexture(): void;
  89770. protected _initializeShadowMap(): void;
  89771. protected _initializeBlurRTTAndPostProcesses(): void;
  89772. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89773. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89774. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89775. protected _applyFilterValues(): void;
  89776. /**
  89777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89778. * @param onCompiled Callback triggered at the and of the effects compilation
  89779. * @param options Sets of optional options forcing the compilation with different modes
  89780. */
  89781. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89782. useInstances: boolean;
  89783. }>): void;
  89784. /**
  89785. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89786. * @param options Sets of optional options forcing the compilation with different modes
  89787. * @returns A promise that resolves when the compilation completes
  89788. */
  89789. forceCompilationAsync(options?: Partial<{
  89790. useInstances: boolean;
  89791. }>): Promise<void>;
  89792. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89793. /**
  89794. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89795. * @param subMesh The submesh we want to render in the shadow map
  89796. * @param useInstances Defines wether will draw in the map using instances
  89797. * @returns true if ready otherwise, false
  89798. */
  89799. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89800. /**
  89801. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89802. * @param defines Defines of the material we want to update
  89803. * @param lightIndex Index of the light in the enabled light list of the material
  89804. */
  89805. prepareDefines(defines: any, lightIndex: number): void;
  89806. /**
  89807. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89808. * defined in the generator but impacting the effect).
  89809. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89810. * @param effect The effect we are binfing the information for
  89811. */
  89812. bindShadowLight(lightIndex: string, effect: Effect): void;
  89813. /**
  89814. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89815. * (eq to shadow prjection matrix * light transform matrix)
  89816. * @returns The transform matrix used to create the shadow map
  89817. */
  89818. getTransformMatrix(): Matrix;
  89819. /**
  89820. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89821. * Cube and 2D textures for instance.
  89822. */
  89823. recreateShadowMap(): void;
  89824. protected _disposeBlurPostProcesses(): void;
  89825. protected _disposeRTTandPostProcesses(): void;
  89826. /**
  89827. * Disposes the ShadowGenerator.
  89828. * Returns nothing.
  89829. */
  89830. dispose(): void;
  89831. /**
  89832. * Serializes the shadow generator setup to a json object.
  89833. * @returns The serialized JSON object
  89834. */
  89835. serialize(): any;
  89836. /**
  89837. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89838. * @param parsedShadowGenerator The JSON object to parse
  89839. * @param scene The scene to create the shadow map for
  89840. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89841. * @returns The parsed shadow generator
  89842. */
  89843. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89844. }
  89845. }
  89846. declare module BABYLON {
  89847. /**
  89848. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89849. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89850. * 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.
  89851. */
  89852. export abstract class Light extends Node {
  89853. /**
  89854. * Falloff Default: light is falling off following the material specification:
  89855. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89856. */
  89857. static readonly FALLOFF_DEFAULT: number;
  89858. /**
  89859. * Falloff Physical: light is falling off following the inverse squared distance law.
  89860. */
  89861. static readonly FALLOFF_PHYSICAL: number;
  89862. /**
  89863. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89864. * to enhance interoperability with other engines.
  89865. */
  89866. static readonly FALLOFF_GLTF: number;
  89867. /**
  89868. * Falloff Standard: light is falling off like in the standard material
  89869. * to enhance interoperability with other materials.
  89870. */
  89871. static readonly FALLOFF_STANDARD: number;
  89872. /**
  89873. * If every light affecting the material is in this lightmapMode,
  89874. * material.lightmapTexture adds or multiplies
  89875. * (depends on material.useLightmapAsShadowmap)
  89876. * after every other light calculations.
  89877. */
  89878. static readonly LIGHTMAP_DEFAULT: number;
  89879. /**
  89880. * material.lightmapTexture as only diffuse lighting from this light
  89881. * adds only specular lighting from this light
  89882. * adds dynamic shadows
  89883. */
  89884. static readonly LIGHTMAP_SPECULAR: number;
  89885. /**
  89886. * material.lightmapTexture as only lighting
  89887. * no light calculation from this light
  89888. * only adds dynamic shadows from this light
  89889. */
  89890. static readonly LIGHTMAP_SHADOWSONLY: number;
  89891. /**
  89892. * Each light type uses the default quantity according to its type:
  89893. * point/spot lights use luminous intensity
  89894. * directional lights use illuminance
  89895. */
  89896. static readonly INTENSITYMODE_AUTOMATIC: number;
  89897. /**
  89898. * lumen (lm)
  89899. */
  89900. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89901. /**
  89902. * candela (lm/sr)
  89903. */
  89904. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89905. /**
  89906. * lux (lm/m^2)
  89907. */
  89908. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89909. /**
  89910. * nit (cd/m^2)
  89911. */
  89912. static readonly INTENSITYMODE_LUMINANCE: number;
  89913. /**
  89914. * Light type const id of the point light.
  89915. */
  89916. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89917. /**
  89918. * Light type const id of the directional light.
  89919. */
  89920. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89921. /**
  89922. * Light type const id of the spot light.
  89923. */
  89924. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89925. /**
  89926. * Light type const id of the hemispheric light.
  89927. */
  89928. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89929. /**
  89930. * Diffuse gives the basic color to an object.
  89931. */
  89932. diffuse: Color3;
  89933. /**
  89934. * Specular produces a highlight color on an object.
  89935. * Note: This is note affecting PBR materials.
  89936. */
  89937. specular: Color3;
  89938. /**
  89939. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89940. * falling off base on range or angle.
  89941. * This can be set to any values in Light.FALLOFF_x.
  89942. *
  89943. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89944. * other types of materials.
  89945. */
  89946. falloffType: number;
  89947. /**
  89948. * Strength of the light.
  89949. * Note: By default it is define in the framework own unit.
  89950. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89951. */
  89952. intensity: number;
  89953. private _range;
  89954. protected _inverseSquaredRange: number;
  89955. /**
  89956. * Defines how far from the source the light is impacting in scene units.
  89957. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89958. */
  89959. get range(): number;
  89960. /**
  89961. * Defines how far from the source the light is impacting in scene units.
  89962. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89963. */
  89964. set range(value: number);
  89965. /**
  89966. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89967. * of light.
  89968. */
  89969. private _photometricScale;
  89970. private _intensityMode;
  89971. /**
  89972. * Gets the photometric scale used to interpret the intensity.
  89973. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89974. */
  89975. get intensityMode(): number;
  89976. /**
  89977. * Sets the photometric scale used to interpret the intensity.
  89978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89979. */
  89980. set intensityMode(value: number);
  89981. private _radius;
  89982. /**
  89983. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89984. */
  89985. get radius(): number;
  89986. /**
  89987. * sets the light radius used by PBR Materials to simulate soft area lights.
  89988. */
  89989. set radius(value: number);
  89990. private _renderPriority;
  89991. /**
  89992. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89993. * exceeding the number allowed of the materials.
  89994. */
  89995. renderPriority: number;
  89996. private _shadowEnabled;
  89997. /**
  89998. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89999. * the current shadow generator.
  90000. */
  90001. get shadowEnabled(): boolean;
  90002. /**
  90003. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90004. * the current shadow generator.
  90005. */
  90006. set shadowEnabled(value: boolean);
  90007. private _includedOnlyMeshes;
  90008. /**
  90009. * Gets the only meshes impacted by this light.
  90010. */
  90011. get includedOnlyMeshes(): AbstractMesh[];
  90012. /**
  90013. * Sets the only meshes impacted by this light.
  90014. */
  90015. set includedOnlyMeshes(value: AbstractMesh[]);
  90016. private _excludedMeshes;
  90017. /**
  90018. * Gets the meshes not impacted by this light.
  90019. */
  90020. get excludedMeshes(): AbstractMesh[];
  90021. /**
  90022. * Sets the meshes not impacted by this light.
  90023. */
  90024. set excludedMeshes(value: AbstractMesh[]);
  90025. private _excludeWithLayerMask;
  90026. /**
  90027. * Gets the layer id use to find what meshes are not impacted by the light.
  90028. * Inactive if 0
  90029. */
  90030. get excludeWithLayerMask(): number;
  90031. /**
  90032. * Sets the layer id use to find what meshes are not impacted by the light.
  90033. * Inactive if 0
  90034. */
  90035. set excludeWithLayerMask(value: number);
  90036. private _includeOnlyWithLayerMask;
  90037. /**
  90038. * Gets the layer id use to find what meshes are impacted by the light.
  90039. * Inactive if 0
  90040. */
  90041. get includeOnlyWithLayerMask(): number;
  90042. /**
  90043. * Sets the layer id use to find what meshes are impacted by the light.
  90044. * Inactive if 0
  90045. */
  90046. set includeOnlyWithLayerMask(value: number);
  90047. private _lightmapMode;
  90048. /**
  90049. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90050. */
  90051. get lightmapMode(): number;
  90052. /**
  90053. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90054. */
  90055. set lightmapMode(value: number);
  90056. /**
  90057. * Shadow generator associted to the light.
  90058. * @hidden Internal use only.
  90059. */
  90060. _shadowGenerator: Nullable<IShadowGenerator>;
  90061. /**
  90062. * @hidden Internal use only.
  90063. */
  90064. _excludedMeshesIds: string[];
  90065. /**
  90066. * @hidden Internal use only.
  90067. */
  90068. _includedOnlyMeshesIds: string[];
  90069. /**
  90070. * The current light unifom buffer.
  90071. * @hidden Internal use only.
  90072. */
  90073. _uniformBuffer: UniformBuffer;
  90074. /** @hidden */
  90075. _renderId: number;
  90076. /**
  90077. * Creates a Light object in the scene.
  90078. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90079. * @param name The firendly name of the light
  90080. * @param scene The scene the light belongs too
  90081. */
  90082. constructor(name: string, scene: Scene);
  90083. protected abstract _buildUniformLayout(): void;
  90084. /**
  90085. * Sets the passed Effect "effect" with the Light information.
  90086. * @param effect The effect to update
  90087. * @param lightIndex The index of the light in the effect to update
  90088. * @returns The light
  90089. */
  90090. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90091. /**
  90092. * Sets the passed Effect "effect" with the Light textures.
  90093. * @param effect The effect to update
  90094. * @param lightIndex The index of the light in the effect to update
  90095. * @returns The light
  90096. */
  90097. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90098. /**
  90099. * Binds the lights information from the scene to the effect for the given mesh.
  90100. * @param lightIndex Light index
  90101. * @param scene The scene where the light belongs to
  90102. * @param effect The effect we are binding the data to
  90103. * @param useSpecular Defines if specular is supported
  90104. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90105. */
  90106. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90107. /**
  90108. * Sets the passed Effect "effect" with the Light information.
  90109. * @param effect The effect to update
  90110. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90111. * @returns The light
  90112. */
  90113. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90114. /**
  90115. * Returns the string "Light".
  90116. * @returns the class name
  90117. */
  90118. getClassName(): string;
  90119. /** @hidden */
  90120. readonly _isLight: boolean;
  90121. /**
  90122. * Converts the light information to a readable string for debug purpose.
  90123. * @param fullDetails Supports for multiple levels of logging within scene loading
  90124. * @returns the human readable light info
  90125. */
  90126. toString(fullDetails?: boolean): string;
  90127. /** @hidden */
  90128. protected _syncParentEnabledState(): void;
  90129. /**
  90130. * Set the enabled state of this node.
  90131. * @param value - the new enabled state
  90132. */
  90133. setEnabled(value: boolean): void;
  90134. /**
  90135. * Returns the Light associated shadow generator if any.
  90136. * @return the associated shadow generator.
  90137. */
  90138. getShadowGenerator(): Nullable<IShadowGenerator>;
  90139. /**
  90140. * Returns a Vector3, the absolute light position in the World.
  90141. * @returns the world space position of the light
  90142. */
  90143. getAbsolutePosition(): Vector3;
  90144. /**
  90145. * Specifies if the light will affect the passed mesh.
  90146. * @param mesh The mesh to test against the light
  90147. * @return true the mesh is affected otherwise, false.
  90148. */
  90149. canAffectMesh(mesh: AbstractMesh): boolean;
  90150. /**
  90151. * Sort function to order lights for rendering.
  90152. * @param a First Light object to compare to second.
  90153. * @param b Second Light object to compare first.
  90154. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90155. */
  90156. static CompareLightsPriority(a: Light, b: Light): number;
  90157. /**
  90158. * Releases resources associated with this node.
  90159. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90160. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90161. */
  90162. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90163. /**
  90164. * Returns the light type ID (integer).
  90165. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90166. */
  90167. getTypeID(): number;
  90168. /**
  90169. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90170. * @returns the scaled intensity in intensity mode unit
  90171. */
  90172. getScaledIntensity(): number;
  90173. /**
  90174. * Returns a new Light object, named "name", from the current one.
  90175. * @param name The name of the cloned light
  90176. * @returns the new created light
  90177. */
  90178. clone(name: string): Nullable<Light>;
  90179. /**
  90180. * Serializes the current light into a Serialization object.
  90181. * @returns the serialized object.
  90182. */
  90183. serialize(): any;
  90184. /**
  90185. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90186. * This new light is named "name" and added to the passed scene.
  90187. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90188. * @param name The friendly name of the light
  90189. * @param scene The scene the new light will belong to
  90190. * @returns the constructor function
  90191. */
  90192. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90193. /**
  90194. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90195. * @param parsedLight The JSON representation of the light
  90196. * @param scene The scene to create the parsed light in
  90197. * @returns the created light after parsing
  90198. */
  90199. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90200. private _hookArrayForExcluded;
  90201. private _hookArrayForIncludedOnly;
  90202. private _resyncMeshes;
  90203. /**
  90204. * Forces the meshes to update their light related information in their rendering used effects
  90205. * @hidden Internal Use Only
  90206. */
  90207. _markMeshesAsLightDirty(): void;
  90208. /**
  90209. * Recomputes the cached photometric scale if needed.
  90210. */
  90211. private _computePhotometricScale;
  90212. /**
  90213. * Returns the Photometric Scale according to the light type and intensity mode.
  90214. */
  90215. private _getPhotometricScale;
  90216. /**
  90217. * Reorder the light in the scene according to their defined priority.
  90218. * @hidden Internal Use Only
  90219. */
  90220. _reorderLightsInScene(): void;
  90221. /**
  90222. * Prepares the list of defines specific to the light type.
  90223. * @param defines the list of defines
  90224. * @param lightIndex defines the index of the light for the effect
  90225. */
  90226. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90227. }
  90228. }
  90229. declare module BABYLON {
  90230. /**
  90231. * Interface used to define Action
  90232. */
  90233. export interface IAction {
  90234. /**
  90235. * Trigger for the action
  90236. */
  90237. trigger: number;
  90238. /** Options of the trigger */
  90239. triggerOptions: any;
  90240. /**
  90241. * Gets the trigger parameters
  90242. * @returns the trigger parameters
  90243. */
  90244. getTriggerParameter(): any;
  90245. /**
  90246. * Internal only - executes current action event
  90247. * @hidden
  90248. */
  90249. _executeCurrent(evt?: ActionEvent): void;
  90250. /**
  90251. * Serialize placeholder for child classes
  90252. * @param parent of child
  90253. * @returns the serialized object
  90254. */
  90255. serialize(parent: any): any;
  90256. /**
  90257. * Internal only
  90258. * @hidden
  90259. */
  90260. _prepare(): void;
  90261. /**
  90262. * Internal only - manager for action
  90263. * @hidden
  90264. */
  90265. _actionManager: AbstractActionManager;
  90266. /**
  90267. * Adds action to chain of actions, may be a DoNothingAction
  90268. * @param action defines the next action to execute
  90269. * @returns The action passed in
  90270. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90271. */
  90272. then(action: IAction): IAction;
  90273. }
  90274. /**
  90275. * The action to be carried out following a trigger
  90276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90277. */
  90278. export class Action implements IAction {
  90279. /** the trigger, with or without parameters, for the action */
  90280. triggerOptions: any;
  90281. /**
  90282. * Trigger for the action
  90283. */
  90284. trigger: number;
  90285. /**
  90286. * Internal only - manager for action
  90287. * @hidden
  90288. */
  90289. _actionManager: ActionManager;
  90290. private _nextActiveAction;
  90291. private _child;
  90292. private _condition?;
  90293. private _triggerParameter;
  90294. /**
  90295. * An event triggered prior to action being executed.
  90296. */
  90297. onBeforeExecuteObservable: Observable<Action>;
  90298. /**
  90299. * Creates a new Action
  90300. * @param triggerOptions the trigger, with or without parameters, for the action
  90301. * @param condition an optional determinant of action
  90302. */
  90303. constructor(
  90304. /** the trigger, with or without parameters, for the action */
  90305. triggerOptions: any, condition?: Condition);
  90306. /**
  90307. * Internal only
  90308. * @hidden
  90309. */
  90310. _prepare(): void;
  90311. /**
  90312. * Gets the trigger parameters
  90313. * @returns the trigger parameters
  90314. */
  90315. getTriggerParameter(): any;
  90316. /**
  90317. * Internal only - executes current action event
  90318. * @hidden
  90319. */
  90320. _executeCurrent(evt?: ActionEvent): void;
  90321. /**
  90322. * Execute placeholder for child classes
  90323. * @param evt optional action event
  90324. */
  90325. execute(evt?: ActionEvent): void;
  90326. /**
  90327. * Skips to next active action
  90328. */
  90329. skipToNextActiveAction(): void;
  90330. /**
  90331. * Adds action to chain of actions, may be a DoNothingAction
  90332. * @param action defines the next action to execute
  90333. * @returns The action passed in
  90334. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90335. */
  90336. then(action: Action): Action;
  90337. /**
  90338. * Internal only
  90339. * @hidden
  90340. */
  90341. _getProperty(propertyPath: string): string;
  90342. /**
  90343. * Internal only
  90344. * @hidden
  90345. */
  90346. _getEffectiveTarget(target: any, propertyPath: string): any;
  90347. /**
  90348. * Serialize placeholder for child classes
  90349. * @param parent of child
  90350. * @returns the serialized object
  90351. */
  90352. serialize(parent: any): any;
  90353. /**
  90354. * Internal only called by serialize
  90355. * @hidden
  90356. */
  90357. protected _serialize(serializedAction: any, parent?: any): any;
  90358. /**
  90359. * Internal only
  90360. * @hidden
  90361. */
  90362. static _SerializeValueAsString: (value: any) => string;
  90363. /**
  90364. * Internal only
  90365. * @hidden
  90366. */
  90367. static _GetTargetProperty: (target: Node | Scene) => {
  90368. name: string;
  90369. targetType: string;
  90370. value: string;
  90371. };
  90372. }
  90373. }
  90374. declare module BABYLON {
  90375. /**
  90376. * A Condition applied to an Action
  90377. */
  90378. export class Condition {
  90379. /**
  90380. * Internal only - manager for action
  90381. * @hidden
  90382. */
  90383. _actionManager: ActionManager;
  90384. /**
  90385. * Internal only
  90386. * @hidden
  90387. */
  90388. _evaluationId: number;
  90389. /**
  90390. * Internal only
  90391. * @hidden
  90392. */
  90393. _currentResult: boolean;
  90394. /**
  90395. * Creates a new Condition
  90396. * @param actionManager the manager of the action the condition is applied to
  90397. */
  90398. constructor(actionManager: ActionManager);
  90399. /**
  90400. * Check if the current condition is valid
  90401. * @returns a boolean
  90402. */
  90403. isValid(): boolean;
  90404. /**
  90405. * Internal only
  90406. * @hidden
  90407. */
  90408. _getProperty(propertyPath: string): string;
  90409. /**
  90410. * Internal only
  90411. * @hidden
  90412. */
  90413. _getEffectiveTarget(target: any, propertyPath: string): any;
  90414. /**
  90415. * Serialize placeholder for child classes
  90416. * @returns the serialized object
  90417. */
  90418. serialize(): any;
  90419. /**
  90420. * Internal only
  90421. * @hidden
  90422. */
  90423. protected _serialize(serializedCondition: any): any;
  90424. }
  90425. /**
  90426. * Defines specific conditional operators as extensions of Condition
  90427. */
  90428. export class ValueCondition extends Condition {
  90429. /** path to specify the property of the target the conditional operator uses */
  90430. propertyPath: string;
  90431. /** the value compared by the conditional operator against the current value of the property */
  90432. value: any;
  90433. /** the conditional operator, default ValueCondition.IsEqual */
  90434. operator: number;
  90435. /**
  90436. * Internal only
  90437. * @hidden
  90438. */
  90439. private static _IsEqual;
  90440. /**
  90441. * Internal only
  90442. * @hidden
  90443. */
  90444. private static _IsDifferent;
  90445. /**
  90446. * Internal only
  90447. * @hidden
  90448. */
  90449. private static _IsGreater;
  90450. /**
  90451. * Internal only
  90452. * @hidden
  90453. */
  90454. private static _IsLesser;
  90455. /**
  90456. * returns the number for IsEqual
  90457. */
  90458. static get IsEqual(): number;
  90459. /**
  90460. * Returns the number for IsDifferent
  90461. */
  90462. static get IsDifferent(): number;
  90463. /**
  90464. * Returns the number for IsGreater
  90465. */
  90466. static get IsGreater(): number;
  90467. /**
  90468. * Returns the number for IsLesser
  90469. */
  90470. static get IsLesser(): number;
  90471. /**
  90472. * Internal only The action manager for the condition
  90473. * @hidden
  90474. */
  90475. _actionManager: ActionManager;
  90476. /**
  90477. * Internal only
  90478. * @hidden
  90479. */
  90480. private _target;
  90481. /**
  90482. * Internal only
  90483. * @hidden
  90484. */
  90485. private _effectiveTarget;
  90486. /**
  90487. * Internal only
  90488. * @hidden
  90489. */
  90490. private _property;
  90491. /**
  90492. * Creates a new ValueCondition
  90493. * @param actionManager manager for the action the condition applies to
  90494. * @param target for the action
  90495. * @param propertyPath path to specify the property of the target the conditional operator uses
  90496. * @param value the value compared by the conditional operator against the current value of the property
  90497. * @param operator the conditional operator, default ValueCondition.IsEqual
  90498. */
  90499. constructor(actionManager: ActionManager, target: any,
  90500. /** path to specify the property of the target the conditional operator uses */
  90501. propertyPath: string,
  90502. /** the value compared by the conditional operator against the current value of the property */
  90503. value: any,
  90504. /** the conditional operator, default ValueCondition.IsEqual */
  90505. operator?: number);
  90506. /**
  90507. * Compares the given value with the property value for the specified conditional operator
  90508. * @returns the result of the comparison
  90509. */
  90510. isValid(): boolean;
  90511. /**
  90512. * Serialize the ValueCondition into a JSON compatible object
  90513. * @returns serialization object
  90514. */
  90515. serialize(): any;
  90516. /**
  90517. * Gets the name of the conditional operator for the ValueCondition
  90518. * @param operator the conditional operator
  90519. * @returns the name
  90520. */
  90521. static GetOperatorName(operator: number): string;
  90522. }
  90523. /**
  90524. * Defines a predicate condition as an extension of Condition
  90525. */
  90526. export class PredicateCondition extends Condition {
  90527. /** defines the predicate function used to validate the condition */
  90528. predicate: () => boolean;
  90529. /**
  90530. * Internal only - manager for action
  90531. * @hidden
  90532. */
  90533. _actionManager: ActionManager;
  90534. /**
  90535. * Creates a new PredicateCondition
  90536. * @param actionManager manager for the action the condition applies to
  90537. * @param predicate defines the predicate function used to validate the condition
  90538. */
  90539. constructor(actionManager: ActionManager,
  90540. /** defines the predicate function used to validate the condition */
  90541. predicate: () => boolean);
  90542. /**
  90543. * @returns the validity of the predicate condition
  90544. */
  90545. isValid(): boolean;
  90546. }
  90547. /**
  90548. * Defines a state condition as an extension of Condition
  90549. */
  90550. export class StateCondition extends Condition {
  90551. /** Value to compare with target state */
  90552. value: string;
  90553. /**
  90554. * Internal only - manager for action
  90555. * @hidden
  90556. */
  90557. _actionManager: ActionManager;
  90558. /**
  90559. * Internal only
  90560. * @hidden
  90561. */
  90562. private _target;
  90563. /**
  90564. * Creates a new StateCondition
  90565. * @param actionManager manager for the action the condition applies to
  90566. * @param target of the condition
  90567. * @param value to compare with target state
  90568. */
  90569. constructor(actionManager: ActionManager, target: any,
  90570. /** Value to compare with target state */
  90571. value: string);
  90572. /**
  90573. * Gets a boolean indicating if the current condition is met
  90574. * @returns the validity of the state
  90575. */
  90576. isValid(): boolean;
  90577. /**
  90578. * Serialize the StateCondition into a JSON compatible object
  90579. * @returns serialization object
  90580. */
  90581. serialize(): any;
  90582. }
  90583. }
  90584. declare module BABYLON {
  90585. /**
  90586. * This defines an action responsible to toggle a boolean once triggered.
  90587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90588. */
  90589. export class SwitchBooleanAction extends Action {
  90590. /**
  90591. * The path to the boolean property in the target object
  90592. */
  90593. propertyPath: string;
  90594. private _target;
  90595. private _effectiveTarget;
  90596. private _property;
  90597. /**
  90598. * Instantiate the action
  90599. * @param triggerOptions defines the trigger options
  90600. * @param target defines the object containing the boolean
  90601. * @param propertyPath defines the path to the boolean property in the target object
  90602. * @param condition defines the trigger related conditions
  90603. */
  90604. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90605. /** @hidden */
  90606. _prepare(): void;
  90607. /**
  90608. * Execute the action toggle the boolean value.
  90609. */
  90610. execute(): void;
  90611. /**
  90612. * Serializes the actions and its related information.
  90613. * @param parent defines the object to serialize in
  90614. * @returns the serialized object
  90615. */
  90616. serialize(parent: any): any;
  90617. }
  90618. /**
  90619. * This defines an action responsible to set a the state field of the target
  90620. * to a desired value once triggered.
  90621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90622. */
  90623. export class SetStateAction extends Action {
  90624. /**
  90625. * The value to store in the state field.
  90626. */
  90627. value: string;
  90628. private _target;
  90629. /**
  90630. * Instantiate the action
  90631. * @param triggerOptions defines the trigger options
  90632. * @param target defines the object containing the state property
  90633. * @param value defines the value to store in the state field
  90634. * @param condition defines the trigger related conditions
  90635. */
  90636. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90637. /**
  90638. * Execute the action and store the value on the target state property.
  90639. */
  90640. execute(): void;
  90641. /**
  90642. * Serializes the actions and its related information.
  90643. * @param parent defines the object to serialize in
  90644. * @returns the serialized object
  90645. */
  90646. serialize(parent: any): any;
  90647. }
  90648. /**
  90649. * This defines an action responsible to set a property of the target
  90650. * to a desired value once triggered.
  90651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90652. */
  90653. export class SetValueAction extends Action {
  90654. /**
  90655. * The path of the property to set in the target.
  90656. */
  90657. propertyPath: string;
  90658. /**
  90659. * The value to set in the property
  90660. */
  90661. value: any;
  90662. private _target;
  90663. private _effectiveTarget;
  90664. private _property;
  90665. /**
  90666. * Instantiate the action
  90667. * @param triggerOptions defines the trigger options
  90668. * @param target defines the object containing the property
  90669. * @param propertyPath defines the path of the property to set in the target
  90670. * @param value defines the value to set in the property
  90671. * @param condition defines the trigger related conditions
  90672. */
  90673. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90674. /** @hidden */
  90675. _prepare(): void;
  90676. /**
  90677. * Execute the action and set the targetted property to the desired value.
  90678. */
  90679. execute(): void;
  90680. /**
  90681. * Serializes the actions and its related information.
  90682. * @param parent defines the object to serialize in
  90683. * @returns the serialized object
  90684. */
  90685. serialize(parent: any): any;
  90686. }
  90687. /**
  90688. * This defines an action responsible to increment the target value
  90689. * to a desired value once triggered.
  90690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90691. */
  90692. export class IncrementValueAction extends Action {
  90693. /**
  90694. * The path of the property to increment in the target.
  90695. */
  90696. propertyPath: string;
  90697. /**
  90698. * The value we should increment the property by.
  90699. */
  90700. value: any;
  90701. private _target;
  90702. private _effectiveTarget;
  90703. private _property;
  90704. /**
  90705. * Instantiate the action
  90706. * @param triggerOptions defines the trigger options
  90707. * @param target defines the object containing the property
  90708. * @param propertyPath defines the path of the property to increment in the target
  90709. * @param value defines the value value we should increment the property by
  90710. * @param condition defines the trigger related conditions
  90711. */
  90712. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90713. /** @hidden */
  90714. _prepare(): void;
  90715. /**
  90716. * Execute the action and increment the target of the value amount.
  90717. */
  90718. execute(): void;
  90719. /**
  90720. * Serializes the actions and its related information.
  90721. * @param parent defines the object to serialize in
  90722. * @returns the serialized object
  90723. */
  90724. serialize(parent: any): any;
  90725. }
  90726. /**
  90727. * This defines an action responsible to start an animation once triggered.
  90728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90729. */
  90730. export class PlayAnimationAction extends Action {
  90731. /**
  90732. * Where the animation should start (animation frame)
  90733. */
  90734. from: number;
  90735. /**
  90736. * Where the animation should stop (animation frame)
  90737. */
  90738. to: number;
  90739. /**
  90740. * Define if the animation should loop or stop after the first play.
  90741. */
  90742. loop?: boolean;
  90743. private _target;
  90744. /**
  90745. * Instantiate the action
  90746. * @param triggerOptions defines the trigger options
  90747. * @param target defines the target animation or animation name
  90748. * @param from defines from where the animation should start (animation frame)
  90749. * @param end defines where the animation should stop (animation frame)
  90750. * @param loop defines if the animation should loop or stop after the first play
  90751. * @param condition defines the trigger related conditions
  90752. */
  90753. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90754. /** @hidden */
  90755. _prepare(): void;
  90756. /**
  90757. * Execute the action and play the animation.
  90758. */
  90759. execute(): void;
  90760. /**
  90761. * Serializes the actions and its related information.
  90762. * @param parent defines the object to serialize in
  90763. * @returns the serialized object
  90764. */
  90765. serialize(parent: any): any;
  90766. }
  90767. /**
  90768. * This defines an action responsible to stop an animation once triggered.
  90769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90770. */
  90771. export class StopAnimationAction extends Action {
  90772. private _target;
  90773. /**
  90774. * Instantiate the action
  90775. * @param triggerOptions defines the trigger options
  90776. * @param target defines the target animation or animation name
  90777. * @param condition defines the trigger related conditions
  90778. */
  90779. constructor(triggerOptions: any, target: any, condition?: Condition);
  90780. /** @hidden */
  90781. _prepare(): void;
  90782. /**
  90783. * Execute the action and stop the animation.
  90784. */
  90785. execute(): void;
  90786. /**
  90787. * Serializes the actions and its related information.
  90788. * @param parent defines the object to serialize in
  90789. * @returns the serialized object
  90790. */
  90791. serialize(parent: any): any;
  90792. }
  90793. /**
  90794. * This defines an action responsible that does nothing once triggered.
  90795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90796. */
  90797. export class DoNothingAction extends Action {
  90798. /**
  90799. * Instantiate the action
  90800. * @param triggerOptions defines the trigger options
  90801. * @param condition defines the trigger related conditions
  90802. */
  90803. constructor(triggerOptions?: any, condition?: Condition);
  90804. /**
  90805. * Execute the action and do nothing.
  90806. */
  90807. execute(): void;
  90808. /**
  90809. * Serializes the actions and its related information.
  90810. * @param parent defines the object to serialize in
  90811. * @returns the serialized object
  90812. */
  90813. serialize(parent: any): any;
  90814. }
  90815. /**
  90816. * This defines an action responsible to trigger several actions once triggered.
  90817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90818. */
  90819. export class CombineAction extends Action {
  90820. /**
  90821. * The list of aggregated animations to run.
  90822. */
  90823. children: Action[];
  90824. /**
  90825. * Instantiate the action
  90826. * @param triggerOptions defines the trigger options
  90827. * @param children defines the list of aggregated animations to run
  90828. * @param condition defines the trigger related conditions
  90829. */
  90830. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90831. /** @hidden */
  90832. _prepare(): void;
  90833. /**
  90834. * Execute the action and executes all the aggregated actions.
  90835. */
  90836. execute(evt: ActionEvent): void;
  90837. /**
  90838. * Serializes the actions and its related information.
  90839. * @param parent defines the object to serialize in
  90840. * @returns the serialized object
  90841. */
  90842. serialize(parent: any): any;
  90843. }
  90844. /**
  90845. * This defines an action responsible to run code (external event) once triggered.
  90846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90847. */
  90848. export class ExecuteCodeAction extends Action {
  90849. /**
  90850. * The callback function to run.
  90851. */
  90852. func: (evt: ActionEvent) => void;
  90853. /**
  90854. * Instantiate the action
  90855. * @param triggerOptions defines the trigger options
  90856. * @param func defines the callback function to run
  90857. * @param condition defines the trigger related conditions
  90858. */
  90859. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90860. /**
  90861. * Execute the action and run the attached code.
  90862. */
  90863. execute(evt: ActionEvent): void;
  90864. }
  90865. /**
  90866. * This defines an action responsible to set the parent property of the target once triggered.
  90867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90868. */
  90869. export class SetParentAction extends Action {
  90870. private _parent;
  90871. private _target;
  90872. /**
  90873. * Instantiate the action
  90874. * @param triggerOptions defines the trigger options
  90875. * @param target defines the target containing the parent property
  90876. * @param parent defines from where the animation should start (animation frame)
  90877. * @param condition defines the trigger related conditions
  90878. */
  90879. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90880. /** @hidden */
  90881. _prepare(): void;
  90882. /**
  90883. * Execute the action and set the parent property.
  90884. */
  90885. execute(): void;
  90886. /**
  90887. * Serializes the actions and its related information.
  90888. * @param parent defines the object to serialize in
  90889. * @returns the serialized object
  90890. */
  90891. serialize(parent: any): any;
  90892. }
  90893. }
  90894. declare module BABYLON {
  90895. /**
  90896. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90897. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90899. */
  90900. export class ActionManager extends AbstractActionManager {
  90901. /**
  90902. * Nothing
  90903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90904. */
  90905. static readonly NothingTrigger: number;
  90906. /**
  90907. * On pick
  90908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90909. */
  90910. static readonly OnPickTrigger: number;
  90911. /**
  90912. * On left pick
  90913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90914. */
  90915. static readonly OnLeftPickTrigger: number;
  90916. /**
  90917. * On right pick
  90918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90919. */
  90920. static readonly OnRightPickTrigger: number;
  90921. /**
  90922. * On center pick
  90923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90924. */
  90925. static readonly OnCenterPickTrigger: number;
  90926. /**
  90927. * On pick down
  90928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90929. */
  90930. static readonly OnPickDownTrigger: number;
  90931. /**
  90932. * On double pick
  90933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90934. */
  90935. static readonly OnDoublePickTrigger: number;
  90936. /**
  90937. * On pick up
  90938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90939. */
  90940. static readonly OnPickUpTrigger: number;
  90941. /**
  90942. * On pick out.
  90943. * This trigger will only be raised if you also declared a OnPickDown
  90944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90945. */
  90946. static readonly OnPickOutTrigger: number;
  90947. /**
  90948. * On long press
  90949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90950. */
  90951. static readonly OnLongPressTrigger: number;
  90952. /**
  90953. * On pointer over
  90954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90955. */
  90956. static readonly OnPointerOverTrigger: number;
  90957. /**
  90958. * On pointer out
  90959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90960. */
  90961. static readonly OnPointerOutTrigger: number;
  90962. /**
  90963. * On every frame
  90964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90965. */
  90966. static readonly OnEveryFrameTrigger: number;
  90967. /**
  90968. * On intersection enter
  90969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90970. */
  90971. static readonly OnIntersectionEnterTrigger: number;
  90972. /**
  90973. * On intersection exit
  90974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90975. */
  90976. static readonly OnIntersectionExitTrigger: number;
  90977. /**
  90978. * On key down
  90979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90980. */
  90981. static readonly OnKeyDownTrigger: number;
  90982. /**
  90983. * On key up
  90984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90985. */
  90986. static readonly OnKeyUpTrigger: number;
  90987. private _scene;
  90988. /**
  90989. * Creates a new action manager
  90990. * @param scene defines the hosting scene
  90991. */
  90992. constructor(scene: Scene);
  90993. /**
  90994. * Releases all associated resources
  90995. */
  90996. dispose(): void;
  90997. /**
  90998. * Gets hosting scene
  90999. * @returns the hosting scene
  91000. */
  91001. getScene(): Scene;
  91002. /**
  91003. * Does this action manager handles actions of any of the given triggers
  91004. * @param triggers defines the triggers to be tested
  91005. * @return a boolean indicating whether one (or more) of the triggers is handled
  91006. */
  91007. hasSpecificTriggers(triggers: number[]): boolean;
  91008. /**
  91009. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91010. * speed.
  91011. * @param triggerA defines the trigger to be tested
  91012. * @param triggerB defines the trigger to be tested
  91013. * @return a boolean indicating whether one (or more) of the triggers is handled
  91014. */
  91015. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91016. /**
  91017. * Does this action manager handles actions of a given trigger
  91018. * @param trigger defines the trigger to be tested
  91019. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91020. * @return whether the trigger is handled
  91021. */
  91022. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91023. /**
  91024. * Does this action manager has pointer triggers
  91025. */
  91026. get hasPointerTriggers(): boolean;
  91027. /**
  91028. * Does this action manager has pick triggers
  91029. */
  91030. get hasPickTriggers(): boolean;
  91031. /**
  91032. * Registers an action to this action manager
  91033. * @param action defines the action to be registered
  91034. * @return the action amended (prepared) after registration
  91035. */
  91036. registerAction(action: IAction): Nullable<IAction>;
  91037. /**
  91038. * Unregisters an action to this action manager
  91039. * @param action defines the action to be unregistered
  91040. * @return a boolean indicating whether the action has been unregistered
  91041. */
  91042. unregisterAction(action: IAction): Boolean;
  91043. /**
  91044. * Process a specific trigger
  91045. * @param trigger defines the trigger to process
  91046. * @param evt defines the event details to be processed
  91047. */
  91048. processTrigger(trigger: number, evt?: IActionEvent): void;
  91049. /** @hidden */
  91050. _getEffectiveTarget(target: any, propertyPath: string): any;
  91051. /** @hidden */
  91052. _getProperty(propertyPath: string): string;
  91053. /**
  91054. * Serialize this manager to a JSON object
  91055. * @param name defines the property name to store this manager
  91056. * @returns a JSON representation of this manager
  91057. */
  91058. serialize(name: string): any;
  91059. /**
  91060. * Creates a new ActionManager from a JSON data
  91061. * @param parsedActions defines the JSON data to read from
  91062. * @param object defines the hosting mesh
  91063. * @param scene defines the hosting scene
  91064. */
  91065. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91066. /**
  91067. * Get a trigger name by index
  91068. * @param trigger defines the trigger index
  91069. * @returns a trigger name
  91070. */
  91071. static GetTriggerName(trigger: number): string;
  91072. }
  91073. }
  91074. declare module BABYLON {
  91075. /**
  91076. * Class used to represent a sprite
  91077. * @see http://doc.babylonjs.com/babylon101/sprites
  91078. */
  91079. export class Sprite {
  91080. /** defines the name */
  91081. name: string;
  91082. /** Gets or sets the current world position */
  91083. position: Vector3;
  91084. /** Gets or sets the main color */
  91085. color: Color4;
  91086. /** Gets or sets the width */
  91087. width: number;
  91088. /** Gets or sets the height */
  91089. height: number;
  91090. /** Gets or sets rotation angle */
  91091. angle: number;
  91092. /** Gets or sets the cell index in the sprite sheet */
  91093. cellIndex: number;
  91094. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91095. cellRef: string;
  91096. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91097. invertU: number;
  91098. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91099. invertV: number;
  91100. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91101. disposeWhenFinishedAnimating: boolean;
  91102. /** Gets the list of attached animations */
  91103. animations: Animation[];
  91104. /** Gets or sets a boolean indicating if the sprite can be picked */
  91105. isPickable: boolean;
  91106. /**
  91107. * Gets or sets the associated action manager
  91108. */
  91109. actionManager: Nullable<ActionManager>;
  91110. private _animationStarted;
  91111. private _loopAnimation;
  91112. private _fromIndex;
  91113. private _toIndex;
  91114. private _delay;
  91115. private _direction;
  91116. private _manager;
  91117. private _time;
  91118. private _onAnimationEnd;
  91119. /**
  91120. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91121. */
  91122. isVisible: boolean;
  91123. /**
  91124. * Gets or sets the sprite size
  91125. */
  91126. get size(): number;
  91127. set size(value: number);
  91128. /**
  91129. * Creates a new Sprite
  91130. * @param name defines the name
  91131. * @param manager defines the manager
  91132. */
  91133. constructor(
  91134. /** defines the name */
  91135. name: string, manager: ISpriteManager);
  91136. /**
  91137. * Starts an animation
  91138. * @param from defines the initial key
  91139. * @param to defines the end key
  91140. * @param loop defines if the animation must loop
  91141. * @param delay defines the start delay (in ms)
  91142. * @param onAnimationEnd defines a callback to call when animation ends
  91143. */
  91144. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91145. /** Stops current animation (if any) */
  91146. stopAnimation(): void;
  91147. /** @hidden */
  91148. _animate(deltaTime: number): void;
  91149. /** Release associated resources */
  91150. dispose(): void;
  91151. }
  91152. }
  91153. declare module BABYLON {
  91154. /**
  91155. * Information about the result of picking within a scene
  91156. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91157. */
  91158. export class PickingInfo {
  91159. /** @hidden */
  91160. _pickingUnavailable: boolean;
  91161. /**
  91162. * If the pick collided with an object
  91163. */
  91164. hit: boolean;
  91165. /**
  91166. * Distance away where the pick collided
  91167. */
  91168. distance: number;
  91169. /**
  91170. * The location of pick collision
  91171. */
  91172. pickedPoint: Nullable<Vector3>;
  91173. /**
  91174. * The mesh corresponding the the pick collision
  91175. */
  91176. pickedMesh: Nullable<AbstractMesh>;
  91177. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91178. bu: number;
  91179. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91180. bv: number;
  91181. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91182. faceId: number;
  91183. /** Id of the the submesh that was picked */
  91184. subMeshId: number;
  91185. /** If a sprite was picked, this will be the sprite the pick collided with */
  91186. pickedSprite: Nullable<Sprite>;
  91187. /**
  91188. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91189. */
  91190. originMesh: Nullable<AbstractMesh>;
  91191. /**
  91192. * The ray that was used to perform the picking.
  91193. */
  91194. ray: Nullable<Ray>;
  91195. /**
  91196. * Gets the normal correspodning to the face the pick collided with
  91197. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91198. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91199. * @returns The normal correspodning to the face the pick collided with
  91200. */
  91201. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91202. /**
  91203. * Gets the texture coordinates of where the pick occured
  91204. * @returns the vector containing the coordnates of the texture
  91205. */
  91206. getTextureCoordinates(): Nullable<Vector2>;
  91207. }
  91208. }
  91209. declare module BABYLON {
  91210. /**
  91211. * Gather the list of pointer event types as constants.
  91212. */
  91213. export class PointerEventTypes {
  91214. /**
  91215. * 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.
  91216. */
  91217. static readonly POINTERDOWN: number;
  91218. /**
  91219. * The pointerup event is fired when a pointer is no longer active.
  91220. */
  91221. static readonly POINTERUP: number;
  91222. /**
  91223. * The pointermove event is fired when a pointer changes coordinates.
  91224. */
  91225. static readonly POINTERMOVE: number;
  91226. /**
  91227. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91228. */
  91229. static readonly POINTERWHEEL: number;
  91230. /**
  91231. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91232. */
  91233. static readonly POINTERPICK: number;
  91234. /**
  91235. * The pointertap event is fired when a the object has been touched and released without drag.
  91236. */
  91237. static readonly POINTERTAP: number;
  91238. /**
  91239. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91240. */
  91241. static readonly POINTERDOUBLETAP: number;
  91242. }
  91243. /**
  91244. * Base class of pointer info types.
  91245. */
  91246. export class PointerInfoBase {
  91247. /**
  91248. * Defines the type of event (PointerEventTypes)
  91249. */
  91250. type: number;
  91251. /**
  91252. * Defines the related dom event
  91253. */
  91254. event: PointerEvent | MouseWheelEvent;
  91255. /**
  91256. * Instantiates the base class of pointers info.
  91257. * @param type Defines the type of event (PointerEventTypes)
  91258. * @param event Defines the related dom event
  91259. */
  91260. constructor(
  91261. /**
  91262. * Defines the type of event (PointerEventTypes)
  91263. */
  91264. type: number,
  91265. /**
  91266. * Defines the related dom event
  91267. */
  91268. event: PointerEvent | MouseWheelEvent);
  91269. }
  91270. /**
  91271. * This class is used to store pointer related info for the onPrePointerObservable event.
  91272. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91273. */
  91274. export class PointerInfoPre extends PointerInfoBase {
  91275. /**
  91276. * Ray from a pointer if availible (eg. 6dof controller)
  91277. */
  91278. ray: Nullable<Ray>;
  91279. /**
  91280. * Defines the local position of the pointer on the canvas.
  91281. */
  91282. localPosition: Vector2;
  91283. /**
  91284. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91285. */
  91286. skipOnPointerObservable: boolean;
  91287. /**
  91288. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91289. * @param type Defines the type of event (PointerEventTypes)
  91290. * @param event Defines the related dom event
  91291. * @param localX Defines the local x coordinates of the pointer when the event occured
  91292. * @param localY Defines the local y coordinates of the pointer when the event occured
  91293. */
  91294. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91295. }
  91296. /**
  91297. * This type contains all the data related to a pointer event in Babylon.js.
  91298. * 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.
  91299. */
  91300. export class PointerInfo extends PointerInfoBase {
  91301. /**
  91302. * Defines the picking info associated to the info (if any)\
  91303. */
  91304. pickInfo: Nullable<PickingInfo>;
  91305. /**
  91306. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91307. * @param type Defines the type of event (PointerEventTypes)
  91308. * @param event Defines the related dom event
  91309. * @param pickInfo Defines the picking info associated to the info (if any)\
  91310. */
  91311. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91312. /**
  91313. * Defines the picking info associated to the info (if any)\
  91314. */
  91315. pickInfo: Nullable<PickingInfo>);
  91316. }
  91317. /**
  91318. * Data relating to a touch event on the screen.
  91319. */
  91320. export interface PointerTouch {
  91321. /**
  91322. * X coordinate of touch.
  91323. */
  91324. x: number;
  91325. /**
  91326. * Y coordinate of touch.
  91327. */
  91328. y: number;
  91329. /**
  91330. * Id of touch. Unique for each finger.
  91331. */
  91332. pointerId: number;
  91333. /**
  91334. * Event type passed from DOM.
  91335. */
  91336. type: any;
  91337. }
  91338. }
  91339. declare module BABYLON {
  91340. /**
  91341. * Manage the mouse inputs to control the movement of a free camera.
  91342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91343. */
  91344. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91345. /**
  91346. * Define if touch is enabled in the mouse input
  91347. */
  91348. touchEnabled: boolean;
  91349. /**
  91350. * Defines the camera the input is attached to.
  91351. */
  91352. camera: FreeCamera;
  91353. /**
  91354. * Defines the buttons associated with the input to handle camera move.
  91355. */
  91356. buttons: number[];
  91357. /**
  91358. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91359. */
  91360. angularSensibility: number;
  91361. private _pointerInput;
  91362. private _onMouseMove;
  91363. private _observer;
  91364. private previousPosition;
  91365. /**
  91366. * Observable for when a pointer move event occurs containing the move offset
  91367. */
  91368. onPointerMovedObservable: Observable<{
  91369. offsetX: number;
  91370. offsetY: number;
  91371. }>;
  91372. /**
  91373. * @hidden
  91374. * If the camera should be rotated automatically based on pointer movement
  91375. */
  91376. _allowCameraRotation: boolean;
  91377. /**
  91378. * Manage the mouse inputs to control the movement of a free camera.
  91379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91380. * @param touchEnabled Defines if touch is enabled or not
  91381. */
  91382. constructor(
  91383. /**
  91384. * Define if touch is enabled in the mouse input
  91385. */
  91386. touchEnabled?: boolean);
  91387. /**
  91388. * Attach the input controls to a specific dom element to get the input from.
  91389. * @param element Defines the element the controls should be listened from
  91390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91391. */
  91392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91393. /**
  91394. * Called on JS contextmenu event.
  91395. * Override this method to provide functionality.
  91396. */
  91397. protected onContextMenu(evt: PointerEvent): void;
  91398. /**
  91399. * Detach the current controls from the specified dom element.
  91400. * @param element Defines the element to stop listening the inputs from
  91401. */
  91402. detachControl(element: Nullable<HTMLElement>): void;
  91403. /**
  91404. * Gets the class name of the current intput.
  91405. * @returns the class name
  91406. */
  91407. getClassName(): string;
  91408. /**
  91409. * Get the friendly name associated with the input class.
  91410. * @returns the input friendly name
  91411. */
  91412. getSimpleName(): string;
  91413. }
  91414. }
  91415. declare module BABYLON {
  91416. /**
  91417. * Manage the touch inputs to control the movement of a free camera.
  91418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91419. */
  91420. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91421. /**
  91422. * Defines the camera the input is attached to.
  91423. */
  91424. camera: FreeCamera;
  91425. /**
  91426. * Defines the touch sensibility for rotation.
  91427. * The higher the faster.
  91428. */
  91429. touchAngularSensibility: number;
  91430. /**
  91431. * Defines the touch sensibility for move.
  91432. * The higher the faster.
  91433. */
  91434. touchMoveSensibility: number;
  91435. private _offsetX;
  91436. private _offsetY;
  91437. private _pointerPressed;
  91438. private _pointerInput;
  91439. private _observer;
  91440. private _onLostFocus;
  91441. /**
  91442. * Attach the input controls to a specific dom element to get the input from.
  91443. * @param element Defines the element the controls should be listened from
  91444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91445. */
  91446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91447. /**
  91448. * Detach the current controls from the specified dom element.
  91449. * @param element Defines the element to stop listening the inputs from
  91450. */
  91451. detachControl(element: Nullable<HTMLElement>): void;
  91452. /**
  91453. * Update the current camera state depending on the inputs that have been used this frame.
  91454. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91455. */
  91456. checkInputs(): void;
  91457. /**
  91458. * Gets the class name of the current intput.
  91459. * @returns the class name
  91460. */
  91461. getClassName(): string;
  91462. /**
  91463. * Get the friendly name associated with the input class.
  91464. * @returns the input friendly name
  91465. */
  91466. getSimpleName(): string;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /**
  91471. * Default Inputs manager for the FreeCamera.
  91472. * It groups all the default supported inputs for ease of use.
  91473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91474. */
  91475. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91476. /**
  91477. * @hidden
  91478. */
  91479. _mouseInput: Nullable<FreeCameraMouseInput>;
  91480. /**
  91481. * Instantiates a new FreeCameraInputsManager.
  91482. * @param camera Defines the camera the inputs belong to
  91483. */
  91484. constructor(camera: FreeCamera);
  91485. /**
  91486. * Add keyboard input support to the input manager.
  91487. * @returns the current input manager
  91488. */
  91489. addKeyboard(): FreeCameraInputsManager;
  91490. /**
  91491. * Add mouse input support to the input manager.
  91492. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91493. * @returns the current input manager
  91494. */
  91495. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91496. /**
  91497. * Removes the mouse input support from the manager
  91498. * @returns the current input manager
  91499. */
  91500. removeMouse(): FreeCameraInputsManager;
  91501. /**
  91502. * Add touch input support to the input manager.
  91503. * @returns the current input manager
  91504. */
  91505. addTouch(): FreeCameraInputsManager;
  91506. /**
  91507. * Remove all attached input methods from a camera
  91508. */
  91509. clear(): void;
  91510. }
  91511. }
  91512. declare module BABYLON {
  91513. /**
  91514. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91515. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91517. */
  91518. export class FreeCamera extends TargetCamera {
  91519. /**
  91520. * Define the collision ellipsoid of the camera.
  91521. * This is helpful to simulate a camera body like the player body around the camera
  91522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91523. */
  91524. ellipsoid: Vector3;
  91525. /**
  91526. * Define an offset for the position of the ellipsoid around the camera.
  91527. * This can be helpful to determine the center of the body near the gravity center of the body
  91528. * instead of its head.
  91529. */
  91530. ellipsoidOffset: Vector3;
  91531. /**
  91532. * Enable or disable collisions of the camera with the rest of the scene objects.
  91533. */
  91534. checkCollisions: boolean;
  91535. /**
  91536. * Enable or disable gravity on the camera.
  91537. */
  91538. applyGravity: boolean;
  91539. /**
  91540. * Define the input manager associated to the camera.
  91541. */
  91542. inputs: FreeCameraInputsManager;
  91543. /**
  91544. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91545. * Higher values reduce sensitivity.
  91546. */
  91547. get angularSensibility(): number;
  91548. /**
  91549. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91550. * Higher values reduce sensitivity.
  91551. */
  91552. set angularSensibility(value: number);
  91553. /**
  91554. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91555. */
  91556. get keysUp(): number[];
  91557. set keysUp(value: number[]);
  91558. /**
  91559. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91560. */
  91561. get keysDown(): number[];
  91562. set keysDown(value: number[]);
  91563. /**
  91564. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91565. */
  91566. get keysLeft(): number[];
  91567. set keysLeft(value: number[]);
  91568. /**
  91569. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91570. */
  91571. get keysRight(): number[];
  91572. set keysRight(value: number[]);
  91573. /**
  91574. * Event raised when the camera collide with a mesh in the scene.
  91575. */
  91576. onCollide: (collidedMesh: AbstractMesh) => void;
  91577. private _collider;
  91578. private _needMoveForGravity;
  91579. private _oldPosition;
  91580. private _diffPosition;
  91581. private _newPosition;
  91582. /** @hidden */
  91583. _localDirection: Vector3;
  91584. /** @hidden */
  91585. _transformedDirection: Vector3;
  91586. /**
  91587. * Instantiates a Free Camera.
  91588. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91589. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91591. * @param name Define the name of the camera in the scene
  91592. * @param position Define the start position of the camera in the scene
  91593. * @param scene Define the scene the camera belongs to
  91594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91595. */
  91596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91597. /**
  91598. * Attached controls to the current camera.
  91599. * @param element Defines the element the controls should be listened from
  91600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91601. */
  91602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91603. /**
  91604. * Detach the current controls from the camera.
  91605. * The camera will stop reacting to inputs.
  91606. * @param element Defines the element to stop listening the inputs from
  91607. */
  91608. detachControl(element: HTMLElement): void;
  91609. private _collisionMask;
  91610. /**
  91611. * Define a collision mask to limit the list of object the camera can collide with
  91612. */
  91613. get collisionMask(): number;
  91614. set collisionMask(mask: number);
  91615. /** @hidden */
  91616. _collideWithWorld(displacement: Vector3): void;
  91617. private _onCollisionPositionChange;
  91618. /** @hidden */
  91619. _checkInputs(): void;
  91620. /** @hidden */
  91621. _decideIfNeedsToMove(): boolean;
  91622. /** @hidden */
  91623. _updatePosition(): void;
  91624. /**
  91625. * Destroy the camera and release the current resources hold by it.
  91626. */
  91627. dispose(): void;
  91628. /**
  91629. * Gets the current object class name.
  91630. * @return the class name
  91631. */
  91632. getClassName(): string;
  91633. }
  91634. }
  91635. declare module BABYLON {
  91636. /**
  91637. * Represents a gamepad control stick position
  91638. */
  91639. export class StickValues {
  91640. /**
  91641. * The x component of the control stick
  91642. */
  91643. x: number;
  91644. /**
  91645. * The y component of the control stick
  91646. */
  91647. y: number;
  91648. /**
  91649. * Initializes the gamepad x and y control stick values
  91650. * @param x The x component of the gamepad control stick value
  91651. * @param y The y component of the gamepad control stick value
  91652. */
  91653. constructor(
  91654. /**
  91655. * The x component of the control stick
  91656. */
  91657. x: number,
  91658. /**
  91659. * The y component of the control stick
  91660. */
  91661. y: number);
  91662. }
  91663. /**
  91664. * An interface which manages callbacks for gamepad button changes
  91665. */
  91666. export interface GamepadButtonChanges {
  91667. /**
  91668. * Called when a gamepad has been changed
  91669. */
  91670. changed: boolean;
  91671. /**
  91672. * Called when a gamepad press event has been triggered
  91673. */
  91674. pressChanged: boolean;
  91675. /**
  91676. * Called when a touch event has been triggered
  91677. */
  91678. touchChanged: boolean;
  91679. /**
  91680. * Called when a value has changed
  91681. */
  91682. valueChanged: boolean;
  91683. }
  91684. /**
  91685. * Represents a gamepad
  91686. */
  91687. export class Gamepad {
  91688. /**
  91689. * The id of the gamepad
  91690. */
  91691. id: string;
  91692. /**
  91693. * The index of the gamepad
  91694. */
  91695. index: number;
  91696. /**
  91697. * The browser gamepad
  91698. */
  91699. browserGamepad: any;
  91700. /**
  91701. * Specifies what type of gamepad this represents
  91702. */
  91703. type: number;
  91704. private _leftStick;
  91705. private _rightStick;
  91706. /** @hidden */
  91707. _isConnected: boolean;
  91708. private _leftStickAxisX;
  91709. private _leftStickAxisY;
  91710. private _rightStickAxisX;
  91711. private _rightStickAxisY;
  91712. /**
  91713. * Triggered when the left control stick has been changed
  91714. */
  91715. private _onleftstickchanged;
  91716. /**
  91717. * Triggered when the right control stick has been changed
  91718. */
  91719. private _onrightstickchanged;
  91720. /**
  91721. * Represents a gamepad controller
  91722. */
  91723. static GAMEPAD: number;
  91724. /**
  91725. * Represents a generic controller
  91726. */
  91727. static GENERIC: number;
  91728. /**
  91729. * Represents an XBox controller
  91730. */
  91731. static XBOX: number;
  91732. /**
  91733. * Represents a pose-enabled controller
  91734. */
  91735. static POSE_ENABLED: number;
  91736. /**
  91737. * Represents an Dual Shock controller
  91738. */
  91739. static DUALSHOCK: number;
  91740. /**
  91741. * Specifies whether the left control stick should be Y-inverted
  91742. */
  91743. protected _invertLeftStickY: boolean;
  91744. /**
  91745. * Specifies if the gamepad has been connected
  91746. */
  91747. get isConnected(): boolean;
  91748. /**
  91749. * Initializes the gamepad
  91750. * @param id The id of the gamepad
  91751. * @param index The index of the gamepad
  91752. * @param browserGamepad The browser gamepad
  91753. * @param leftStickX The x component of the left joystick
  91754. * @param leftStickY The y component of the left joystick
  91755. * @param rightStickX The x component of the right joystick
  91756. * @param rightStickY The y component of the right joystick
  91757. */
  91758. constructor(
  91759. /**
  91760. * The id of the gamepad
  91761. */
  91762. id: string,
  91763. /**
  91764. * The index of the gamepad
  91765. */
  91766. index: number,
  91767. /**
  91768. * The browser gamepad
  91769. */
  91770. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91771. /**
  91772. * Callback triggered when the left joystick has changed
  91773. * @param callback
  91774. */
  91775. onleftstickchanged(callback: (values: StickValues) => void): void;
  91776. /**
  91777. * Callback triggered when the right joystick has changed
  91778. * @param callback
  91779. */
  91780. onrightstickchanged(callback: (values: StickValues) => void): void;
  91781. /**
  91782. * Gets the left joystick
  91783. */
  91784. get leftStick(): StickValues;
  91785. /**
  91786. * Sets the left joystick values
  91787. */
  91788. set leftStick(newValues: StickValues);
  91789. /**
  91790. * Gets the right joystick
  91791. */
  91792. get rightStick(): StickValues;
  91793. /**
  91794. * Sets the right joystick value
  91795. */
  91796. set rightStick(newValues: StickValues);
  91797. /**
  91798. * Updates the gamepad joystick positions
  91799. */
  91800. update(): void;
  91801. /**
  91802. * Disposes the gamepad
  91803. */
  91804. dispose(): void;
  91805. }
  91806. /**
  91807. * Represents a generic gamepad
  91808. */
  91809. export class GenericPad extends Gamepad {
  91810. private _buttons;
  91811. private _onbuttondown;
  91812. private _onbuttonup;
  91813. /**
  91814. * Observable triggered when a button has been pressed
  91815. */
  91816. onButtonDownObservable: Observable<number>;
  91817. /**
  91818. * Observable triggered when a button has been released
  91819. */
  91820. onButtonUpObservable: Observable<number>;
  91821. /**
  91822. * Callback triggered when a button has been pressed
  91823. * @param callback Called when a button has been pressed
  91824. */
  91825. onbuttondown(callback: (buttonPressed: number) => void): void;
  91826. /**
  91827. * Callback triggered when a button has been released
  91828. * @param callback Called when a button has been released
  91829. */
  91830. onbuttonup(callback: (buttonReleased: number) => void): void;
  91831. /**
  91832. * Initializes the generic gamepad
  91833. * @param id The id of the generic gamepad
  91834. * @param index The index of the generic gamepad
  91835. * @param browserGamepad The browser gamepad
  91836. */
  91837. constructor(id: string, index: number, browserGamepad: any);
  91838. private _setButtonValue;
  91839. /**
  91840. * Updates the generic gamepad
  91841. */
  91842. update(): void;
  91843. /**
  91844. * Disposes the generic gamepad
  91845. */
  91846. dispose(): void;
  91847. }
  91848. }
  91849. declare module BABYLON {
  91850. /**
  91851. * Defines the types of pose enabled controllers that are supported
  91852. */
  91853. export enum PoseEnabledControllerType {
  91854. /**
  91855. * HTC Vive
  91856. */
  91857. VIVE = 0,
  91858. /**
  91859. * Oculus Rift
  91860. */
  91861. OCULUS = 1,
  91862. /**
  91863. * Windows mixed reality
  91864. */
  91865. WINDOWS = 2,
  91866. /**
  91867. * Samsung gear VR
  91868. */
  91869. GEAR_VR = 3,
  91870. /**
  91871. * Google Daydream
  91872. */
  91873. DAYDREAM = 4,
  91874. /**
  91875. * Generic
  91876. */
  91877. GENERIC = 5
  91878. }
  91879. /**
  91880. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91881. */
  91882. export interface MutableGamepadButton {
  91883. /**
  91884. * Value of the button/trigger
  91885. */
  91886. value: number;
  91887. /**
  91888. * If the button/trigger is currently touched
  91889. */
  91890. touched: boolean;
  91891. /**
  91892. * If the button/trigger is currently pressed
  91893. */
  91894. pressed: boolean;
  91895. }
  91896. /**
  91897. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91898. * @hidden
  91899. */
  91900. export interface ExtendedGamepadButton extends GamepadButton {
  91901. /**
  91902. * If the button/trigger is currently pressed
  91903. */
  91904. readonly pressed: boolean;
  91905. /**
  91906. * If the button/trigger is currently touched
  91907. */
  91908. readonly touched: boolean;
  91909. /**
  91910. * Value of the button/trigger
  91911. */
  91912. readonly value: number;
  91913. }
  91914. /** @hidden */
  91915. export interface _GamePadFactory {
  91916. /**
  91917. * Returns whether or not the current gamepad can be created for this type of controller.
  91918. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91919. * @returns true if it can be created, otherwise false
  91920. */
  91921. canCreate(gamepadInfo: any): boolean;
  91922. /**
  91923. * Creates a new instance of the Gamepad.
  91924. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91925. * @returns the new gamepad instance
  91926. */
  91927. create(gamepadInfo: any): Gamepad;
  91928. }
  91929. /**
  91930. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91931. */
  91932. export class PoseEnabledControllerHelper {
  91933. /** @hidden */
  91934. static _ControllerFactories: _GamePadFactory[];
  91935. /** @hidden */
  91936. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91937. /**
  91938. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91939. * @param vrGamepad the gamepad to initialized
  91940. * @returns a vr controller of the type the gamepad identified as
  91941. */
  91942. static InitiateController(vrGamepad: any): Gamepad;
  91943. }
  91944. /**
  91945. * Defines the PoseEnabledController object that contains state of a vr capable controller
  91946. */
  91947. export class PoseEnabledController extends Gamepad implements PoseControlled {
  91948. /**
  91949. * If the controller is used in a webXR session
  91950. */
  91951. isXR: boolean;
  91952. private _deviceRoomPosition;
  91953. private _deviceRoomRotationQuaternion;
  91954. /**
  91955. * The device position in babylon space
  91956. */
  91957. devicePosition: Vector3;
  91958. /**
  91959. * The device rotation in babylon space
  91960. */
  91961. deviceRotationQuaternion: Quaternion;
  91962. /**
  91963. * The scale factor of the device in babylon space
  91964. */
  91965. deviceScaleFactor: number;
  91966. /**
  91967. * (Likely devicePosition should be used instead) The device position in its room space
  91968. */
  91969. position: Vector3;
  91970. /**
  91971. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  91972. */
  91973. rotationQuaternion: Quaternion;
  91974. /**
  91975. * The type of controller (Eg. Windows mixed reality)
  91976. */
  91977. controllerType: PoseEnabledControllerType;
  91978. protected _calculatedPosition: Vector3;
  91979. private _calculatedRotation;
  91980. /**
  91981. * The raw pose from the device
  91982. */
  91983. rawPose: DevicePose;
  91984. private _trackPosition;
  91985. private _maxRotationDistFromHeadset;
  91986. private _draggedRoomRotation;
  91987. /**
  91988. * @hidden
  91989. */
  91990. _disableTrackPosition(fixedPosition: Vector3): void;
  91991. /**
  91992. * Internal, the mesh attached to the controller
  91993. * @hidden
  91994. */
  91995. _mesh: Nullable<AbstractMesh>;
  91996. private _poseControlledCamera;
  91997. private _leftHandSystemQuaternion;
  91998. /**
  91999. * Internal, matrix used to convert room space to babylon space
  92000. * @hidden
  92001. */
  92002. _deviceToWorld: Matrix;
  92003. /**
  92004. * Node to be used when casting a ray from the controller
  92005. * @hidden
  92006. */
  92007. _pointingPoseNode: Nullable<TransformNode>;
  92008. /**
  92009. * Name of the child mesh that can be used to cast a ray from the controller
  92010. */
  92011. static readonly POINTING_POSE: string;
  92012. /**
  92013. * Creates a new PoseEnabledController from a gamepad
  92014. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92015. */
  92016. constructor(browserGamepad: any);
  92017. private _workingMatrix;
  92018. /**
  92019. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92020. */
  92021. update(): void;
  92022. /**
  92023. * Updates only the pose device and mesh without doing any button event checking
  92024. */
  92025. protected _updatePoseAndMesh(): void;
  92026. /**
  92027. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92028. * @param poseData raw pose fromthe device
  92029. */
  92030. updateFromDevice(poseData: DevicePose): void;
  92031. /**
  92032. * @hidden
  92033. */
  92034. _meshAttachedObservable: Observable<AbstractMesh>;
  92035. /**
  92036. * Attaches a mesh to the controller
  92037. * @param mesh the mesh to be attached
  92038. */
  92039. attachToMesh(mesh: AbstractMesh): void;
  92040. /**
  92041. * Attaches the controllers mesh to a camera
  92042. * @param camera the camera the mesh should be attached to
  92043. */
  92044. attachToPoseControlledCamera(camera: TargetCamera): void;
  92045. /**
  92046. * Disposes of the controller
  92047. */
  92048. dispose(): void;
  92049. /**
  92050. * The mesh that is attached to the controller
  92051. */
  92052. get mesh(): Nullable<AbstractMesh>;
  92053. /**
  92054. * Gets the ray of the controller in the direction the controller is pointing
  92055. * @param length the length the resulting ray should be
  92056. * @returns a ray in the direction the controller is pointing
  92057. */
  92058. getForwardRay(length?: number): Ray;
  92059. }
  92060. }
  92061. declare module BABYLON {
  92062. /**
  92063. * Defines the WebVRController object that represents controllers tracked in 3D space
  92064. */
  92065. export abstract class WebVRController extends PoseEnabledController {
  92066. /**
  92067. * Internal, the default controller model for the controller
  92068. */
  92069. protected _defaultModel: Nullable<AbstractMesh>;
  92070. /**
  92071. * Fired when the trigger state has changed
  92072. */
  92073. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92074. /**
  92075. * Fired when the main button state has changed
  92076. */
  92077. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92078. /**
  92079. * Fired when the secondary button state has changed
  92080. */
  92081. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92082. /**
  92083. * Fired when the pad state has changed
  92084. */
  92085. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92086. /**
  92087. * Fired when controllers stick values have changed
  92088. */
  92089. onPadValuesChangedObservable: Observable<StickValues>;
  92090. /**
  92091. * Array of button availible on the controller
  92092. */
  92093. protected _buttons: Array<MutableGamepadButton>;
  92094. private _onButtonStateChange;
  92095. /**
  92096. * Fired when a controller button's state has changed
  92097. * @param callback the callback containing the button that was modified
  92098. */
  92099. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92100. /**
  92101. * X and Y axis corresponding to the controllers joystick
  92102. */
  92103. pad: StickValues;
  92104. /**
  92105. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92106. */
  92107. hand: string;
  92108. /**
  92109. * The default controller model for the controller
  92110. */
  92111. get defaultModel(): Nullable<AbstractMesh>;
  92112. /**
  92113. * Creates a new WebVRController from a gamepad
  92114. * @param vrGamepad the gamepad that the WebVRController should be created from
  92115. */
  92116. constructor(vrGamepad: any);
  92117. /**
  92118. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92119. */
  92120. update(): void;
  92121. /**
  92122. * Function to be called when a button is modified
  92123. */
  92124. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92125. /**
  92126. * Loads a mesh and attaches it to the controller
  92127. * @param scene the scene the mesh should be added to
  92128. * @param meshLoaded callback for when the mesh has been loaded
  92129. */
  92130. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92131. private _setButtonValue;
  92132. private _changes;
  92133. private _checkChanges;
  92134. /**
  92135. * Disposes of th webVRCOntroller
  92136. */
  92137. dispose(): void;
  92138. }
  92139. }
  92140. declare module BABYLON {
  92141. /**
  92142. * The HemisphericLight simulates the ambient environment light,
  92143. * so the passed direction is the light reflection direction, not the incoming direction.
  92144. */
  92145. export class HemisphericLight extends Light {
  92146. /**
  92147. * The groundColor is the light in the opposite direction to the one specified during creation.
  92148. * 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.
  92149. */
  92150. groundColor: Color3;
  92151. /**
  92152. * The light reflection direction, not the incoming direction.
  92153. */
  92154. direction: Vector3;
  92155. /**
  92156. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92157. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92158. * The HemisphericLight can't cast shadows.
  92159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92160. * @param name The friendly name of the light
  92161. * @param direction The direction of the light reflection
  92162. * @param scene The scene the light belongs to
  92163. */
  92164. constructor(name: string, direction: Vector3, scene: Scene);
  92165. protected _buildUniformLayout(): void;
  92166. /**
  92167. * Returns the string "HemisphericLight".
  92168. * @return The class name
  92169. */
  92170. getClassName(): string;
  92171. /**
  92172. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92173. * Returns the updated direction.
  92174. * @param target The target the direction should point to
  92175. * @return The computed direction
  92176. */
  92177. setDirectionToTarget(target: Vector3): Vector3;
  92178. /**
  92179. * Returns the shadow generator associated to the light.
  92180. * @returns Always null for hemispheric lights because it does not support shadows.
  92181. */
  92182. getShadowGenerator(): Nullable<IShadowGenerator>;
  92183. /**
  92184. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92185. * @param effect The effect to update
  92186. * @param lightIndex The index of the light in the effect to update
  92187. * @returns The hemispheric light
  92188. */
  92189. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92190. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92191. /**
  92192. * Computes the world matrix of the node
  92193. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92194. * @param useWasUpdatedFlag defines a reserved property
  92195. * @returns the world matrix
  92196. */
  92197. computeWorldMatrix(): Matrix;
  92198. /**
  92199. * Returns the integer 3.
  92200. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92201. */
  92202. getTypeID(): number;
  92203. /**
  92204. * Prepares the list of defines specific to the light type.
  92205. * @param defines the list of defines
  92206. * @param lightIndex defines the index of the light for the effect
  92207. */
  92208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92209. }
  92210. }
  92211. declare module BABYLON {
  92212. /** @hidden */
  92213. export var vrMultiviewToSingleviewPixelShader: {
  92214. name: string;
  92215. shader: string;
  92216. };
  92217. }
  92218. declare module BABYLON {
  92219. /**
  92220. * Renders to multiple views with a single draw call
  92221. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92222. */
  92223. export class MultiviewRenderTarget extends RenderTargetTexture {
  92224. /**
  92225. * Creates a multiview render target
  92226. * @param scene scene used with the render target
  92227. * @param size the size of the render target (used for each view)
  92228. */
  92229. constructor(scene: Scene, size?: number | {
  92230. width: number;
  92231. height: number;
  92232. } | {
  92233. ratio: number;
  92234. });
  92235. /**
  92236. * @hidden
  92237. * @param faceIndex the face index, if its a cube texture
  92238. */
  92239. _bindFrameBuffer(faceIndex?: number): void;
  92240. /**
  92241. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92242. * @returns the view count
  92243. */
  92244. getViewCount(): number;
  92245. }
  92246. }
  92247. declare module BABYLON {
  92248. /**
  92249. * Represents a camera frustum
  92250. */
  92251. export class Frustum {
  92252. /**
  92253. * Gets the planes representing the frustum
  92254. * @param transform matrix to be applied to the returned planes
  92255. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92256. */
  92257. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92258. /**
  92259. * Gets the near frustum plane transformed by the transform matrix
  92260. * @param transform transformation matrix to be applied to the resulting frustum plane
  92261. * @param frustumPlane the resuling frustum plane
  92262. */
  92263. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92264. /**
  92265. * Gets the far frustum plane transformed by the transform matrix
  92266. * @param transform transformation matrix to be applied to the resulting frustum plane
  92267. * @param frustumPlane the resuling frustum plane
  92268. */
  92269. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92270. /**
  92271. * Gets the left frustum plane transformed by the transform matrix
  92272. * @param transform transformation matrix to be applied to the resulting frustum plane
  92273. * @param frustumPlane the resuling frustum plane
  92274. */
  92275. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92276. /**
  92277. * Gets the right frustum plane transformed by the transform matrix
  92278. * @param transform transformation matrix to be applied to the resulting frustum plane
  92279. * @param frustumPlane the resuling frustum plane
  92280. */
  92281. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92282. /**
  92283. * Gets the top frustum plane transformed by the transform matrix
  92284. * @param transform transformation matrix to be applied to the resulting frustum plane
  92285. * @param frustumPlane the resuling frustum plane
  92286. */
  92287. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92288. /**
  92289. * Gets the bottom frustum plane transformed by the transform matrix
  92290. * @param transform transformation matrix to be applied to the resulting frustum plane
  92291. * @param frustumPlane the resuling frustum plane
  92292. */
  92293. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92294. /**
  92295. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92296. * @param transform transformation matrix to be applied to the resulting frustum planes
  92297. * @param frustumPlanes the resuling frustum planes
  92298. */
  92299. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92300. }
  92301. }
  92302. declare module BABYLON {
  92303. interface Engine {
  92304. /**
  92305. * Creates a new multiview render target
  92306. * @param width defines the width of the texture
  92307. * @param height defines the height of the texture
  92308. * @returns the created multiview texture
  92309. */
  92310. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92311. /**
  92312. * Binds a multiview framebuffer to be drawn to
  92313. * @param multiviewTexture texture to bind
  92314. */
  92315. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92316. }
  92317. interface Camera {
  92318. /**
  92319. * @hidden
  92320. * 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)
  92321. */
  92322. _useMultiviewToSingleView: boolean;
  92323. /**
  92324. * @hidden
  92325. * 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)
  92326. */
  92327. _multiviewTexture: Nullable<RenderTargetTexture>;
  92328. /**
  92329. * @hidden
  92330. * ensures the multiview texture of the camera exists and has the specified width/height
  92331. * @param width height to set on the multiview texture
  92332. * @param height width to set on the multiview texture
  92333. */
  92334. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92335. }
  92336. interface Scene {
  92337. /** @hidden */
  92338. _transformMatrixR: Matrix;
  92339. /** @hidden */
  92340. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92341. /** @hidden */
  92342. _createMultiviewUbo(): void;
  92343. /** @hidden */
  92344. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92345. /** @hidden */
  92346. _renderMultiviewToSingleView(camera: Camera): void;
  92347. }
  92348. }
  92349. declare module BABYLON {
  92350. /**
  92351. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92352. * This will not be used for webXR as it supports displaying texture arrays directly
  92353. */
  92354. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92355. /**
  92356. * Initializes a VRMultiviewToSingleview
  92357. * @param name name of the post process
  92358. * @param camera camera to be applied to
  92359. * @param scaleFactor scaling factor to the size of the output texture
  92360. */
  92361. constructor(name: string, camera: Camera, scaleFactor: number);
  92362. }
  92363. }
  92364. declare module BABYLON {
  92365. /**
  92366. * Interface used to define additional presentation attributes
  92367. */
  92368. export interface IVRPresentationAttributes {
  92369. /**
  92370. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92371. */
  92372. highRefreshRate: boolean;
  92373. /**
  92374. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92375. */
  92376. foveationLevel: number;
  92377. }
  92378. interface Engine {
  92379. /** @hidden */
  92380. _vrDisplay: any;
  92381. /** @hidden */
  92382. _vrSupported: boolean;
  92383. /** @hidden */
  92384. _oldSize: Size;
  92385. /** @hidden */
  92386. _oldHardwareScaleFactor: number;
  92387. /** @hidden */
  92388. _vrExclusivePointerMode: boolean;
  92389. /** @hidden */
  92390. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92391. /** @hidden */
  92392. _onVRDisplayPointerRestricted: () => void;
  92393. /** @hidden */
  92394. _onVRDisplayPointerUnrestricted: () => void;
  92395. /** @hidden */
  92396. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92397. /** @hidden */
  92398. _onVrDisplayDisconnect: Nullable<() => void>;
  92399. /** @hidden */
  92400. _onVrDisplayPresentChange: Nullable<() => void>;
  92401. /**
  92402. * Observable signaled when VR display mode changes
  92403. */
  92404. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92405. /**
  92406. * Observable signaled when VR request present is complete
  92407. */
  92408. onVRRequestPresentComplete: Observable<boolean>;
  92409. /**
  92410. * Observable signaled when VR request present starts
  92411. */
  92412. onVRRequestPresentStart: Observable<Engine>;
  92413. /**
  92414. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92415. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92416. */
  92417. isInVRExclusivePointerMode: boolean;
  92418. /**
  92419. * Gets a boolean indicating if a webVR device was detected
  92420. * @returns true if a webVR device was detected
  92421. */
  92422. isVRDevicePresent(): boolean;
  92423. /**
  92424. * Gets the current webVR device
  92425. * @returns the current webVR device (or null)
  92426. */
  92427. getVRDevice(): any;
  92428. /**
  92429. * Initializes a webVR display and starts listening to display change events
  92430. * The onVRDisplayChangedObservable will be notified upon these changes
  92431. * @returns A promise containing a VRDisplay and if vr is supported
  92432. */
  92433. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92434. /** @hidden */
  92435. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92436. /**
  92437. * Gets or sets the presentation attributes used to configure VR rendering
  92438. */
  92439. vrPresentationAttributes?: IVRPresentationAttributes;
  92440. /**
  92441. * Call this function to switch to webVR mode
  92442. * Will do nothing if webVR is not supported or if there is no webVR device
  92443. * @param options the webvr options provided to the camera. mainly used for multiview
  92444. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92445. */
  92446. enableVR(options: WebVROptions): void;
  92447. /** @hidden */
  92448. _onVRFullScreenTriggered(): void;
  92449. }
  92450. }
  92451. declare module BABYLON {
  92452. /**
  92453. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92454. * IMPORTANT!! The data is right-hand data.
  92455. * @export
  92456. * @interface DevicePose
  92457. */
  92458. export interface DevicePose {
  92459. /**
  92460. * The position of the device, values in array are [x,y,z].
  92461. */
  92462. readonly position: Nullable<Float32Array>;
  92463. /**
  92464. * The linearVelocity of the device, values in array are [x,y,z].
  92465. */
  92466. readonly linearVelocity: Nullable<Float32Array>;
  92467. /**
  92468. * The linearAcceleration of the device, values in array are [x,y,z].
  92469. */
  92470. readonly linearAcceleration: Nullable<Float32Array>;
  92471. /**
  92472. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92473. */
  92474. readonly orientation: Nullable<Float32Array>;
  92475. /**
  92476. * The angularVelocity of the device, values in array are [x,y,z].
  92477. */
  92478. readonly angularVelocity: Nullable<Float32Array>;
  92479. /**
  92480. * The angularAcceleration of the device, values in array are [x,y,z].
  92481. */
  92482. readonly angularAcceleration: Nullable<Float32Array>;
  92483. }
  92484. /**
  92485. * Interface representing a pose controlled object in Babylon.
  92486. * A pose controlled object has both regular pose values as well as pose values
  92487. * from an external device such as a VR head mounted display
  92488. */
  92489. export interface PoseControlled {
  92490. /**
  92491. * The position of the object in babylon space.
  92492. */
  92493. position: Vector3;
  92494. /**
  92495. * The rotation quaternion of the object in babylon space.
  92496. */
  92497. rotationQuaternion: Quaternion;
  92498. /**
  92499. * The position of the device in babylon space.
  92500. */
  92501. devicePosition?: Vector3;
  92502. /**
  92503. * The rotation quaternion of the device in babylon space.
  92504. */
  92505. deviceRotationQuaternion: Quaternion;
  92506. /**
  92507. * The raw pose coming from the device.
  92508. */
  92509. rawPose: Nullable<DevicePose>;
  92510. /**
  92511. * The scale of the device to be used when translating from device space to babylon space.
  92512. */
  92513. deviceScaleFactor: number;
  92514. /**
  92515. * Updates the poseControlled values based on the input device pose.
  92516. * @param poseData the pose data to update the object with
  92517. */
  92518. updateFromDevice(poseData: DevicePose): void;
  92519. }
  92520. /**
  92521. * Set of options to customize the webVRCamera
  92522. */
  92523. export interface WebVROptions {
  92524. /**
  92525. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92526. */
  92527. trackPosition?: boolean;
  92528. /**
  92529. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92530. */
  92531. positionScale?: number;
  92532. /**
  92533. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92534. */
  92535. displayName?: string;
  92536. /**
  92537. * Should the native controller meshes be initialized. (default: true)
  92538. */
  92539. controllerMeshes?: boolean;
  92540. /**
  92541. * Creating a default HemiLight only on controllers. (default: true)
  92542. */
  92543. defaultLightingOnControllers?: boolean;
  92544. /**
  92545. * If you don't want to use the default VR button of the helper. (default: false)
  92546. */
  92547. useCustomVRButton?: boolean;
  92548. /**
  92549. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92550. */
  92551. customVRButton?: HTMLButtonElement;
  92552. /**
  92553. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92554. */
  92555. rayLength?: number;
  92556. /**
  92557. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92558. */
  92559. defaultHeight?: number;
  92560. /**
  92561. * If multiview should be used if availible (default: false)
  92562. */
  92563. useMultiview?: boolean;
  92564. }
  92565. /**
  92566. * This represents a WebVR camera.
  92567. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92568. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92569. */
  92570. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92571. private webVROptions;
  92572. /**
  92573. * @hidden
  92574. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92575. */
  92576. _vrDevice: any;
  92577. /**
  92578. * The rawPose of the vrDevice.
  92579. */
  92580. rawPose: Nullable<DevicePose>;
  92581. private _onVREnabled;
  92582. private _specsVersion;
  92583. private _attached;
  92584. private _frameData;
  92585. protected _descendants: Array<Node>;
  92586. private _deviceRoomPosition;
  92587. /** @hidden */
  92588. _deviceRoomRotationQuaternion: Quaternion;
  92589. private _standingMatrix;
  92590. /**
  92591. * Represents device position in babylon space.
  92592. */
  92593. devicePosition: Vector3;
  92594. /**
  92595. * Represents device rotation in babylon space.
  92596. */
  92597. deviceRotationQuaternion: Quaternion;
  92598. /**
  92599. * The scale of the device to be used when translating from device space to babylon space.
  92600. */
  92601. deviceScaleFactor: number;
  92602. private _deviceToWorld;
  92603. private _worldToDevice;
  92604. /**
  92605. * References to the webVR controllers for the vrDevice.
  92606. */
  92607. controllers: Array<WebVRController>;
  92608. /**
  92609. * Emits an event when a controller is attached.
  92610. */
  92611. onControllersAttachedObservable: Observable<WebVRController[]>;
  92612. /**
  92613. * Emits an event when a controller's mesh has been loaded;
  92614. */
  92615. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92616. /**
  92617. * Emits an event when the HMD's pose has been updated.
  92618. */
  92619. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92620. private _poseSet;
  92621. /**
  92622. * If the rig cameras be used as parent instead of this camera.
  92623. */
  92624. rigParenting: boolean;
  92625. private _lightOnControllers;
  92626. private _defaultHeight?;
  92627. /**
  92628. * Instantiates a WebVRFreeCamera.
  92629. * @param name The name of the WebVRFreeCamera
  92630. * @param position The starting anchor position for the camera
  92631. * @param scene The scene the camera belongs to
  92632. * @param webVROptions a set of customizable options for the webVRCamera
  92633. */
  92634. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92635. /**
  92636. * Gets the device distance from the ground in meters.
  92637. * @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.
  92638. */
  92639. deviceDistanceToRoomGround(): number;
  92640. /**
  92641. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92642. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92643. */
  92644. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92645. /**
  92646. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92647. * @returns A promise with a boolean set to if the standing matrix is supported.
  92648. */
  92649. useStandingMatrixAsync(): Promise<boolean>;
  92650. /**
  92651. * Disposes the camera
  92652. */
  92653. dispose(): void;
  92654. /**
  92655. * Gets a vrController by name.
  92656. * @param name The name of the controller to retreive
  92657. * @returns the controller matching the name specified or null if not found
  92658. */
  92659. getControllerByName(name: string): Nullable<WebVRController>;
  92660. private _leftController;
  92661. /**
  92662. * The controller corresponding to the users left hand.
  92663. */
  92664. get leftController(): Nullable<WebVRController>;
  92665. private _rightController;
  92666. /**
  92667. * The controller corresponding to the users right hand.
  92668. */
  92669. get rightController(): Nullable<WebVRController>;
  92670. /**
  92671. * Casts a ray forward from the vrCamera's gaze.
  92672. * @param length Length of the ray (default: 100)
  92673. * @returns the ray corresponding to the gaze
  92674. */
  92675. getForwardRay(length?: number): Ray;
  92676. /**
  92677. * @hidden
  92678. * Updates the camera based on device's frame data
  92679. */
  92680. _checkInputs(): void;
  92681. /**
  92682. * Updates the poseControlled values based on the input device pose.
  92683. * @param poseData Pose coming from the device
  92684. */
  92685. updateFromDevice(poseData: DevicePose): void;
  92686. private _htmlElementAttached;
  92687. private _detachIfAttached;
  92688. /**
  92689. * WebVR's attach control will start broadcasting frames to the device.
  92690. * Note that in certain browsers (chrome for example) this function must be called
  92691. * within a user-interaction callback. Example:
  92692. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92693. *
  92694. * @param element html element to attach the vrDevice to
  92695. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92696. */
  92697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92698. /**
  92699. * Detaches the camera from the html element and disables VR
  92700. *
  92701. * @param element html element to detach from
  92702. */
  92703. detachControl(element: HTMLElement): void;
  92704. /**
  92705. * @returns the name of this class
  92706. */
  92707. getClassName(): string;
  92708. /**
  92709. * Calls resetPose on the vrDisplay
  92710. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92711. */
  92712. resetToCurrentRotation(): void;
  92713. /**
  92714. * @hidden
  92715. * Updates the rig cameras (left and right eye)
  92716. */
  92717. _updateRigCameras(): void;
  92718. private _workingVector;
  92719. private _oneVector;
  92720. private _workingMatrix;
  92721. private updateCacheCalled;
  92722. private _correctPositionIfNotTrackPosition;
  92723. /**
  92724. * @hidden
  92725. * Updates the cached values of the camera
  92726. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92727. */
  92728. _updateCache(ignoreParentClass?: boolean): void;
  92729. /**
  92730. * @hidden
  92731. * Get current device position in babylon world
  92732. */
  92733. _computeDevicePosition(): void;
  92734. /**
  92735. * Updates the current device position and rotation in the babylon world
  92736. */
  92737. update(): void;
  92738. /**
  92739. * @hidden
  92740. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92741. * @returns an identity matrix
  92742. */
  92743. _getViewMatrix(): Matrix;
  92744. private _tmpMatrix;
  92745. /**
  92746. * This function is called by the two RIG cameras.
  92747. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92748. * @hidden
  92749. */
  92750. _getWebVRViewMatrix(): Matrix;
  92751. /** @hidden */
  92752. _getWebVRProjectionMatrix(): Matrix;
  92753. private _onGamepadConnectedObserver;
  92754. private _onGamepadDisconnectedObserver;
  92755. private _updateCacheWhenTrackingDisabledObserver;
  92756. /**
  92757. * Initializes the controllers and their meshes
  92758. */
  92759. initControllers(): void;
  92760. }
  92761. }
  92762. declare module BABYLON {
  92763. /**
  92764. * Size options for a post process
  92765. */
  92766. export type PostProcessOptions = {
  92767. width: number;
  92768. height: number;
  92769. };
  92770. /**
  92771. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92772. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92773. */
  92774. export class PostProcess {
  92775. /** Name of the PostProcess. */
  92776. name: string;
  92777. /**
  92778. * Gets or sets the unique id of the post process
  92779. */
  92780. uniqueId: number;
  92781. /**
  92782. * Width of the texture to apply the post process on
  92783. */
  92784. width: number;
  92785. /**
  92786. * Height of the texture to apply the post process on
  92787. */
  92788. height: number;
  92789. /**
  92790. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92791. * @hidden
  92792. */
  92793. _outputTexture: Nullable<InternalTexture>;
  92794. /**
  92795. * Sampling mode used by the shader
  92796. * See https://doc.babylonjs.com/classes/3.1/texture
  92797. */
  92798. renderTargetSamplingMode: number;
  92799. /**
  92800. * Clear color to use when screen clearing
  92801. */
  92802. clearColor: Color4;
  92803. /**
  92804. * If the buffer needs to be cleared before applying the post process. (default: true)
  92805. * Should be set to false if shader will overwrite all previous pixels.
  92806. */
  92807. autoClear: boolean;
  92808. /**
  92809. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92810. */
  92811. alphaMode: number;
  92812. /**
  92813. * Sets the setAlphaBlendConstants of the babylon engine
  92814. */
  92815. alphaConstants: Color4;
  92816. /**
  92817. * Animations to be used for the post processing
  92818. */
  92819. animations: Animation[];
  92820. /**
  92821. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92822. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92823. */
  92824. enablePixelPerfectMode: boolean;
  92825. /**
  92826. * Force the postprocess to be applied without taking in account viewport
  92827. */
  92828. forceFullscreenViewport: boolean;
  92829. /**
  92830. * List of inspectable custom properties (used by the Inspector)
  92831. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92832. */
  92833. inspectableCustomProperties: IInspectable[];
  92834. /**
  92835. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92836. *
  92837. * | Value | Type | Description |
  92838. * | ----- | ----------------------------------- | ----------- |
  92839. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92840. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92841. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92842. *
  92843. */
  92844. scaleMode: number;
  92845. /**
  92846. * Force textures to be a power of two (default: false)
  92847. */
  92848. alwaysForcePOT: boolean;
  92849. private _samples;
  92850. /**
  92851. * Number of sample textures (default: 1)
  92852. */
  92853. get samples(): number;
  92854. set samples(n: number);
  92855. /**
  92856. * Modify the scale of the post process to be the same as the viewport (default: false)
  92857. */
  92858. adaptScaleToCurrentViewport: boolean;
  92859. private _camera;
  92860. private _scene;
  92861. private _engine;
  92862. private _options;
  92863. private _reusable;
  92864. private _textureType;
  92865. private _textureFormat;
  92866. /**
  92867. * Smart array of input and output textures for the post process.
  92868. * @hidden
  92869. */
  92870. _textures: SmartArray<InternalTexture>;
  92871. /**
  92872. * The index in _textures that corresponds to the output texture.
  92873. * @hidden
  92874. */
  92875. _currentRenderTextureInd: number;
  92876. private _effect;
  92877. private _samplers;
  92878. private _fragmentUrl;
  92879. private _vertexUrl;
  92880. private _parameters;
  92881. private _scaleRatio;
  92882. protected _indexParameters: any;
  92883. private _shareOutputWithPostProcess;
  92884. private _texelSize;
  92885. private _forcedOutputTexture;
  92886. /**
  92887. * Returns the fragment url or shader name used in the post process.
  92888. * @returns the fragment url or name in the shader store.
  92889. */
  92890. getEffectName(): string;
  92891. /**
  92892. * An event triggered when the postprocess is activated.
  92893. */
  92894. onActivateObservable: Observable<Camera>;
  92895. private _onActivateObserver;
  92896. /**
  92897. * A function that is added to the onActivateObservable
  92898. */
  92899. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92900. /**
  92901. * An event triggered when the postprocess changes its size.
  92902. */
  92903. onSizeChangedObservable: Observable<PostProcess>;
  92904. private _onSizeChangedObserver;
  92905. /**
  92906. * A function that is added to the onSizeChangedObservable
  92907. */
  92908. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92909. /**
  92910. * An event triggered when the postprocess applies its effect.
  92911. */
  92912. onApplyObservable: Observable<Effect>;
  92913. private _onApplyObserver;
  92914. /**
  92915. * A function that is added to the onApplyObservable
  92916. */
  92917. set onApply(callback: (effect: Effect) => void);
  92918. /**
  92919. * An event triggered before rendering the postprocess
  92920. */
  92921. onBeforeRenderObservable: Observable<Effect>;
  92922. private _onBeforeRenderObserver;
  92923. /**
  92924. * A function that is added to the onBeforeRenderObservable
  92925. */
  92926. set onBeforeRender(callback: (effect: Effect) => void);
  92927. /**
  92928. * An event triggered after rendering the postprocess
  92929. */
  92930. onAfterRenderObservable: Observable<Effect>;
  92931. private _onAfterRenderObserver;
  92932. /**
  92933. * A function that is added to the onAfterRenderObservable
  92934. */
  92935. set onAfterRender(callback: (efect: Effect) => void);
  92936. /**
  92937. * 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
  92938. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92939. */
  92940. get inputTexture(): InternalTexture;
  92941. set inputTexture(value: InternalTexture);
  92942. /**
  92943. * Gets the camera which post process is applied to.
  92944. * @returns The camera the post process is applied to.
  92945. */
  92946. getCamera(): Camera;
  92947. /**
  92948. * Gets the texel size of the postprocess.
  92949. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  92950. */
  92951. get texelSize(): Vector2;
  92952. /**
  92953. * Creates a new instance PostProcess
  92954. * @param name The name of the PostProcess.
  92955. * @param fragmentUrl The url of the fragment shader to be used.
  92956. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  92957. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  92958. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  92959. * @param camera The camera to apply the render pass to.
  92960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92961. * @param engine The engine which the post process will be applied. (default: current engine)
  92962. * @param reusable If the post process can be reused on the same frame. (default: false)
  92963. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  92964. * @param textureType Type of textures used when performing the post process. (default: 0)
  92965. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  92966. * @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
  92967. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  92968. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  92969. */
  92970. constructor(
  92971. /** Name of the PostProcess. */
  92972. 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);
  92973. /**
  92974. * Gets a string idenfifying the name of the class
  92975. * @returns "PostProcess" string
  92976. */
  92977. getClassName(): string;
  92978. /**
  92979. * Gets the engine which this post process belongs to.
  92980. * @returns The engine the post process was enabled with.
  92981. */
  92982. getEngine(): Engine;
  92983. /**
  92984. * The effect that is created when initializing the post process.
  92985. * @returns The created effect corresponding the the postprocess.
  92986. */
  92987. getEffect(): Effect;
  92988. /**
  92989. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  92990. * @param postProcess The post process to share the output with.
  92991. * @returns This post process.
  92992. */
  92993. shareOutputWith(postProcess: PostProcess): PostProcess;
  92994. /**
  92995. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  92996. * This should be called if the post process that shares output with this post process is disabled/disposed.
  92997. */
  92998. useOwnOutput(): void;
  92999. /**
  93000. * Updates the effect with the current post process compile time values and recompiles the shader.
  93001. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93002. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93003. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93004. * @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
  93005. * @param onCompiled Called when the shader has been compiled.
  93006. * @param onError Called if there is an error when compiling a shader.
  93007. */
  93008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93009. /**
  93010. * The post process is reusable if it can be used multiple times within one frame.
  93011. * @returns If the post process is reusable
  93012. */
  93013. isReusable(): boolean;
  93014. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93015. markTextureDirty(): void;
  93016. /**
  93017. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93018. * 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.
  93019. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93020. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93021. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93022. * @returns The target texture that was bound to be written to.
  93023. */
  93024. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93025. /**
  93026. * If the post process is supported.
  93027. */
  93028. get isSupported(): boolean;
  93029. /**
  93030. * The aspect ratio of the output texture.
  93031. */
  93032. get aspectRatio(): number;
  93033. /**
  93034. * Get a value indicating if the post-process is ready to be used
  93035. * @returns true if the post-process is ready (shader is compiled)
  93036. */
  93037. isReady(): boolean;
  93038. /**
  93039. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93040. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93041. */
  93042. apply(): Nullable<Effect>;
  93043. private _disposeTextures;
  93044. /**
  93045. * Disposes the post process.
  93046. * @param camera The camera to dispose the post process on.
  93047. */
  93048. dispose(camera?: Camera): void;
  93049. }
  93050. }
  93051. declare module BABYLON {
  93052. /** @hidden */
  93053. export var kernelBlurVaryingDeclaration: {
  93054. name: string;
  93055. shader: string;
  93056. };
  93057. }
  93058. declare module BABYLON {
  93059. /** @hidden */
  93060. export var kernelBlurFragment: {
  93061. name: string;
  93062. shader: string;
  93063. };
  93064. }
  93065. declare module BABYLON {
  93066. /** @hidden */
  93067. export var kernelBlurFragment2: {
  93068. name: string;
  93069. shader: string;
  93070. };
  93071. }
  93072. declare module BABYLON {
  93073. /** @hidden */
  93074. export var kernelBlurPixelShader: {
  93075. name: string;
  93076. shader: string;
  93077. };
  93078. }
  93079. declare module BABYLON {
  93080. /** @hidden */
  93081. export var kernelBlurVertex: {
  93082. name: string;
  93083. shader: string;
  93084. };
  93085. }
  93086. declare module BABYLON {
  93087. /** @hidden */
  93088. export var kernelBlurVertexShader: {
  93089. name: string;
  93090. shader: string;
  93091. };
  93092. }
  93093. declare module BABYLON {
  93094. /**
  93095. * The Blur Post Process which blurs an image based on a kernel and direction.
  93096. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93097. */
  93098. export class BlurPostProcess extends PostProcess {
  93099. /** The direction in which to blur the image. */
  93100. direction: Vector2;
  93101. private blockCompilation;
  93102. protected _kernel: number;
  93103. protected _idealKernel: number;
  93104. protected _packedFloat: boolean;
  93105. private _staticDefines;
  93106. /**
  93107. * Sets the length in pixels of the blur sample region
  93108. */
  93109. set kernel(v: number);
  93110. /**
  93111. * Gets the length in pixels of the blur sample region
  93112. */
  93113. get kernel(): number;
  93114. /**
  93115. * Sets wether or not the blur needs to unpack/repack floats
  93116. */
  93117. set packedFloat(v: boolean);
  93118. /**
  93119. * Gets wether or not the blur is unpacking/repacking floats
  93120. */
  93121. get packedFloat(): boolean;
  93122. /**
  93123. * Creates a new instance BlurPostProcess
  93124. * @param name The name of the effect.
  93125. * @param direction The direction in which to blur the image.
  93126. * @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.
  93127. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93128. * @param camera The camera to apply the render pass to.
  93129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93130. * @param engine The engine which the post process will be applied. (default: current engine)
  93131. * @param reusable If the post process can be reused on the same frame. (default: false)
  93132. * @param textureType Type of textures used when performing the post process. (default: 0)
  93133. * @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)
  93134. */
  93135. constructor(name: string,
  93136. /** The direction in which to blur the image. */
  93137. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93138. /**
  93139. * Updates the effect with the current post process compile time values and recompiles the shader.
  93140. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93141. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93142. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93143. * @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
  93144. * @param onCompiled Called when the shader has been compiled.
  93145. * @param onError Called if there is an error when compiling a shader.
  93146. */
  93147. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93148. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93149. /**
  93150. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93151. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93152. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93153. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93154. * The gaps between physical kernels are compensated for in the weighting of the samples
  93155. * @param idealKernel Ideal blur kernel.
  93156. * @return Nearest best kernel.
  93157. */
  93158. protected _nearestBestKernel(idealKernel: number): number;
  93159. /**
  93160. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93161. * @param x The point on the Gaussian distribution to sample.
  93162. * @return the value of the Gaussian function at x.
  93163. */
  93164. protected _gaussianWeight(x: number): number;
  93165. /**
  93166. * Generates a string that can be used as a floating point number in GLSL.
  93167. * @param x Value to print.
  93168. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93169. * @return GLSL float string.
  93170. */
  93171. protected _glslFloat(x: number, decimalFigures?: number): string;
  93172. }
  93173. }
  93174. declare module BABYLON {
  93175. /**
  93176. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93177. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93178. * You can then easily use it as a reflectionTexture on a flat surface.
  93179. * In case the surface is not a plane, please consider relying on reflection probes.
  93180. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93181. */
  93182. export class MirrorTexture extends RenderTargetTexture {
  93183. private scene;
  93184. /**
  93185. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93186. * 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.
  93187. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93188. */
  93189. mirrorPlane: Plane;
  93190. /**
  93191. * Define the blur ratio used to blur the reflection if needed.
  93192. */
  93193. set blurRatio(value: number);
  93194. get blurRatio(): number;
  93195. /**
  93196. * Define the adaptive blur kernel used to blur the reflection if needed.
  93197. * This will autocompute the closest best match for the `blurKernel`
  93198. */
  93199. set adaptiveBlurKernel(value: number);
  93200. /**
  93201. * Define the blur kernel used to blur the reflection if needed.
  93202. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93203. */
  93204. set blurKernel(value: number);
  93205. /**
  93206. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93207. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93208. */
  93209. set blurKernelX(value: number);
  93210. get blurKernelX(): number;
  93211. /**
  93212. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93213. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93214. */
  93215. set blurKernelY(value: number);
  93216. get blurKernelY(): number;
  93217. private _autoComputeBlurKernel;
  93218. protected _onRatioRescale(): void;
  93219. private _updateGammaSpace;
  93220. private _imageProcessingConfigChangeObserver;
  93221. private _transformMatrix;
  93222. private _mirrorMatrix;
  93223. private _savedViewMatrix;
  93224. private _blurX;
  93225. private _blurY;
  93226. private _adaptiveBlurKernel;
  93227. private _blurKernelX;
  93228. private _blurKernelY;
  93229. private _blurRatio;
  93230. /**
  93231. * Instantiates a Mirror Texture.
  93232. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93233. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93234. * You can then easily use it as a reflectionTexture on a flat surface.
  93235. * In case the surface is not a plane, please consider relying on reflection probes.
  93236. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93237. * @param name
  93238. * @param size
  93239. * @param scene
  93240. * @param generateMipMaps
  93241. * @param type
  93242. * @param samplingMode
  93243. * @param generateDepthBuffer
  93244. */
  93245. constructor(name: string, size: number | {
  93246. width: number;
  93247. height: number;
  93248. } | {
  93249. ratio: number;
  93250. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93251. private _preparePostProcesses;
  93252. /**
  93253. * Clone the mirror texture.
  93254. * @returns the cloned texture
  93255. */
  93256. clone(): MirrorTexture;
  93257. /**
  93258. * Serialize the texture to a JSON representation you could use in Parse later on
  93259. * @returns the serialized JSON representation
  93260. */
  93261. serialize(): any;
  93262. /**
  93263. * Dispose the texture and release its associated resources.
  93264. */
  93265. dispose(): void;
  93266. }
  93267. }
  93268. declare module BABYLON {
  93269. /**
  93270. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93271. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93272. */
  93273. export class Texture extends BaseTexture {
  93274. /**
  93275. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93276. */
  93277. static SerializeBuffers: boolean;
  93278. /** @hidden */
  93279. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93280. /** @hidden */
  93281. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93282. /** @hidden */
  93283. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93284. /** nearest is mag = nearest and min = nearest and mip = linear */
  93285. static readonly NEAREST_SAMPLINGMODE: number;
  93286. /** nearest is mag = nearest and min = nearest and mip = linear */
  93287. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93288. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93289. static readonly BILINEAR_SAMPLINGMODE: number;
  93290. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93291. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93292. /** Trilinear is mag = linear and min = linear and mip = linear */
  93293. static readonly TRILINEAR_SAMPLINGMODE: number;
  93294. /** Trilinear is mag = linear and min = linear and mip = linear */
  93295. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93296. /** mag = nearest and min = nearest and mip = nearest */
  93297. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93298. /** mag = nearest and min = linear and mip = nearest */
  93299. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93300. /** mag = nearest and min = linear and mip = linear */
  93301. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93302. /** mag = nearest and min = linear and mip = none */
  93303. static readonly NEAREST_LINEAR: number;
  93304. /** mag = nearest and min = nearest and mip = none */
  93305. static readonly NEAREST_NEAREST: number;
  93306. /** mag = linear and min = nearest and mip = nearest */
  93307. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93308. /** mag = linear and min = nearest and mip = linear */
  93309. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93310. /** mag = linear and min = linear and mip = none */
  93311. static readonly LINEAR_LINEAR: number;
  93312. /** mag = linear and min = nearest and mip = none */
  93313. static readonly LINEAR_NEAREST: number;
  93314. /** Explicit coordinates mode */
  93315. static readonly EXPLICIT_MODE: number;
  93316. /** Spherical coordinates mode */
  93317. static readonly SPHERICAL_MODE: number;
  93318. /** Planar coordinates mode */
  93319. static readonly PLANAR_MODE: number;
  93320. /** Cubic coordinates mode */
  93321. static readonly CUBIC_MODE: number;
  93322. /** Projection coordinates mode */
  93323. static readonly PROJECTION_MODE: number;
  93324. /** Inverse Cubic coordinates mode */
  93325. static readonly SKYBOX_MODE: number;
  93326. /** Inverse Cubic coordinates mode */
  93327. static readonly INVCUBIC_MODE: number;
  93328. /** Equirectangular coordinates mode */
  93329. static readonly EQUIRECTANGULAR_MODE: number;
  93330. /** Equirectangular Fixed coordinates mode */
  93331. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93332. /** Equirectangular Fixed Mirrored coordinates mode */
  93333. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93334. /** Texture is not repeating outside of 0..1 UVs */
  93335. static readonly CLAMP_ADDRESSMODE: number;
  93336. /** Texture is repeating outside of 0..1 UVs */
  93337. static readonly WRAP_ADDRESSMODE: number;
  93338. /** Texture is repeating and mirrored */
  93339. static readonly MIRROR_ADDRESSMODE: number;
  93340. /**
  93341. * 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
  93342. */
  93343. static UseSerializedUrlIfAny: boolean;
  93344. /**
  93345. * Define the url of the texture.
  93346. */
  93347. url: Nullable<string>;
  93348. /**
  93349. * Define an offset on the texture to offset the u coordinates of the UVs
  93350. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93351. */
  93352. uOffset: number;
  93353. /**
  93354. * Define an offset on the texture to offset the v coordinates of the UVs
  93355. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93356. */
  93357. vOffset: number;
  93358. /**
  93359. * Define an offset on the texture to scale the u coordinates of the UVs
  93360. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93361. */
  93362. uScale: number;
  93363. /**
  93364. * Define an offset on the texture to scale the v coordinates of the UVs
  93365. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93366. */
  93367. vScale: number;
  93368. /**
  93369. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93370. * @see http://doc.babylonjs.com/how_to/more_materials
  93371. */
  93372. uAng: number;
  93373. /**
  93374. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93375. * @see http://doc.babylonjs.com/how_to/more_materials
  93376. */
  93377. vAng: number;
  93378. /**
  93379. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93380. * @see http://doc.babylonjs.com/how_to/more_materials
  93381. */
  93382. wAng: number;
  93383. /**
  93384. * Defines the center of rotation (U)
  93385. */
  93386. uRotationCenter: number;
  93387. /**
  93388. * Defines the center of rotation (V)
  93389. */
  93390. vRotationCenter: number;
  93391. /**
  93392. * Defines the center of rotation (W)
  93393. */
  93394. wRotationCenter: number;
  93395. /**
  93396. * Are mip maps generated for this texture or not.
  93397. */
  93398. get noMipmap(): boolean;
  93399. /**
  93400. * List of inspectable custom properties (used by the Inspector)
  93401. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93402. */
  93403. inspectableCustomProperties: Nullable<IInspectable[]>;
  93404. private _noMipmap;
  93405. /** @hidden */
  93406. _invertY: boolean;
  93407. private _rowGenerationMatrix;
  93408. private _cachedTextureMatrix;
  93409. private _projectionModeMatrix;
  93410. private _t0;
  93411. private _t1;
  93412. private _t2;
  93413. private _cachedUOffset;
  93414. private _cachedVOffset;
  93415. private _cachedUScale;
  93416. private _cachedVScale;
  93417. private _cachedUAng;
  93418. private _cachedVAng;
  93419. private _cachedWAng;
  93420. private _cachedProjectionMatrixId;
  93421. private _cachedCoordinatesMode;
  93422. /** @hidden */
  93423. protected _initialSamplingMode: number;
  93424. /** @hidden */
  93425. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93426. private _deleteBuffer;
  93427. protected _format: Nullable<number>;
  93428. private _delayedOnLoad;
  93429. private _delayedOnError;
  93430. private _mimeType?;
  93431. /**
  93432. * Observable triggered once the texture has been loaded.
  93433. */
  93434. onLoadObservable: Observable<Texture>;
  93435. protected _isBlocking: boolean;
  93436. /**
  93437. * Is the texture preventing material to render while loading.
  93438. * If false, a default texture will be used instead of the loading one during the preparation step.
  93439. */
  93440. set isBlocking(value: boolean);
  93441. get isBlocking(): boolean;
  93442. /**
  93443. * Get the current sampling mode associated with the texture.
  93444. */
  93445. get samplingMode(): number;
  93446. /**
  93447. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93448. */
  93449. get invertY(): boolean;
  93450. /**
  93451. * Instantiates a new texture.
  93452. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93453. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93454. * @param url defines the url of the picture to load as a texture
  93455. * @param scene defines the scene or engine the texture will belong to
  93456. * @param noMipmap defines if the texture will require mip maps or not
  93457. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93458. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93459. * @param onLoad defines a callback triggered when the texture has been loaded
  93460. * @param onError defines a callback triggered when an error occurred during the loading session
  93461. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93462. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93463. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93464. * @param mimeType defines an optional mime type information
  93465. */
  93466. 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);
  93467. /**
  93468. * Update the url (and optional buffer) of this texture if url was null during construction.
  93469. * @param url the url of the texture
  93470. * @param buffer the buffer of the texture (defaults to null)
  93471. * @param onLoad callback called when the texture is loaded (defaults to null)
  93472. */
  93473. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93474. /**
  93475. * Finish the loading sequence of a texture flagged as delayed load.
  93476. * @hidden
  93477. */
  93478. delayLoad(): void;
  93479. private _prepareRowForTextureGeneration;
  93480. /**
  93481. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93482. * @returns the transform matrix of the texture.
  93483. */
  93484. getTextureMatrix(uBase?: number): Matrix;
  93485. /**
  93486. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93487. * @returns The reflection texture transform
  93488. */
  93489. getReflectionTextureMatrix(): Matrix;
  93490. /**
  93491. * Clones the texture.
  93492. * @returns the cloned texture
  93493. */
  93494. clone(): Texture;
  93495. /**
  93496. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93497. * @returns The JSON representation of the texture
  93498. */
  93499. serialize(): any;
  93500. /**
  93501. * Get the current class name of the texture useful for serialization or dynamic coding.
  93502. * @returns "Texture"
  93503. */
  93504. getClassName(): string;
  93505. /**
  93506. * Dispose the texture and release its associated resources.
  93507. */
  93508. dispose(): void;
  93509. /**
  93510. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93511. * @param parsedTexture Define the JSON representation of the texture
  93512. * @param scene Define the scene the parsed texture should be instantiated in
  93513. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93514. * @returns The parsed texture if successful
  93515. */
  93516. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93517. /**
  93518. * Creates a texture from its base 64 representation.
  93519. * @param data Define the base64 payload without the data: prefix
  93520. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93521. * @param scene Define the scene the texture should belong to
  93522. * @param noMipmap Forces the texture to not create mip map information if true
  93523. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93524. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93525. * @param onLoad define a callback triggered when the texture has been loaded
  93526. * @param onError define a callback triggered when an error occurred during the loading session
  93527. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93528. * @returns the created texture
  93529. */
  93530. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93531. /**
  93532. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93533. * @param data Define the base64 payload without the data: prefix
  93534. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93535. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93536. * @param scene Define the scene the texture should belong to
  93537. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93538. * @param noMipmap Forces the texture to not create mip map information if true
  93539. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93540. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93541. * @param onLoad define a callback triggered when the texture has been loaded
  93542. * @param onError define a callback triggered when an error occurred during the loading session
  93543. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93544. * @returns the created texture
  93545. */
  93546. 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;
  93547. }
  93548. }
  93549. declare module BABYLON {
  93550. /**
  93551. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93552. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93553. */
  93554. export class PostProcessManager {
  93555. private _scene;
  93556. private _indexBuffer;
  93557. private _vertexBuffers;
  93558. /**
  93559. * Creates a new instance PostProcess
  93560. * @param scene The scene that the post process is associated with.
  93561. */
  93562. constructor(scene: Scene);
  93563. private _prepareBuffers;
  93564. private _buildIndexBuffer;
  93565. /**
  93566. * Rebuilds the vertex buffers of the manager.
  93567. * @hidden
  93568. */
  93569. _rebuild(): void;
  93570. /**
  93571. * Prepares a frame to be run through a post process.
  93572. * @param sourceTexture The input texture to the post procesess. (default: null)
  93573. * @param postProcesses An array of post processes to be run. (default: null)
  93574. * @returns True if the post processes were able to be run.
  93575. * @hidden
  93576. */
  93577. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93578. /**
  93579. * Manually render a set of post processes to a texture.
  93580. * @param postProcesses An array of post processes to be run.
  93581. * @param targetTexture The target texture to render to.
  93582. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93583. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93584. * @param lodLevel defines which lod of the texture to render to
  93585. */
  93586. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93587. /**
  93588. * Finalize the result of the output of the postprocesses.
  93589. * @param doNotPresent If true the result will not be displayed to the screen.
  93590. * @param targetTexture The target texture to render to.
  93591. * @param faceIndex The index of the face to bind the target texture to.
  93592. * @param postProcesses The array of post processes to render.
  93593. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93594. * @hidden
  93595. */
  93596. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93597. /**
  93598. * Disposes of the post process manager.
  93599. */
  93600. dispose(): void;
  93601. }
  93602. }
  93603. declare module BABYLON {
  93604. /**
  93605. * This Helps creating a texture that will be created from a camera in your scene.
  93606. * It is basically a dynamic texture that could be used to create special effects for instance.
  93607. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93608. */
  93609. export class RenderTargetTexture extends Texture {
  93610. isCube: boolean;
  93611. /**
  93612. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93613. */
  93614. static readonly REFRESHRATE_RENDER_ONCE: number;
  93615. /**
  93616. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93617. */
  93618. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93619. /**
  93620. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93621. * the central point of your effect and can save a lot of performances.
  93622. */
  93623. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93624. /**
  93625. * Use this predicate to dynamically define the list of mesh you want to render.
  93626. * If set, the renderList property will be overwritten.
  93627. */
  93628. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93629. private _renderList;
  93630. /**
  93631. * Use this list to define the list of mesh you want to render.
  93632. */
  93633. get renderList(): Nullable<Array<AbstractMesh>>;
  93634. set renderList(value: Nullable<Array<AbstractMesh>>);
  93635. /**
  93636. * Use this function to overload the renderList array at rendering time.
  93637. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93638. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93639. * the cube (if the RTT is a cube, else layerOrFace=0).
  93640. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93641. */
  93642. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93643. private _hookArray;
  93644. /**
  93645. * Define if particles should be rendered in your texture.
  93646. */
  93647. renderParticles: boolean;
  93648. /**
  93649. * Define if sprites should be rendered in your texture.
  93650. */
  93651. renderSprites: boolean;
  93652. /**
  93653. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93654. */
  93655. coordinatesMode: number;
  93656. /**
  93657. * Define the camera used to render the texture.
  93658. */
  93659. activeCamera: Nullable<Camera>;
  93660. /**
  93661. * Override the render function of the texture with your own one.
  93662. */
  93663. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93664. /**
  93665. * Define if camera post processes should be use while rendering the texture.
  93666. */
  93667. useCameraPostProcesses: boolean;
  93668. /**
  93669. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93670. */
  93671. ignoreCameraViewport: boolean;
  93672. private _postProcessManager;
  93673. private _postProcesses;
  93674. private _resizeObserver;
  93675. /**
  93676. * An event triggered when the texture is unbind.
  93677. */
  93678. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93679. /**
  93680. * An event triggered when the texture is unbind.
  93681. */
  93682. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93683. private _onAfterUnbindObserver;
  93684. /**
  93685. * Set a after unbind callback in the texture.
  93686. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93687. */
  93688. set onAfterUnbind(callback: () => void);
  93689. /**
  93690. * An event triggered before rendering the texture
  93691. */
  93692. onBeforeRenderObservable: Observable<number>;
  93693. private _onBeforeRenderObserver;
  93694. /**
  93695. * Set a before render callback in the texture.
  93696. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93697. */
  93698. set onBeforeRender(callback: (faceIndex: number) => void);
  93699. /**
  93700. * An event triggered after rendering the texture
  93701. */
  93702. onAfterRenderObservable: Observable<number>;
  93703. private _onAfterRenderObserver;
  93704. /**
  93705. * Set a after render callback in the texture.
  93706. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93707. */
  93708. set onAfterRender(callback: (faceIndex: number) => void);
  93709. /**
  93710. * An event triggered after the texture clear
  93711. */
  93712. onClearObservable: Observable<Engine>;
  93713. private _onClearObserver;
  93714. /**
  93715. * Set a clear callback in the texture.
  93716. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93717. */
  93718. set onClear(callback: (Engine: Engine) => void);
  93719. /**
  93720. * An event triggered when the texture is resized.
  93721. */
  93722. onResizeObservable: Observable<RenderTargetTexture>;
  93723. /**
  93724. * Define the clear color of the Render Target if it should be different from the scene.
  93725. */
  93726. clearColor: Color4;
  93727. protected _size: number | {
  93728. width: number;
  93729. height: number;
  93730. layers?: number;
  93731. };
  93732. protected _initialSizeParameter: number | {
  93733. width: number;
  93734. height: number;
  93735. } | {
  93736. ratio: number;
  93737. };
  93738. protected _sizeRatio: Nullable<number>;
  93739. /** @hidden */
  93740. _generateMipMaps: boolean;
  93741. protected _renderingManager: RenderingManager;
  93742. /** @hidden */
  93743. _waitingRenderList: string[];
  93744. protected _doNotChangeAspectRatio: boolean;
  93745. protected _currentRefreshId: number;
  93746. protected _refreshRate: number;
  93747. protected _textureMatrix: Matrix;
  93748. protected _samples: number;
  93749. protected _renderTargetOptions: RenderTargetCreationOptions;
  93750. /**
  93751. * Gets render target creation options that were used.
  93752. */
  93753. get renderTargetOptions(): RenderTargetCreationOptions;
  93754. protected _engine: Engine;
  93755. protected _onRatioRescale(): void;
  93756. /**
  93757. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93758. * It must define where the camera used to render the texture is set
  93759. */
  93760. boundingBoxPosition: Vector3;
  93761. private _boundingBoxSize;
  93762. /**
  93763. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93764. * When defined, the cubemap will switch to local mode
  93765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93766. * @example https://www.babylonjs-playground.com/#RNASML
  93767. */
  93768. set boundingBoxSize(value: Vector3);
  93769. get boundingBoxSize(): Vector3;
  93770. /**
  93771. * In case the RTT has been created with a depth texture, get the associated
  93772. * depth texture.
  93773. * Otherwise, return null.
  93774. */
  93775. get depthStencilTexture(): Nullable<InternalTexture>;
  93776. /**
  93777. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93778. * or used a shadow, depth texture...
  93779. * @param name The friendly name of the texture
  93780. * @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)
  93781. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93782. * @param generateMipMaps True if mip maps need to be generated after render.
  93783. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93784. * @param type The type of the buffer in the RTT (int, half float, float...)
  93785. * @param isCube True if a cube texture needs to be created
  93786. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93787. * @param generateDepthBuffer True to generate a depth buffer
  93788. * @param generateStencilBuffer True to generate a stencil buffer
  93789. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93790. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93791. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93792. */
  93793. constructor(name: string, size: number | {
  93794. width: number;
  93795. height: number;
  93796. layers?: number;
  93797. } | {
  93798. ratio: number;
  93799. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93800. /**
  93801. * Creates a depth stencil texture.
  93802. * This is only available in WebGL 2 or with the depth texture extension available.
  93803. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93804. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93805. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93806. */
  93807. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93808. private _processSizeParameter;
  93809. /**
  93810. * Define the number of samples to use in case of MSAA.
  93811. * It defaults to one meaning no MSAA has been enabled.
  93812. */
  93813. get samples(): number;
  93814. set samples(value: number);
  93815. /**
  93816. * Resets the refresh counter of the texture and start bak from scratch.
  93817. * Could be useful to regenerate the texture if it is setup to render only once.
  93818. */
  93819. resetRefreshCounter(): void;
  93820. /**
  93821. * Define the refresh rate of the texture or the rendering frequency.
  93822. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93823. */
  93824. get refreshRate(): number;
  93825. set refreshRate(value: number);
  93826. /**
  93827. * Adds a post process to the render target rendering passes.
  93828. * @param postProcess define the post process to add
  93829. */
  93830. addPostProcess(postProcess: PostProcess): void;
  93831. /**
  93832. * Clear all the post processes attached to the render target
  93833. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93834. */
  93835. clearPostProcesses(dispose?: boolean): void;
  93836. /**
  93837. * Remove one of the post process from the list of attached post processes to the texture
  93838. * @param postProcess define the post process to remove from the list
  93839. */
  93840. removePostProcess(postProcess: PostProcess): void;
  93841. /** @hidden */
  93842. _shouldRender(): boolean;
  93843. /**
  93844. * Gets the actual render size of the texture.
  93845. * @returns the width of the render size
  93846. */
  93847. getRenderSize(): number;
  93848. /**
  93849. * Gets the actual render width of the texture.
  93850. * @returns the width of the render size
  93851. */
  93852. getRenderWidth(): number;
  93853. /**
  93854. * Gets the actual render height of the texture.
  93855. * @returns the height of the render size
  93856. */
  93857. getRenderHeight(): number;
  93858. /**
  93859. * Gets the actual number of layers of the texture.
  93860. * @returns the number of layers
  93861. */
  93862. getRenderLayers(): number;
  93863. /**
  93864. * Get if the texture can be rescaled or not.
  93865. */
  93866. get canRescale(): boolean;
  93867. /**
  93868. * Resize the texture using a ratio.
  93869. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93870. */
  93871. scale(ratio: number): void;
  93872. /**
  93873. * Get the texture reflection matrix used to rotate/transform the reflection.
  93874. * @returns the reflection matrix
  93875. */
  93876. getReflectionTextureMatrix(): Matrix;
  93877. /**
  93878. * Resize the texture to a new desired size.
  93879. * Be carrefull as it will recreate all the data in the new texture.
  93880. * @param size Define the new size. It can be:
  93881. * - a number for squared texture,
  93882. * - an object containing { width: number, height: number }
  93883. * - or an object containing a ratio { ratio: number }
  93884. */
  93885. resize(size: number | {
  93886. width: number;
  93887. height: number;
  93888. } | {
  93889. ratio: number;
  93890. }): void;
  93891. private _defaultRenderListPrepared;
  93892. /**
  93893. * Renders all the objects from the render list into the texture.
  93894. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93895. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93896. */
  93897. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93898. private _bestReflectionRenderTargetDimension;
  93899. private _prepareRenderingManager;
  93900. /**
  93901. * @hidden
  93902. * @param faceIndex face index to bind to if this is a cubetexture
  93903. * @param layer defines the index of the texture to bind in the array
  93904. */
  93905. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93906. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93907. private renderToTarget;
  93908. /**
  93909. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93910. * This allowed control for front to back rendering or reversly depending of the special needs.
  93911. *
  93912. * @param renderingGroupId The rendering group id corresponding to its index
  93913. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93914. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93915. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93916. */
  93917. 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;
  93918. /**
  93919. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93920. *
  93921. * @param renderingGroupId The rendering group id corresponding to its index
  93922. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93923. */
  93924. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93925. /**
  93926. * Clones the texture.
  93927. * @returns the cloned texture
  93928. */
  93929. clone(): RenderTargetTexture;
  93930. /**
  93931. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93932. * @returns The JSON representation of the texture
  93933. */
  93934. serialize(): any;
  93935. /**
  93936. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93937. */
  93938. disposeFramebufferObjects(): void;
  93939. /**
  93940. * Dispose the texture and release its associated resources.
  93941. */
  93942. dispose(): void;
  93943. /** @hidden */
  93944. _rebuild(): void;
  93945. /**
  93946. * Clear the info related to rendering groups preventing retention point in material dispose.
  93947. */
  93948. freeRenderingGroups(): void;
  93949. /**
  93950. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93951. * @returns the view count
  93952. */
  93953. getViewCount(): number;
  93954. }
  93955. }
  93956. declare module BABYLON {
  93957. /**
  93958. * Options for compiling materials.
  93959. */
  93960. export interface IMaterialCompilationOptions {
  93961. /**
  93962. * Defines whether clip planes are enabled.
  93963. */
  93964. clipPlane: boolean;
  93965. /**
  93966. * Defines whether instances are enabled.
  93967. */
  93968. useInstances: boolean;
  93969. }
  93970. /**
  93971. * Base class for the main features of a material in Babylon.js
  93972. */
  93973. export class Material implements IAnimatable {
  93974. /**
  93975. * Returns the triangle fill mode
  93976. */
  93977. static readonly TriangleFillMode: number;
  93978. /**
  93979. * Returns the wireframe mode
  93980. */
  93981. static readonly WireFrameFillMode: number;
  93982. /**
  93983. * Returns the point fill mode
  93984. */
  93985. static readonly PointFillMode: number;
  93986. /**
  93987. * Returns the point list draw mode
  93988. */
  93989. static readonly PointListDrawMode: number;
  93990. /**
  93991. * Returns the line list draw mode
  93992. */
  93993. static readonly LineListDrawMode: number;
  93994. /**
  93995. * Returns the line loop draw mode
  93996. */
  93997. static readonly LineLoopDrawMode: number;
  93998. /**
  93999. * Returns the line strip draw mode
  94000. */
  94001. static readonly LineStripDrawMode: number;
  94002. /**
  94003. * Returns the triangle strip draw mode
  94004. */
  94005. static readonly TriangleStripDrawMode: number;
  94006. /**
  94007. * Returns the triangle fan draw mode
  94008. */
  94009. static readonly TriangleFanDrawMode: number;
  94010. /**
  94011. * Stores the clock-wise side orientation
  94012. */
  94013. static readonly ClockWiseSideOrientation: number;
  94014. /**
  94015. * Stores the counter clock-wise side orientation
  94016. */
  94017. static readonly CounterClockWiseSideOrientation: number;
  94018. /**
  94019. * The dirty texture flag value
  94020. */
  94021. static readonly TextureDirtyFlag: number;
  94022. /**
  94023. * The dirty light flag value
  94024. */
  94025. static readonly LightDirtyFlag: number;
  94026. /**
  94027. * The dirty fresnel flag value
  94028. */
  94029. static readonly FresnelDirtyFlag: number;
  94030. /**
  94031. * The dirty attribute flag value
  94032. */
  94033. static readonly AttributesDirtyFlag: number;
  94034. /**
  94035. * The dirty misc flag value
  94036. */
  94037. static readonly MiscDirtyFlag: number;
  94038. /**
  94039. * The all dirty flag value
  94040. */
  94041. static readonly AllDirtyFlag: number;
  94042. /**
  94043. * The ID of the material
  94044. */
  94045. id: string;
  94046. /**
  94047. * Gets or sets the unique id of the material
  94048. */
  94049. uniqueId: number;
  94050. /**
  94051. * The name of the material
  94052. */
  94053. name: string;
  94054. /**
  94055. * Gets or sets user defined metadata
  94056. */
  94057. metadata: any;
  94058. /**
  94059. * For internal use only. Please do not use.
  94060. */
  94061. reservedDataStore: any;
  94062. /**
  94063. * Specifies if the ready state should be checked on each call
  94064. */
  94065. checkReadyOnEveryCall: boolean;
  94066. /**
  94067. * Specifies if the ready state should be checked once
  94068. */
  94069. checkReadyOnlyOnce: boolean;
  94070. /**
  94071. * The state of the material
  94072. */
  94073. state: string;
  94074. /**
  94075. * The alpha value of the material
  94076. */
  94077. protected _alpha: number;
  94078. /**
  94079. * List of inspectable custom properties (used by the Inspector)
  94080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94081. */
  94082. inspectableCustomProperties: IInspectable[];
  94083. /**
  94084. * Sets the alpha value of the material
  94085. */
  94086. set alpha(value: number);
  94087. /**
  94088. * Gets the alpha value of the material
  94089. */
  94090. get alpha(): number;
  94091. /**
  94092. * Specifies if back face culling is enabled
  94093. */
  94094. protected _backFaceCulling: boolean;
  94095. /**
  94096. * Sets the back-face culling state
  94097. */
  94098. set backFaceCulling(value: boolean);
  94099. /**
  94100. * Gets the back-face culling state
  94101. */
  94102. get backFaceCulling(): boolean;
  94103. /**
  94104. * Stores the value for side orientation
  94105. */
  94106. sideOrientation: number;
  94107. /**
  94108. * Callback triggered when the material is compiled
  94109. */
  94110. onCompiled: Nullable<(effect: Effect) => void>;
  94111. /**
  94112. * Callback triggered when an error occurs
  94113. */
  94114. onError: Nullable<(effect: Effect, errors: string) => void>;
  94115. /**
  94116. * Callback triggered to get the render target textures
  94117. */
  94118. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94119. /**
  94120. * Gets a boolean indicating that current material needs to register RTT
  94121. */
  94122. get hasRenderTargetTextures(): boolean;
  94123. /**
  94124. * Specifies if the material should be serialized
  94125. */
  94126. doNotSerialize: boolean;
  94127. /**
  94128. * @hidden
  94129. */
  94130. _storeEffectOnSubMeshes: boolean;
  94131. /**
  94132. * Stores the animations for the material
  94133. */
  94134. animations: Nullable<Array<Animation>>;
  94135. /**
  94136. * An event triggered when the material is disposed
  94137. */
  94138. onDisposeObservable: Observable<Material>;
  94139. /**
  94140. * An observer which watches for dispose events
  94141. */
  94142. private _onDisposeObserver;
  94143. private _onUnBindObservable;
  94144. /**
  94145. * Called during a dispose event
  94146. */
  94147. set onDispose(callback: () => void);
  94148. private _onBindObservable;
  94149. /**
  94150. * An event triggered when the material is bound
  94151. */
  94152. get onBindObservable(): Observable<AbstractMesh>;
  94153. /**
  94154. * An observer which watches for bind events
  94155. */
  94156. private _onBindObserver;
  94157. /**
  94158. * Called during a bind event
  94159. */
  94160. set onBind(callback: (Mesh: AbstractMesh) => void);
  94161. /**
  94162. * An event triggered when the material is unbound
  94163. */
  94164. get onUnBindObservable(): Observable<Material>;
  94165. /**
  94166. * Stores the value of the alpha mode
  94167. */
  94168. private _alphaMode;
  94169. /**
  94170. * Sets the value of the alpha mode.
  94171. *
  94172. * | Value | Type | Description |
  94173. * | --- | --- | --- |
  94174. * | 0 | ALPHA_DISABLE | |
  94175. * | 1 | ALPHA_ADD | |
  94176. * | 2 | ALPHA_COMBINE | |
  94177. * | 3 | ALPHA_SUBTRACT | |
  94178. * | 4 | ALPHA_MULTIPLY | |
  94179. * | 5 | ALPHA_MAXIMIZED | |
  94180. * | 6 | ALPHA_ONEONE | |
  94181. * | 7 | ALPHA_PREMULTIPLIED | |
  94182. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94183. * | 9 | ALPHA_INTERPOLATE | |
  94184. * | 10 | ALPHA_SCREENMODE | |
  94185. *
  94186. */
  94187. set alphaMode(value: number);
  94188. /**
  94189. * Gets the value of the alpha mode
  94190. */
  94191. get alphaMode(): number;
  94192. /**
  94193. * Stores the state of the need depth pre-pass value
  94194. */
  94195. private _needDepthPrePass;
  94196. /**
  94197. * Sets the need depth pre-pass value
  94198. */
  94199. set needDepthPrePass(value: boolean);
  94200. /**
  94201. * Gets the depth pre-pass value
  94202. */
  94203. get needDepthPrePass(): boolean;
  94204. /**
  94205. * Specifies if depth writing should be disabled
  94206. */
  94207. disableDepthWrite: boolean;
  94208. /**
  94209. * Specifies if depth writing should be forced
  94210. */
  94211. forceDepthWrite: boolean;
  94212. /**
  94213. * Specifies the depth function that should be used. 0 means the default engine function
  94214. */
  94215. depthFunction: number;
  94216. /**
  94217. * Specifies if there should be a separate pass for culling
  94218. */
  94219. separateCullingPass: boolean;
  94220. /**
  94221. * Stores the state specifing if fog should be enabled
  94222. */
  94223. private _fogEnabled;
  94224. /**
  94225. * Sets the state for enabling fog
  94226. */
  94227. set fogEnabled(value: boolean);
  94228. /**
  94229. * Gets the value of the fog enabled state
  94230. */
  94231. get fogEnabled(): boolean;
  94232. /**
  94233. * Stores the size of points
  94234. */
  94235. pointSize: number;
  94236. /**
  94237. * Stores the z offset value
  94238. */
  94239. zOffset: number;
  94240. /**
  94241. * Gets a value specifying if wireframe mode is enabled
  94242. */
  94243. get wireframe(): boolean;
  94244. /**
  94245. * Sets the state of wireframe mode
  94246. */
  94247. set wireframe(value: boolean);
  94248. /**
  94249. * Gets the value specifying if point clouds are enabled
  94250. */
  94251. get pointsCloud(): boolean;
  94252. /**
  94253. * Sets the state of point cloud mode
  94254. */
  94255. set pointsCloud(value: boolean);
  94256. /**
  94257. * Gets the material fill mode
  94258. */
  94259. get fillMode(): number;
  94260. /**
  94261. * Sets the material fill mode
  94262. */
  94263. set fillMode(value: number);
  94264. /**
  94265. * @hidden
  94266. * Stores the effects for the material
  94267. */
  94268. _effect: Nullable<Effect>;
  94269. /**
  94270. * Specifies if uniform buffers should be used
  94271. */
  94272. private _useUBO;
  94273. /**
  94274. * Stores a reference to the scene
  94275. */
  94276. private _scene;
  94277. /**
  94278. * Stores the fill mode state
  94279. */
  94280. private _fillMode;
  94281. /**
  94282. * Specifies if the depth write state should be cached
  94283. */
  94284. private _cachedDepthWriteState;
  94285. /**
  94286. * Specifies if the depth function state should be cached
  94287. */
  94288. private _cachedDepthFunctionState;
  94289. /**
  94290. * Stores the uniform buffer
  94291. */
  94292. protected _uniformBuffer: UniformBuffer;
  94293. /** @hidden */
  94294. _indexInSceneMaterialArray: number;
  94295. /** @hidden */
  94296. meshMap: Nullable<{
  94297. [id: string]: AbstractMesh | undefined;
  94298. }>;
  94299. /**
  94300. * Creates a material instance
  94301. * @param name defines the name of the material
  94302. * @param scene defines the scene to reference
  94303. * @param doNotAdd specifies if the material should be added to the scene
  94304. */
  94305. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94306. /**
  94307. * Returns a string representation of the current material
  94308. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94309. * @returns a string with material information
  94310. */
  94311. toString(fullDetails?: boolean): string;
  94312. /**
  94313. * Gets the class name of the material
  94314. * @returns a string with the class name of the material
  94315. */
  94316. getClassName(): string;
  94317. /**
  94318. * Specifies if updates for the material been locked
  94319. */
  94320. get isFrozen(): boolean;
  94321. /**
  94322. * Locks updates for the material
  94323. */
  94324. freeze(): void;
  94325. /**
  94326. * Unlocks updates for the material
  94327. */
  94328. unfreeze(): void;
  94329. /**
  94330. * Specifies if the material is ready to be used
  94331. * @param mesh defines the mesh to check
  94332. * @param useInstances specifies if instances should be used
  94333. * @returns a boolean indicating if the material is ready to be used
  94334. */
  94335. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94336. /**
  94337. * Specifies that the submesh is ready to be used
  94338. * @param mesh defines the mesh to check
  94339. * @param subMesh defines which submesh to check
  94340. * @param useInstances specifies that instances should be used
  94341. * @returns a boolean indicating that the submesh is ready or not
  94342. */
  94343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94344. /**
  94345. * Returns the material effect
  94346. * @returns the effect associated with the material
  94347. */
  94348. getEffect(): Nullable<Effect>;
  94349. /**
  94350. * Returns the current scene
  94351. * @returns a Scene
  94352. */
  94353. getScene(): Scene;
  94354. /**
  94355. * Specifies if the material will require alpha blending
  94356. * @returns a boolean specifying if alpha blending is needed
  94357. */
  94358. needAlphaBlending(): boolean;
  94359. /**
  94360. * Specifies if the mesh will require alpha blending
  94361. * @param mesh defines the mesh to check
  94362. * @returns a boolean specifying if alpha blending is needed for the mesh
  94363. */
  94364. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94365. /**
  94366. * Specifies if this material should be rendered in alpha test mode
  94367. * @returns a boolean specifying if an alpha test is needed.
  94368. */
  94369. needAlphaTesting(): boolean;
  94370. /**
  94371. * Gets the texture used for the alpha test
  94372. * @returns the texture to use for alpha testing
  94373. */
  94374. getAlphaTestTexture(): Nullable<BaseTexture>;
  94375. /**
  94376. * Marks the material to indicate that it needs to be re-calculated
  94377. */
  94378. markDirty(): void;
  94379. /** @hidden */
  94380. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94381. /**
  94382. * Binds the material to the mesh
  94383. * @param world defines the world transformation matrix
  94384. * @param mesh defines the mesh to bind the material to
  94385. */
  94386. bind(world: Matrix, mesh?: Mesh): void;
  94387. /**
  94388. * Binds the submesh to the material
  94389. * @param world defines the world transformation matrix
  94390. * @param mesh defines the mesh containing the submesh
  94391. * @param subMesh defines the submesh to bind the material to
  94392. */
  94393. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94394. /**
  94395. * Binds the world matrix to the material
  94396. * @param world defines the world transformation matrix
  94397. */
  94398. bindOnlyWorldMatrix(world: Matrix): void;
  94399. /**
  94400. * Binds the scene's uniform buffer to the effect.
  94401. * @param effect defines the effect to bind to the scene uniform buffer
  94402. * @param sceneUbo defines the uniform buffer storing scene data
  94403. */
  94404. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94405. /**
  94406. * Binds the view matrix to the effect
  94407. * @param effect defines the effect to bind the view matrix to
  94408. */
  94409. bindView(effect: Effect): void;
  94410. /**
  94411. * Binds the view projection matrix to the effect
  94412. * @param effect defines the effect to bind the view projection matrix to
  94413. */
  94414. bindViewProjection(effect: Effect): void;
  94415. /**
  94416. * Specifies if material alpha testing should be turned on for the mesh
  94417. * @param mesh defines the mesh to check
  94418. */
  94419. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94420. /**
  94421. * Processes to execute after binding the material to a mesh
  94422. * @param mesh defines the rendered mesh
  94423. */
  94424. protected _afterBind(mesh?: Mesh): void;
  94425. /**
  94426. * Unbinds the material from the mesh
  94427. */
  94428. unbind(): void;
  94429. /**
  94430. * Gets the active textures from the material
  94431. * @returns an array of textures
  94432. */
  94433. getActiveTextures(): BaseTexture[];
  94434. /**
  94435. * Specifies if the material uses a texture
  94436. * @param texture defines the texture to check against the material
  94437. * @returns a boolean specifying if the material uses the texture
  94438. */
  94439. hasTexture(texture: BaseTexture): boolean;
  94440. /**
  94441. * Makes a duplicate of the material, and gives it a new name
  94442. * @param name defines the new name for the duplicated material
  94443. * @returns the cloned material
  94444. */
  94445. clone(name: string): Nullable<Material>;
  94446. /**
  94447. * Gets the meshes bound to the material
  94448. * @returns an array of meshes bound to the material
  94449. */
  94450. getBindedMeshes(): AbstractMesh[];
  94451. /**
  94452. * Force shader compilation
  94453. * @param mesh defines the mesh associated with this material
  94454. * @param onCompiled defines a function to execute once the material is compiled
  94455. * @param options defines the options to configure the compilation
  94456. * @param onError defines a function to execute if the material fails compiling
  94457. */
  94458. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94459. /**
  94460. * Force shader compilation
  94461. * @param mesh defines the mesh that will use this material
  94462. * @param options defines additional options for compiling the shaders
  94463. * @returns a promise that resolves when the compilation completes
  94464. */
  94465. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94466. private static readonly _AllDirtyCallBack;
  94467. private static readonly _ImageProcessingDirtyCallBack;
  94468. private static readonly _TextureDirtyCallBack;
  94469. private static readonly _FresnelDirtyCallBack;
  94470. private static readonly _MiscDirtyCallBack;
  94471. private static readonly _LightsDirtyCallBack;
  94472. private static readonly _AttributeDirtyCallBack;
  94473. private static _FresnelAndMiscDirtyCallBack;
  94474. private static _TextureAndMiscDirtyCallBack;
  94475. private static readonly _DirtyCallbackArray;
  94476. private static readonly _RunDirtyCallBacks;
  94477. /**
  94478. * Marks a define in the material to indicate that it needs to be re-computed
  94479. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94480. */
  94481. markAsDirty(flag: number): void;
  94482. /**
  94483. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94484. * @param func defines a function which checks material defines against the submeshes
  94485. */
  94486. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94487. /**
  94488. * Indicates that we need to re-calculated for all submeshes
  94489. */
  94490. protected _markAllSubMeshesAsAllDirty(): void;
  94491. /**
  94492. * Indicates that image processing needs to be re-calculated for all submeshes
  94493. */
  94494. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94495. /**
  94496. * Indicates that textures need to be re-calculated for all submeshes
  94497. */
  94498. protected _markAllSubMeshesAsTexturesDirty(): void;
  94499. /**
  94500. * Indicates that fresnel needs to be re-calculated for all submeshes
  94501. */
  94502. protected _markAllSubMeshesAsFresnelDirty(): void;
  94503. /**
  94504. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94505. */
  94506. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94507. /**
  94508. * Indicates that lights need to be re-calculated for all submeshes
  94509. */
  94510. protected _markAllSubMeshesAsLightsDirty(): void;
  94511. /**
  94512. * Indicates that attributes need to be re-calculated for all submeshes
  94513. */
  94514. protected _markAllSubMeshesAsAttributesDirty(): void;
  94515. /**
  94516. * Indicates that misc needs to be re-calculated for all submeshes
  94517. */
  94518. protected _markAllSubMeshesAsMiscDirty(): void;
  94519. /**
  94520. * Indicates that textures and misc need to be re-calculated for all submeshes
  94521. */
  94522. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94523. /**
  94524. * Disposes the material
  94525. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94526. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94527. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94528. */
  94529. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94530. /** @hidden */
  94531. private releaseVertexArrayObject;
  94532. /**
  94533. * Serializes this material
  94534. * @returns the serialized material object
  94535. */
  94536. serialize(): any;
  94537. /**
  94538. * Creates a material from parsed material data
  94539. * @param parsedMaterial defines parsed material data
  94540. * @param scene defines the hosting scene
  94541. * @param rootUrl defines the root URL to use to load textures
  94542. * @returns a new material
  94543. */
  94544. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94545. }
  94546. }
  94547. declare module BABYLON {
  94548. /**
  94549. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94550. * separate meshes. This can be use to improve performances.
  94551. * @see http://doc.babylonjs.com/how_to/multi_materials
  94552. */
  94553. export class MultiMaterial extends Material {
  94554. private _subMaterials;
  94555. /**
  94556. * Gets or Sets the list of Materials used within the multi material.
  94557. * They need to be ordered according to the submeshes order in the associated mesh
  94558. */
  94559. get subMaterials(): Nullable<Material>[];
  94560. set subMaterials(value: Nullable<Material>[]);
  94561. /**
  94562. * Function used to align with Node.getChildren()
  94563. * @returns the list of Materials used within the multi material
  94564. */
  94565. getChildren(): Nullable<Material>[];
  94566. /**
  94567. * Instantiates a new Multi Material
  94568. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94569. * separate meshes. This can be use to improve performances.
  94570. * @see http://doc.babylonjs.com/how_to/multi_materials
  94571. * @param name Define the name in the scene
  94572. * @param scene Define the scene the material belongs to
  94573. */
  94574. constructor(name: string, scene: Scene);
  94575. private _hookArray;
  94576. /**
  94577. * Get one of the submaterial by its index in the submaterials array
  94578. * @param index The index to look the sub material at
  94579. * @returns The Material if the index has been defined
  94580. */
  94581. getSubMaterial(index: number): Nullable<Material>;
  94582. /**
  94583. * Get the list of active textures for the whole sub materials list.
  94584. * @returns All the textures that will be used during the rendering
  94585. */
  94586. getActiveTextures(): BaseTexture[];
  94587. /**
  94588. * Gets the current class name of the material e.g. "MultiMaterial"
  94589. * Mainly use in serialization.
  94590. * @returns the class name
  94591. */
  94592. getClassName(): string;
  94593. /**
  94594. * Checks if the material is ready to render the requested sub mesh
  94595. * @param mesh Define the mesh the submesh belongs to
  94596. * @param subMesh Define the sub mesh to look readyness for
  94597. * @param useInstances Define whether or not the material is used with instances
  94598. * @returns true if ready, otherwise false
  94599. */
  94600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94601. /**
  94602. * Clones the current material and its related sub materials
  94603. * @param name Define the name of the newly cloned material
  94604. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94605. * @returns the cloned material
  94606. */
  94607. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94608. /**
  94609. * Serializes the materials into a JSON representation.
  94610. * @returns the JSON representation
  94611. */
  94612. serialize(): any;
  94613. /**
  94614. * Dispose the material and release its associated resources
  94615. * @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)
  94616. * @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)
  94617. * @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)
  94618. */
  94619. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94620. /**
  94621. * Creates a MultiMaterial from parsed MultiMaterial data.
  94622. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94623. * @param scene defines the hosting scene
  94624. * @returns a new MultiMaterial
  94625. */
  94626. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94627. }
  94628. }
  94629. declare module BABYLON {
  94630. /**
  94631. * Base class for submeshes
  94632. */
  94633. export class BaseSubMesh {
  94634. /** @hidden */
  94635. _materialDefines: Nullable<MaterialDefines>;
  94636. /** @hidden */
  94637. _materialEffect: Nullable<Effect>;
  94638. /**
  94639. * Gets material defines used by the effect associated to the sub mesh
  94640. */
  94641. get materialDefines(): Nullable<MaterialDefines>;
  94642. /**
  94643. * Sets material defines used by the effect associated to the sub mesh
  94644. */
  94645. set materialDefines(defines: Nullable<MaterialDefines>);
  94646. /**
  94647. * Gets associated effect
  94648. */
  94649. get effect(): Nullable<Effect>;
  94650. /**
  94651. * Sets associated effect (effect used to render this submesh)
  94652. * @param effect defines the effect to associate with
  94653. * @param defines defines the set of defines used to compile this effect
  94654. */
  94655. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94656. }
  94657. /**
  94658. * Defines a subdivision inside a mesh
  94659. */
  94660. export class SubMesh extends BaseSubMesh implements ICullable {
  94661. /** the material index to use */
  94662. materialIndex: number;
  94663. /** vertex index start */
  94664. verticesStart: number;
  94665. /** vertices count */
  94666. verticesCount: number;
  94667. /** index start */
  94668. indexStart: number;
  94669. /** indices count */
  94670. indexCount: number;
  94671. /** @hidden */
  94672. _linesIndexCount: number;
  94673. private _mesh;
  94674. private _renderingMesh;
  94675. private _boundingInfo;
  94676. private _linesIndexBuffer;
  94677. /** @hidden */
  94678. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94679. /** @hidden */
  94680. _trianglePlanes: Plane[];
  94681. /** @hidden */
  94682. _lastColliderTransformMatrix: Nullable<Matrix>;
  94683. /** @hidden */
  94684. _renderId: number;
  94685. /** @hidden */
  94686. _alphaIndex: number;
  94687. /** @hidden */
  94688. _distanceToCamera: number;
  94689. /** @hidden */
  94690. _id: number;
  94691. private _currentMaterial;
  94692. /**
  94693. * Add a new submesh to a mesh
  94694. * @param materialIndex defines the material index to use
  94695. * @param verticesStart defines vertex index start
  94696. * @param verticesCount defines vertices count
  94697. * @param indexStart defines index start
  94698. * @param indexCount defines indices count
  94699. * @param mesh defines the parent mesh
  94700. * @param renderingMesh defines an optional rendering mesh
  94701. * @param createBoundingBox defines if bounding box should be created for this submesh
  94702. * @returns the new submesh
  94703. */
  94704. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94705. /**
  94706. * Creates a new submesh
  94707. * @param materialIndex defines the material index to use
  94708. * @param verticesStart defines vertex index start
  94709. * @param verticesCount defines vertices count
  94710. * @param indexStart defines index start
  94711. * @param indexCount defines indices count
  94712. * @param mesh defines the parent mesh
  94713. * @param renderingMesh defines an optional rendering mesh
  94714. * @param createBoundingBox defines if bounding box should be created for this submesh
  94715. */
  94716. constructor(
  94717. /** the material index to use */
  94718. materialIndex: number,
  94719. /** vertex index start */
  94720. verticesStart: number,
  94721. /** vertices count */
  94722. verticesCount: number,
  94723. /** index start */
  94724. indexStart: number,
  94725. /** indices count */
  94726. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94727. /**
  94728. * Returns true if this submesh covers the entire parent mesh
  94729. * @ignorenaming
  94730. */
  94731. get IsGlobal(): boolean;
  94732. /**
  94733. * Returns the submesh BoudingInfo object
  94734. * @returns current bounding info (or mesh's one if the submesh is global)
  94735. */
  94736. getBoundingInfo(): BoundingInfo;
  94737. /**
  94738. * Sets the submesh BoundingInfo
  94739. * @param boundingInfo defines the new bounding info to use
  94740. * @returns the SubMesh
  94741. */
  94742. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94743. /**
  94744. * Returns the mesh of the current submesh
  94745. * @return the parent mesh
  94746. */
  94747. getMesh(): AbstractMesh;
  94748. /**
  94749. * Returns the rendering mesh of the submesh
  94750. * @returns the rendering mesh (could be different from parent mesh)
  94751. */
  94752. getRenderingMesh(): Mesh;
  94753. /**
  94754. * Returns the submesh material
  94755. * @returns null or the current material
  94756. */
  94757. getMaterial(): Nullable<Material>;
  94758. /**
  94759. * Sets a new updated BoundingInfo object to the submesh
  94760. * @param data defines an optional position array to use to determine the bounding info
  94761. * @returns the SubMesh
  94762. */
  94763. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94764. /** @hidden */
  94765. _checkCollision(collider: Collider): boolean;
  94766. /**
  94767. * Updates the submesh BoundingInfo
  94768. * @param world defines the world matrix to use to update the bounding info
  94769. * @returns the submesh
  94770. */
  94771. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94772. /**
  94773. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94774. * @param frustumPlanes defines the frustum planes
  94775. * @returns true if the submesh is intersecting with the frustum
  94776. */
  94777. isInFrustum(frustumPlanes: Plane[]): boolean;
  94778. /**
  94779. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94780. * @param frustumPlanes defines the frustum planes
  94781. * @returns true if the submesh is inside the frustum
  94782. */
  94783. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94784. /**
  94785. * Renders the submesh
  94786. * @param enableAlphaMode defines if alpha needs to be used
  94787. * @returns the submesh
  94788. */
  94789. render(enableAlphaMode: boolean): SubMesh;
  94790. /**
  94791. * @hidden
  94792. */
  94793. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94794. /**
  94795. * Checks if the submesh intersects with a ray
  94796. * @param ray defines the ray to test
  94797. * @returns true is the passed ray intersects the submesh bounding box
  94798. */
  94799. canIntersects(ray: Ray): boolean;
  94800. /**
  94801. * Intersects current submesh with a ray
  94802. * @param ray defines the ray to test
  94803. * @param positions defines mesh's positions array
  94804. * @param indices defines mesh's indices array
  94805. * @param fastCheck defines if only bounding info should be used
  94806. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94807. * @returns intersection info or null if no intersection
  94808. */
  94809. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94810. /** @hidden */
  94811. private _intersectLines;
  94812. /** @hidden */
  94813. private _intersectUnIndexedLines;
  94814. /** @hidden */
  94815. private _intersectTriangles;
  94816. /** @hidden */
  94817. private _intersectUnIndexedTriangles;
  94818. /** @hidden */
  94819. _rebuild(): void;
  94820. /**
  94821. * Creates a new submesh from the passed mesh
  94822. * @param newMesh defines the new hosting mesh
  94823. * @param newRenderingMesh defines an optional rendering mesh
  94824. * @returns the new submesh
  94825. */
  94826. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94827. /**
  94828. * Release associated resources
  94829. */
  94830. dispose(): void;
  94831. /**
  94832. * Gets the class name
  94833. * @returns the string "SubMesh".
  94834. */
  94835. getClassName(): string;
  94836. /**
  94837. * Creates a new submesh from indices data
  94838. * @param materialIndex the index of the main mesh material
  94839. * @param startIndex the index where to start the copy in the mesh indices array
  94840. * @param indexCount the number of indices to copy then from the startIndex
  94841. * @param mesh the main mesh to create the submesh from
  94842. * @param renderingMesh the optional rendering mesh
  94843. * @returns a new submesh
  94844. */
  94845. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94846. }
  94847. }
  94848. declare module BABYLON {
  94849. /**
  94850. * Class used to represent data loading progression
  94851. */
  94852. export class SceneLoaderFlags {
  94853. private static _ForceFullSceneLoadingForIncremental;
  94854. private static _ShowLoadingScreen;
  94855. private static _CleanBoneMatrixWeights;
  94856. private static _loggingLevel;
  94857. /**
  94858. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94859. */
  94860. static get ForceFullSceneLoadingForIncremental(): boolean;
  94861. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94862. /**
  94863. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94864. */
  94865. static get ShowLoadingScreen(): boolean;
  94866. static set ShowLoadingScreen(value: boolean);
  94867. /**
  94868. * Defines the current logging level (while loading the scene)
  94869. * @ignorenaming
  94870. */
  94871. static get loggingLevel(): number;
  94872. static set loggingLevel(value: number);
  94873. /**
  94874. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94875. */
  94876. static get CleanBoneMatrixWeights(): boolean;
  94877. static set CleanBoneMatrixWeights(value: boolean);
  94878. }
  94879. }
  94880. declare module BABYLON {
  94881. /**
  94882. * Class used to store geometry data (vertex buffers + index buffer)
  94883. */
  94884. export class Geometry implements IGetSetVerticesData {
  94885. /**
  94886. * Gets or sets the ID of the geometry
  94887. */
  94888. id: string;
  94889. /**
  94890. * Gets or sets the unique ID of the geometry
  94891. */
  94892. uniqueId: number;
  94893. /**
  94894. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94895. */
  94896. delayLoadState: number;
  94897. /**
  94898. * Gets the file containing the data to load when running in delay load state
  94899. */
  94900. delayLoadingFile: Nullable<string>;
  94901. /**
  94902. * Callback called when the geometry is updated
  94903. */
  94904. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94905. private _scene;
  94906. private _engine;
  94907. private _meshes;
  94908. private _totalVertices;
  94909. /** @hidden */
  94910. _indices: IndicesArray;
  94911. /** @hidden */
  94912. _vertexBuffers: {
  94913. [key: string]: VertexBuffer;
  94914. };
  94915. private _isDisposed;
  94916. private _extend;
  94917. private _boundingBias;
  94918. /** @hidden */
  94919. _delayInfo: Array<string>;
  94920. private _indexBuffer;
  94921. private _indexBufferIsUpdatable;
  94922. /** @hidden */
  94923. _boundingInfo: Nullable<BoundingInfo>;
  94924. /** @hidden */
  94925. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94926. /** @hidden */
  94927. _softwareSkinningFrameId: number;
  94928. private _vertexArrayObjects;
  94929. private _updatable;
  94930. /** @hidden */
  94931. _positions: Nullable<Vector3[]>;
  94932. /**
  94933. * 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
  94934. */
  94935. get boundingBias(): Vector2;
  94936. /**
  94937. * 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
  94938. */
  94939. set boundingBias(value: Vector2);
  94940. /**
  94941. * Static function used to attach a new empty geometry to a mesh
  94942. * @param mesh defines the mesh to attach the geometry to
  94943. * @returns the new Geometry
  94944. */
  94945. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94946. /**
  94947. * Creates a new geometry
  94948. * @param id defines the unique ID
  94949. * @param scene defines the hosting scene
  94950. * @param vertexData defines the VertexData used to get geometry data
  94951. * @param updatable defines if geometry must be updatable (false by default)
  94952. * @param mesh defines the mesh that will be associated with the geometry
  94953. */
  94954. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94955. /**
  94956. * Gets the current extend of the geometry
  94957. */
  94958. get extend(): {
  94959. minimum: Vector3;
  94960. maximum: Vector3;
  94961. };
  94962. /**
  94963. * Gets the hosting scene
  94964. * @returns the hosting Scene
  94965. */
  94966. getScene(): Scene;
  94967. /**
  94968. * Gets the hosting engine
  94969. * @returns the hosting Engine
  94970. */
  94971. getEngine(): Engine;
  94972. /**
  94973. * Defines if the geometry is ready to use
  94974. * @returns true if the geometry is ready to be used
  94975. */
  94976. isReady(): boolean;
  94977. /**
  94978. * Gets a value indicating that the geometry should not be serialized
  94979. */
  94980. get doNotSerialize(): boolean;
  94981. /** @hidden */
  94982. _rebuild(): void;
  94983. /**
  94984. * Affects all geometry data in one call
  94985. * @param vertexData defines the geometry data
  94986. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94987. */
  94988. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94989. /**
  94990. * Set specific vertex data
  94991. * @param kind defines the data kind (Position, normal, etc...)
  94992. * @param data defines the vertex data to use
  94993. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94994. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94995. */
  94996. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94997. /**
  94998. * Removes a specific vertex data
  94999. * @param kind defines the data kind (Position, normal, etc...)
  95000. */
  95001. removeVerticesData(kind: string): void;
  95002. /**
  95003. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95004. * @param buffer defines the vertex buffer to use
  95005. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95006. */
  95007. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95008. /**
  95009. * Update a specific vertex buffer
  95010. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95011. * It will do nothing if the buffer is not updatable
  95012. * @param kind defines the data kind (Position, normal, etc...)
  95013. * @param data defines the data to use
  95014. * @param offset defines the offset in the target buffer where to store the data
  95015. * @param useBytes set to true if the offset is in bytes
  95016. */
  95017. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95018. /**
  95019. * Update a specific vertex buffer
  95020. * This function will create a new buffer if the current one is not updatable
  95021. * @param kind defines the data kind (Position, normal, etc...)
  95022. * @param data defines the data to use
  95023. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95024. */
  95025. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95026. private _updateBoundingInfo;
  95027. /** @hidden */
  95028. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95029. /**
  95030. * Gets total number of vertices
  95031. * @returns the total number of vertices
  95032. */
  95033. getTotalVertices(): number;
  95034. /**
  95035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95036. * @param kind defines the data kind (Position, normal, etc...)
  95037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95039. * @returns a float array containing vertex data
  95040. */
  95041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95042. /**
  95043. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95044. * @param kind defines the data kind (Position, normal, etc...)
  95045. * @returns true if the vertex buffer with the specified kind is updatable
  95046. */
  95047. isVertexBufferUpdatable(kind: string): boolean;
  95048. /**
  95049. * Gets a specific vertex buffer
  95050. * @param kind defines the data kind (Position, normal, etc...)
  95051. * @returns a VertexBuffer
  95052. */
  95053. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95054. /**
  95055. * Returns all vertex buffers
  95056. * @return an object holding all vertex buffers indexed by kind
  95057. */
  95058. getVertexBuffers(): Nullable<{
  95059. [key: string]: VertexBuffer;
  95060. }>;
  95061. /**
  95062. * Gets a boolean indicating if specific vertex buffer is present
  95063. * @param kind defines the data kind (Position, normal, etc...)
  95064. * @returns true if data is present
  95065. */
  95066. isVerticesDataPresent(kind: string): boolean;
  95067. /**
  95068. * Gets a list of all attached data kinds (Position, normal, etc...)
  95069. * @returns a list of string containing all kinds
  95070. */
  95071. getVerticesDataKinds(): string[];
  95072. /**
  95073. * Update index buffer
  95074. * @param indices defines the indices to store in the index buffer
  95075. * @param offset defines the offset in the target buffer where to store the data
  95076. * @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)
  95077. */
  95078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95079. /**
  95080. * Creates a new index buffer
  95081. * @param indices defines the indices to store in the index buffer
  95082. * @param totalVertices defines the total number of vertices (could be null)
  95083. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95084. */
  95085. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95086. /**
  95087. * Return the total number of indices
  95088. * @returns the total number of indices
  95089. */
  95090. getTotalIndices(): number;
  95091. /**
  95092. * Gets the index buffer array
  95093. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95094. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95095. * @returns the index buffer array
  95096. */
  95097. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95098. /**
  95099. * Gets the index buffer
  95100. * @return the index buffer
  95101. */
  95102. getIndexBuffer(): Nullable<DataBuffer>;
  95103. /** @hidden */
  95104. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95105. /**
  95106. * Release the associated resources for a specific mesh
  95107. * @param mesh defines the source mesh
  95108. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95109. */
  95110. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95111. /**
  95112. * Apply current geometry to a given mesh
  95113. * @param mesh defines the mesh to apply geometry to
  95114. */
  95115. applyToMesh(mesh: Mesh): void;
  95116. private _updateExtend;
  95117. private _applyToMesh;
  95118. private notifyUpdate;
  95119. /**
  95120. * Load the geometry if it was flagged as delay loaded
  95121. * @param scene defines the hosting scene
  95122. * @param onLoaded defines a callback called when the geometry is loaded
  95123. */
  95124. load(scene: Scene, onLoaded?: () => void): void;
  95125. private _queueLoad;
  95126. /**
  95127. * Invert the geometry to move from a right handed system to a left handed one.
  95128. */
  95129. toLeftHanded(): void;
  95130. /** @hidden */
  95131. _resetPointsArrayCache(): void;
  95132. /** @hidden */
  95133. _generatePointsArray(): boolean;
  95134. /**
  95135. * Gets a value indicating if the geometry is disposed
  95136. * @returns true if the geometry was disposed
  95137. */
  95138. isDisposed(): boolean;
  95139. private _disposeVertexArrayObjects;
  95140. /**
  95141. * Free all associated resources
  95142. */
  95143. dispose(): void;
  95144. /**
  95145. * Clone the current geometry into a new geometry
  95146. * @param id defines the unique ID of the new geometry
  95147. * @returns a new geometry object
  95148. */
  95149. copy(id: string): Geometry;
  95150. /**
  95151. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95152. * @return a JSON representation of the current geometry data (without the vertices data)
  95153. */
  95154. serialize(): any;
  95155. private toNumberArray;
  95156. /**
  95157. * Serialize all vertices data into a JSON oject
  95158. * @returns a JSON representation of the current geometry data
  95159. */
  95160. serializeVerticeData(): any;
  95161. /**
  95162. * Extracts a clone of a mesh geometry
  95163. * @param mesh defines the source mesh
  95164. * @param id defines the unique ID of the new geometry object
  95165. * @returns the new geometry object
  95166. */
  95167. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95168. /**
  95169. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95170. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95171. * Be aware Math.random() could cause collisions, but:
  95172. * "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"
  95173. * @returns a string containing a new GUID
  95174. */
  95175. static RandomId(): string;
  95176. /** @hidden */
  95177. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95178. private static _CleanMatricesWeights;
  95179. /**
  95180. * Create a new geometry from persisted data (Using .babylon file format)
  95181. * @param parsedVertexData defines the persisted data
  95182. * @param scene defines the hosting scene
  95183. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95184. * @returns the new geometry object
  95185. */
  95186. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95187. }
  95188. }
  95189. declare module BABYLON {
  95190. /**
  95191. * Define an interface for all classes that will get and set the data on vertices
  95192. */
  95193. export interface IGetSetVerticesData {
  95194. /**
  95195. * Gets a boolean indicating if specific vertex data is present
  95196. * @param kind defines the vertex data kind to use
  95197. * @returns true is data kind is present
  95198. */
  95199. isVerticesDataPresent(kind: string): boolean;
  95200. /**
  95201. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95202. * @param kind defines the data kind (Position, normal, etc...)
  95203. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95204. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95205. * @returns a float array containing vertex data
  95206. */
  95207. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95208. /**
  95209. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95210. * @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.
  95211. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95212. * @returns the indices array or an empty array if the mesh has no geometry
  95213. */
  95214. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95215. /**
  95216. * Set specific vertex data
  95217. * @param kind defines the data kind (Position, normal, etc...)
  95218. * @param data defines the vertex data to use
  95219. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95220. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95221. */
  95222. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95223. /**
  95224. * Update a specific associated vertex buffer
  95225. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95226. * - VertexBuffer.PositionKind
  95227. * - VertexBuffer.UVKind
  95228. * - VertexBuffer.UV2Kind
  95229. * - VertexBuffer.UV3Kind
  95230. * - VertexBuffer.UV4Kind
  95231. * - VertexBuffer.UV5Kind
  95232. * - VertexBuffer.UV6Kind
  95233. * - VertexBuffer.ColorKind
  95234. * - VertexBuffer.MatricesIndicesKind
  95235. * - VertexBuffer.MatricesIndicesExtraKind
  95236. * - VertexBuffer.MatricesWeightsKind
  95237. * - VertexBuffer.MatricesWeightsExtraKind
  95238. * @param data defines the data source
  95239. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95240. * @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)
  95241. */
  95242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95243. /**
  95244. * Creates a new index buffer
  95245. * @param indices defines the indices to store in the index buffer
  95246. * @param totalVertices defines the total number of vertices (could be null)
  95247. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95248. */
  95249. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95250. }
  95251. /**
  95252. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95253. */
  95254. export class VertexData {
  95255. /**
  95256. * Mesh side orientation : usually the external or front surface
  95257. */
  95258. static readonly FRONTSIDE: number;
  95259. /**
  95260. * Mesh side orientation : usually the internal or back surface
  95261. */
  95262. static readonly BACKSIDE: number;
  95263. /**
  95264. * Mesh side orientation : both internal and external or front and back surfaces
  95265. */
  95266. static readonly DOUBLESIDE: number;
  95267. /**
  95268. * Mesh side orientation : by default, `FRONTSIDE`
  95269. */
  95270. static readonly DEFAULTSIDE: number;
  95271. /**
  95272. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95273. */
  95274. positions: Nullable<FloatArray>;
  95275. /**
  95276. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95277. */
  95278. normals: Nullable<FloatArray>;
  95279. /**
  95280. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95281. */
  95282. tangents: Nullable<FloatArray>;
  95283. /**
  95284. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95285. */
  95286. uvs: Nullable<FloatArray>;
  95287. /**
  95288. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95289. */
  95290. uvs2: Nullable<FloatArray>;
  95291. /**
  95292. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95293. */
  95294. uvs3: Nullable<FloatArray>;
  95295. /**
  95296. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95297. */
  95298. uvs4: Nullable<FloatArray>;
  95299. /**
  95300. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95301. */
  95302. uvs5: Nullable<FloatArray>;
  95303. /**
  95304. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95305. */
  95306. uvs6: Nullable<FloatArray>;
  95307. /**
  95308. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95309. */
  95310. colors: Nullable<FloatArray>;
  95311. /**
  95312. * 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).
  95313. */
  95314. matricesIndices: Nullable<FloatArray>;
  95315. /**
  95316. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95317. */
  95318. matricesWeights: Nullable<FloatArray>;
  95319. /**
  95320. * An array extending the number of possible indices
  95321. */
  95322. matricesIndicesExtra: Nullable<FloatArray>;
  95323. /**
  95324. * An array extending the number of possible weights when the number of indices is extended
  95325. */
  95326. matricesWeightsExtra: Nullable<FloatArray>;
  95327. /**
  95328. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95329. */
  95330. indices: Nullable<IndicesArray>;
  95331. /**
  95332. * Uses the passed data array to set the set the values for the specified kind of data
  95333. * @param data a linear array of floating numbers
  95334. * @param kind the type of data that is being set, eg positions, colors etc
  95335. */
  95336. set(data: FloatArray, kind: string): void;
  95337. /**
  95338. * Associates the vertexData to the passed Mesh.
  95339. * Sets it as updatable or not (default `false`)
  95340. * @param mesh the mesh the vertexData is applied to
  95341. * @param updatable when used and having the value true allows new data to update the vertexData
  95342. * @returns the VertexData
  95343. */
  95344. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95345. /**
  95346. * Associates the vertexData to the passed Geometry.
  95347. * Sets it as updatable or not (default `false`)
  95348. * @param geometry the geometry the vertexData is applied to
  95349. * @param updatable when used and having the value true allows new data to update the vertexData
  95350. * @returns VertexData
  95351. */
  95352. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95353. /**
  95354. * Updates the associated mesh
  95355. * @param mesh the mesh to be updated
  95356. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95357. * @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
  95358. * @returns VertexData
  95359. */
  95360. updateMesh(mesh: Mesh): VertexData;
  95361. /**
  95362. * Updates the associated geometry
  95363. * @param geometry the geometry to be updated
  95364. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95365. * @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
  95366. * @returns VertexData.
  95367. */
  95368. updateGeometry(geometry: Geometry): VertexData;
  95369. private _applyTo;
  95370. private _update;
  95371. /**
  95372. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95373. * @param matrix the transforming matrix
  95374. * @returns the VertexData
  95375. */
  95376. transform(matrix: Matrix): VertexData;
  95377. /**
  95378. * Merges the passed VertexData into the current one
  95379. * @param other the VertexData to be merged into the current one
  95380. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95381. * @returns the modified VertexData
  95382. */
  95383. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95384. private _mergeElement;
  95385. private _validate;
  95386. /**
  95387. * Serializes the VertexData
  95388. * @returns a serialized object
  95389. */
  95390. serialize(): any;
  95391. /**
  95392. * Extracts the vertexData from a mesh
  95393. * @param mesh the mesh from which to extract the VertexData
  95394. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95395. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95396. * @returns the object VertexData associated to the passed mesh
  95397. */
  95398. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95399. /**
  95400. * Extracts the vertexData from the geometry
  95401. * @param geometry the geometry from which to extract the VertexData
  95402. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95403. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95404. * @returns the object VertexData associated to the passed mesh
  95405. */
  95406. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95407. private static _ExtractFrom;
  95408. /**
  95409. * Creates the VertexData for a Ribbon
  95410. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95411. * * pathArray array of paths, each of which an array of successive Vector3
  95412. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95413. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95414. * * 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
  95415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95416. * * 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)
  95417. * * 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)
  95418. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95419. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95420. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95421. * @returns the VertexData of the ribbon
  95422. */
  95423. static CreateRibbon(options: {
  95424. pathArray: Vector3[][];
  95425. closeArray?: boolean;
  95426. closePath?: boolean;
  95427. offset?: number;
  95428. sideOrientation?: number;
  95429. frontUVs?: Vector4;
  95430. backUVs?: Vector4;
  95431. invertUV?: boolean;
  95432. uvs?: Vector2[];
  95433. colors?: Color4[];
  95434. }): VertexData;
  95435. /**
  95436. * Creates the VertexData for a box
  95437. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95438. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95439. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95440. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95441. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95442. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95443. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95445. * * 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)
  95446. * * 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)
  95447. * @returns the VertexData of the box
  95448. */
  95449. static CreateBox(options: {
  95450. size?: number;
  95451. width?: number;
  95452. height?: number;
  95453. depth?: number;
  95454. faceUV?: Vector4[];
  95455. faceColors?: Color4[];
  95456. sideOrientation?: number;
  95457. frontUVs?: Vector4;
  95458. backUVs?: Vector4;
  95459. }): VertexData;
  95460. /**
  95461. * Creates the VertexData for a tiled box
  95462. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95463. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95464. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95465. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95467. * @returns the VertexData of the box
  95468. */
  95469. static CreateTiledBox(options: {
  95470. pattern?: number;
  95471. width?: number;
  95472. height?: number;
  95473. depth?: number;
  95474. tileSize?: number;
  95475. tileWidth?: number;
  95476. tileHeight?: number;
  95477. alignHorizontal?: number;
  95478. alignVertical?: number;
  95479. faceUV?: Vector4[];
  95480. faceColors?: Color4[];
  95481. sideOrientation?: number;
  95482. }): VertexData;
  95483. /**
  95484. * Creates the VertexData for a tiled plane
  95485. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95486. * * pattern a limited pattern arrangement depending on the number
  95487. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95488. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95489. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95491. * * 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)
  95492. * * 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)
  95493. * @returns the VertexData of the tiled plane
  95494. */
  95495. static CreateTiledPlane(options: {
  95496. pattern?: number;
  95497. tileSize?: number;
  95498. tileWidth?: number;
  95499. tileHeight?: number;
  95500. size?: number;
  95501. width?: number;
  95502. height?: number;
  95503. alignHorizontal?: number;
  95504. alignVertical?: number;
  95505. sideOrientation?: number;
  95506. frontUVs?: Vector4;
  95507. backUVs?: Vector4;
  95508. }): VertexData;
  95509. /**
  95510. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95511. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95512. * * segments sets the number of horizontal strips optional, default 32
  95513. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95514. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95515. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95516. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95517. * * 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
  95518. * * 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
  95519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95520. * * 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)
  95521. * * 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)
  95522. * @returns the VertexData of the ellipsoid
  95523. */
  95524. static CreateSphere(options: {
  95525. segments?: number;
  95526. diameter?: number;
  95527. diameterX?: number;
  95528. diameterY?: number;
  95529. diameterZ?: number;
  95530. arc?: number;
  95531. slice?: number;
  95532. sideOrientation?: number;
  95533. frontUVs?: Vector4;
  95534. backUVs?: Vector4;
  95535. }): VertexData;
  95536. /**
  95537. * Creates the VertexData for a cylinder, cone or prism
  95538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95539. * * height sets the height (y direction) of the cylinder, optional, default 2
  95540. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95541. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95542. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95543. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95544. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95545. * * 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
  95546. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95548. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95549. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95551. * * 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)
  95552. * * 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)
  95553. * @returns the VertexData of the cylinder, cone or prism
  95554. */
  95555. static CreateCylinder(options: {
  95556. height?: number;
  95557. diameterTop?: number;
  95558. diameterBottom?: number;
  95559. diameter?: number;
  95560. tessellation?: number;
  95561. subdivisions?: number;
  95562. arc?: number;
  95563. faceColors?: Color4[];
  95564. faceUV?: Vector4[];
  95565. hasRings?: boolean;
  95566. enclose?: boolean;
  95567. sideOrientation?: number;
  95568. frontUVs?: Vector4;
  95569. backUVs?: Vector4;
  95570. }): VertexData;
  95571. /**
  95572. * Creates the VertexData for a torus
  95573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95574. * * diameter the diameter of the torus, optional default 1
  95575. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95576. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95578. * * 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)
  95579. * * 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)
  95580. * @returns the VertexData of the torus
  95581. */
  95582. static CreateTorus(options: {
  95583. diameter?: number;
  95584. thickness?: number;
  95585. tessellation?: number;
  95586. sideOrientation?: number;
  95587. frontUVs?: Vector4;
  95588. backUVs?: Vector4;
  95589. }): VertexData;
  95590. /**
  95591. * Creates the VertexData of the LineSystem
  95592. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95593. * - lines an array of lines, each line being an array of successive Vector3
  95594. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95595. * @returns the VertexData of the LineSystem
  95596. */
  95597. static CreateLineSystem(options: {
  95598. lines: Vector3[][];
  95599. colors?: Nullable<Color4[][]>;
  95600. }): VertexData;
  95601. /**
  95602. * Create the VertexData for a DashedLines
  95603. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95604. * - points an array successive Vector3
  95605. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95606. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95607. * - dashNb the intended total number of dashes, optional, default 200
  95608. * @returns the VertexData for the DashedLines
  95609. */
  95610. static CreateDashedLines(options: {
  95611. points: Vector3[];
  95612. dashSize?: number;
  95613. gapSize?: number;
  95614. dashNb?: number;
  95615. }): VertexData;
  95616. /**
  95617. * Creates the VertexData for a Ground
  95618. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95619. * - width the width (x direction) of the ground, optional, default 1
  95620. * - height the height (z direction) of the ground, optional, default 1
  95621. * - subdivisions the number of subdivisions per side, optional, default 1
  95622. * @returns the VertexData of the Ground
  95623. */
  95624. static CreateGround(options: {
  95625. width?: number;
  95626. height?: number;
  95627. subdivisions?: number;
  95628. subdivisionsX?: number;
  95629. subdivisionsY?: number;
  95630. }): VertexData;
  95631. /**
  95632. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95633. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95634. * * xmin the ground minimum X coordinate, optional, default -1
  95635. * * zmin the ground minimum Z coordinate, optional, default -1
  95636. * * xmax the ground maximum X coordinate, optional, default 1
  95637. * * zmax the ground maximum Z coordinate, optional, default 1
  95638. * * 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}
  95639. * * 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}
  95640. * @returns the VertexData of the TiledGround
  95641. */
  95642. static CreateTiledGround(options: {
  95643. xmin: number;
  95644. zmin: number;
  95645. xmax: number;
  95646. zmax: number;
  95647. subdivisions?: {
  95648. w: number;
  95649. h: number;
  95650. };
  95651. precision?: {
  95652. w: number;
  95653. h: number;
  95654. };
  95655. }): VertexData;
  95656. /**
  95657. * Creates the VertexData of the Ground designed from a heightmap
  95658. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95659. * * width the width (x direction) of the ground
  95660. * * height the height (z direction) of the ground
  95661. * * subdivisions the number of subdivisions per side
  95662. * * minHeight the minimum altitude on the ground, optional, default 0
  95663. * * maxHeight the maximum altitude on the ground, optional default 1
  95664. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95665. * * buffer the array holding the image color data
  95666. * * bufferWidth the width of image
  95667. * * bufferHeight the height of image
  95668. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95669. * @returns the VertexData of the Ground designed from a heightmap
  95670. */
  95671. static CreateGroundFromHeightMap(options: {
  95672. width: number;
  95673. height: number;
  95674. subdivisions: number;
  95675. minHeight: number;
  95676. maxHeight: number;
  95677. colorFilter: Color3;
  95678. buffer: Uint8Array;
  95679. bufferWidth: number;
  95680. bufferHeight: number;
  95681. alphaFilter: number;
  95682. }): VertexData;
  95683. /**
  95684. * Creates the VertexData for a Plane
  95685. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95686. * * size sets the width and height of the plane to the value of size, optional default 1
  95687. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95688. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95690. * * 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)
  95691. * * 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)
  95692. * @returns the VertexData of the box
  95693. */
  95694. static CreatePlane(options: {
  95695. size?: number;
  95696. width?: number;
  95697. height?: number;
  95698. sideOrientation?: number;
  95699. frontUVs?: Vector4;
  95700. backUVs?: Vector4;
  95701. }): VertexData;
  95702. /**
  95703. * Creates the VertexData of the Disc or regular Polygon
  95704. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95705. * * radius the radius of the disc, optional default 0.5
  95706. * * tessellation the number of polygon sides, optional, default 64
  95707. * * 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
  95708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95709. * * 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)
  95710. * * 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)
  95711. * @returns the VertexData of the box
  95712. */
  95713. static CreateDisc(options: {
  95714. radius?: number;
  95715. tessellation?: number;
  95716. arc?: number;
  95717. sideOrientation?: number;
  95718. frontUVs?: Vector4;
  95719. backUVs?: Vector4;
  95720. }): VertexData;
  95721. /**
  95722. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95723. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95724. * @param polygon a mesh built from polygonTriangulation.build()
  95725. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95726. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95727. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95728. * @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)
  95729. * @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)
  95730. * @returns the VertexData of the Polygon
  95731. */
  95732. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95733. /**
  95734. * Creates the VertexData of the IcoSphere
  95735. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95736. * * radius the radius of the IcoSphere, optional default 1
  95737. * * radiusX allows stretching in the x direction, optional, default radius
  95738. * * radiusY allows stretching in the y direction, optional, default radius
  95739. * * radiusZ allows stretching in the z direction, optional, default radius
  95740. * * flat when true creates a flat shaded mesh, optional, default true
  95741. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95743. * * 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)
  95744. * * 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)
  95745. * @returns the VertexData of the IcoSphere
  95746. */
  95747. static CreateIcoSphere(options: {
  95748. radius?: number;
  95749. radiusX?: number;
  95750. radiusY?: number;
  95751. radiusZ?: number;
  95752. flat?: boolean;
  95753. subdivisions?: number;
  95754. sideOrientation?: number;
  95755. frontUVs?: Vector4;
  95756. backUVs?: Vector4;
  95757. }): VertexData;
  95758. /**
  95759. * Creates the VertexData for a Polyhedron
  95760. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95761. * * type provided types are:
  95762. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95763. * * 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)
  95764. * * size the size of the IcoSphere, optional default 1
  95765. * * sizeX allows stretching in the x direction, optional, default size
  95766. * * sizeY allows stretching in the y direction, optional, default size
  95767. * * sizeZ allows stretching in the z direction, optional, default size
  95768. * * 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
  95769. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95770. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95771. * * flat when true creates a flat shaded mesh, optional, default true
  95772. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95773. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95774. * * 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)
  95775. * * 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)
  95776. * @returns the VertexData of the Polyhedron
  95777. */
  95778. static CreatePolyhedron(options: {
  95779. type?: number;
  95780. size?: number;
  95781. sizeX?: number;
  95782. sizeY?: number;
  95783. sizeZ?: number;
  95784. custom?: any;
  95785. faceUV?: Vector4[];
  95786. faceColors?: Color4[];
  95787. flat?: boolean;
  95788. sideOrientation?: number;
  95789. frontUVs?: Vector4;
  95790. backUVs?: Vector4;
  95791. }): VertexData;
  95792. /**
  95793. * Creates the VertexData for a TorusKnot
  95794. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95795. * * radius the radius of the torus knot, optional, default 2
  95796. * * tube the thickness of the tube, optional, default 0.5
  95797. * * radialSegments the number of sides on each tube segments, optional, default 32
  95798. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95799. * * p the number of windings around the z axis, optional, default 2
  95800. * * q the number of windings around the x axis, optional, default 3
  95801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95802. * * 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)
  95803. * * 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)
  95804. * @returns the VertexData of the Torus Knot
  95805. */
  95806. static CreateTorusKnot(options: {
  95807. radius?: number;
  95808. tube?: number;
  95809. radialSegments?: number;
  95810. tubularSegments?: number;
  95811. p?: number;
  95812. q?: number;
  95813. sideOrientation?: number;
  95814. frontUVs?: Vector4;
  95815. backUVs?: Vector4;
  95816. }): VertexData;
  95817. /**
  95818. * Compute normals for given positions and indices
  95819. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95820. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95821. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95822. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95823. * * facetNormals : optional array of facet normals (vector3)
  95824. * * facetPositions : optional array of facet positions (vector3)
  95825. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95826. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95827. * * bInfo : optional bounding info, required for facetPartitioning computation
  95828. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95829. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95830. * * useRightHandedSystem: optional boolean to for right handed system computation
  95831. * * depthSort : optional boolean to enable the facet depth sort computation
  95832. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95833. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95834. */
  95835. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95836. facetNormals?: any;
  95837. facetPositions?: any;
  95838. facetPartitioning?: any;
  95839. ratio?: number;
  95840. bInfo?: any;
  95841. bbSize?: Vector3;
  95842. subDiv?: any;
  95843. useRightHandedSystem?: boolean;
  95844. depthSort?: boolean;
  95845. distanceTo?: Vector3;
  95846. depthSortedFacets?: any;
  95847. }): void;
  95848. /** @hidden */
  95849. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95850. /**
  95851. * Applies VertexData created from the imported parameters to the geometry
  95852. * @param parsedVertexData the parsed data from an imported file
  95853. * @param geometry the geometry to apply the VertexData to
  95854. */
  95855. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95856. }
  95857. }
  95858. declare module BABYLON {
  95859. /**
  95860. * Defines a target to use with MorphTargetManager
  95861. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95862. */
  95863. export class MorphTarget implements IAnimatable {
  95864. /** defines the name of the target */
  95865. name: string;
  95866. /**
  95867. * Gets or sets the list of animations
  95868. */
  95869. animations: Animation[];
  95870. private _scene;
  95871. private _positions;
  95872. private _normals;
  95873. private _tangents;
  95874. private _uvs;
  95875. private _influence;
  95876. private _uniqueId;
  95877. /**
  95878. * Observable raised when the influence changes
  95879. */
  95880. onInfluenceChanged: Observable<boolean>;
  95881. /** @hidden */
  95882. _onDataLayoutChanged: Observable<void>;
  95883. /**
  95884. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95885. */
  95886. get influence(): number;
  95887. set influence(influence: number);
  95888. /**
  95889. * Gets or sets the id of the morph Target
  95890. */
  95891. id: string;
  95892. private _animationPropertiesOverride;
  95893. /**
  95894. * Gets or sets the animation properties override
  95895. */
  95896. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95897. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95898. /**
  95899. * Creates a new MorphTarget
  95900. * @param name defines the name of the target
  95901. * @param influence defines the influence to use
  95902. * @param scene defines the scene the morphtarget belongs to
  95903. */
  95904. constructor(
  95905. /** defines the name of the target */
  95906. name: string, influence?: number, scene?: Nullable<Scene>);
  95907. /**
  95908. * Gets the unique ID of this manager
  95909. */
  95910. get uniqueId(): number;
  95911. /**
  95912. * Gets a boolean defining if the target contains position data
  95913. */
  95914. get hasPositions(): boolean;
  95915. /**
  95916. * Gets a boolean defining if the target contains normal data
  95917. */
  95918. get hasNormals(): boolean;
  95919. /**
  95920. * Gets a boolean defining if the target contains tangent data
  95921. */
  95922. get hasTangents(): boolean;
  95923. /**
  95924. * Gets a boolean defining if the target contains texture coordinates data
  95925. */
  95926. get hasUVs(): boolean;
  95927. /**
  95928. * Affects position data to this target
  95929. * @param data defines the position data to use
  95930. */
  95931. setPositions(data: Nullable<FloatArray>): void;
  95932. /**
  95933. * Gets the position data stored in this target
  95934. * @returns a FloatArray containing the position data (or null if not present)
  95935. */
  95936. getPositions(): Nullable<FloatArray>;
  95937. /**
  95938. * Affects normal data to this target
  95939. * @param data defines the normal data to use
  95940. */
  95941. setNormals(data: Nullable<FloatArray>): void;
  95942. /**
  95943. * Gets the normal data stored in this target
  95944. * @returns a FloatArray containing the normal data (or null if not present)
  95945. */
  95946. getNormals(): Nullable<FloatArray>;
  95947. /**
  95948. * Affects tangent data to this target
  95949. * @param data defines the tangent data to use
  95950. */
  95951. setTangents(data: Nullable<FloatArray>): void;
  95952. /**
  95953. * Gets the tangent data stored in this target
  95954. * @returns a FloatArray containing the tangent data (or null if not present)
  95955. */
  95956. getTangents(): Nullable<FloatArray>;
  95957. /**
  95958. * Affects texture coordinates data to this target
  95959. * @param data defines the texture coordinates data to use
  95960. */
  95961. setUVs(data: Nullable<FloatArray>): void;
  95962. /**
  95963. * Gets the texture coordinates data stored in this target
  95964. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95965. */
  95966. getUVs(): Nullable<FloatArray>;
  95967. /**
  95968. * Clone the current target
  95969. * @returns a new MorphTarget
  95970. */
  95971. clone(): MorphTarget;
  95972. /**
  95973. * Serializes the current target into a Serialization object
  95974. * @returns the serialized object
  95975. */
  95976. serialize(): any;
  95977. /**
  95978. * Returns the string "MorphTarget"
  95979. * @returns "MorphTarget"
  95980. */
  95981. getClassName(): string;
  95982. /**
  95983. * Creates a new target from serialized data
  95984. * @param serializationObject defines the serialized data to use
  95985. * @returns a new MorphTarget
  95986. */
  95987. static Parse(serializationObject: any): MorphTarget;
  95988. /**
  95989. * Creates a MorphTarget from mesh data
  95990. * @param mesh defines the source mesh
  95991. * @param name defines the name to use for the new target
  95992. * @param influence defines the influence to attach to the target
  95993. * @returns a new MorphTarget
  95994. */
  95995. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95996. }
  95997. }
  95998. declare module BABYLON {
  95999. /**
  96000. * This class is used to deform meshes using morphing between different targets
  96001. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96002. */
  96003. export class MorphTargetManager {
  96004. private _targets;
  96005. private _targetInfluenceChangedObservers;
  96006. private _targetDataLayoutChangedObservers;
  96007. private _activeTargets;
  96008. private _scene;
  96009. private _influences;
  96010. private _supportsNormals;
  96011. private _supportsTangents;
  96012. private _supportsUVs;
  96013. private _vertexCount;
  96014. private _uniqueId;
  96015. private _tempInfluences;
  96016. /**
  96017. * Gets or sets a boolean indicating if normals must be morphed
  96018. */
  96019. enableNormalMorphing: boolean;
  96020. /**
  96021. * Gets or sets a boolean indicating if tangents must be morphed
  96022. */
  96023. enableTangentMorphing: boolean;
  96024. /**
  96025. * Gets or sets a boolean indicating if UV must be morphed
  96026. */
  96027. enableUVMorphing: boolean;
  96028. /**
  96029. * Creates a new MorphTargetManager
  96030. * @param scene defines the current scene
  96031. */
  96032. constructor(scene?: Nullable<Scene>);
  96033. /**
  96034. * Gets the unique ID of this manager
  96035. */
  96036. get uniqueId(): number;
  96037. /**
  96038. * Gets the number of vertices handled by this manager
  96039. */
  96040. get vertexCount(): number;
  96041. /**
  96042. * Gets a boolean indicating if this manager supports morphing of normals
  96043. */
  96044. get supportsNormals(): boolean;
  96045. /**
  96046. * Gets a boolean indicating if this manager supports morphing of tangents
  96047. */
  96048. get supportsTangents(): boolean;
  96049. /**
  96050. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96051. */
  96052. get supportsUVs(): boolean;
  96053. /**
  96054. * Gets the number of targets stored in this manager
  96055. */
  96056. get numTargets(): number;
  96057. /**
  96058. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96059. */
  96060. get numInfluencers(): number;
  96061. /**
  96062. * Gets the list of influences (one per target)
  96063. */
  96064. get influences(): Float32Array;
  96065. /**
  96066. * Gets the active target at specified index. An active target is a target with an influence > 0
  96067. * @param index defines the index to check
  96068. * @returns the requested target
  96069. */
  96070. getActiveTarget(index: number): MorphTarget;
  96071. /**
  96072. * Gets the target at specified index
  96073. * @param index defines the index to check
  96074. * @returns the requested target
  96075. */
  96076. getTarget(index: number): MorphTarget;
  96077. /**
  96078. * Add a new target to this manager
  96079. * @param target defines the target to add
  96080. */
  96081. addTarget(target: MorphTarget): void;
  96082. /**
  96083. * Removes a target from the manager
  96084. * @param target defines the target to remove
  96085. */
  96086. removeTarget(target: MorphTarget): void;
  96087. /**
  96088. * Clone the current manager
  96089. * @returns a new MorphTargetManager
  96090. */
  96091. clone(): MorphTargetManager;
  96092. /**
  96093. * Serializes the current manager into a Serialization object
  96094. * @returns the serialized object
  96095. */
  96096. serialize(): any;
  96097. private _syncActiveTargets;
  96098. /**
  96099. * Syncrhonize the targets with all the meshes using this morph target manager
  96100. */
  96101. synchronize(): void;
  96102. /**
  96103. * Creates a new MorphTargetManager from serialized data
  96104. * @param serializationObject defines the serialized data
  96105. * @param scene defines the hosting scene
  96106. * @returns the new MorphTargetManager
  96107. */
  96108. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96109. }
  96110. }
  96111. declare module BABYLON {
  96112. /**
  96113. * Class used to represent a specific level of detail of a mesh
  96114. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96115. */
  96116. export class MeshLODLevel {
  96117. /** Defines the distance where this level should start being displayed */
  96118. distance: number;
  96119. /** Defines the mesh to use to render this level */
  96120. mesh: Nullable<Mesh>;
  96121. /**
  96122. * Creates a new LOD level
  96123. * @param distance defines the distance where this level should star being displayed
  96124. * @param mesh defines the mesh to use to render this level
  96125. */
  96126. constructor(
  96127. /** Defines the distance where this level should start being displayed */
  96128. distance: number,
  96129. /** Defines the mesh to use to render this level */
  96130. mesh: Nullable<Mesh>);
  96131. }
  96132. }
  96133. declare module BABYLON {
  96134. /**
  96135. * Mesh representing the gorund
  96136. */
  96137. export class GroundMesh extends Mesh {
  96138. /** If octree should be generated */
  96139. generateOctree: boolean;
  96140. private _heightQuads;
  96141. /** @hidden */
  96142. _subdivisionsX: number;
  96143. /** @hidden */
  96144. _subdivisionsY: number;
  96145. /** @hidden */
  96146. _width: number;
  96147. /** @hidden */
  96148. _height: number;
  96149. /** @hidden */
  96150. _minX: number;
  96151. /** @hidden */
  96152. _maxX: number;
  96153. /** @hidden */
  96154. _minZ: number;
  96155. /** @hidden */
  96156. _maxZ: number;
  96157. constructor(name: string, scene: Scene);
  96158. /**
  96159. * "GroundMesh"
  96160. * @returns "GroundMesh"
  96161. */
  96162. getClassName(): string;
  96163. /**
  96164. * The minimum of x and y subdivisions
  96165. */
  96166. get subdivisions(): number;
  96167. /**
  96168. * X subdivisions
  96169. */
  96170. get subdivisionsX(): number;
  96171. /**
  96172. * Y subdivisions
  96173. */
  96174. get subdivisionsY(): number;
  96175. /**
  96176. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96177. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96178. * @param chunksCount the number of subdivisions for x and y
  96179. * @param octreeBlocksSize (Default: 32)
  96180. */
  96181. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96182. /**
  96183. * Returns a height (y) value in the Worl system :
  96184. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96185. * @param x x coordinate
  96186. * @param z z coordinate
  96187. * @returns the ground y position if (x, z) are outside the ground surface.
  96188. */
  96189. getHeightAtCoordinates(x: number, z: number): number;
  96190. /**
  96191. * Returns a normalized vector (Vector3) orthogonal to the ground
  96192. * at the ground coordinates (x, z) expressed in the World system.
  96193. * @param x x coordinate
  96194. * @param z z coordinate
  96195. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96196. */
  96197. getNormalAtCoordinates(x: number, z: number): Vector3;
  96198. /**
  96199. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96200. * at the ground coordinates (x, z) expressed in the World system.
  96201. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96202. * @param x x coordinate
  96203. * @param z z coordinate
  96204. * @param ref vector to store the result
  96205. * @returns the GroundMesh.
  96206. */
  96207. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96208. /**
  96209. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96210. * if the ground has been updated.
  96211. * This can be used in the render loop.
  96212. * @returns the GroundMesh.
  96213. */
  96214. updateCoordinateHeights(): GroundMesh;
  96215. private _getFacetAt;
  96216. private _initHeightQuads;
  96217. private _computeHeightQuads;
  96218. /**
  96219. * Serializes this ground mesh
  96220. * @param serializationObject object to write serialization to
  96221. */
  96222. serialize(serializationObject: any): void;
  96223. /**
  96224. * Parses a serialized ground mesh
  96225. * @param parsedMesh the serialized mesh
  96226. * @param scene the scene to create the ground mesh in
  96227. * @returns the created ground mesh
  96228. */
  96229. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96230. }
  96231. }
  96232. declare module BABYLON {
  96233. /**
  96234. * Interface for Physics-Joint data
  96235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96236. */
  96237. export interface PhysicsJointData {
  96238. /**
  96239. * The main pivot of the joint
  96240. */
  96241. mainPivot?: Vector3;
  96242. /**
  96243. * The connected pivot of the joint
  96244. */
  96245. connectedPivot?: Vector3;
  96246. /**
  96247. * The main axis of the joint
  96248. */
  96249. mainAxis?: Vector3;
  96250. /**
  96251. * The connected axis of the joint
  96252. */
  96253. connectedAxis?: Vector3;
  96254. /**
  96255. * The collision of the joint
  96256. */
  96257. collision?: boolean;
  96258. /**
  96259. * Native Oimo/Cannon/Energy data
  96260. */
  96261. nativeParams?: any;
  96262. }
  96263. /**
  96264. * This is a holder class for the physics joint created by the physics plugin
  96265. * It holds a set of functions to control the underlying joint
  96266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96267. */
  96268. export class PhysicsJoint {
  96269. /**
  96270. * The type of the physics joint
  96271. */
  96272. type: number;
  96273. /**
  96274. * The data for the physics joint
  96275. */
  96276. jointData: PhysicsJointData;
  96277. private _physicsJoint;
  96278. protected _physicsPlugin: IPhysicsEnginePlugin;
  96279. /**
  96280. * Initializes the physics joint
  96281. * @param type The type of the physics joint
  96282. * @param jointData The data for the physics joint
  96283. */
  96284. constructor(
  96285. /**
  96286. * The type of the physics joint
  96287. */
  96288. type: number,
  96289. /**
  96290. * The data for the physics joint
  96291. */
  96292. jointData: PhysicsJointData);
  96293. /**
  96294. * Gets the physics joint
  96295. */
  96296. get physicsJoint(): any;
  96297. /**
  96298. * Sets the physics joint
  96299. */
  96300. set physicsJoint(newJoint: any);
  96301. /**
  96302. * Sets the physics plugin
  96303. */
  96304. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96305. /**
  96306. * Execute a function that is physics-plugin specific.
  96307. * @param {Function} func the function that will be executed.
  96308. * It accepts two parameters: the physics world and the physics joint
  96309. */
  96310. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96311. /**
  96312. * Distance-Joint type
  96313. */
  96314. static DistanceJoint: number;
  96315. /**
  96316. * Hinge-Joint type
  96317. */
  96318. static HingeJoint: number;
  96319. /**
  96320. * Ball-and-Socket joint type
  96321. */
  96322. static BallAndSocketJoint: number;
  96323. /**
  96324. * Wheel-Joint type
  96325. */
  96326. static WheelJoint: number;
  96327. /**
  96328. * Slider-Joint type
  96329. */
  96330. static SliderJoint: number;
  96331. /**
  96332. * Prismatic-Joint type
  96333. */
  96334. static PrismaticJoint: number;
  96335. /**
  96336. * Universal-Joint type
  96337. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96338. */
  96339. static UniversalJoint: number;
  96340. /**
  96341. * Hinge-Joint 2 type
  96342. */
  96343. static Hinge2Joint: number;
  96344. /**
  96345. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96346. */
  96347. static PointToPointJoint: number;
  96348. /**
  96349. * Spring-Joint type
  96350. */
  96351. static SpringJoint: number;
  96352. /**
  96353. * Lock-Joint type
  96354. */
  96355. static LockJoint: number;
  96356. }
  96357. /**
  96358. * A class representing a physics distance joint
  96359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96360. */
  96361. export class DistanceJoint extends PhysicsJoint {
  96362. /**
  96363. *
  96364. * @param jointData The data for the Distance-Joint
  96365. */
  96366. constructor(jointData: DistanceJointData);
  96367. /**
  96368. * Update the predefined distance.
  96369. * @param maxDistance The maximum preferred distance
  96370. * @param minDistance The minimum preferred distance
  96371. */
  96372. updateDistance(maxDistance: number, minDistance?: number): void;
  96373. }
  96374. /**
  96375. * Represents a Motor-Enabled Joint
  96376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96377. */
  96378. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96379. /**
  96380. * Initializes the Motor-Enabled Joint
  96381. * @param type The type of the joint
  96382. * @param jointData The physica joint data for the joint
  96383. */
  96384. constructor(type: number, jointData: PhysicsJointData);
  96385. /**
  96386. * Set the motor values.
  96387. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96388. * @param force the force to apply
  96389. * @param maxForce max force for this motor.
  96390. */
  96391. setMotor(force?: number, maxForce?: number): void;
  96392. /**
  96393. * Set the motor's limits.
  96394. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96395. * @param upperLimit The upper limit of the motor
  96396. * @param lowerLimit The lower limit of the motor
  96397. */
  96398. setLimit(upperLimit: number, lowerLimit?: number): void;
  96399. }
  96400. /**
  96401. * This class represents a single physics Hinge-Joint
  96402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96403. */
  96404. export class HingeJoint extends MotorEnabledJoint {
  96405. /**
  96406. * Initializes the Hinge-Joint
  96407. * @param jointData The joint data for the Hinge-Joint
  96408. */
  96409. constructor(jointData: PhysicsJointData);
  96410. /**
  96411. * Set the motor values.
  96412. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96413. * @param {number} force the force to apply
  96414. * @param {number} maxForce max force for this motor.
  96415. */
  96416. setMotor(force?: number, maxForce?: number): void;
  96417. /**
  96418. * Set the motor's limits.
  96419. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96420. * @param upperLimit The upper limit of the motor
  96421. * @param lowerLimit The lower limit of the motor
  96422. */
  96423. setLimit(upperLimit: number, lowerLimit?: number): void;
  96424. }
  96425. /**
  96426. * This class represents a dual hinge physics joint (same as wheel joint)
  96427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96428. */
  96429. export class Hinge2Joint extends MotorEnabledJoint {
  96430. /**
  96431. * Initializes the Hinge2-Joint
  96432. * @param jointData The joint data for the Hinge2-Joint
  96433. */
  96434. constructor(jointData: PhysicsJointData);
  96435. /**
  96436. * Set the motor values.
  96437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96438. * @param {number} targetSpeed the speed the motor is to reach
  96439. * @param {number} maxForce max force for this motor.
  96440. * @param {motorIndex} the motor's index, 0 or 1.
  96441. */
  96442. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96443. /**
  96444. * Set the motor limits.
  96445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96446. * @param {number} upperLimit the upper limit
  96447. * @param {number} lowerLimit lower limit
  96448. * @param {motorIndex} the motor's index, 0 or 1.
  96449. */
  96450. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96451. }
  96452. /**
  96453. * Interface for a motor enabled joint
  96454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96455. */
  96456. export interface IMotorEnabledJoint {
  96457. /**
  96458. * Physics joint
  96459. */
  96460. physicsJoint: any;
  96461. /**
  96462. * Sets the motor of the motor-enabled joint
  96463. * @param force The force of the motor
  96464. * @param maxForce The maximum force of the motor
  96465. * @param motorIndex The index of the motor
  96466. */
  96467. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96468. /**
  96469. * Sets the limit of the motor
  96470. * @param upperLimit The upper limit of the motor
  96471. * @param lowerLimit The lower limit of the motor
  96472. * @param motorIndex The index of the motor
  96473. */
  96474. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96475. }
  96476. /**
  96477. * Joint data for a Distance-Joint
  96478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96479. */
  96480. export interface DistanceJointData extends PhysicsJointData {
  96481. /**
  96482. * Max distance the 2 joint objects can be apart
  96483. */
  96484. maxDistance: number;
  96485. }
  96486. /**
  96487. * Joint data from a spring joint
  96488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96489. */
  96490. export interface SpringJointData extends PhysicsJointData {
  96491. /**
  96492. * Length of the spring
  96493. */
  96494. length: number;
  96495. /**
  96496. * Stiffness of the spring
  96497. */
  96498. stiffness: number;
  96499. /**
  96500. * Damping of the spring
  96501. */
  96502. damping: number;
  96503. /** this callback will be called when applying the force to the impostors. */
  96504. forceApplicationCallback: () => void;
  96505. }
  96506. }
  96507. declare module BABYLON {
  96508. /**
  96509. * Holds the data for the raycast result
  96510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96511. */
  96512. export class PhysicsRaycastResult {
  96513. private _hasHit;
  96514. private _hitDistance;
  96515. private _hitNormalWorld;
  96516. private _hitPointWorld;
  96517. private _rayFromWorld;
  96518. private _rayToWorld;
  96519. /**
  96520. * Gets if there was a hit
  96521. */
  96522. get hasHit(): boolean;
  96523. /**
  96524. * Gets the distance from the hit
  96525. */
  96526. get hitDistance(): number;
  96527. /**
  96528. * Gets the hit normal/direction in the world
  96529. */
  96530. get hitNormalWorld(): Vector3;
  96531. /**
  96532. * Gets the hit point in the world
  96533. */
  96534. get hitPointWorld(): Vector3;
  96535. /**
  96536. * Gets the ray "start point" of the ray in the world
  96537. */
  96538. get rayFromWorld(): Vector3;
  96539. /**
  96540. * Gets the ray "end point" of the ray in the world
  96541. */
  96542. get rayToWorld(): Vector3;
  96543. /**
  96544. * Sets the hit data (normal & point in world space)
  96545. * @param hitNormalWorld defines the normal in world space
  96546. * @param hitPointWorld defines the point in world space
  96547. */
  96548. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96549. /**
  96550. * Sets the distance from the start point to the hit point
  96551. * @param distance
  96552. */
  96553. setHitDistance(distance: number): void;
  96554. /**
  96555. * Calculates the distance manually
  96556. */
  96557. calculateHitDistance(): void;
  96558. /**
  96559. * Resets all the values to default
  96560. * @param from The from point on world space
  96561. * @param to The to point on world space
  96562. */
  96563. reset(from?: Vector3, to?: Vector3): void;
  96564. }
  96565. /**
  96566. * Interface for the size containing width and height
  96567. */
  96568. interface IXYZ {
  96569. /**
  96570. * X
  96571. */
  96572. x: number;
  96573. /**
  96574. * Y
  96575. */
  96576. y: number;
  96577. /**
  96578. * Z
  96579. */
  96580. z: number;
  96581. }
  96582. }
  96583. declare module BABYLON {
  96584. /**
  96585. * Interface used to describe a physics joint
  96586. */
  96587. export interface PhysicsImpostorJoint {
  96588. /** Defines the main impostor to which the joint is linked */
  96589. mainImpostor: PhysicsImpostor;
  96590. /** Defines the impostor that is connected to the main impostor using this joint */
  96591. connectedImpostor: PhysicsImpostor;
  96592. /** Defines the joint itself */
  96593. joint: PhysicsJoint;
  96594. }
  96595. /** @hidden */
  96596. export interface IPhysicsEnginePlugin {
  96597. world: any;
  96598. name: string;
  96599. setGravity(gravity: Vector3): void;
  96600. setTimeStep(timeStep: number): void;
  96601. getTimeStep(): number;
  96602. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96603. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96604. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96605. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96606. removePhysicsBody(impostor: PhysicsImpostor): void;
  96607. generateJoint(joint: PhysicsImpostorJoint): void;
  96608. removeJoint(joint: PhysicsImpostorJoint): void;
  96609. isSupported(): boolean;
  96610. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96611. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96612. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96613. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96614. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96615. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96616. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96617. getBodyMass(impostor: PhysicsImpostor): number;
  96618. getBodyFriction(impostor: PhysicsImpostor): number;
  96619. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96620. getBodyRestitution(impostor: PhysicsImpostor): number;
  96621. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96622. getBodyPressure?(impostor: PhysicsImpostor): number;
  96623. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96624. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96625. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96626. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96627. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96628. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96629. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96630. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96631. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96632. sleepBody(impostor: PhysicsImpostor): void;
  96633. wakeUpBody(impostor: PhysicsImpostor): void;
  96634. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96635. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96636. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96637. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96638. getRadius(impostor: PhysicsImpostor): number;
  96639. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96640. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96641. dispose(): void;
  96642. }
  96643. /**
  96644. * Interface used to define a physics engine
  96645. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96646. */
  96647. export interface IPhysicsEngine {
  96648. /**
  96649. * Gets the gravity vector used by the simulation
  96650. */
  96651. gravity: Vector3;
  96652. /**
  96653. * Sets the gravity vector used by the simulation
  96654. * @param gravity defines the gravity vector to use
  96655. */
  96656. setGravity(gravity: Vector3): void;
  96657. /**
  96658. * Set the time step of the physics engine.
  96659. * Default is 1/60.
  96660. * To slow it down, enter 1/600 for example.
  96661. * To speed it up, 1/30
  96662. * @param newTimeStep the new timestep to apply to this world.
  96663. */
  96664. setTimeStep(newTimeStep: number): void;
  96665. /**
  96666. * Get the time step of the physics engine.
  96667. * @returns the current time step
  96668. */
  96669. getTimeStep(): number;
  96670. /**
  96671. * Set the sub time step of the physics engine.
  96672. * Default is 0 meaning there is no sub steps
  96673. * To increase physics resolution precision, set a small value (like 1 ms)
  96674. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96675. */
  96676. setSubTimeStep(subTimeStep: number): void;
  96677. /**
  96678. * Get the sub time step of the physics engine.
  96679. * @returns the current sub time step
  96680. */
  96681. getSubTimeStep(): number;
  96682. /**
  96683. * Release all resources
  96684. */
  96685. dispose(): void;
  96686. /**
  96687. * Gets the name of the current physics plugin
  96688. * @returns the name of the plugin
  96689. */
  96690. getPhysicsPluginName(): string;
  96691. /**
  96692. * Adding a new impostor for the impostor tracking.
  96693. * This will be done by the impostor itself.
  96694. * @param impostor the impostor to add
  96695. */
  96696. addImpostor(impostor: PhysicsImpostor): void;
  96697. /**
  96698. * Remove an impostor from the engine.
  96699. * This impostor and its mesh will not longer be updated by the physics engine.
  96700. * @param impostor the impostor to remove
  96701. */
  96702. removeImpostor(impostor: PhysicsImpostor): void;
  96703. /**
  96704. * Add a joint to the physics engine
  96705. * @param mainImpostor defines the main impostor to which the joint is added.
  96706. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96707. * @param joint defines the joint that will connect both impostors.
  96708. */
  96709. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96710. /**
  96711. * Removes a joint from the simulation
  96712. * @param mainImpostor defines the impostor used with the joint
  96713. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96714. * @param joint defines the joint to remove
  96715. */
  96716. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96717. /**
  96718. * Gets the current plugin used to run the simulation
  96719. * @returns current plugin
  96720. */
  96721. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96722. /**
  96723. * Gets the list of physic impostors
  96724. * @returns an array of PhysicsImpostor
  96725. */
  96726. getImpostors(): Array<PhysicsImpostor>;
  96727. /**
  96728. * Gets the impostor for a physics enabled object
  96729. * @param object defines the object impersonated by the impostor
  96730. * @returns the PhysicsImpostor or null if not found
  96731. */
  96732. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96733. /**
  96734. * Gets the impostor for a physics body object
  96735. * @param body defines physics body used by the impostor
  96736. * @returns the PhysicsImpostor or null if not found
  96737. */
  96738. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96739. /**
  96740. * Does a raycast in the physics world
  96741. * @param from when should the ray start?
  96742. * @param to when should the ray end?
  96743. * @returns PhysicsRaycastResult
  96744. */
  96745. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96746. /**
  96747. * Called by the scene. No need to call it.
  96748. * @param delta defines the timespam between frames
  96749. */
  96750. _step(delta: number): void;
  96751. }
  96752. }
  96753. declare module BABYLON {
  96754. /**
  96755. * The interface for the physics imposter parameters
  96756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96757. */
  96758. export interface PhysicsImpostorParameters {
  96759. /**
  96760. * The mass of the physics imposter
  96761. */
  96762. mass: number;
  96763. /**
  96764. * The friction of the physics imposter
  96765. */
  96766. friction?: number;
  96767. /**
  96768. * The coefficient of restitution of the physics imposter
  96769. */
  96770. restitution?: number;
  96771. /**
  96772. * The native options of the physics imposter
  96773. */
  96774. nativeOptions?: any;
  96775. /**
  96776. * Specifies if the parent should be ignored
  96777. */
  96778. ignoreParent?: boolean;
  96779. /**
  96780. * Specifies if bi-directional transformations should be disabled
  96781. */
  96782. disableBidirectionalTransformation?: boolean;
  96783. /**
  96784. * The pressure inside the physics imposter, soft object only
  96785. */
  96786. pressure?: number;
  96787. /**
  96788. * The stiffness the physics imposter, soft object only
  96789. */
  96790. stiffness?: number;
  96791. /**
  96792. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96793. */
  96794. velocityIterations?: number;
  96795. /**
  96796. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96797. */
  96798. positionIterations?: number;
  96799. /**
  96800. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96801. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96802. * Add to fix multiple points
  96803. */
  96804. fixedPoints?: number;
  96805. /**
  96806. * The collision margin around a soft object
  96807. */
  96808. margin?: number;
  96809. /**
  96810. * The collision margin around a soft object
  96811. */
  96812. damping?: number;
  96813. /**
  96814. * The path for a rope based on an extrusion
  96815. */
  96816. path?: any;
  96817. /**
  96818. * The shape of an extrusion used for a rope based on an extrusion
  96819. */
  96820. shape?: any;
  96821. }
  96822. /**
  96823. * Interface for a physics-enabled object
  96824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96825. */
  96826. export interface IPhysicsEnabledObject {
  96827. /**
  96828. * The position of the physics-enabled object
  96829. */
  96830. position: Vector3;
  96831. /**
  96832. * The rotation of the physics-enabled object
  96833. */
  96834. rotationQuaternion: Nullable<Quaternion>;
  96835. /**
  96836. * The scale of the physics-enabled object
  96837. */
  96838. scaling: Vector3;
  96839. /**
  96840. * The rotation of the physics-enabled object
  96841. */
  96842. rotation?: Vector3;
  96843. /**
  96844. * The parent of the physics-enabled object
  96845. */
  96846. parent?: any;
  96847. /**
  96848. * The bounding info of the physics-enabled object
  96849. * @returns The bounding info of the physics-enabled object
  96850. */
  96851. getBoundingInfo(): BoundingInfo;
  96852. /**
  96853. * Computes the world matrix
  96854. * @param force Specifies if the world matrix should be computed by force
  96855. * @returns A world matrix
  96856. */
  96857. computeWorldMatrix(force: boolean): Matrix;
  96858. /**
  96859. * Gets the world matrix
  96860. * @returns A world matrix
  96861. */
  96862. getWorldMatrix?(): Matrix;
  96863. /**
  96864. * Gets the child meshes
  96865. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96866. * @returns An array of abstract meshes
  96867. */
  96868. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96869. /**
  96870. * Gets the vertex data
  96871. * @param kind The type of vertex data
  96872. * @returns A nullable array of numbers, or a float32 array
  96873. */
  96874. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96875. /**
  96876. * Gets the indices from the mesh
  96877. * @returns A nullable array of index arrays
  96878. */
  96879. getIndices?(): Nullable<IndicesArray>;
  96880. /**
  96881. * Gets the scene from the mesh
  96882. * @returns the indices array or null
  96883. */
  96884. getScene?(): Scene;
  96885. /**
  96886. * Gets the absolute position from the mesh
  96887. * @returns the absolute position
  96888. */
  96889. getAbsolutePosition(): Vector3;
  96890. /**
  96891. * Gets the absolute pivot point from the mesh
  96892. * @returns the absolute pivot point
  96893. */
  96894. getAbsolutePivotPoint(): Vector3;
  96895. /**
  96896. * Rotates the mesh
  96897. * @param axis The axis of rotation
  96898. * @param amount The amount of rotation
  96899. * @param space The space of the rotation
  96900. * @returns The rotation transform node
  96901. */
  96902. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96903. /**
  96904. * Translates the mesh
  96905. * @param axis The axis of translation
  96906. * @param distance The distance of translation
  96907. * @param space The space of the translation
  96908. * @returns The transform node
  96909. */
  96910. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96911. /**
  96912. * Sets the absolute position of the mesh
  96913. * @param absolutePosition The absolute position of the mesh
  96914. * @returns The transform node
  96915. */
  96916. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96917. /**
  96918. * Gets the class name of the mesh
  96919. * @returns The class name
  96920. */
  96921. getClassName(): string;
  96922. }
  96923. /**
  96924. * Represents a physics imposter
  96925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96926. */
  96927. export class PhysicsImpostor {
  96928. /**
  96929. * The physics-enabled object used as the physics imposter
  96930. */
  96931. object: IPhysicsEnabledObject;
  96932. /**
  96933. * The type of the physics imposter
  96934. */
  96935. type: number;
  96936. private _options;
  96937. private _scene?;
  96938. /**
  96939. * The default object size of the imposter
  96940. */
  96941. static DEFAULT_OBJECT_SIZE: Vector3;
  96942. /**
  96943. * The identity quaternion of the imposter
  96944. */
  96945. static IDENTITY_QUATERNION: Quaternion;
  96946. /** @hidden */
  96947. _pluginData: any;
  96948. private _physicsEngine;
  96949. private _physicsBody;
  96950. private _bodyUpdateRequired;
  96951. private _onBeforePhysicsStepCallbacks;
  96952. private _onAfterPhysicsStepCallbacks;
  96953. /** @hidden */
  96954. _onPhysicsCollideCallbacks: Array<{
  96955. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96956. otherImpostors: Array<PhysicsImpostor>;
  96957. }>;
  96958. private _deltaPosition;
  96959. private _deltaRotation;
  96960. private _deltaRotationConjugated;
  96961. /** @hidden */
  96962. _isFromLine: boolean;
  96963. private _parent;
  96964. private _isDisposed;
  96965. private static _tmpVecs;
  96966. private static _tmpQuat;
  96967. /**
  96968. * Specifies if the physics imposter is disposed
  96969. */
  96970. get isDisposed(): boolean;
  96971. /**
  96972. * Gets the mass of the physics imposter
  96973. */
  96974. get mass(): number;
  96975. set mass(value: number);
  96976. /**
  96977. * Gets the coefficient of friction
  96978. */
  96979. get friction(): number;
  96980. /**
  96981. * Sets the coefficient of friction
  96982. */
  96983. set friction(value: number);
  96984. /**
  96985. * Gets the coefficient of restitution
  96986. */
  96987. get restitution(): number;
  96988. /**
  96989. * Sets the coefficient of restitution
  96990. */
  96991. set restitution(value: number);
  96992. /**
  96993. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96994. */
  96995. get pressure(): number;
  96996. /**
  96997. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96998. */
  96999. set pressure(value: number);
  97000. /**
  97001. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97002. */
  97003. get stiffness(): number;
  97004. /**
  97005. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97006. */
  97007. set stiffness(value: number);
  97008. /**
  97009. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97010. */
  97011. get velocityIterations(): number;
  97012. /**
  97013. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97014. */
  97015. set velocityIterations(value: number);
  97016. /**
  97017. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97018. */
  97019. get positionIterations(): number;
  97020. /**
  97021. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97022. */
  97023. set positionIterations(value: number);
  97024. /**
  97025. * The unique id of the physics imposter
  97026. * set by the physics engine when adding this impostor to the array
  97027. */
  97028. uniqueId: number;
  97029. /**
  97030. * @hidden
  97031. */
  97032. soft: boolean;
  97033. /**
  97034. * @hidden
  97035. */
  97036. segments: number;
  97037. private _joints;
  97038. /**
  97039. * Initializes the physics imposter
  97040. * @param object The physics-enabled object used as the physics imposter
  97041. * @param type The type of the physics imposter
  97042. * @param _options The options for the physics imposter
  97043. * @param _scene The Babylon scene
  97044. */
  97045. constructor(
  97046. /**
  97047. * The physics-enabled object used as the physics imposter
  97048. */
  97049. object: IPhysicsEnabledObject,
  97050. /**
  97051. * The type of the physics imposter
  97052. */
  97053. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97054. /**
  97055. * This function will completly initialize this impostor.
  97056. * It will create a new body - but only if this mesh has no parent.
  97057. * If it has, this impostor will not be used other than to define the impostor
  97058. * of the child mesh.
  97059. * @hidden
  97060. */
  97061. _init(): void;
  97062. private _getPhysicsParent;
  97063. /**
  97064. * Should a new body be generated.
  97065. * @returns boolean specifying if body initialization is required
  97066. */
  97067. isBodyInitRequired(): boolean;
  97068. /**
  97069. * Sets the updated scaling
  97070. * @param updated Specifies if the scaling is updated
  97071. */
  97072. setScalingUpdated(): void;
  97073. /**
  97074. * Force a regeneration of this or the parent's impostor's body.
  97075. * Use under cautious - This will remove all joints already implemented.
  97076. */
  97077. forceUpdate(): void;
  97078. /**
  97079. * Gets the body that holds this impostor. Either its own, or its parent.
  97080. */
  97081. get physicsBody(): any;
  97082. /**
  97083. * Get the parent of the physics imposter
  97084. * @returns Physics imposter or null
  97085. */
  97086. get parent(): Nullable<PhysicsImpostor>;
  97087. /**
  97088. * Sets the parent of the physics imposter
  97089. */
  97090. set parent(value: Nullable<PhysicsImpostor>);
  97091. /**
  97092. * Set the physics body. Used mainly by the physics engine/plugin
  97093. */
  97094. set physicsBody(physicsBody: any);
  97095. /**
  97096. * Resets the update flags
  97097. */
  97098. resetUpdateFlags(): void;
  97099. /**
  97100. * Gets the object extend size
  97101. * @returns the object extend size
  97102. */
  97103. getObjectExtendSize(): Vector3;
  97104. /**
  97105. * Gets the object center
  97106. * @returns The object center
  97107. */
  97108. getObjectCenter(): Vector3;
  97109. /**
  97110. * Get a specific parameter from the options parameters
  97111. * @param paramName The object parameter name
  97112. * @returns The object parameter
  97113. */
  97114. getParam(paramName: string): any;
  97115. /**
  97116. * Sets a specific parameter in the options given to the physics plugin
  97117. * @param paramName The parameter name
  97118. * @param value The value of the parameter
  97119. */
  97120. setParam(paramName: string, value: number): void;
  97121. /**
  97122. * Specifically change the body's mass option. Won't recreate the physics body object
  97123. * @param mass The mass of the physics imposter
  97124. */
  97125. setMass(mass: number): void;
  97126. /**
  97127. * Gets the linear velocity
  97128. * @returns linear velocity or null
  97129. */
  97130. getLinearVelocity(): Nullable<Vector3>;
  97131. /**
  97132. * Sets the linear velocity
  97133. * @param velocity linear velocity or null
  97134. */
  97135. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97136. /**
  97137. * Gets the angular velocity
  97138. * @returns angular velocity or null
  97139. */
  97140. getAngularVelocity(): Nullable<Vector3>;
  97141. /**
  97142. * Sets the angular velocity
  97143. * @param velocity The velocity or null
  97144. */
  97145. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97146. /**
  97147. * Execute a function with the physics plugin native code
  97148. * Provide a function the will have two variables - the world object and the physics body object
  97149. * @param func The function to execute with the physics plugin native code
  97150. */
  97151. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97152. /**
  97153. * Register a function that will be executed before the physics world is stepping forward
  97154. * @param func The function to execute before the physics world is stepped forward
  97155. */
  97156. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97157. /**
  97158. * Unregister a function that will be executed before the physics world is stepping forward
  97159. * @param func The function to execute before the physics world is stepped forward
  97160. */
  97161. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97162. /**
  97163. * Register a function that will be executed after the physics step
  97164. * @param func The function to execute after physics step
  97165. */
  97166. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97167. /**
  97168. * Unregisters a function that will be executed after the physics step
  97169. * @param func The function to execute after physics step
  97170. */
  97171. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97172. /**
  97173. * register a function that will be executed when this impostor collides against a different body
  97174. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97175. * @param func Callback that is executed on collision
  97176. */
  97177. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97178. /**
  97179. * Unregisters the physics imposter on contact
  97180. * @param collideAgainst The physics object to collide against
  97181. * @param func Callback to execute on collision
  97182. */
  97183. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97184. private _tmpQuat;
  97185. private _tmpQuat2;
  97186. /**
  97187. * Get the parent rotation
  97188. * @returns The parent rotation
  97189. */
  97190. getParentsRotation(): Quaternion;
  97191. /**
  97192. * this function is executed by the physics engine.
  97193. */
  97194. beforeStep: () => void;
  97195. /**
  97196. * this function is executed by the physics engine
  97197. */
  97198. afterStep: () => void;
  97199. /**
  97200. * Legacy collision detection event support
  97201. */
  97202. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97203. /**
  97204. * event and body object due to cannon's event-based architecture.
  97205. */
  97206. onCollide: (e: {
  97207. body: any;
  97208. }) => void;
  97209. /**
  97210. * Apply a force
  97211. * @param force The force to apply
  97212. * @param contactPoint The contact point for the force
  97213. * @returns The physics imposter
  97214. */
  97215. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97216. /**
  97217. * Apply an impulse
  97218. * @param force The impulse force
  97219. * @param contactPoint The contact point for the impulse force
  97220. * @returns The physics imposter
  97221. */
  97222. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97223. /**
  97224. * A help function to create a joint
  97225. * @param otherImpostor A physics imposter used to create a joint
  97226. * @param jointType The type of joint
  97227. * @param jointData The data for the joint
  97228. * @returns The physics imposter
  97229. */
  97230. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97231. /**
  97232. * Add a joint to this impostor with a different impostor
  97233. * @param otherImpostor A physics imposter used to add a joint
  97234. * @param joint The joint to add
  97235. * @returns The physics imposter
  97236. */
  97237. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97238. /**
  97239. * Add an anchor to a cloth impostor
  97240. * @param otherImpostor rigid impostor to anchor to
  97241. * @param width ratio across width from 0 to 1
  97242. * @param height ratio up height from 0 to 1
  97243. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97244. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97245. * @returns impostor the soft imposter
  97246. */
  97247. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97248. /**
  97249. * Add a hook to a rope impostor
  97250. * @param otherImpostor rigid impostor to anchor to
  97251. * @param length ratio across rope from 0 to 1
  97252. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97253. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97254. * @returns impostor the rope imposter
  97255. */
  97256. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97257. /**
  97258. * Will keep this body still, in a sleep mode.
  97259. * @returns the physics imposter
  97260. */
  97261. sleep(): PhysicsImpostor;
  97262. /**
  97263. * Wake the body up.
  97264. * @returns The physics imposter
  97265. */
  97266. wakeUp(): PhysicsImpostor;
  97267. /**
  97268. * Clones the physics imposter
  97269. * @param newObject The physics imposter clones to this physics-enabled object
  97270. * @returns A nullable physics imposter
  97271. */
  97272. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97273. /**
  97274. * Disposes the physics imposter
  97275. */
  97276. dispose(): void;
  97277. /**
  97278. * Sets the delta position
  97279. * @param position The delta position amount
  97280. */
  97281. setDeltaPosition(position: Vector3): void;
  97282. /**
  97283. * Sets the delta rotation
  97284. * @param rotation The delta rotation amount
  97285. */
  97286. setDeltaRotation(rotation: Quaternion): void;
  97287. /**
  97288. * Gets the box size of the physics imposter and stores the result in the input parameter
  97289. * @param result Stores the box size
  97290. * @returns The physics imposter
  97291. */
  97292. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97293. /**
  97294. * Gets the radius of the physics imposter
  97295. * @returns Radius of the physics imposter
  97296. */
  97297. getRadius(): number;
  97298. /**
  97299. * Sync a bone with this impostor
  97300. * @param bone The bone to sync to the impostor.
  97301. * @param boneMesh The mesh that the bone is influencing.
  97302. * @param jointPivot The pivot of the joint / bone in local space.
  97303. * @param distToJoint Optional distance from the impostor to the joint.
  97304. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97305. */
  97306. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97307. /**
  97308. * Sync impostor to a bone
  97309. * @param bone The bone that the impostor will be synced to.
  97310. * @param boneMesh The mesh that the bone is influencing.
  97311. * @param jointPivot The pivot of the joint / bone in local space.
  97312. * @param distToJoint Optional distance from the impostor to the joint.
  97313. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97314. * @param boneAxis Optional vector3 axis the bone is aligned with
  97315. */
  97316. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97317. /**
  97318. * No-Imposter type
  97319. */
  97320. static NoImpostor: number;
  97321. /**
  97322. * Sphere-Imposter type
  97323. */
  97324. static SphereImpostor: number;
  97325. /**
  97326. * Box-Imposter type
  97327. */
  97328. static BoxImpostor: number;
  97329. /**
  97330. * Plane-Imposter type
  97331. */
  97332. static PlaneImpostor: number;
  97333. /**
  97334. * Mesh-imposter type
  97335. */
  97336. static MeshImpostor: number;
  97337. /**
  97338. * Capsule-Impostor type (Ammo.js plugin only)
  97339. */
  97340. static CapsuleImpostor: number;
  97341. /**
  97342. * Cylinder-Imposter type
  97343. */
  97344. static CylinderImpostor: number;
  97345. /**
  97346. * Particle-Imposter type
  97347. */
  97348. static ParticleImpostor: number;
  97349. /**
  97350. * Heightmap-Imposter type
  97351. */
  97352. static HeightmapImpostor: number;
  97353. /**
  97354. * ConvexHull-Impostor type (Ammo.js plugin only)
  97355. */
  97356. static ConvexHullImpostor: number;
  97357. /**
  97358. * Custom-Imposter type (Ammo.js plugin only)
  97359. */
  97360. static CustomImpostor: number;
  97361. /**
  97362. * Rope-Imposter type
  97363. */
  97364. static RopeImpostor: number;
  97365. /**
  97366. * Cloth-Imposter type
  97367. */
  97368. static ClothImpostor: number;
  97369. /**
  97370. * Softbody-Imposter type
  97371. */
  97372. static SoftbodyImpostor: number;
  97373. }
  97374. }
  97375. declare module BABYLON {
  97376. /**
  97377. * @hidden
  97378. **/
  97379. export class _CreationDataStorage {
  97380. closePath?: boolean;
  97381. closeArray?: boolean;
  97382. idx: number[];
  97383. dashSize: number;
  97384. gapSize: number;
  97385. path3D: Path3D;
  97386. pathArray: Vector3[][];
  97387. arc: number;
  97388. radius: number;
  97389. cap: number;
  97390. tessellation: number;
  97391. }
  97392. /**
  97393. * @hidden
  97394. **/
  97395. class _InstanceDataStorage {
  97396. visibleInstances: any;
  97397. batchCache: _InstancesBatch;
  97398. instancesBufferSize: number;
  97399. instancesBuffer: Nullable<Buffer>;
  97400. instancesData: Float32Array;
  97401. overridenInstanceCount: number;
  97402. isFrozen: boolean;
  97403. previousBatch: Nullable<_InstancesBatch>;
  97404. hardwareInstancedRendering: boolean;
  97405. sideOrientation: number;
  97406. manualUpdate: boolean;
  97407. }
  97408. /**
  97409. * @hidden
  97410. **/
  97411. export class _InstancesBatch {
  97412. mustReturn: boolean;
  97413. visibleInstances: Nullable<InstancedMesh[]>[];
  97414. renderSelf: boolean[];
  97415. hardwareInstancedRendering: boolean[];
  97416. }
  97417. /**
  97418. * Class used to represent renderable models
  97419. */
  97420. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97421. /**
  97422. * Mesh side orientation : usually the external or front surface
  97423. */
  97424. static readonly FRONTSIDE: number;
  97425. /**
  97426. * Mesh side orientation : usually the internal or back surface
  97427. */
  97428. static readonly BACKSIDE: number;
  97429. /**
  97430. * Mesh side orientation : both internal and external or front and back surfaces
  97431. */
  97432. static readonly DOUBLESIDE: number;
  97433. /**
  97434. * Mesh side orientation : by default, `FRONTSIDE`
  97435. */
  97436. static readonly DEFAULTSIDE: number;
  97437. /**
  97438. * Mesh cap setting : no cap
  97439. */
  97440. static readonly NO_CAP: number;
  97441. /**
  97442. * Mesh cap setting : one cap at the beginning of the mesh
  97443. */
  97444. static readonly CAP_START: number;
  97445. /**
  97446. * Mesh cap setting : one cap at the end of the mesh
  97447. */
  97448. static readonly CAP_END: number;
  97449. /**
  97450. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97451. */
  97452. static readonly CAP_ALL: number;
  97453. /**
  97454. * Mesh pattern setting : no flip or rotate
  97455. */
  97456. static readonly NO_FLIP: number;
  97457. /**
  97458. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97459. */
  97460. static readonly FLIP_TILE: number;
  97461. /**
  97462. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97463. */
  97464. static readonly ROTATE_TILE: number;
  97465. /**
  97466. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97467. */
  97468. static readonly FLIP_ROW: number;
  97469. /**
  97470. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97471. */
  97472. static readonly ROTATE_ROW: number;
  97473. /**
  97474. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97475. */
  97476. static readonly FLIP_N_ROTATE_TILE: number;
  97477. /**
  97478. * Mesh pattern setting : rotate pattern and rotate
  97479. */
  97480. static readonly FLIP_N_ROTATE_ROW: number;
  97481. /**
  97482. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97483. */
  97484. static readonly CENTER: number;
  97485. /**
  97486. * Mesh tile positioning : part tiles on left
  97487. */
  97488. static readonly LEFT: number;
  97489. /**
  97490. * Mesh tile positioning : part tiles on right
  97491. */
  97492. static readonly RIGHT: number;
  97493. /**
  97494. * Mesh tile positioning : part tiles on top
  97495. */
  97496. static readonly TOP: number;
  97497. /**
  97498. * Mesh tile positioning : part tiles on bottom
  97499. */
  97500. static readonly BOTTOM: number;
  97501. /**
  97502. * Gets the default side orientation.
  97503. * @param orientation the orientation to value to attempt to get
  97504. * @returns the default orientation
  97505. * @hidden
  97506. */
  97507. static _GetDefaultSideOrientation(orientation?: number): number;
  97508. private _internalMeshDataInfo;
  97509. /**
  97510. * An event triggered before rendering the mesh
  97511. */
  97512. get onBeforeRenderObservable(): Observable<Mesh>;
  97513. /**
  97514. * An event triggered before binding the mesh
  97515. */
  97516. get onBeforeBindObservable(): Observable<Mesh>;
  97517. /**
  97518. * An event triggered after rendering the mesh
  97519. */
  97520. get onAfterRenderObservable(): Observable<Mesh>;
  97521. /**
  97522. * An event triggered before drawing the mesh
  97523. */
  97524. get onBeforeDrawObservable(): Observable<Mesh>;
  97525. private _onBeforeDrawObserver;
  97526. /**
  97527. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97528. */
  97529. set onBeforeDraw(callback: () => void);
  97530. get hasInstances(): boolean;
  97531. /**
  97532. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97533. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97534. */
  97535. delayLoadState: number;
  97536. /**
  97537. * Gets the list of instances created from this mesh
  97538. * it is not supposed to be modified manually.
  97539. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97540. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97541. */
  97542. instances: InstancedMesh[];
  97543. /**
  97544. * Gets the file containing delay loading data for this mesh
  97545. */
  97546. delayLoadingFile: string;
  97547. /** @hidden */
  97548. _binaryInfo: any;
  97549. /**
  97550. * User defined function used to change how LOD level selection is done
  97551. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97552. */
  97553. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97554. /**
  97555. * Gets or sets the morph target manager
  97556. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97557. */
  97558. get morphTargetManager(): Nullable<MorphTargetManager>;
  97559. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97560. /** @hidden */
  97561. _creationDataStorage: Nullable<_CreationDataStorage>;
  97562. /** @hidden */
  97563. _geometry: Nullable<Geometry>;
  97564. /** @hidden */
  97565. _delayInfo: Array<string>;
  97566. /** @hidden */
  97567. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97568. /** @hidden */
  97569. _instanceDataStorage: _InstanceDataStorage;
  97570. private _effectiveMaterial;
  97571. /** @hidden */
  97572. _shouldGenerateFlatShading: boolean;
  97573. /** @hidden */
  97574. _originalBuilderSideOrientation: number;
  97575. /**
  97576. * Use this property to change the original side orientation defined at construction time
  97577. */
  97578. overrideMaterialSideOrientation: Nullable<number>;
  97579. /**
  97580. * Gets the source mesh (the one used to clone this one from)
  97581. */
  97582. get source(): Nullable<Mesh>;
  97583. /**
  97584. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97585. */
  97586. get isUnIndexed(): boolean;
  97587. set isUnIndexed(value: boolean);
  97588. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97589. get worldMatrixInstancedBuffer(): Float32Array;
  97590. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97591. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97592. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97593. /**
  97594. * @constructor
  97595. * @param name The value used by scene.getMeshByName() to do a lookup.
  97596. * @param scene The scene to add this mesh to.
  97597. * @param parent The parent of this mesh, if it has one
  97598. * @param source An optional Mesh from which geometry is shared, cloned.
  97599. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97600. * When false, achieved by calling a clone(), also passing False.
  97601. * This will make creation of children, recursive.
  97602. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97603. */
  97604. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97605. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97606. doNotInstantiate: boolean;
  97607. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97608. /**
  97609. * Gets the class name
  97610. * @returns the string "Mesh".
  97611. */
  97612. getClassName(): string;
  97613. /** @hidden */
  97614. get _isMesh(): boolean;
  97615. /**
  97616. * Returns a description of this mesh
  97617. * @param fullDetails define if full details about this mesh must be used
  97618. * @returns a descriptive string representing this mesh
  97619. */
  97620. toString(fullDetails?: boolean): string;
  97621. /** @hidden */
  97622. _unBindEffect(): void;
  97623. /**
  97624. * Gets a boolean indicating if this mesh has LOD
  97625. */
  97626. get hasLODLevels(): boolean;
  97627. /**
  97628. * Gets the list of MeshLODLevel associated with the current mesh
  97629. * @returns an array of MeshLODLevel
  97630. */
  97631. getLODLevels(): MeshLODLevel[];
  97632. private _sortLODLevels;
  97633. /**
  97634. * Add a mesh as LOD level triggered at the given distance.
  97635. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97636. * @param distance The distance from the center of the object to show this level
  97637. * @param mesh The mesh to be added as LOD level (can be null)
  97638. * @return This mesh (for chaining)
  97639. */
  97640. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97641. /**
  97642. * Returns the LOD level mesh at the passed distance or null if not found.
  97643. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97644. * @param distance The distance from the center of the object to show this level
  97645. * @returns a Mesh or `null`
  97646. */
  97647. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97648. /**
  97649. * Remove a mesh from the LOD array
  97650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97651. * @param mesh defines the mesh to be removed
  97652. * @return This mesh (for chaining)
  97653. */
  97654. removeLODLevel(mesh: Mesh): Mesh;
  97655. /**
  97656. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97657. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97658. * @param camera defines the camera to use to compute distance
  97659. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97660. * @return This mesh (for chaining)
  97661. */
  97662. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97663. /**
  97664. * Gets the mesh internal Geometry object
  97665. */
  97666. get geometry(): Nullable<Geometry>;
  97667. /**
  97668. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97669. * @returns the total number of vertices
  97670. */
  97671. getTotalVertices(): number;
  97672. /**
  97673. * Returns the content of an associated vertex buffer
  97674. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97675. * - VertexBuffer.PositionKind
  97676. * - VertexBuffer.UVKind
  97677. * - VertexBuffer.UV2Kind
  97678. * - VertexBuffer.UV3Kind
  97679. * - VertexBuffer.UV4Kind
  97680. * - VertexBuffer.UV5Kind
  97681. * - VertexBuffer.UV6Kind
  97682. * - VertexBuffer.ColorKind
  97683. * - VertexBuffer.MatricesIndicesKind
  97684. * - VertexBuffer.MatricesIndicesExtraKind
  97685. * - VertexBuffer.MatricesWeightsKind
  97686. * - VertexBuffer.MatricesWeightsExtraKind
  97687. * @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
  97688. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97689. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97690. */
  97691. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97692. /**
  97693. * Returns the mesh VertexBuffer object from the requested `kind`
  97694. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97695. * - VertexBuffer.PositionKind
  97696. * - VertexBuffer.NormalKind
  97697. * - VertexBuffer.UVKind
  97698. * - VertexBuffer.UV2Kind
  97699. * - VertexBuffer.UV3Kind
  97700. * - VertexBuffer.UV4Kind
  97701. * - VertexBuffer.UV5Kind
  97702. * - VertexBuffer.UV6Kind
  97703. * - VertexBuffer.ColorKind
  97704. * - VertexBuffer.MatricesIndicesKind
  97705. * - VertexBuffer.MatricesIndicesExtraKind
  97706. * - VertexBuffer.MatricesWeightsKind
  97707. * - VertexBuffer.MatricesWeightsExtraKind
  97708. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97709. */
  97710. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97711. /**
  97712. * Tests if a specific vertex buffer is associated with this mesh
  97713. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97714. * - VertexBuffer.PositionKind
  97715. * - VertexBuffer.NormalKind
  97716. * - VertexBuffer.UVKind
  97717. * - VertexBuffer.UV2Kind
  97718. * - VertexBuffer.UV3Kind
  97719. * - VertexBuffer.UV4Kind
  97720. * - VertexBuffer.UV5Kind
  97721. * - VertexBuffer.UV6Kind
  97722. * - VertexBuffer.ColorKind
  97723. * - VertexBuffer.MatricesIndicesKind
  97724. * - VertexBuffer.MatricesIndicesExtraKind
  97725. * - VertexBuffer.MatricesWeightsKind
  97726. * - VertexBuffer.MatricesWeightsExtraKind
  97727. * @returns a boolean
  97728. */
  97729. isVerticesDataPresent(kind: string): boolean;
  97730. /**
  97731. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97732. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97733. * - VertexBuffer.PositionKind
  97734. * - VertexBuffer.UVKind
  97735. * - VertexBuffer.UV2Kind
  97736. * - VertexBuffer.UV3Kind
  97737. * - VertexBuffer.UV4Kind
  97738. * - VertexBuffer.UV5Kind
  97739. * - VertexBuffer.UV6Kind
  97740. * - VertexBuffer.ColorKind
  97741. * - VertexBuffer.MatricesIndicesKind
  97742. * - VertexBuffer.MatricesIndicesExtraKind
  97743. * - VertexBuffer.MatricesWeightsKind
  97744. * - VertexBuffer.MatricesWeightsExtraKind
  97745. * @returns a boolean
  97746. */
  97747. isVertexBufferUpdatable(kind: string): boolean;
  97748. /**
  97749. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97750. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97751. * - VertexBuffer.PositionKind
  97752. * - VertexBuffer.NormalKind
  97753. * - VertexBuffer.UVKind
  97754. * - VertexBuffer.UV2Kind
  97755. * - VertexBuffer.UV3Kind
  97756. * - VertexBuffer.UV4Kind
  97757. * - VertexBuffer.UV5Kind
  97758. * - VertexBuffer.UV6Kind
  97759. * - VertexBuffer.ColorKind
  97760. * - VertexBuffer.MatricesIndicesKind
  97761. * - VertexBuffer.MatricesIndicesExtraKind
  97762. * - VertexBuffer.MatricesWeightsKind
  97763. * - VertexBuffer.MatricesWeightsExtraKind
  97764. * @returns an array of strings
  97765. */
  97766. getVerticesDataKinds(): string[];
  97767. /**
  97768. * Returns a positive integer : the total number of indices in this mesh geometry.
  97769. * @returns the numner of indices or zero if the mesh has no geometry.
  97770. */
  97771. getTotalIndices(): number;
  97772. /**
  97773. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97774. * @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.
  97775. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97776. * @returns the indices array or an empty array if the mesh has no geometry
  97777. */
  97778. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97779. get isBlocked(): boolean;
  97780. /**
  97781. * Determine if the current mesh is ready to be rendered
  97782. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97783. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97784. * @returns true if all associated assets are ready (material, textures, shaders)
  97785. */
  97786. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97787. /**
  97788. * 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.
  97789. */
  97790. get areNormalsFrozen(): boolean;
  97791. /**
  97792. * 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.
  97793. * @returns the current mesh
  97794. */
  97795. freezeNormals(): Mesh;
  97796. /**
  97797. * 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
  97798. * @returns the current mesh
  97799. */
  97800. unfreezeNormals(): Mesh;
  97801. /**
  97802. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97803. */
  97804. set overridenInstanceCount(count: number);
  97805. /** @hidden */
  97806. _preActivate(): Mesh;
  97807. /** @hidden */
  97808. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97809. /** @hidden */
  97810. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97811. /**
  97812. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97813. * This means the mesh underlying bounding box and sphere are recomputed.
  97814. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97815. * @returns the current mesh
  97816. */
  97817. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97818. /** @hidden */
  97819. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97820. /**
  97821. * This function will subdivide the mesh into multiple submeshes
  97822. * @param count defines the expected number of submeshes
  97823. */
  97824. subdivide(count: number): void;
  97825. /**
  97826. * Copy a FloatArray into a specific associated vertex buffer
  97827. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97828. * - VertexBuffer.PositionKind
  97829. * - VertexBuffer.UVKind
  97830. * - VertexBuffer.UV2Kind
  97831. * - VertexBuffer.UV3Kind
  97832. * - VertexBuffer.UV4Kind
  97833. * - VertexBuffer.UV5Kind
  97834. * - VertexBuffer.UV6Kind
  97835. * - VertexBuffer.ColorKind
  97836. * - VertexBuffer.MatricesIndicesKind
  97837. * - VertexBuffer.MatricesIndicesExtraKind
  97838. * - VertexBuffer.MatricesWeightsKind
  97839. * - VertexBuffer.MatricesWeightsExtraKind
  97840. * @param data defines the data source
  97841. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97842. * @param stride defines the data stride size (can be null)
  97843. * @returns the current mesh
  97844. */
  97845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97846. /**
  97847. * Delete a vertex buffer associated with this mesh
  97848. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97849. * - VertexBuffer.PositionKind
  97850. * - VertexBuffer.UVKind
  97851. * - VertexBuffer.UV2Kind
  97852. * - VertexBuffer.UV3Kind
  97853. * - VertexBuffer.UV4Kind
  97854. * - VertexBuffer.UV5Kind
  97855. * - VertexBuffer.UV6Kind
  97856. * - VertexBuffer.ColorKind
  97857. * - VertexBuffer.MatricesIndicesKind
  97858. * - VertexBuffer.MatricesIndicesExtraKind
  97859. * - VertexBuffer.MatricesWeightsKind
  97860. * - VertexBuffer.MatricesWeightsExtraKind
  97861. */
  97862. removeVerticesData(kind: string): void;
  97863. /**
  97864. * Flags an associated vertex buffer as updatable
  97865. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97866. * - VertexBuffer.PositionKind
  97867. * - VertexBuffer.UVKind
  97868. * - VertexBuffer.UV2Kind
  97869. * - VertexBuffer.UV3Kind
  97870. * - VertexBuffer.UV4Kind
  97871. * - VertexBuffer.UV5Kind
  97872. * - VertexBuffer.UV6Kind
  97873. * - VertexBuffer.ColorKind
  97874. * - VertexBuffer.MatricesIndicesKind
  97875. * - VertexBuffer.MatricesIndicesExtraKind
  97876. * - VertexBuffer.MatricesWeightsKind
  97877. * - VertexBuffer.MatricesWeightsExtraKind
  97878. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97879. */
  97880. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97881. /**
  97882. * Sets the mesh global Vertex Buffer
  97883. * @param buffer defines the buffer to use
  97884. * @returns the current mesh
  97885. */
  97886. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97887. /**
  97888. * Update a specific associated vertex buffer
  97889. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97890. * - VertexBuffer.PositionKind
  97891. * - VertexBuffer.UVKind
  97892. * - VertexBuffer.UV2Kind
  97893. * - VertexBuffer.UV3Kind
  97894. * - VertexBuffer.UV4Kind
  97895. * - VertexBuffer.UV5Kind
  97896. * - VertexBuffer.UV6Kind
  97897. * - VertexBuffer.ColorKind
  97898. * - VertexBuffer.MatricesIndicesKind
  97899. * - VertexBuffer.MatricesIndicesExtraKind
  97900. * - VertexBuffer.MatricesWeightsKind
  97901. * - VertexBuffer.MatricesWeightsExtraKind
  97902. * @param data defines the data source
  97903. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97904. * @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)
  97905. * @returns the current mesh
  97906. */
  97907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97908. /**
  97909. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97910. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97911. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97912. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97913. * @returns the current mesh
  97914. */
  97915. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97916. /**
  97917. * Creates a un-shared specific occurence of the geometry for the mesh.
  97918. * @returns the current mesh
  97919. */
  97920. makeGeometryUnique(): Mesh;
  97921. /**
  97922. * Set the index buffer of this mesh
  97923. * @param indices defines the source data
  97924. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97925. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97926. * @returns the current mesh
  97927. */
  97928. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97929. /**
  97930. * Update the current index buffer
  97931. * @param indices defines the source data
  97932. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97933. * @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)
  97934. * @returns the current mesh
  97935. */
  97936. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97937. /**
  97938. * Invert the geometry to move from a right handed system to a left handed one.
  97939. * @returns the current mesh
  97940. */
  97941. toLeftHanded(): Mesh;
  97942. /** @hidden */
  97943. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97944. /** @hidden */
  97945. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97946. /**
  97947. * Registers for this mesh a javascript function called just before the rendering process
  97948. * @param func defines the function to call before rendering this mesh
  97949. * @returns the current mesh
  97950. */
  97951. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97952. /**
  97953. * Disposes a previously registered javascript function called before the rendering
  97954. * @param func defines the function to remove
  97955. * @returns the current mesh
  97956. */
  97957. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97958. /**
  97959. * Registers for this mesh a javascript function called just after the rendering is complete
  97960. * @param func defines the function to call after rendering this mesh
  97961. * @returns the current mesh
  97962. */
  97963. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97964. /**
  97965. * Disposes a previously registered javascript function called after the rendering.
  97966. * @param func defines the function to remove
  97967. * @returns the current mesh
  97968. */
  97969. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97970. /** @hidden */
  97971. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97972. /** @hidden */
  97973. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97974. /** @hidden */
  97975. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97976. /** @hidden */
  97977. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97978. /** @hidden */
  97979. _rebuild(): void;
  97980. /** @hidden */
  97981. _freeze(): void;
  97982. /** @hidden */
  97983. _unFreeze(): void;
  97984. /**
  97985. * 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
  97986. * @param subMesh defines the subMesh to render
  97987. * @param enableAlphaMode defines if alpha mode can be changed
  97988. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97989. * @returns the current mesh
  97990. */
  97991. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97992. private _onBeforeDraw;
  97993. /**
  97994. * Renormalize the mesh and patch it up if there are no weights
  97995. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97996. * However in the case of zero weights then we set just a single influence to 1.
  97997. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97998. */
  97999. cleanMatrixWeights(): void;
  98000. private normalizeSkinFourWeights;
  98001. private normalizeSkinWeightsAndExtra;
  98002. /**
  98003. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98004. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98005. * the user know there was an issue with importing the mesh
  98006. * @returns a validation object with skinned, valid and report string
  98007. */
  98008. validateSkinning(): {
  98009. skinned: boolean;
  98010. valid: boolean;
  98011. report: string;
  98012. };
  98013. /** @hidden */
  98014. _checkDelayState(): Mesh;
  98015. private _queueLoad;
  98016. /**
  98017. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98018. * A mesh is in the frustum if its bounding box intersects the frustum
  98019. * @param frustumPlanes defines the frustum to test
  98020. * @returns true if the mesh is in the frustum planes
  98021. */
  98022. isInFrustum(frustumPlanes: Plane[]): boolean;
  98023. /**
  98024. * Sets the mesh material by the material or multiMaterial `id` property
  98025. * @param id is a string identifying the material or the multiMaterial
  98026. * @returns the current mesh
  98027. */
  98028. setMaterialByID(id: string): Mesh;
  98029. /**
  98030. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98031. * @returns an array of IAnimatable
  98032. */
  98033. getAnimatables(): IAnimatable[];
  98034. /**
  98035. * Modifies the mesh geometry according to the passed transformation matrix.
  98036. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98037. * The mesh normals are modified using the same transformation.
  98038. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98039. * @param transform defines the transform matrix to use
  98040. * @see http://doc.babylonjs.com/resources/baking_transformations
  98041. * @returns the current mesh
  98042. */
  98043. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98044. /**
  98045. * Modifies the mesh geometry according to its own current World Matrix.
  98046. * The mesh World Matrix is then reset.
  98047. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98048. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98049. * @see http://doc.babylonjs.com/resources/baking_transformations
  98050. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98051. * @returns the current mesh
  98052. */
  98053. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98054. /** @hidden */
  98055. get _positions(): Nullable<Vector3[]>;
  98056. /** @hidden */
  98057. _resetPointsArrayCache(): Mesh;
  98058. /** @hidden */
  98059. _generatePointsArray(): boolean;
  98060. /**
  98061. * Returns a new Mesh object generated from the current mesh properties.
  98062. * This method must not get confused with createInstance()
  98063. * @param name is a string, the name given to the new mesh
  98064. * @param newParent can be any Node object (default `null`)
  98065. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98066. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98067. * @returns a new mesh
  98068. */
  98069. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98070. /**
  98071. * Releases resources associated with this mesh.
  98072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98074. */
  98075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98076. /** @hidden */
  98077. _disposeInstanceSpecificData(): void;
  98078. /**
  98079. * Modifies the mesh geometry according to a displacement map.
  98080. * 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.
  98081. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98082. * @param url is a string, the URL from the image file is to be downloaded.
  98083. * @param minHeight is the lower limit of the displacement.
  98084. * @param maxHeight is the upper limit of the displacement.
  98085. * @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.
  98086. * @param uvOffset is an optional vector2 used to offset UV.
  98087. * @param uvScale is an optional vector2 used to scale UV.
  98088. * @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.
  98089. * @returns the Mesh.
  98090. */
  98091. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98092. /**
  98093. * Modifies the mesh geometry according to a displacementMap buffer.
  98094. * 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.
  98095. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98096. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98097. * @param heightMapWidth is the width of the buffer image.
  98098. * @param heightMapHeight is the height of the buffer image.
  98099. * @param minHeight is the lower limit of the displacement.
  98100. * @param maxHeight is the upper limit of the displacement.
  98101. * @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.
  98102. * @param uvOffset is an optional vector2 used to offset UV.
  98103. * @param uvScale is an optional vector2 used to scale UV.
  98104. * @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.
  98105. * @returns the Mesh.
  98106. */
  98107. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98108. /**
  98109. * Modify the mesh to get a flat shading rendering.
  98110. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98111. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98112. * @returns current mesh
  98113. */
  98114. convertToFlatShadedMesh(): Mesh;
  98115. /**
  98116. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98117. * In other words, more vertices, no more indices and a single bigger VBO.
  98118. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98119. * @returns current mesh
  98120. */
  98121. convertToUnIndexedMesh(): Mesh;
  98122. /**
  98123. * Inverses facet orientations.
  98124. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98125. * @param flipNormals will also inverts the normals
  98126. * @returns current mesh
  98127. */
  98128. flipFaces(flipNormals?: boolean): Mesh;
  98129. /**
  98130. * Increase the number of facets and hence vertices in a mesh
  98131. * Vertex normals are interpolated from existing vertex normals
  98132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98133. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98134. */
  98135. increaseVertices(numberPerEdge: number): void;
  98136. /**
  98137. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98138. * This will undo any application of covertToFlatShadedMesh
  98139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98140. */
  98141. forceSharedVertices(): void;
  98142. /** @hidden */
  98143. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98144. /** @hidden */
  98145. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98146. /**
  98147. * Creates a new InstancedMesh object from the mesh model.
  98148. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98149. * @param name defines the name of the new instance
  98150. * @returns a new InstancedMesh
  98151. */
  98152. createInstance(name: string): InstancedMesh;
  98153. /**
  98154. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98155. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98156. * @returns the current mesh
  98157. */
  98158. synchronizeInstances(): Mesh;
  98159. /**
  98160. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98161. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98162. * This should be used together with the simplification to avoid disappearing triangles.
  98163. * @param successCallback an optional success callback to be called after the optimization finished.
  98164. * @returns the current mesh
  98165. */
  98166. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98167. /**
  98168. * Serialize current mesh
  98169. * @param serializationObject defines the object which will receive the serialization data
  98170. */
  98171. serialize(serializationObject: any): void;
  98172. /** @hidden */
  98173. _syncGeometryWithMorphTargetManager(): void;
  98174. /** @hidden */
  98175. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98176. /**
  98177. * Returns a new Mesh object parsed from the source provided.
  98178. * @param parsedMesh is the source
  98179. * @param scene defines the hosting scene
  98180. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98181. * @returns a new Mesh
  98182. */
  98183. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98184. /**
  98185. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98186. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98187. * @param name defines the name of the mesh to create
  98188. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98189. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98190. * @param closePath creates a seam between the first and the last points of each path of the path array
  98191. * @param offset is taken in account only if the `pathArray` is containing a single path
  98192. * @param scene defines the hosting scene
  98193. * @param updatable defines if the mesh must be flagged as updatable
  98194. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98195. * @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)
  98196. * @returns a new Mesh
  98197. */
  98198. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98199. /**
  98200. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98201. * @param name defines the name of the mesh to create
  98202. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98203. * @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
  98204. * @param scene defines the hosting scene
  98205. * @param updatable defines if the mesh must be flagged as updatable
  98206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98207. * @returns a new Mesh
  98208. */
  98209. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98210. /**
  98211. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98212. * @param name defines the name of the mesh to create
  98213. * @param size sets the size (float) of each box side (default 1)
  98214. * @param scene defines the hosting scene
  98215. * @param updatable defines if the mesh must be flagged as updatable
  98216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98217. * @returns a new Mesh
  98218. */
  98219. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98220. /**
  98221. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98222. * @param name defines the name of the mesh to create
  98223. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98224. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98225. * @param scene defines the hosting scene
  98226. * @param updatable defines if the mesh must be flagged as updatable
  98227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98228. * @returns a new Mesh
  98229. */
  98230. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98231. /**
  98232. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98233. * @param name defines the name of the mesh to create
  98234. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98235. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98236. * @param scene defines the hosting scene
  98237. * @returns a new Mesh
  98238. */
  98239. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98240. /**
  98241. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98242. * @param name defines the name of the mesh to create
  98243. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98244. * @param diameterTop set the top cap diameter (floats, default 1)
  98245. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98246. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98247. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98248. * @param scene defines the hosting scene
  98249. * @param updatable defines if the mesh must be flagged as updatable
  98250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98251. * @returns a new Mesh
  98252. */
  98253. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98254. /**
  98255. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98256. * @param name defines the name of the mesh to create
  98257. * @param diameter sets the diameter size (float) of the torus (default 1)
  98258. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98259. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98260. * @param scene defines the hosting scene
  98261. * @param updatable defines if the mesh must be flagged as updatable
  98262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98263. * @returns a new Mesh
  98264. */
  98265. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98266. /**
  98267. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98268. * @param name defines the name of the mesh to create
  98269. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98270. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98271. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98272. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98273. * @param p the number of windings on X axis (positive integers, default 2)
  98274. * @param q the number of windings on Y axis (positive integers, default 3)
  98275. * @param scene defines the hosting scene
  98276. * @param updatable defines if the mesh must be flagged as updatable
  98277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98278. * @returns a new Mesh
  98279. */
  98280. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98281. /**
  98282. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98283. * @param name defines the name of the mesh to create
  98284. * @param points is an array successive Vector3
  98285. * @param scene defines the hosting scene
  98286. * @param updatable defines if the mesh must be flagged as updatable
  98287. * @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).
  98288. * @returns a new Mesh
  98289. */
  98290. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98291. /**
  98292. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98293. * @param name defines the name of the mesh to create
  98294. * @param points is an array successive Vector3
  98295. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98296. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98297. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98298. * @param scene defines the hosting scene
  98299. * @param updatable defines if the mesh must be flagged as updatable
  98300. * @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)
  98301. * @returns a new Mesh
  98302. */
  98303. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98304. /**
  98305. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98306. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98307. * 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.
  98308. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98309. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98310. * Remember you can only change the shape positions, not their number when updating a polygon.
  98311. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98312. * @param name defines the name of the mesh to create
  98313. * @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
  98314. * @param scene defines the hosting scene
  98315. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98316. * @param updatable defines if the mesh must be flagged as updatable
  98317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98318. * @param earcutInjection can be used to inject your own earcut reference
  98319. * @returns a new Mesh
  98320. */
  98321. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98322. /**
  98323. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98324. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98325. * @param name defines the name of the mesh to create
  98326. * @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
  98327. * @param depth defines the height of extrusion
  98328. * @param scene defines the hosting scene
  98329. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98330. * @param updatable defines if the mesh must be flagged as updatable
  98331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98332. * @param earcutInjection can be used to inject your own earcut reference
  98333. * @returns a new Mesh
  98334. */
  98335. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98336. /**
  98337. * Creates an extruded shape mesh.
  98338. * 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
  98339. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98340. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98341. * @param name defines the name of the mesh to create
  98342. * @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
  98343. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98344. * @param scale is the value to scale the shape
  98345. * @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
  98346. * @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
  98347. * @param scene defines the hosting scene
  98348. * @param updatable defines if the mesh must be flagged as updatable
  98349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98350. * @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)
  98351. * @returns a new Mesh
  98352. */
  98353. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98354. /**
  98355. * Creates an custom extruded shape mesh.
  98356. * The custom extrusion is a parametric shape.
  98357. * It has no predefined shape. Its final shape will depend on the input parameters.
  98358. * Please consider using the same method from the MeshBuilder class instead
  98359. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98360. * @param name defines the name of the mesh to create
  98361. * @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
  98362. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98363. * @param scaleFunction is a custom Javascript function called on each path point
  98364. * @param rotationFunction is a custom Javascript function called on each path point
  98365. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98366. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98367. * @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
  98368. * @param scene defines the hosting scene
  98369. * @param updatable defines if the mesh must be flagged as updatable
  98370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98371. * @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)
  98372. * @returns a new Mesh
  98373. */
  98374. 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;
  98375. /**
  98376. * Creates lathe mesh.
  98377. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98378. * Please consider using the same method from the MeshBuilder class instead
  98379. * @param name defines the name of the mesh to create
  98380. * @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
  98381. * @param radius is the radius value of the lathe
  98382. * @param tessellation is the side number of the lathe.
  98383. * @param scene defines the hosting scene
  98384. * @param updatable defines if the mesh must be flagged as updatable
  98385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98386. * @returns a new Mesh
  98387. */
  98388. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98389. /**
  98390. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98391. * @param name defines the name of the mesh to create
  98392. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98393. * @param scene defines the hosting scene
  98394. * @param updatable defines if the mesh must be flagged as updatable
  98395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98396. * @returns a new Mesh
  98397. */
  98398. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98399. /**
  98400. * Creates a ground mesh.
  98401. * Please consider using the same method from the MeshBuilder class instead
  98402. * @param name defines the name of the mesh to create
  98403. * @param width set the width of the ground
  98404. * @param height set the height of the ground
  98405. * @param subdivisions sets the number of subdivisions per side
  98406. * @param scene defines the hosting scene
  98407. * @param updatable defines if the mesh must be flagged as updatable
  98408. * @returns a new Mesh
  98409. */
  98410. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98411. /**
  98412. * Creates a tiled ground mesh.
  98413. * Please consider using the same method from the MeshBuilder class instead
  98414. * @param name defines the name of the mesh to create
  98415. * @param xmin set the ground minimum X coordinate
  98416. * @param zmin set the ground minimum Y coordinate
  98417. * @param xmax set the ground maximum X coordinate
  98418. * @param zmax set the ground maximum Z coordinate
  98419. * @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
  98420. * @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
  98421. * @param scene defines the hosting scene
  98422. * @param updatable defines if the mesh must be flagged as updatable
  98423. * @returns a new Mesh
  98424. */
  98425. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98426. w: number;
  98427. h: number;
  98428. }, precision: {
  98429. w: number;
  98430. h: number;
  98431. }, scene: Scene, updatable?: boolean): Mesh;
  98432. /**
  98433. * Creates a ground mesh from a height map.
  98434. * Please consider using the same method from the MeshBuilder class instead
  98435. * @see http://doc.babylonjs.com/babylon101/height_map
  98436. * @param name defines the name of the mesh to create
  98437. * @param url sets the URL of the height map image resource
  98438. * @param width set the ground width size
  98439. * @param height set the ground height size
  98440. * @param subdivisions sets the number of subdivision per side
  98441. * @param minHeight is the minimum altitude on the ground
  98442. * @param maxHeight is the maximum altitude on the ground
  98443. * @param scene defines the hosting scene
  98444. * @param updatable defines if the mesh must be flagged as updatable
  98445. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98446. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98447. * @returns a new Mesh
  98448. */
  98449. 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;
  98450. /**
  98451. * Creates a tube mesh.
  98452. * The tube is a parametric shape.
  98453. * It has no predefined shape. Its final shape will depend on the input parameters.
  98454. * Please consider using the same method from the MeshBuilder class instead
  98455. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98456. * @param name defines the name of the mesh to create
  98457. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98458. * @param radius sets the tube radius size
  98459. * @param tessellation is the number of sides on the tubular surface
  98460. * @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
  98461. * @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
  98462. * @param scene defines the hosting scene
  98463. * @param updatable defines if the mesh must be flagged as updatable
  98464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98465. * @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)
  98466. * @returns a new Mesh
  98467. */
  98468. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98469. (i: number, distance: number): number;
  98470. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98471. /**
  98472. * Creates a polyhedron mesh.
  98473. * Please consider using the same method from the MeshBuilder class instead.
  98474. * * 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
  98475. * * The parameter `size` (positive float, default 1) sets the polygon size
  98476. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98477. * * 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`
  98478. * * 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
  98479. * * 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)`)
  98480. * * 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
  98481. * * 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
  98482. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98483. * * If you create a double-sided mesh, you can choose what parts of 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
  98484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98485. * @param name defines the name of the mesh to create
  98486. * @param options defines the options used to create the mesh
  98487. * @param scene defines the hosting scene
  98488. * @returns a new Mesh
  98489. */
  98490. static CreatePolyhedron(name: string, options: {
  98491. type?: number;
  98492. size?: number;
  98493. sizeX?: number;
  98494. sizeY?: number;
  98495. sizeZ?: number;
  98496. custom?: any;
  98497. faceUV?: Vector4[];
  98498. faceColors?: Color4[];
  98499. updatable?: boolean;
  98500. sideOrientation?: number;
  98501. }, scene: Scene): Mesh;
  98502. /**
  98503. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98504. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98505. * * 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`)
  98506. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98507. * * 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
  98508. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98509. * * If you create a double-sided mesh, you can choose what parts of 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
  98510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98511. * @param name defines the name of the mesh
  98512. * @param options defines the options used to create the mesh
  98513. * @param scene defines the hosting scene
  98514. * @returns a new Mesh
  98515. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98516. */
  98517. static CreateIcoSphere(name: string, options: {
  98518. radius?: number;
  98519. flat?: boolean;
  98520. subdivisions?: number;
  98521. sideOrientation?: number;
  98522. updatable?: boolean;
  98523. }, scene: Scene): Mesh;
  98524. /**
  98525. * Creates a decal mesh.
  98526. * Please consider using the same method from the MeshBuilder class instead.
  98527. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98528. * @param name defines the name of the mesh
  98529. * @param sourceMesh defines the mesh receiving the decal
  98530. * @param position sets the position of the decal in world coordinates
  98531. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98532. * @param size sets the decal scaling
  98533. * @param angle sets the angle to rotate the decal
  98534. * @returns a new Mesh
  98535. */
  98536. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98537. /**
  98538. * Prepare internal position array for software CPU skinning
  98539. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98540. */
  98541. setPositionsForCPUSkinning(): Float32Array;
  98542. /**
  98543. * Prepare internal normal array for software CPU skinning
  98544. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98545. */
  98546. setNormalsForCPUSkinning(): Float32Array;
  98547. /**
  98548. * Updates the vertex buffer by applying transformation from the bones
  98549. * @param skeleton defines the skeleton to apply to current mesh
  98550. * @returns the current mesh
  98551. */
  98552. applySkeleton(skeleton: Skeleton): Mesh;
  98553. /**
  98554. * 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
  98555. * @param meshes defines the list of meshes to scan
  98556. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98557. */
  98558. static MinMax(meshes: AbstractMesh[]): {
  98559. min: Vector3;
  98560. max: Vector3;
  98561. };
  98562. /**
  98563. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98564. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98565. * @returns a vector3
  98566. */
  98567. static Center(meshesOrMinMaxVector: {
  98568. min: Vector3;
  98569. max: Vector3;
  98570. } | AbstractMesh[]): Vector3;
  98571. /**
  98572. * Merge the array of meshes into a single mesh for performance reasons.
  98573. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98574. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98575. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98576. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98577. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98578. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98579. * @returns a new mesh
  98580. */
  98581. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98582. /** @hidden */
  98583. addInstance(instance: InstancedMesh): void;
  98584. /** @hidden */
  98585. removeInstance(instance: InstancedMesh): void;
  98586. }
  98587. }
  98588. declare module BABYLON {
  98589. /**
  98590. * This is the base class of all the camera used in the application.
  98591. * @see http://doc.babylonjs.com/features/cameras
  98592. */
  98593. export class Camera extends Node {
  98594. /** @hidden */
  98595. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98596. /**
  98597. * This is the default projection mode used by the cameras.
  98598. * It helps recreating a feeling of perspective and better appreciate depth.
  98599. * This is the best way to simulate real life cameras.
  98600. */
  98601. static readonly PERSPECTIVE_CAMERA: number;
  98602. /**
  98603. * This helps creating camera with an orthographic mode.
  98604. * 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.
  98605. */
  98606. static readonly ORTHOGRAPHIC_CAMERA: number;
  98607. /**
  98608. * This is the default FOV mode for perspective cameras.
  98609. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98610. */
  98611. static readonly FOVMODE_VERTICAL_FIXED: number;
  98612. /**
  98613. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98614. */
  98615. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98616. /**
  98617. * This specifies ther is no need for a camera rig.
  98618. * Basically only one eye is rendered corresponding to the camera.
  98619. */
  98620. static readonly RIG_MODE_NONE: number;
  98621. /**
  98622. * Simulates a camera Rig with one blue eye and one red eye.
  98623. * This can be use with 3d blue and red glasses.
  98624. */
  98625. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98626. /**
  98627. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98628. */
  98629. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98630. /**
  98631. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98632. */
  98633. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98634. /**
  98635. * Defines that both eyes of the camera will be rendered over under each other.
  98636. */
  98637. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98638. /**
  98639. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98640. */
  98641. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98642. /**
  98643. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98644. */
  98645. static readonly RIG_MODE_VR: number;
  98646. /**
  98647. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98648. */
  98649. static readonly RIG_MODE_WEBVR: number;
  98650. /**
  98651. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98652. */
  98653. static readonly RIG_MODE_CUSTOM: number;
  98654. /**
  98655. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98656. */
  98657. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98658. /**
  98659. * Define the input manager associated with the camera.
  98660. */
  98661. inputs: CameraInputsManager<Camera>;
  98662. /** @hidden */
  98663. _position: Vector3;
  98664. /**
  98665. * Define the current local position of the camera in the scene
  98666. */
  98667. get position(): Vector3;
  98668. set position(newPosition: Vector3);
  98669. /**
  98670. * The vector the camera should consider as up.
  98671. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98672. */
  98673. upVector: Vector3;
  98674. /**
  98675. * Define the current limit on the left side for an orthographic camera
  98676. * In scene unit
  98677. */
  98678. orthoLeft: Nullable<number>;
  98679. /**
  98680. * Define the current limit on the right side for an orthographic camera
  98681. * In scene unit
  98682. */
  98683. orthoRight: Nullable<number>;
  98684. /**
  98685. * Define the current limit on the bottom side for an orthographic camera
  98686. * In scene unit
  98687. */
  98688. orthoBottom: Nullable<number>;
  98689. /**
  98690. * Define the current limit on the top side for an orthographic camera
  98691. * In scene unit
  98692. */
  98693. orthoTop: Nullable<number>;
  98694. /**
  98695. * Field Of View is set in Radians. (default is 0.8)
  98696. */
  98697. fov: number;
  98698. /**
  98699. * Define the minimum distance the camera can see from.
  98700. * This is important to note that the depth buffer are not infinite and the closer it starts
  98701. * the more your scene might encounter depth fighting issue.
  98702. */
  98703. minZ: number;
  98704. /**
  98705. * Define the maximum distance the camera can see to.
  98706. * This is important to note that the depth buffer are not infinite and the further it end
  98707. * the more your scene might encounter depth fighting issue.
  98708. */
  98709. maxZ: number;
  98710. /**
  98711. * Define the default inertia of the camera.
  98712. * This helps giving a smooth feeling to the camera movement.
  98713. */
  98714. inertia: number;
  98715. /**
  98716. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98717. */
  98718. mode: number;
  98719. /**
  98720. * Define whether the camera is intermediate.
  98721. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98722. */
  98723. isIntermediate: boolean;
  98724. /**
  98725. * Define the viewport of the camera.
  98726. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98727. */
  98728. viewport: Viewport;
  98729. /**
  98730. * Restricts the camera to viewing objects with the same layerMask.
  98731. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98732. */
  98733. layerMask: number;
  98734. /**
  98735. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98736. */
  98737. fovMode: number;
  98738. /**
  98739. * Rig mode of the camera.
  98740. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98741. * This is normally controlled byt the camera themselves as internal use.
  98742. */
  98743. cameraRigMode: number;
  98744. /**
  98745. * Defines the distance between both "eyes" in case of a RIG
  98746. */
  98747. interaxialDistance: number;
  98748. /**
  98749. * Defines if stereoscopic rendering is done side by side or over under.
  98750. */
  98751. isStereoscopicSideBySide: boolean;
  98752. /**
  98753. * 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
  98754. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98755. * else in the scene. (Eg. security camera)
  98756. *
  98757. * 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)
  98758. */
  98759. customRenderTargets: RenderTargetTexture[];
  98760. /**
  98761. * When set, the camera will render to this render target instead of the default canvas
  98762. *
  98763. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98764. */
  98765. outputRenderTarget: Nullable<RenderTargetTexture>;
  98766. /**
  98767. * Observable triggered when the camera view matrix has changed.
  98768. */
  98769. onViewMatrixChangedObservable: Observable<Camera>;
  98770. /**
  98771. * Observable triggered when the camera Projection matrix has changed.
  98772. */
  98773. onProjectionMatrixChangedObservable: Observable<Camera>;
  98774. /**
  98775. * Observable triggered when the inputs have been processed.
  98776. */
  98777. onAfterCheckInputsObservable: Observable<Camera>;
  98778. /**
  98779. * Observable triggered when reset has been called and applied to the camera.
  98780. */
  98781. onRestoreStateObservable: Observable<Camera>;
  98782. /**
  98783. * Is this camera a part of a rig system?
  98784. */
  98785. isRigCamera: boolean;
  98786. /**
  98787. * If isRigCamera set to true this will be set with the parent camera.
  98788. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98789. */
  98790. rigParent?: Camera;
  98791. /** @hidden */
  98792. _cameraRigParams: any;
  98793. /** @hidden */
  98794. _rigCameras: Camera[];
  98795. /** @hidden */
  98796. _rigPostProcess: Nullable<PostProcess>;
  98797. protected _webvrViewMatrix: Matrix;
  98798. /** @hidden */
  98799. _skipRendering: boolean;
  98800. /** @hidden */
  98801. _projectionMatrix: Matrix;
  98802. /** @hidden */
  98803. _postProcesses: Nullable<PostProcess>[];
  98804. /** @hidden */
  98805. _activeMeshes: SmartArray<AbstractMesh>;
  98806. protected _globalPosition: Vector3;
  98807. /** @hidden */
  98808. _computedViewMatrix: Matrix;
  98809. private _doNotComputeProjectionMatrix;
  98810. private _transformMatrix;
  98811. private _frustumPlanes;
  98812. private _refreshFrustumPlanes;
  98813. private _storedFov;
  98814. private _stateStored;
  98815. /**
  98816. * Instantiates a new camera object.
  98817. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98818. * @see http://doc.babylonjs.com/features/cameras
  98819. * @param name Defines the name of the camera in the scene
  98820. * @param position Defines the position of the camera
  98821. * @param scene Defines the scene the camera belongs too
  98822. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98823. */
  98824. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98825. /**
  98826. * Store current camera state (fov, position, etc..)
  98827. * @returns the camera
  98828. */
  98829. storeState(): Camera;
  98830. /**
  98831. * Restores the camera state values if it has been stored. You must call storeState() first
  98832. */
  98833. protected _restoreStateValues(): boolean;
  98834. /**
  98835. * Restored camera state. You must call storeState() first.
  98836. * @returns true if restored and false otherwise
  98837. */
  98838. restoreState(): boolean;
  98839. /**
  98840. * Gets the class name of the camera.
  98841. * @returns the class name
  98842. */
  98843. getClassName(): string;
  98844. /** @hidden */
  98845. readonly _isCamera: boolean;
  98846. /**
  98847. * Gets a string representation of the camera useful for debug purpose.
  98848. * @param fullDetails Defines that a more verboe level of logging is required
  98849. * @returns the string representation
  98850. */
  98851. toString(fullDetails?: boolean): string;
  98852. /**
  98853. * Gets the current world space position of the camera.
  98854. */
  98855. get globalPosition(): Vector3;
  98856. /**
  98857. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98858. * @returns the active meshe list
  98859. */
  98860. getActiveMeshes(): SmartArray<AbstractMesh>;
  98861. /**
  98862. * Check whether a mesh is part of the current active mesh list of the camera
  98863. * @param mesh Defines the mesh to check
  98864. * @returns true if active, false otherwise
  98865. */
  98866. isActiveMesh(mesh: Mesh): boolean;
  98867. /**
  98868. * Is this camera ready to be used/rendered
  98869. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98870. * @return true if the camera is ready
  98871. */
  98872. isReady(completeCheck?: boolean): boolean;
  98873. /** @hidden */
  98874. _initCache(): void;
  98875. /** @hidden */
  98876. _updateCache(ignoreParentClass?: boolean): void;
  98877. /** @hidden */
  98878. _isSynchronized(): boolean;
  98879. /** @hidden */
  98880. _isSynchronizedViewMatrix(): boolean;
  98881. /** @hidden */
  98882. _isSynchronizedProjectionMatrix(): boolean;
  98883. /**
  98884. * Attach the input controls to a specific dom element to get the input from.
  98885. * @param element Defines the element the controls should be listened from
  98886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98887. */
  98888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98889. /**
  98890. * Detach the current controls from the specified dom element.
  98891. * @param element Defines the element to stop listening the inputs from
  98892. */
  98893. detachControl(element: HTMLElement): void;
  98894. /**
  98895. * Update the camera state according to the different inputs gathered during the frame.
  98896. */
  98897. update(): void;
  98898. /** @hidden */
  98899. _checkInputs(): void;
  98900. /** @hidden */
  98901. get rigCameras(): Camera[];
  98902. /**
  98903. * Gets the post process used by the rig cameras
  98904. */
  98905. get rigPostProcess(): Nullable<PostProcess>;
  98906. /**
  98907. * Internal, gets the first post proces.
  98908. * @returns the first post process to be run on this camera.
  98909. */
  98910. _getFirstPostProcess(): Nullable<PostProcess>;
  98911. private _cascadePostProcessesToRigCams;
  98912. /**
  98913. * Attach a post process to the camera.
  98914. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98915. * @param postProcess The post process to attach to the camera
  98916. * @param insertAt The position of the post process in case several of them are in use in the scene
  98917. * @returns the position the post process has been inserted at
  98918. */
  98919. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98920. /**
  98921. * Detach a post process to the camera.
  98922. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98923. * @param postProcess The post process to detach from the camera
  98924. */
  98925. detachPostProcess(postProcess: PostProcess): void;
  98926. /**
  98927. * Gets the current world matrix of the camera
  98928. */
  98929. getWorldMatrix(): Matrix;
  98930. /** @hidden */
  98931. _getViewMatrix(): Matrix;
  98932. /**
  98933. * Gets the current view matrix of the camera.
  98934. * @param force forces the camera to recompute the matrix without looking at the cached state
  98935. * @returns the view matrix
  98936. */
  98937. getViewMatrix(force?: boolean): Matrix;
  98938. /**
  98939. * Freeze the projection matrix.
  98940. * It will prevent the cache check of the camera projection compute and can speed up perf
  98941. * if no parameter of the camera are meant to change
  98942. * @param projection Defines manually a projection if necessary
  98943. */
  98944. freezeProjectionMatrix(projection?: Matrix): void;
  98945. /**
  98946. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98947. */
  98948. unfreezeProjectionMatrix(): void;
  98949. /**
  98950. * Gets the current projection matrix of the camera.
  98951. * @param force forces the camera to recompute the matrix without looking at the cached state
  98952. * @returns the projection matrix
  98953. */
  98954. getProjectionMatrix(force?: boolean): Matrix;
  98955. /**
  98956. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98957. * @returns a Matrix
  98958. */
  98959. getTransformationMatrix(): Matrix;
  98960. private _updateFrustumPlanes;
  98961. /**
  98962. * Checks if a cullable object (mesh...) is in the camera frustum
  98963. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98964. * @param target The object to check
  98965. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98966. * @returns true if the object is in frustum otherwise false
  98967. */
  98968. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98969. /**
  98970. * Checks if a cullable object (mesh...) is in the camera frustum
  98971. * Unlike isInFrustum this cheks the full bounding box
  98972. * @param target The object to check
  98973. * @returns true if the object is in frustum otherwise false
  98974. */
  98975. isCompletelyInFrustum(target: ICullable): boolean;
  98976. /**
  98977. * Gets a ray in the forward direction from the camera.
  98978. * @param length Defines the length of the ray to create
  98979. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98980. * @param origin Defines the start point of the ray which defaults to the camera position
  98981. * @returns the forward ray
  98982. */
  98983. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98984. /**
  98985. * Releases resources associated with this node.
  98986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98988. */
  98989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98990. /** @hidden */
  98991. _isLeftCamera: boolean;
  98992. /**
  98993. * Gets the left camera of a rig setup in case of Rigged Camera
  98994. */
  98995. get isLeftCamera(): boolean;
  98996. /** @hidden */
  98997. _isRightCamera: boolean;
  98998. /**
  98999. * Gets the right camera of a rig setup in case of Rigged Camera
  99000. */
  99001. get isRightCamera(): boolean;
  99002. /**
  99003. * Gets the left camera of a rig setup in case of Rigged Camera
  99004. */
  99005. get leftCamera(): Nullable<FreeCamera>;
  99006. /**
  99007. * Gets the right camera of a rig setup in case of Rigged Camera
  99008. */
  99009. get rightCamera(): Nullable<FreeCamera>;
  99010. /**
  99011. * Gets the left camera target of a rig setup in case of Rigged Camera
  99012. * @returns the target position
  99013. */
  99014. getLeftTarget(): Nullable<Vector3>;
  99015. /**
  99016. * Gets the right camera target of a rig setup in case of Rigged Camera
  99017. * @returns the target position
  99018. */
  99019. getRightTarget(): Nullable<Vector3>;
  99020. /**
  99021. * @hidden
  99022. */
  99023. setCameraRigMode(mode: number, rigParams: any): void;
  99024. /** @hidden */
  99025. static _setStereoscopicRigMode(camera: Camera): void;
  99026. /** @hidden */
  99027. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99028. /** @hidden */
  99029. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99030. /** @hidden */
  99031. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99032. /** @hidden */
  99033. _getVRProjectionMatrix(): Matrix;
  99034. protected _updateCameraRotationMatrix(): void;
  99035. protected _updateWebVRCameraRotationMatrix(): void;
  99036. /**
  99037. * This function MUST be overwritten by the different WebVR cameras available.
  99038. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99039. * @hidden
  99040. */
  99041. _getWebVRProjectionMatrix(): Matrix;
  99042. /**
  99043. * This function MUST be overwritten by the different WebVR cameras available.
  99044. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99045. * @hidden
  99046. */
  99047. _getWebVRViewMatrix(): Matrix;
  99048. /** @hidden */
  99049. setCameraRigParameter(name: string, value: any): void;
  99050. /**
  99051. * needs to be overridden by children so sub has required properties to be copied
  99052. * @hidden
  99053. */
  99054. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99055. /**
  99056. * May need to be overridden by children
  99057. * @hidden
  99058. */
  99059. _updateRigCameras(): void;
  99060. /** @hidden */
  99061. _setupInputs(): void;
  99062. /**
  99063. * Serialiaze the camera setup to a json represention
  99064. * @returns the JSON representation
  99065. */
  99066. serialize(): any;
  99067. /**
  99068. * Clones the current camera.
  99069. * @param name The cloned camera name
  99070. * @returns the cloned camera
  99071. */
  99072. clone(name: string): Camera;
  99073. /**
  99074. * Gets the direction of the camera relative to a given local axis.
  99075. * @param localAxis Defines the reference axis to provide a relative direction.
  99076. * @return the direction
  99077. */
  99078. getDirection(localAxis: Vector3): Vector3;
  99079. /**
  99080. * Returns the current camera absolute rotation
  99081. */
  99082. get absoluteRotation(): Quaternion;
  99083. /**
  99084. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99085. * @param localAxis Defines the reference axis to provide a relative direction.
  99086. * @param result Defines the vector to store the result in
  99087. */
  99088. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99089. /**
  99090. * Gets a camera constructor for a given camera type
  99091. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99092. * @param name The name of the camera the result will be able to instantiate
  99093. * @param scene The scene the result will construct the camera in
  99094. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99095. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99096. * @returns a factory method to construc the camera
  99097. */
  99098. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99099. /**
  99100. * Compute the world matrix of the camera.
  99101. * @returns the camera world matrix
  99102. */
  99103. computeWorldMatrix(): Matrix;
  99104. /**
  99105. * Parse a JSON and creates the camera from the parsed information
  99106. * @param parsedCamera The JSON to parse
  99107. * @param scene The scene to instantiate the camera in
  99108. * @returns the newly constructed camera
  99109. */
  99110. static Parse(parsedCamera: any, scene: Scene): Camera;
  99111. }
  99112. }
  99113. declare module BABYLON {
  99114. /**
  99115. * Class containing static functions to help procedurally build meshes
  99116. */
  99117. export class DiscBuilder {
  99118. /**
  99119. * Creates a plane polygonal mesh. By default, this is a disc
  99120. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99121. * * 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
  99122. * * 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
  99123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99126. * @param name defines the name of the mesh
  99127. * @param options defines the options used to create the mesh
  99128. * @param scene defines the hosting scene
  99129. * @returns the plane polygonal mesh
  99130. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99131. */
  99132. static CreateDisc(name: string, options: {
  99133. radius?: number;
  99134. tessellation?: number;
  99135. arc?: number;
  99136. updatable?: boolean;
  99137. sideOrientation?: number;
  99138. frontUVs?: Vector4;
  99139. backUVs?: Vector4;
  99140. }, scene?: Nullable<Scene>): Mesh;
  99141. }
  99142. }
  99143. declare module BABYLON {
  99144. /**
  99145. * This represents all the required information to add a fresnel effect on a material:
  99146. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99147. */
  99148. export class FresnelParameters {
  99149. private _isEnabled;
  99150. /**
  99151. * Define if the fresnel effect is enable or not.
  99152. */
  99153. get isEnabled(): boolean;
  99154. set isEnabled(value: boolean);
  99155. /**
  99156. * Define the color used on edges (grazing angle)
  99157. */
  99158. leftColor: Color3;
  99159. /**
  99160. * Define the color used on center
  99161. */
  99162. rightColor: Color3;
  99163. /**
  99164. * Define bias applied to computed fresnel term
  99165. */
  99166. bias: number;
  99167. /**
  99168. * Defined the power exponent applied to fresnel term
  99169. */
  99170. power: number;
  99171. /**
  99172. * Clones the current fresnel and its valuues
  99173. * @returns a clone fresnel configuration
  99174. */
  99175. clone(): FresnelParameters;
  99176. /**
  99177. * Serializes the current fresnel parameters to a JSON representation.
  99178. * @return the JSON serialization
  99179. */
  99180. serialize(): any;
  99181. /**
  99182. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99183. * @param parsedFresnelParameters Define the JSON representation
  99184. * @returns the parsed parameters
  99185. */
  99186. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99187. }
  99188. }
  99189. declare module BABYLON {
  99190. /**
  99191. * Base class of materials working in push mode in babylon JS
  99192. * @hidden
  99193. */
  99194. export class PushMaterial extends Material {
  99195. protected _activeEffect: Effect;
  99196. protected _normalMatrix: Matrix;
  99197. /**
  99198. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99199. * This means that the material can keep using a previous shader while a new one is being compiled.
  99200. * This is mostly used when shader parallel compilation is supported (true by default)
  99201. */
  99202. allowShaderHotSwapping: boolean;
  99203. constructor(name: string, scene: Scene);
  99204. getEffect(): Effect;
  99205. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99206. /**
  99207. * Binds the given world matrix to the active effect
  99208. *
  99209. * @param world the matrix to bind
  99210. */
  99211. bindOnlyWorldMatrix(world: Matrix): void;
  99212. /**
  99213. * Binds the given normal matrix to the active effect
  99214. *
  99215. * @param normalMatrix the matrix to bind
  99216. */
  99217. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99218. bind(world: Matrix, mesh?: Mesh): void;
  99219. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99220. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99221. }
  99222. }
  99223. declare module BABYLON {
  99224. /**
  99225. * This groups all the flags used to control the materials channel.
  99226. */
  99227. export class MaterialFlags {
  99228. private static _DiffuseTextureEnabled;
  99229. /**
  99230. * Are diffuse textures enabled in the application.
  99231. */
  99232. static get DiffuseTextureEnabled(): boolean;
  99233. static set DiffuseTextureEnabled(value: boolean);
  99234. private static _AmbientTextureEnabled;
  99235. /**
  99236. * Are ambient textures enabled in the application.
  99237. */
  99238. static get AmbientTextureEnabled(): boolean;
  99239. static set AmbientTextureEnabled(value: boolean);
  99240. private static _OpacityTextureEnabled;
  99241. /**
  99242. * Are opacity textures enabled in the application.
  99243. */
  99244. static get OpacityTextureEnabled(): boolean;
  99245. static set OpacityTextureEnabled(value: boolean);
  99246. private static _ReflectionTextureEnabled;
  99247. /**
  99248. * Are reflection textures enabled in the application.
  99249. */
  99250. static get ReflectionTextureEnabled(): boolean;
  99251. static set ReflectionTextureEnabled(value: boolean);
  99252. private static _EmissiveTextureEnabled;
  99253. /**
  99254. * Are emissive textures enabled in the application.
  99255. */
  99256. static get EmissiveTextureEnabled(): boolean;
  99257. static set EmissiveTextureEnabled(value: boolean);
  99258. private static _SpecularTextureEnabled;
  99259. /**
  99260. * Are specular textures enabled in the application.
  99261. */
  99262. static get SpecularTextureEnabled(): boolean;
  99263. static set SpecularTextureEnabled(value: boolean);
  99264. private static _BumpTextureEnabled;
  99265. /**
  99266. * Are bump textures enabled in the application.
  99267. */
  99268. static get BumpTextureEnabled(): boolean;
  99269. static set BumpTextureEnabled(value: boolean);
  99270. private static _LightmapTextureEnabled;
  99271. /**
  99272. * Are lightmap textures enabled in the application.
  99273. */
  99274. static get LightmapTextureEnabled(): boolean;
  99275. static set LightmapTextureEnabled(value: boolean);
  99276. private static _RefractionTextureEnabled;
  99277. /**
  99278. * Are refraction textures enabled in the application.
  99279. */
  99280. static get RefractionTextureEnabled(): boolean;
  99281. static set RefractionTextureEnabled(value: boolean);
  99282. private static _ColorGradingTextureEnabled;
  99283. /**
  99284. * Are color grading textures enabled in the application.
  99285. */
  99286. static get ColorGradingTextureEnabled(): boolean;
  99287. static set ColorGradingTextureEnabled(value: boolean);
  99288. private static _FresnelEnabled;
  99289. /**
  99290. * Are fresnels enabled in the application.
  99291. */
  99292. static get FresnelEnabled(): boolean;
  99293. static set FresnelEnabled(value: boolean);
  99294. private static _ClearCoatTextureEnabled;
  99295. /**
  99296. * Are clear coat textures enabled in the application.
  99297. */
  99298. static get ClearCoatTextureEnabled(): boolean;
  99299. static set ClearCoatTextureEnabled(value: boolean);
  99300. private static _ClearCoatBumpTextureEnabled;
  99301. /**
  99302. * Are clear coat bump textures enabled in the application.
  99303. */
  99304. static get ClearCoatBumpTextureEnabled(): boolean;
  99305. static set ClearCoatBumpTextureEnabled(value: boolean);
  99306. private static _ClearCoatTintTextureEnabled;
  99307. /**
  99308. * Are clear coat tint textures enabled in the application.
  99309. */
  99310. static get ClearCoatTintTextureEnabled(): boolean;
  99311. static set ClearCoatTintTextureEnabled(value: boolean);
  99312. private static _SheenTextureEnabled;
  99313. /**
  99314. * Are sheen textures enabled in the application.
  99315. */
  99316. static get SheenTextureEnabled(): boolean;
  99317. static set SheenTextureEnabled(value: boolean);
  99318. private static _AnisotropicTextureEnabled;
  99319. /**
  99320. * Are anisotropic textures enabled in the application.
  99321. */
  99322. static get AnisotropicTextureEnabled(): boolean;
  99323. static set AnisotropicTextureEnabled(value: boolean);
  99324. private static _ThicknessTextureEnabled;
  99325. /**
  99326. * Are thickness textures enabled in the application.
  99327. */
  99328. static get ThicknessTextureEnabled(): boolean;
  99329. static set ThicknessTextureEnabled(value: boolean);
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. /** @hidden */
  99334. export var defaultFragmentDeclaration: {
  99335. name: string;
  99336. shader: string;
  99337. };
  99338. }
  99339. declare module BABYLON {
  99340. /** @hidden */
  99341. export var defaultUboDeclaration: {
  99342. name: string;
  99343. shader: string;
  99344. };
  99345. }
  99346. declare module BABYLON {
  99347. /** @hidden */
  99348. export var lightFragmentDeclaration: {
  99349. name: string;
  99350. shader: string;
  99351. };
  99352. }
  99353. declare module BABYLON {
  99354. /** @hidden */
  99355. export var lightUboDeclaration: {
  99356. name: string;
  99357. shader: string;
  99358. };
  99359. }
  99360. declare module BABYLON {
  99361. /** @hidden */
  99362. export var lightsFragmentFunctions: {
  99363. name: string;
  99364. shader: string;
  99365. };
  99366. }
  99367. declare module BABYLON {
  99368. /** @hidden */
  99369. export var shadowsFragmentFunctions: {
  99370. name: string;
  99371. shader: string;
  99372. };
  99373. }
  99374. declare module BABYLON {
  99375. /** @hidden */
  99376. export var fresnelFunction: {
  99377. name: string;
  99378. shader: string;
  99379. };
  99380. }
  99381. declare module BABYLON {
  99382. /** @hidden */
  99383. export var reflectionFunction: {
  99384. name: string;
  99385. shader: string;
  99386. };
  99387. }
  99388. declare module BABYLON {
  99389. /** @hidden */
  99390. export var bumpFragmentFunctions: {
  99391. name: string;
  99392. shader: string;
  99393. };
  99394. }
  99395. declare module BABYLON {
  99396. /** @hidden */
  99397. export var logDepthDeclaration: {
  99398. name: string;
  99399. shader: string;
  99400. };
  99401. }
  99402. declare module BABYLON {
  99403. /** @hidden */
  99404. export var bumpFragment: {
  99405. name: string;
  99406. shader: string;
  99407. };
  99408. }
  99409. declare module BABYLON {
  99410. /** @hidden */
  99411. export var depthPrePass: {
  99412. name: string;
  99413. shader: string;
  99414. };
  99415. }
  99416. declare module BABYLON {
  99417. /** @hidden */
  99418. export var lightFragment: {
  99419. name: string;
  99420. shader: string;
  99421. };
  99422. }
  99423. declare module BABYLON {
  99424. /** @hidden */
  99425. export var logDepthFragment: {
  99426. name: string;
  99427. shader: string;
  99428. };
  99429. }
  99430. declare module BABYLON {
  99431. /** @hidden */
  99432. export var defaultPixelShader: {
  99433. name: string;
  99434. shader: string;
  99435. };
  99436. }
  99437. declare module BABYLON {
  99438. /** @hidden */
  99439. export var defaultVertexDeclaration: {
  99440. name: string;
  99441. shader: string;
  99442. };
  99443. }
  99444. declare module BABYLON {
  99445. /** @hidden */
  99446. export var bumpVertexDeclaration: {
  99447. name: string;
  99448. shader: string;
  99449. };
  99450. }
  99451. declare module BABYLON {
  99452. /** @hidden */
  99453. export var bumpVertex: {
  99454. name: string;
  99455. shader: string;
  99456. };
  99457. }
  99458. declare module BABYLON {
  99459. /** @hidden */
  99460. export var fogVertex: {
  99461. name: string;
  99462. shader: string;
  99463. };
  99464. }
  99465. declare module BABYLON {
  99466. /** @hidden */
  99467. export var shadowsVertex: {
  99468. name: string;
  99469. shader: string;
  99470. };
  99471. }
  99472. declare module BABYLON {
  99473. /** @hidden */
  99474. export var pointCloudVertex: {
  99475. name: string;
  99476. shader: string;
  99477. };
  99478. }
  99479. declare module BABYLON {
  99480. /** @hidden */
  99481. export var logDepthVertex: {
  99482. name: string;
  99483. shader: string;
  99484. };
  99485. }
  99486. declare module BABYLON {
  99487. /** @hidden */
  99488. export var defaultVertexShader: {
  99489. name: string;
  99490. shader: string;
  99491. };
  99492. }
  99493. declare module BABYLON {
  99494. /** @hidden */
  99495. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99496. MAINUV1: boolean;
  99497. MAINUV2: boolean;
  99498. DIFFUSE: boolean;
  99499. DIFFUSEDIRECTUV: number;
  99500. AMBIENT: boolean;
  99501. AMBIENTDIRECTUV: number;
  99502. OPACITY: boolean;
  99503. OPACITYDIRECTUV: number;
  99504. OPACITYRGB: boolean;
  99505. REFLECTION: boolean;
  99506. EMISSIVE: boolean;
  99507. EMISSIVEDIRECTUV: number;
  99508. SPECULAR: boolean;
  99509. SPECULARDIRECTUV: number;
  99510. BUMP: boolean;
  99511. BUMPDIRECTUV: number;
  99512. PARALLAX: boolean;
  99513. PARALLAXOCCLUSION: boolean;
  99514. SPECULAROVERALPHA: boolean;
  99515. CLIPPLANE: boolean;
  99516. CLIPPLANE2: boolean;
  99517. CLIPPLANE3: boolean;
  99518. CLIPPLANE4: boolean;
  99519. CLIPPLANE5: boolean;
  99520. CLIPPLANE6: boolean;
  99521. ALPHATEST: boolean;
  99522. DEPTHPREPASS: boolean;
  99523. ALPHAFROMDIFFUSE: boolean;
  99524. POINTSIZE: boolean;
  99525. FOG: boolean;
  99526. SPECULARTERM: boolean;
  99527. DIFFUSEFRESNEL: boolean;
  99528. OPACITYFRESNEL: boolean;
  99529. REFLECTIONFRESNEL: boolean;
  99530. REFRACTIONFRESNEL: boolean;
  99531. EMISSIVEFRESNEL: boolean;
  99532. FRESNEL: boolean;
  99533. NORMAL: boolean;
  99534. UV1: boolean;
  99535. UV2: boolean;
  99536. VERTEXCOLOR: boolean;
  99537. VERTEXALPHA: boolean;
  99538. NUM_BONE_INFLUENCERS: number;
  99539. BonesPerMesh: number;
  99540. BONETEXTURE: boolean;
  99541. INSTANCES: boolean;
  99542. GLOSSINESS: boolean;
  99543. ROUGHNESS: boolean;
  99544. EMISSIVEASILLUMINATION: boolean;
  99545. LINKEMISSIVEWITHDIFFUSE: boolean;
  99546. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99547. LIGHTMAP: boolean;
  99548. LIGHTMAPDIRECTUV: number;
  99549. OBJECTSPACE_NORMALMAP: boolean;
  99550. USELIGHTMAPASSHADOWMAP: boolean;
  99551. REFLECTIONMAP_3D: boolean;
  99552. REFLECTIONMAP_SPHERICAL: boolean;
  99553. REFLECTIONMAP_PLANAR: boolean;
  99554. REFLECTIONMAP_CUBIC: boolean;
  99555. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99556. REFLECTIONMAP_PROJECTION: boolean;
  99557. REFLECTIONMAP_SKYBOX: boolean;
  99558. REFLECTIONMAP_EXPLICIT: boolean;
  99559. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99560. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99561. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99562. INVERTCUBICMAP: boolean;
  99563. LOGARITHMICDEPTH: boolean;
  99564. REFRACTION: boolean;
  99565. REFRACTIONMAP_3D: boolean;
  99566. REFLECTIONOVERALPHA: boolean;
  99567. TWOSIDEDLIGHTING: boolean;
  99568. SHADOWFLOAT: boolean;
  99569. MORPHTARGETS: boolean;
  99570. MORPHTARGETS_NORMAL: boolean;
  99571. MORPHTARGETS_TANGENT: boolean;
  99572. MORPHTARGETS_UV: boolean;
  99573. NUM_MORPH_INFLUENCERS: number;
  99574. NONUNIFORMSCALING: boolean;
  99575. PREMULTIPLYALPHA: boolean;
  99576. IMAGEPROCESSING: boolean;
  99577. VIGNETTE: boolean;
  99578. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99579. VIGNETTEBLENDMODEOPAQUE: boolean;
  99580. TONEMAPPING: boolean;
  99581. TONEMAPPING_ACES: boolean;
  99582. CONTRAST: boolean;
  99583. COLORCURVES: boolean;
  99584. COLORGRADING: boolean;
  99585. COLORGRADING3D: boolean;
  99586. SAMPLER3DGREENDEPTH: boolean;
  99587. SAMPLER3DBGRMAP: boolean;
  99588. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99589. MULTIVIEW: boolean;
  99590. /**
  99591. * If the reflection texture on this material is in linear color space
  99592. * @hidden
  99593. */
  99594. IS_REFLECTION_LINEAR: boolean;
  99595. /**
  99596. * If the refraction texture on this material is in linear color space
  99597. * @hidden
  99598. */
  99599. IS_REFRACTION_LINEAR: boolean;
  99600. EXPOSURE: boolean;
  99601. constructor();
  99602. setReflectionMode(modeToEnable: string): void;
  99603. }
  99604. /**
  99605. * This is the default material used in Babylon. It is the best trade off between quality
  99606. * and performances.
  99607. * @see http://doc.babylonjs.com/babylon101/materials
  99608. */
  99609. export class StandardMaterial extends PushMaterial {
  99610. private _diffuseTexture;
  99611. /**
  99612. * The basic texture of the material as viewed under a light.
  99613. */
  99614. diffuseTexture: Nullable<BaseTexture>;
  99615. private _ambientTexture;
  99616. /**
  99617. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99618. */
  99619. ambientTexture: Nullable<BaseTexture>;
  99620. private _opacityTexture;
  99621. /**
  99622. * Define the transparency of the material from a texture.
  99623. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99624. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99625. */
  99626. opacityTexture: Nullable<BaseTexture>;
  99627. private _reflectionTexture;
  99628. /**
  99629. * Define the texture used to display the reflection.
  99630. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99631. */
  99632. reflectionTexture: Nullable<BaseTexture>;
  99633. private _emissiveTexture;
  99634. /**
  99635. * Define texture of the material as if self lit.
  99636. * This will be mixed in the final result even in the absence of light.
  99637. */
  99638. emissiveTexture: Nullable<BaseTexture>;
  99639. private _specularTexture;
  99640. /**
  99641. * Define how the color and intensity of the highlight given by the light in the material.
  99642. */
  99643. specularTexture: Nullable<BaseTexture>;
  99644. private _bumpTexture;
  99645. /**
  99646. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99647. * 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.
  99648. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99649. */
  99650. bumpTexture: Nullable<BaseTexture>;
  99651. private _lightmapTexture;
  99652. /**
  99653. * Complex lighting can be computationally expensive to compute at runtime.
  99654. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99655. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99656. */
  99657. lightmapTexture: Nullable<BaseTexture>;
  99658. private _refractionTexture;
  99659. /**
  99660. * Define the texture used to display the refraction.
  99661. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99662. */
  99663. refractionTexture: Nullable<BaseTexture>;
  99664. /**
  99665. * The color of the material lit by the environmental background lighting.
  99666. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99667. */
  99668. ambientColor: Color3;
  99669. /**
  99670. * The basic color of the material as viewed under a light.
  99671. */
  99672. diffuseColor: Color3;
  99673. /**
  99674. * Define how the color and intensity of the highlight given by the light in the material.
  99675. */
  99676. specularColor: Color3;
  99677. /**
  99678. * Define the color of the material as if self lit.
  99679. * This will be mixed in the final result even in the absence of light.
  99680. */
  99681. emissiveColor: Color3;
  99682. /**
  99683. * Defines how sharp are the highlights in the material.
  99684. * The bigger the value the sharper giving a more glossy feeling to the result.
  99685. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99686. */
  99687. specularPower: number;
  99688. private _useAlphaFromDiffuseTexture;
  99689. /**
  99690. * Does the transparency come from the diffuse texture alpha channel.
  99691. */
  99692. useAlphaFromDiffuseTexture: boolean;
  99693. private _useEmissiveAsIllumination;
  99694. /**
  99695. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99696. */
  99697. useEmissiveAsIllumination: boolean;
  99698. private _linkEmissiveWithDiffuse;
  99699. /**
  99700. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99701. * the emissive level when the final color is close to one.
  99702. */
  99703. linkEmissiveWithDiffuse: boolean;
  99704. private _useSpecularOverAlpha;
  99705. /**
  99706. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99707. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99708. */
  99709. useSpecularOverAlpha: boolean;
  99710. private _useReflectionOverAlpha;
  99711. /**
  99712. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99713. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99714. */
  99715. useReflectionOverAlpha: boolean;
  99716. private _disableLighting;
  99717. /**
  99718. * Does lights from the scene impacts this material.
  99719. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99720. */
  99721. disableLighting: boolean;
  99722. private _useObjectSpaceNormalMap;
  99723. /**
  99724. * Allows using an object space normal map (instead of tangent space).
  99725. */
  99726. useObjectSpaceNormalMap: boolean;
  99727. private _useParallax;
  99728. /**
  99729. * Is parallax enabled or not.
  99730. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99731. */
  99732. useParallax: boolean;
  99733. private _useParallaxOcclusion;
  99734. /**
  99735. * Is parallax occlusion enabled or not.
  99736. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99737. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99738. */
  99739. useParallaxOcclusion: boolean;
  99740. /**
  99741. * 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.
  99742. */
  99743. parallaxScaleBias: number;
  99744. private _roughness;
  99745. /**
  99746. * Helps to define how blurry the reflections should appears in the material.
  99747. */
  99748. roughness: number;
  99749. /**
  99750. * In case of refraction, define the value of the index of refraction.
  99751. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99752. */
  99753. indexOfRefraction: number;
  99754. /**
  99755. * Invert the refraction texture alongside the y axis.
  99756. * It can be useful with procedural textures or probe for instance.
  99757. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99758. */
  99759. invertRefractionY: boolean;
  99760. /**
  99761. * Defines the alpha limits in alpha test mode.
  99762. */
  99763. alphaCutOff: number;
  99764. private _useLightmapAsShadowmap;
  99765. /**
  99766. * In case of light mapping, define whether the map contains light or shadow informations.
  99767. */
  99768. useLightmapAsShadowmap: boolean;
  99769. private _diffuseFresnelParameters;
  99770. /**
  99771. * Define the diffuse fresnel parameters of the material.
  99772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99773. */
  99774. diffuseFresnelParameters: FresnelParameters;
  99775. private _opacityFresnelParameters;
  99776. /**
  99777. * Define the opacity fresnel parameters of the material.
  99778. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99779. */
  99780. opacityFresnelParameters: FresnelParameters;
  99781. private _reflectionFresnelParameters;
  99782. /**
  99783. * Define the reflection fresnel parameters of the material.
  99784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99785. */
  99786. reflectionFresnelParameters: FresnelParameters;
  99787. private _refractionFresnelParameters;
  99788. /**
  99789. * Define the refraction fresnel parameters of the material.
  99790. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99791. */
  99792. refractionFresnelParameters: FresnelParameters;
  99793. private _emissiveFresnelParameters;
  99794. /**
  99795. * Define the emissive fresnel parameters of the material.
  99796. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99797. */
  99798. emissiveFresnelParameters: FresnelParameters;
  99799. private _useReflectionFresnelFromSpecular;
  99800. /**
  99801. * If true automatically deducts the fresnels values from the material specularity.
  99802. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99803. */
  99804. useReflectionFresnelFromSpecular: boolean;
  99805. private _useGlossinessFromSpecularMapAlpha;
  99806. /**
  99807. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99808. */
  99809. useGlossinessFromSpecularMapAlpha: boolean;
  99810. private _maxSimultaneousLights;
  99811. /**
  99812. * Defines the maximum number of lights that can be used in the material
  99813. */
  99814. maxSimultaneousLights: number;
  99815. private _invertNormalMapX;
  99816. /**
  99817. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99818. */
  99819. invertNormalMapX: boolean;
  99820. private _invertNormalMapY;
  99821. /**
  99822. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99823. */
  99824. invertNormalMapY: boolean;
  99825. private _twoSidedLighting;
  99826. /**
  99827. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99828. */
  99829. twoSidedLighting: boolean;
  99830. /**
  99831. * Default configuration related to image processing available in the standard Material.
  99832. */
  99833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99834. /**
  99835. * Gets the image processing configuration used either in this material.
  99836. */
  99837. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99838. /**
  99839. * Sets the Default image processing configuration used either in the this material.
  99840. *
  99841. * If sets to null, the scene one is in use.
  99842. */
  99843. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99844. /**
  99845. * Keep track of the image processing observer to allow dispose and replace.
  99846. */
  99847. private _imageProcessingObserver;
  99848. /**
  99849. * Attaches a new image processing configuration to the Standard Material.
  99850. * @param configuration
  99851. */
  99852. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99853. /**
  99854. * Gets wether the color curves effect is enabled.
  99855. */
  99856. get cameraColorCurvesEnabled(): boolean;
  99857. /**
  99858. * Sets wether the color curves effect is enabled.
  99859. */
  99860. set cameraColorCurvesEnabled(value: boolean);
  99861. /**
  99862. * Gets wether the color grading effect is enabled.
  99863. */
  99864. get cameraColorGradingEnabled(): boolean;
  99865. /**
  99866. * Gets wether the color grading effect is enabled.
  99867. */
  99868. set cameraColorGradingEnabled(value: boolean);
  99869. /**
  99870. * Gets wether tonemapping is enabled or not.
  99871. */
  99872. get cameraToneMappingEnabled(): boolean;
  99873. /**
  99874. * Sets wether tonemapping is enabled or not
  99875. */
  99876. set cameraToneMappingEnabled(value: boolean);
  99877. /**
  99878. * The camera exposure used on this material.
  99879. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99880. * This corresponds to a photographic exposure.
  99881. */
  99882. get cameraExposure(): number;
  99883. /**
  99884. * The camera exposure used on this material.
  99885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99886. * This corresponds to a photographic exposure.
  99887. */
  99888. set cameraExposure(value: number);
  99889. /**
  99890. * Gets The camera contrast used on this material.
  99891. */
  99892. get cameraContrast(): number;
  99893. /**
  99894. * Sets The camera contrast used on this material.
  99895. */
  99896. set cameraContrast(value: number);
  99897. /**
  99898. * Gets the Color Grading 2D Lookup Texture.
  99899. */
  99900. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99901. /**
  99902. * Sets the Color Grading 2D Lookup Texture.
  99903. */
  99904. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99905. /**
  99906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99908. * 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;
  99909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99910. */
  99911. get cameraColorCurves(): Nullable<ColorCurves>;
  99912. /**
  99913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99915. * 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;
  99916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99917. */
  99918. set cameraColorCurves(value: Nullable<ColorCurves>);
  99919. /**
  99920. * Custom callback helping to override the default shader used in the material.
  99921. */
  99922. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99923. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99924. protected _worldViewProjectionMatrix: Matrix;
  99925. protected _globalAmbientColor: Color3;
  99926. protected _useLogarithmicDepth: boolean;
  99927. protected _rebuildInParallel: boolean;
  99928. /**
  99929. * Instantiates a new standard material.
  99930. * This is the default material used in Babylon. It is the best trade off between quality
  99931. * and performances.
  99932. * @see http://doc.babylonjs.com/babylon101/materials
  99933. * @param name Define the name of the material in the scene
  99934. * @param scene Define the scene the material belong to
  99935. */
  99936. constructor(name: string, scene: Scene);
  99937. /**
  99938. * Gets a boolean indicating that current material needs to register RTT
  99939. */
  99940. get hasRenderTargetTextures(): boolean;
  99941. /**
  99942. * Gets the current class name of the material e.g. "StandardMaterial"
  99943. * Mainly use in serialization.
  99944. * @returns the class name
  99945. */
  99946. getClassName(): string;
  99947. /**
  99948. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99949. * You can try switching to logarithmic depth.
  99950. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99951. */
  99952. get useLogarithmicDepth(): boolean;
  99953. set useLogarithmicDepth(value: boolean);
  99954. /**
  99955. * Specifies if the material will require alpha blending
  99956. * @returns a boolean specifying if alpha blending is needed
  99957. */
  99958. needAlphaBlending(): boolean;
  99959. /**
  99960. * Specifies if this material should be rendered in alpha test mode
  99961. * @returns a boolean specifying if an alpha test is needed.
  99962. */
  99963. needAlphaTesting(): boolean;
  99964. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99965. /**
  99966. * Get the texture used for alpha test purpose.
  99967. * @returns the diffuse texture in case of the standard material.
  99968. */
  99969. getAlphaTestTexture(): Nullable<BaseTexture>;
  99970. /**
  99971. * Get if the submesh is ready to be used and all its information available.
  99972. * Child classes can use it to update shaders
  99973. * @param mesh defines the mesh to check
  99974. * @param subMesh defines which submesh to check
  99975. * @param useInstances specifies that instances should be used
  99976. * @returns a boolean indicating that the submesh is ready or not
  99977. */
  99978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99979. /**
  99980. * Builds the material UBO layouts.
  99981. * Used internally during the effect preparation.
  99982. */
  99983. buildUniformLayout(): void;
  99984. /**
  99985. * Unbinds the material from the mesh
  99986. */
  99987. unbind(): void;
  99988. /**
  99989. * Binds the submesh to this material by preparing the effect and shader to draw
  99990. * @param world defines the world transformation matrix
  99991. * @param mesh defines the mesh containing the submesh
  99992. * @param subMesh defines the submesh to bind the material to
  99993. */
  99994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99995. /**
  99996. * Get the list of animatables in the material.
  99997. * @returns the list of animatables object used in the material
  99998. */
  99999. getAnimatables(): IAnimatable[];
  100000. /**
  100001. * Gets the active textures from the material
  100002. * @returns an array of textures
  100003. */
  100004. getActiveTextures(): BaseTexture[];
  100005. /**
  100006. * Specifies if the material uses a texture
  100007. * @param texture defines the texture to check against the material
  100008. * @returns a boolean specifying if the material uses the texture
  100009. */
  100010. hasTexture(texture: BaseTexture): boolean;
  100011. /**
  100012. * Disposes the material
  100013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100015. */
  100016. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100017. /**
  100018. * Makes a duplicate of the material, and gives it a new name
  100019. * @param name defines the new name for the duplicated material
  100020. * @returns the cloned material
  100021. */
  100022. clone(name: string): StandardMaterial;
  100023. /**
  100024. * Serializes this material in a JSON representation
  100025. * @returns the serialized material object
  100026. */
  100027. serialize(): any;
  100028. /**
  100029. * Creates a standard material from parsed material data
  100030. * @param source defines the JSON representation of the material
  100031. * @param scene defines the hosting scene
  100032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100033. * @returns a new standard material
  100034. */
  100035. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100036. /**
  100037. * Are diffuse textures enabled in the application.
  100038. */
  100039. static get DiffuseTextureEnabled(): boolean;
  100040. static set DiffuseTextureEnabled(value: boolean);
  100041. /**
  100042. * Are ambient textures enabled in the application.
  100043. */
  100044. static get AmbientTextureEnabled(): boolean;
  100045. static set AmbientTextureEnabled(value: boolean);
  100046. /**
  100047. * Are opacity textures enabled in the application.
  100048. */
  100049. static get OpacityTextureEnabled(): boolean;
  100050. static set OpacityTextureEnabled(value: boolean);
  100051. /**
  100052. * Are reflection textures enabled in the application.
  100053. */
  100054. static get ReflectionTextureEnabled(): boolean;
  100055. static set ReflectionTextureEnabled(value: boolean);
  100056. /**
  100057. * Are emissive textures enabled in the application.
  100058. */
  100059. static get EmissiveTextureEnabled(): boolean;
  100060. static set EmissiveTextureEnabled(value: boolean);
  100061. /**
  100062. * Are specular textures enabled in the application.
  100063. */
  100064. static get SpecularTextureEnabled(): boolean;
  100065. static set SpecularTextureEnabled(value: boolean);
  100066. /**
  100067. * Are bump textures enabled in the application.
  100068. */
  100069. static get BumpTextureEnabled(): boolean;
  100070. static set BumpTextureEnabled(value: boolean);
  100071. /**
  100072. * Are lightmap textures enabled in the application.
  100073. */
  100074. static get LightmapTextureEnabled(): boolean;
  100075. static set LightmapTextureEnabled(value: boolean);
  100076. /**
  100077. * Are refraction textures enabled in the application.
  100078. */
  100079. static get RefractionTextureEnabled(): boolean;
  100080. static set RefractionTextureEnabled(value: boolean);
  100081. /**
  100082. * Are color grading textures enabled in the application.
  100083. */
  100084. static get ColorGradingTextureEnabled(): boolean;
  100085. static set ColorGradingTextureEnabled(value: boolean);
  100086. /**
  100087. * Are fresnels enabled in the application.
  100088. */
  100089. static get FresnelEnabled(): boolean;
  100090. static set FresnelEnabled(value: boolean);
  100091. }
  100092. }
  100093. declare module BABYLON {
  100094. /**
  100095. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100096. *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.
  100097. * The SPS is also a particle system. It provides some methods to manage the particles.
  100098. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100099. *
  100100. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100101. */
  100102. export class SolidParticleSystem implements IDisposable {
  100103. /**
  100104. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100105. * Example : var p = SPS.particles[i];
  100106. */
  100107. particles: SolidParticle[];
  100108. /**
  100109. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100110. */
  100111. nbParticles: number;
  100112. /**
  100113. * If the particles must ever face the camera (default false). Useful for planar particles.
  100114. */
  100115. billboard: boolean;
  100116. /**
  100117. * Recompute normals when adding a shape
  100118. */
  100119. recomputeNormals: boolean;
  100120. /**
  100121. * This a counter ofr your own usage. It's not set by any SPS functions.
  100122. */
  100123. counter: number;
  100124. /**
  100125. * The SPS name. This name is also given to the underlying mesh.
  100126. */
  100127. name: string;
  100128. /**
  100129. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100130. */
  100131. mesh: Mesh;
  100132. /**
  100133. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100134. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100135. */
  100136. vars: any;
  100137. /**
  100138. * This array is populated when the SPS is set as 'pickable'.
  100139. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100140. * Each element of this array is an object `{idx: int, faceId: int}`.
  100141. * `idx` is the picked particle index in the `SPS.particles` array
  100142. * `faceId` is the picked face index counted within this particle.
  100143. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100144. */
  100145. pickedParticles: {
  100146. idx: number;
  100147. faceId: number;
  100148. }[];
  100149. /**
  100150. * This array is populated when `enableDepthSort` is set to true.
  100151. * Each element of this array is an instance of the class DepthSortedParticle.
  100152. */
  100153. depthSortedParticles: DepthSortedParticle[];
  100154. /**
  100155. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100156. * @hidden
  100157. */
  100158. _bSphereOnly: boolean;
  100159. /**
  100160. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100161. * @hidden
  100162. */
  100163. _bSphereRadiusFactor: number;
  100164. private _scene;
  100165. private _positions;
  100166. private _indices;
  100167. private _normals;
  100168. private _colors;
  100169. private _uvs;
  100170. private _indices32;
  100171. private _positions32;
  100172. private _normals32;
  100173. private _fixedNormal32;
  100174. private _colors32;
  100175. private _uvs32;
  100176. private _index;
  100177. private _updatable;
  100178. private _pickable;
  100179. private _isVisibilityBoxLocked;
  100180. private _alwaysVisible;
  100181. private _depthSort;
  100182. private _expandable;
  100183. private _shapeCounter;
  100184. private _copy;
  100185. private _color;
  100186. private _computeParticleColor;
  100187. private _computeParticleTexture;
  100188. private _computeParticleRotation;
  100189. private _computeParticleVertex;
  100190. private _computeBoundingBox;
  100191. private _depthSortParticles;
  100192. private _camera;
  100193. private _mustUnrotateFixedNormals;
  100194. private _particlesIntersect;
  100195. private _needs32Bits;
  100196. private _isNotBuilt;
  100197. private _lastParticleId;
  100198. private _idxOfId;
  100199. private _multimaterialEnabled;
  100200. private _useModelMaterial;
  100201. private _indicesByMaterial;
  100202. private _materialIndexes;
  100203. private _depthSortFunction;
  100204. private _materialSortFunction;
  100205. private _materials;
  100206. private _multimaterial;
  100207. private _materialIndexesById;
  100208. private _defaultMaterial;
  100209. private _autoUpdateSubMeshes;
  100210. /**
  100211. * Creates a SPS (Solid Particle System) object.
  100212. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100213. * @param scene (Scene) is the scene in which the SPS is added.
  100214. * @param options defines the options of the sps e.g.
  100215. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100216. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100217. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100218. * * 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.
  100219. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100220. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100221. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100222. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100223. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100224. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100225. */
  100226. constructor(name: string, scene: Scene, options?: {
  100227. updatable?: boolean;
  100228. isPickable?: boolean;
  100229. enableDepthSort?: boolean;
  100230. particleIntersection?: boolean;
  100231. boundingSphereOnly?: boolean;
  100232. bSphereRadiusFactor?: number;
  100233. expandable?: boolean;
  100234. useModelMaterial?: boolean;
  100235. enableMultiMaterial?: boolean;
  100236. });
  100237. /**
  100238. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100239. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100240. * @returns the created mesh
  100241. */
  100242. buildMesh(): Mesh;
  100243. /**
  100244. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100245. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100246. * Thus the particles generated from `digest()` have their property `position` set yet.
  100247. * @param mesh ( Mesh ) is the mesh to be digested
  100248. * @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
  100249. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100250. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100251. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100252. * @returns the current SPS
  100253. */
  100254. digest(mesh: Mesh, options?: {
  100255. facetNb?: number;
  100256. number?: number;
  100257. delta?: number;
  100258. storage?: [];
  100259. }): SolidParticleSystem;
  100260. /**
  100261. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100262. * @hidden
  100263. */
  100264. private _unrotateFixedNormals;
  100265. /**
  100266. * Resets the temporary working copy particle
  100267. * @hidden
  100268. */
  100269. private _resetCopy;
  100270. /**
  100271. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100272. * @param p the current index in the positions array to be updated
  100273. * @param ind the current index in the indices array
  100274. * @param shape a Vector3 array, the shape geometry
  100275. * @param positions the positions array to be updated
  100276. * @param meshInd the shape indices array
  100277. * @param indices the indices array to be updated
  100278. * @param meshUV the shape uv array
  100279. * @param uvs the uv array to be updated
  100280. * @param meshCol the shape color array
  100281. * @param colors the color array to be updated
  100282. * @param meshNor the shape normals array
  100283. * @param normals the normals array to be updated
  100284. * @param idx the particle index
  100285. * @param idxInShape the particle index in its shape
  100286. * @param options the addShape() method passed options
  100287. * @model the particle model
  100288. * @hidden
  100289. */
  100290. private _meshBuilder;
  100291. /**
  100292. * Returns a shape Vector3 array from positions float array
  100293. * @param positions float array
  100294. * @returns a vector3 array
  100295. * @hidden
  100296. */
  100297. private _posToShape;
  100298. /**
  100299. * Returns a shapeUV array from a float uvs (array deep copy)
  100300. * @param uvs as a float array
  100301. * @returns a shapeUV array
  100302. * @hidden
  100303. */
  100304. private _uvsToShapeUV;
  100305. /**
  100306. * Adds a new particle object in the particles array
  100307. * @param idx particle index in particles array
  100308. * @param id particle id
  100309. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100310. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100311. * @param model particle ModelShape object
  100312. * @param shapeId model shape identifier
  100313. * @param idxInShape index of the particle in the current model
  100314. * @param bInfo model bounding info object
  100315. * @param storage target storage array, if any
  100316. * @hidden
  100317. */
  100318. private _addParticle;
  100319. /**
  100320. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100321. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100322. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100323. * @param nb (positive integer) the number of particles to be created from this model
  100324. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100325. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100326. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100327. * @returns the number of shapes in the system
  100328. */
  100329. addShape(mesh: Mesh, nb: number, options?: {
  100330. positionFunction?: any;
  100331. vertexFunction?: any;
  100332. storage?: [];
  100333. }): number;
  100334. /**
  100335. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100336. * @hidden
  100337. */
  100338. private _rebuildParticle;
  100339. /**
  100340. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100341. * @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.
  100342. * @returns the SPS.
  100343. */
  100344. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100345. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100346. * Returns an array with the removed particles.
  100347. * 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.
  100348. * The SPS can't be empty so at least one particle needs to remain in place.
  100349. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100350. * @param start index of the first particle to remove
  100351. * @param end index of the last particle to remove (included)
  100352. * @returns an array populated with the removed particles
  100353. */
  100354. removeParticles(start: number, end: number): SolidParticle[];
  100355. /**
  100356. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100357. * @param solidParticleArray an array populated with Solid Particles objects
  100358. * @returns the SPS
  100359. */
  100360. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100361. /**
  100362. * Creates a new particle and modifies the SPS mesh geometry :
  100363. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100364. * - calls _addParticle() to populate the particle array
  100365. * factorized code from addShape() and insertParticlesFromArray()
  100366. * @param idx particle index in the particles array
  100367. * @param i particle index in its shape
  100368. * @param modelShape particle ModelShape object
  100369. * @param shape shape vertex array
  100370. * @param meshInd shape indices array
  100371. * @param meshUV shape uv array
  100372. * @param meshCol shape color array
  100373. * @param meshNor shape normals array
  100374. * @param bbInfo shape bounding info
  100375. * @param storage target particle storage
  100376. * @options addShape() passed options
  100377. * @hidden
  100378. */
  100379. private _insertNewParticle;
  100380. /**
  100381. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100382. * This method calls `updateParticle()` for each particle of the SPS.
  100383. * For an animated SPS, it is usually called within the render loop.
  100384. * 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.
  100385. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100386. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100387. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100388. * @returns the SPS.
  100389. */
  100390. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100391. /**
  100392. * Disposes the SPS.
  100393. */
  100394. dispose(): void;
  100395. /**
  100396. * Returns a SolidParticle object from its identifier : particle.id
  100397. * @param id (integer) the particle Id
  100398. * @returns the searched particle or null if not found in the SPS.
  100399. */
  100400. getParticleById(id: number): Nullable<SolidParticle>;
  100401. /**
  100402. * Returns a new array populated with the particles having the passed shapeId.
  100403. * @param shapeId (integer) the shape identifier
  100404. * @returns a new solid particle array
  100405. */
  100406. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100407. /**
  100408. * Populates the passed array "ref" with the particles having the passed shapeId.
  100409. * @param shapeId the shape identifier
  100410. * @returns the SPS
  100411. * @param ref
  100412. */
  100413. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100414. /**
  100415. * Computes the required SubMeshes according the materials assigned to the particles.
  100416. * @returns the solid particle system.
  100417. * Does nothing if called before the SPS mesh is built.
  100418. */
  100419. computeSubMeshes(): SolidParticleSystem;
  100420. /**
  100421. * Sorts the solid particles by material when MultiMaterial is enabled.
  100422. * Updates the indices32 array.
  100423. * Updates the indicesByMaterial array.
  100424. * Updates the mesh indices array.
  100425. * @returns the SPS
  100426. * @hidden
  100427. */
  100428. private _sortParticlesByMaterial;
  100429. /**
  100430. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100431. * @hidden
  100432. */
  100433. private _setMaterialIndexesById;
  100434. /**
  100435. * Returns an array with unique values of Materials from the passed array
  100436. * @param array the material array to be checked and filtered
  100437. * @hidden
  100438. */
  100439. private _filterUniqueMaterialId;
  100440. /**
  100441. * Sets a new Standard Material as _defaultMaterial if not already set.
  100442. * @hidden
  100443. */
  100444. private _setDefaultMaterial;
  100445. /**
  100446. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100447. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100448. * @returns the SPS.
  100449. */
  100450. refreshVisibleSize(): SolidParticleSystem;
  100451. /**
  100452. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100453. * @param size the size (float) of the visibility box
  100454. * note : this doesn't lock the SPS mesh bounding box.
  100455. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100456. */
  100457. setVisibilityBox(size: number): void;
  100458. /**
  100459. * Gets whether the SPS as always visible or not
  100460. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100461. */
  100462. get isAlwaysVisible(): boolean;
  100463. /**
  100464. * Sets the SPS as always visible or not
  100465. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100466. */
  100467. set isAlwaysVisible(val: boolean);
  100468. /**
  100469. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100470. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100471. */
  100472. set isVisibilityBoxLocked(val: boolean);
  100473. /**
  100474. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100475. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100476. */
  100477. get isVisibilityBoxLocked(): boolean;
  100478. /**
  100479. * Tells to `setParticles()` to compute the particle rotations or not.
  100480. * Default value : true. The SPS is faster when it's set to false.
  100481. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100482. */
  100483. set computeParticleRotation(val: boolean);
  100484. /**
  100485. * Tells to `setParticles()` to compute the particle colors or not.
  100486. * Default value : true. The SPS is faster when it's set to false.
  100487. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100488. */
  100489. set computeParticleColor(val: boolean);
  100490. set computeParticleTexture(val: boolean);
  100491. /**
  100492. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100493. * Default value : false. The SPS is faster when it's set to false.
  100494. * Note : the particle custom vertex positions aren't stored values.
  100495. */
  100496. set computeParticleVertex(val: boolean);
  100497. /**
  100498. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100499. */
  100500. set computeBoundingBox(val: boolean);
  100501. /**
  100502. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100503. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100504. * Default : `true`
  100505. */
  100506. set depthSortParticles(val: boolean);
  100507. /**
  100508. * Gets if `setParticles()` computes the particle rotations or not.
  100509. * Default value : true. The SPS is faster when it's set to false.
  100510. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100511. */
  100512. get computeParticleRotation(): boolean;
  100513. /**
  100514. * Gets if `setParticles()` computes the particle colors or not.
  100515. * Default value : true. The SPS is faster when it's set to false.
  100516. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100517. */
  100518. get computeParticleColor(): boolean;
  100519. /**
  100520. * Gets if `setParticles()` computes the particle textures or not.
  100521. * Default value : true. The SPS is faster when it's set to false.
  100522. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100523. */
  100524. get computeParticleTexture(): boolean;
  100525. /**
  100526. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100527. * Default value : false. The SPS is faster when it's set to false.
  100528. * Note : the particle custom vertex positions aren't stored values.
  100529. */
  100530. get computeParticleVertex(): boolean;
  100531. /**
  100532. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100533. */
  100534. get computeBoundingBox(): boolean;
  100535. /**
  100536. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100537. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100538. * Default : `true`
  100539. */
  100540. get depthSortParticles(): boolean;
  100541. /**
  100542. * Gets if the SPS is created as expandable at construction time.
  100543. * Default : `false`
  100544. */
  100545. get expandable(): boolean;
  100546. /**
  100547. * Gets if the SPS supports the Multi Materials
  100548. */
  100549. get multimaterialEnabled(): boolean;
  100550. /**
  100551. * Gets if the SPS uses the model materials for its own multimaterial.
  100552. */
  100553. get useModelMaterial(): boolean;
  100554. /**
  100555. * The SPS used material array.
  100556. */
  100557. get materials(): Material[];
  100558. /**
  100559. * Sets the SPS MultiMaterial from the passed materials.
  100560. * Note : the passed array is internally copied and not used then by reference.
  100561. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100562. */
  100563. setMultiMaterial(materials: Material[]): void;
  100564. /**
  100565. * The SPS computed multimaterial object
  100566. */
  100567. get multimaterial(): MultiMaterial;
  100568. set multimaterial(mm: MultiMaterial);
  100569. /**
  100570. * If the subMeshes must be updated on the next call to setParticles()
  100571. */
  100572. get autoUpdateSubMeshes(): boolean;
  100573. set autoUpdateSubMeshes(val: boolean);
  100574. /**
  100575. * This function does nothing. It may be overwritten to set all the particle first values.
  100576. * The SPS doesn't call this function, you may have to call it by your own.
  100577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100578. */
  100579. initParticles(): void;
  100580. /**
  100581. * This function does nothing. It may be overwritten to recycle a particle.
  100582. * The SPS doesn't call this function, you may have to call it by your own.
  100583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100584. * @param particle The particle to recycle
  100585. * @returns the recycled particle
  100586. */
  100587. recycleParticle(particle: SolidParticle): SolidParticle;
  100588. /**
  100589. * Updates a particle : this function should be overwritten by the user.
  100590. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100592. * @example : just set a particle position or velocity and recycle conditions
  100593. * @param particle The particle to update
  100594. * @returns the updated particle
  100595. */
  100596. updateParticle(particle: SolidParticle): SolidParticle;
  100597. /**
  100598. * Updates a vertex of a particle : it can be overwritten by the user.
  100599. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100600. * @param particle the current particle
  100601. * @param vertex the current index of the current particle
  100602. * @param pt the index of the current vertex in the particle shape
  100603. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100604. * @example : just set a vertex particle position
  100605. * @returns the updated vertex
  100606. */
  100607. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100608. /**
  100609. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100610. * This does nothing and may be overwritten by the user.
  100611. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100612. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100613. * @param update the boolean update value actually passed to setParticles()
  100614. */
  100615. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100616. /**
  100617. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100618. * This will be passed three parameters.
  100619. * This does nothing and may be overwritten by the user.
  100620. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100621. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100622. * @param update the boolean update value actually passed to setParticles()
  100623. */
  100624. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100625. }
  100626. }
  100627. declare module BABYLON {
  100628. /**
  100629. * Represents one particle of a solid particle system.
  100630. */
  100631. export class SolidParticle {
  100632. /**
  100633. * particle global index
  100634. */
  100635. idx: number;
  100636. /**
  100637. * particle identifier
  100638. */
  100639. id: number;
  100640. /**
  100641. * The color of the particle
  100642. */
  100643. color: Nullable<Color4>;
  100644. /**
  100645. * The world space position of the particle.
  100646. */
  100647. position: Vector3;
  100648. /**
  100649. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100650. */
  100651. rotation: Vector3;
  100652. /**
  100653. * The world space rotation quaternion of the particle.
  100654. */
  100655. rotationQuaternion: Nullable<Quaternion>;
  100656. /**
  100657. * The scaling of the particle.
  100658. */
  100659. scaling: Vector3;
  100660. /**
  100661. * The uvs of the particle.
  100662. */
  100663. uvs: Vector4;
  100664. /**
  100665. * The current speed of the particle.
  100666. */
  100667. velocity: Vector3;
  100668. /**
  100669. * The pivot point in the particle local space.
  100670. */
  100671. pivot: Vector3;
  100672. /**
  100673. * Must the particle be translated from its pivot point in its local space ?
  100674. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100675. * Default : false
  100676. */
  100677. translateFromPivot: boolean;
  100678. /**
  100679. * Is the particle active or not ?
  100680. */
  100681. alive: boolean;
  100682. /**
  100683. * Is the particle visible or not ?
  100684. */
  100685. isVisible: boolean;
  100686. /**
  100687. * Index of this particle in the global "positions" array (Internal use)
  100688. * @hidden
  100689. */
  100690. _pos: number;
  100691. /**
  100692. * @hidden Index of this particle in the global "indices" array (Internal use)
  100693. */
  100694. _ind: number;
  100695. /**
  100696. * @hidden ModelShape of this particle (Internal use)
  100697. */
  100698. _model: ModelShape;
  100699. /**
  100700. * ModelShape id of this particle
  100701. */
  100702. shapeId: number;
  100703. /**
  100704. * Index of the particle in its shape id
  100705. */
  100706. idxInShape: number;
  100707. /**
  100708. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100709. */
  100710. _modelBoundingInfo: BoundingInfo;
  100711. /**
  100712. * @hidden Particle BoundingInfo object (Internal use)
  100713. */
  100714. _boundingInfo: BoundingInfo;
  100715. /**
  100716. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100717. */
  100718. _sps: SolidParticleSystem;
  100719. /**
  100720. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100721. */
  100722. _stillInvisible: boolean;
  100723. /**
  100724. * @hidden Last computed particle rotation matrix
  100725. */
  100726. _rotationMatrix: number[];
  100727. /**
  100728. * Parent particle Id, if any.
  100729. * Default null.
  100730. */
  100731. parentId: Nullable<number>;
  100732. /**
  100733. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100734. */
  100735. materialIndex: Nullable<number>;
  100736. /**
  100737. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100738. * The possible values are :
  100739. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100740. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100741. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100742. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100743. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100744. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100745. * */
  100746. cullingStrategy: number;
  100747. /**
  100748. * @hidden Internal global position in the SPS.
  100749. */
  100750. _globalPosition: Vector3;
  100751. /**
  100752. * Creates a Solid Particle object.
  100753. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100754. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100755. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100756. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100757. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100758. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100759. * @param shapeId (integer) is the model shape identifier in the SPS.
  100760. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100761. * @param sps defines the sps it is associated to
  100762. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100763. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100764. */
  100765. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100766. /**
  100767. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100768. * @param target the particle target
  100769. * @returns the current particle
  100770. */
  100771. copyToRef(target: SolidParticle): SolidParticle;
  100772. /**
  100773. * Legacy support, changed scale to scaling
  100774. */
  100775. get scale(): Vector3;
  100776. /**
  100777. * Legacy support, changed scale to scaling
  100778. */
  100779. set scale(scale: Vector3);
  100780. /**
  100781. * Legacy support, changed quaternion to rotationQuaternion
  100782. */
  100783. get quaternion(): Nullable<Quaternion>;
  100784. /**
  100785. * Legacy support, changed quaternion to rotationQuaternion
  100786. */
  100787. set quaternion(q: Nullable<Quaternion>);
  100788. /**
  100789. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100790. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100791. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100792. * @returns true if it intersects
  100793. */
  100794. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100795. /**
  100796. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100797. * A particle is in the frustum if its bounding box intersects the frustum
  100798. * @param frustumPlanes defines the frustum to test
  100799. * @returns true if the particle is in the frustum planes
  100800. */
  100801. isInFrustum(frustumPlanes: Plane[]): boolean;
  100802. /**
  100803. * get the rotation matrix of the particle
  100804. * @hidden
  100805. */
  100806. getRotationMatrix(m: Matrix): void;
  100807. }
  100808. /**
  100809. * Represents the shape of the model used by one particle of a solid particle system.
  100810. * SPS internal tool, don't use it manually.
  100811. */
  100812. export class ModelShape {
  100813. /**
  100814. * The shape id
  100815. * @hidden
  100816. */
  100817. shapeID: number;
  100818. /**
  100819. * flat array of model positions (internal use)
  100820. * @hidden
  100821. */
  100822. _shape: Vector3[];
  100823. /**
  100824. * flat array of model UVs (internal use)
  100825. * @hidden
  100826. */
  100827. _shapeUV: number[];
  100828. /**
  100829. * color array of the model
  100830. * @hidden
  100831. */
  100832. _shapeColors: number[];
  100833. /**
  100834. * indices array of the model
  100835. * @hidden
  100836. */
  100837. _indices: number[];
  100838. /**
  100839. * normals array of the model
  100840. * @hidden
  100841. */
  100842. _normals: number[];
  100843. /**
  100844. * length of the shape in the model indices array (internal use)
  100845. * @hidden
  100846. */
  100847. _indicesLength: number;
  100848. /**
  100849. * Custom position function (internal use)
  100850. * @hidden
  100851. */
  100852. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100853. /**
  100854. * Custom vertex function (internal use)
  100855. * @hidden
  100856. */
  100857. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100858. /**
  100859. * Model material (internal use)
  100860. * @hidden
  100861. */
  100862. _material: Nullable<Material>;
  100863. /**
  100864. * 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.
  100865. * SPS internal tool, don't use it manually.
  100866. * @hidden
  100867. */
  100868. 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>);
  100869. }
  100870. /**
  100871. * Represents a Depth Sorted Particle in the solid particle system.
  100872. * @hidden
  100873. */
  100874. export class DepthSortedParticle {
  100875. /**
  100876. * Index of the particle in the "indices" array
  100877. */
  100878. ind: number;
  100879. /**
  100880. * Length of the particle shape in the "indices" array
  100881. */
  100882. indicesLength: number;
  100883. /**
  100884. * Squared distance from the particle to the camera
  100885. */
  100886. sqDistance: number;
  100887. /**
  100888. * Material index when used with MultiMaterials
  100889. */
  100890. materialIndex: number;
  100891. /**
  100892. * Creates a new sorted particle
  100893. * @param materialIndex
  100894. */
  100895. constructor(ind: number, indLength: number, materialIndex: number);
  100896. }
  100897. }
  100898. declare module BABYLON {
  100899. /**
  100900. * @hidden
  100901. */
  100902. export class _MeshCollisionData {
  100903. _checkCollisions: boolean;
  100904. _collisionMask: number;
  100905. _collisionGroup: number;
  100906. _collider: Nullable<Collider>;
  100907. _oldPositionForCollisions: Vector3;
  100908. _diffPositionForCollisions: Vector3;
  100909. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100910. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100911. }
  100912. }
  100913. declare module BABYLON {
  100914. /** @hidden */
  100915. class _FacetDataStorage {
  100916. facetPositions: Vector3[];
  100917. facetNormals: Vector3[];
  100918. facetPartitioning: number[][];
  100919. facetNb: number;
  100920. partitioningSubdivisions: number;
  100921. partitioningBBoxRatio: number;
  100922. facetDataEnabled: boolean;
  100923. facetParameters: any;
  100924. bbSize: Vector3;
  100925. subDiv: {
  100926. max: number;
  100927. X: number;
  100928. Y: number;
  100929. Z: number;
  100930. };
  100931. facetDepthSort: boolean;
  100932. facetDepthSortEnabled: boolean;
  100933. depthSortedIndices: IndicesArray;
  100934. depthSortedFacets: {
  100935. ind: number;
  100936. sqDistance: number;
  100937. }[];
  100938. facetDepthSortFunction: (f1: {
  100939. ind: number;
  100940. sqDistance: number;
  100941. }, f2: {
  100942. ind: number;
  100943. sqDistance: number;
  100944. }) => number;
  100945. facetDepthSortFrom: Vector3;
  100946. facetDepthSortOrigin: Vector3;
  100947. invertedMatrix: Matrix;
  100948. }
  100949. /**
  100950. * @hidden
  100951. **/
  100952. class _InternalAbstractMeshDataInfo {
  100953. _hasVertexAlpha: boolean;
  100954. _useVertexColors: boolean;
  100955. _numBoneInfluencers: number;
  100956. _applyFog: boolean;
  100957. _receiveShadows: boolean;
  100958. _facetData: _FacetDataStorage;
  100959. _visibility: number;
  100960. _skeleton: Nullable<Skeleton>;
  100961. _layerMask: number;
  100962. _computeBonesUsingShaders: boolean;
  100963. _isActive: boolean;
  100964. _onlyForInstances: boolean;
  100965. _isActiveIntermediate: boolean;
  100966. _onlyForInstancesIntermediate: boolean;
  100967. _actAsRegularMesh: boolean;
  100968. }
  100969. /**
  100970. * Class used to store all common mesh properties
  100971. */
  100972. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100973. /** No occlusion */
  100974. static OCCLUSION_TYPE_NONE: number;
  100975. /** Occlusion set to optimisitic */
  100976. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100977. /** Occlusion set to strict */
  100978. static OCCLUSION_TYPE_STRICT: number;
  100979. /** Use an accurante occlusion algorithm */
  100980. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100981. /** Use a conservative occlusion algorithm */
  100982. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100983. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100984. * Test order :
  100985. * Is the bounding sphere outside the frustum ?
  100986. * If not, are the bounding box vertices outside the frustum ?
  100987. * It not, then the cullable object is in the frustum.
  100988. */
  100989. static readonly CULLINGSTRATEGY_STANDARD: number;
  100990. /** Culling strategy : Bounding Sphere Only.
  100991. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100992. * It's also less accurate than the standard because some not visible objects can still be selected.
  100993. * Test : is the bounding sphere outside the frustum ?
  100994. * If not, then the cullable object is in the frustum.
  100995. */
  100996. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100997. /** Culling strategy : Optimistic Inclusion.
  100998. * This in an inclusion test first, then the standard exclusion test.
  100999. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101000. * 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.
  101001. * Anyway, it's as accurate as the standard strategy.
  101002. * Test :
  101003. * Is the cullable object bounding sphere center in the frustum ?
  101004. * If not, apply the default culling strategy.
  101005. */
  101006. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101007. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101008. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101009. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101010. * 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.
  101011. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101012. * Test :
  101013. * Is the cullable object bounding sphere center in the frustum ?
  101014. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101015. */
  101016. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101017. /**
  101018. * No billboard
  101019. */
  101020. static get BILLBOARDMODE_NONE(): number;
  101021. /** Billboard on X axis */
  101022. static get BILLBOARDMODE_X(): number;
  101023. /** Billboard on Y axis */
  101024. static get BILLBOARDMODE_Y(): number;
  101025. /** Billboard on Z axis */
  101026. static get BILLBOARDMODE_Z(): number;
  101027. /** Billboard on all axes */
  101028. static get BILLBOARDMODE_ALL(): number;
  101029. /** Billboard on using position instead of orientation */
  101030. static get BILLBOARDMODE_USE_POSITION(): number;
  101031. /** @hidden */
  101032. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101033. /**
  101034. * The culling strategy to use to check whether the mesh must be rendered or not.
  101035. * This value can be changed at any time and will be used on the next render mesh selection.
  101036. * The possible values are :
  101037. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101038. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101039. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101040. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101041. * Please read each static variable documentation to get details about the culling process.
  101042. * */
  101043. cullingStrategy: number;
  101044. /**
  101045. * Gets the number of facets in the mesh
  101046. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101047. */
  101048. get facetNb(): number;
  101049. /**
  101050. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101052. */
  101053. get partitioningSubdivisions(): number;
  101054. set partitioningSubdivisions(nb: number);
  101055. /**
  101056. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101057. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101059. */
  101060. get partitioningBBoxRatio(): number;
  101061. set partitioningBBoxRatio(ratio: number);
  101062. /**
  101063. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101064. * Works only for updatable meshes.
  101065. * Doesn't work with multi-materials
  101066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101067. */
  101068. get mustDepthSortFacets(): boolean;
  101069. set mustDepthSortFacets(sort: boolean);
  101070. /**
  101071. * The location (Vector3) where the facet depth sort must be computed from.
  101072. * By default, the active camera position.
  101073. * Used only when facet depth sort is enabled
  101074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101075. */
  101076. get facetDepthSortFrom(): Vector3;
  101077. set facetDepthSortFrom(location: Vector3);
  101078. /**
  101079. * gets a boolean indicating if facetData is enabled
  101080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101081. */
  101082. get isFacetDataEnabled(): boolean;
  101083. /** @hidden */
  101084. _updateNonUniformScalingState(value: boolean): boolean;
  101085. /**
  101086. * An event triggered when this mesh collides with another one
  101087. */
  101088. onCollideObservable: Observable<AbstractMesh>;
  101089. /** Set a function to call when this mesh collides with another one */
  101090. set onCollide(callback: () => void);
  101091. /**
  101092. * An event triggered when the collision's position changes
  101093. */
  101094. onCollisionPositionChangeObservable: Observable<Vector3>;
  101095. /** Set a function to call when the collision's position changes */
  101096. set onCollisionPositionChange(callback: () => void);
  101097. /**
  101098. * An event triggered when material is changed
  101099. */
  101100. onMaterialChangedObservable: Observable<AbstractMesh>;
  101101. /**
  101102. * Gets or sets the orientation for POV movement & rotation
  101103. */
  101104. definedFacingForward: boolean;
  101105. /** @hidden */
  101106. _occlusionQuery: Nullable<WebGLQuery>;
  101107. /** @hidden */
  101108. _renderingGroup: Nullable<RenderingGroup>;
  101109. /**
  101110. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101111. */
  101112. get visibility(): number;
  101113. /**
  101114. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101115. */
  101116. set visibility(value: number);
  101117. /** Gets or sets the alpha index used to sort transparent meshes
  101118. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101119. */
  101120. alphaIndex: number;
  101121. /**
  101122. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101123. */
  101124. isVisible: boolean;
  101125. /**
  101126. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101127. */
  101128. isPickable: boolean;
  101129. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101130. showSubMeshesBoundingBox: boolean;
  101131. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101133. */
  101134. isBlocker: boolean;
  101135. /**
  101136. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101137. */
  101138. enablePointerMoveEvents: boolean;
  101139. /**
  101140. * Specifies the rendering group id for this mesh (0 by default)
  101141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101142. */
  101143. renderingGroupId: number;
  101144. private _material;
  101145. /** Gets or sets current material */
  101146. get material(): Nullable<Material>;
  101147. set material(value: Nullable<Material>);
  101148. /**
  101149. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101150. * @see http://doc.babylonjs.com/babylon101/shadows
  101151. */
  101152. get receiveShadows(): boolean;
  101153. set receiveShadows(value: boolean);
  101154. /** Defines color to use when rendering outline */
  101155. outlineColor: Color3;
  101156. /** Define width to use when rendering outline */
  101157. outlineWidth: number;
  101158. /** Defines color to use when rendering overlay */
  101159. overlayColor: Color3;
  101160. /** Defines alpha to use when rendering overlay */
  101161. overlayAlpha: number;
  101162. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101163. get hasVertexAlpha(): boolean;
  101164. set hasVertexAlpha(value: boolean);
  101165. /** 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) */
  101166. get useVertexColors(): boolean;
  101167. set useVertexColors(value: boolean);
  101168. /**
  101169. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101170. */
  101171. get computeBonesUsingShaders(): boolean;
  101172. set computeBonesUsingShaders(value: boolean);
  101173. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101174. get numBoneInfluencers(): number;
  101175. set numBoneInfluencers(value: number);
  101176. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101177. get applyFog(): boolean;
  101178. set applyFog(value: boolean);
  101179. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101180. useOctreeForRenderingSelection: boolean;
  101181. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101182. useOctreeForPicking: boolean;
  101183. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101184. useOctreeForCollisions: boolean;
  101185. /**
  101186. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101187. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101188. */
  101189. get layerMask(): number;
  101190. set layerMask(value: number);
  101191. /**
  101192. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101193. */
  101194. alwaysSelectAsActiveMesh: boolean;
  101195. /**
  101196. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101197. */
  101198. doNotSyncBoundingInfo: boolean;
  101199. /**
  101200. * Gets or sets the current action manager
  101201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101202. */
  101203. actionManager: Nullable<AbstractActionManager>;
  101204. private _meshCollisionData;
  101205. /**
  101206. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101208. */
  101209. ellipsoid: Vector3;
  101210. /**
  101211. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101213. */
  101214. ellipsoidOffset: Vector3;
  101215. /**
  101216. * Gets or sets a collision mask used to mask collisions (default is -1).
  101217. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101218. */
  101219. get collisionMask(): number;
  101220. set collisionMask(mask: number);
  101221. /**
  101222. * Gets or sets the current collision group mask (-1 by default).
  101223. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101224. */
  101225. get collisionGroup(): number;
  101226. set collisionGroup(mask: number);
  101227. /**
  101228. * Defines edge width used when edgesRenderer is enabled
  101229. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101230. */
  101231. edgesWidth: number;
  101232. /**
  101233. * Defines edge color used when edgesRenderer is enabled
  101234. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101235. */
  101236. edgesColor: Color4;
  101237. /** @hidden */
  101238. _edgesRenderer: Nullable<IEdgesRenderer>;
  101239. /** @hidden */
  101240. _masterMesh: Nullable<AbstractMesh>;
  101241. /** @hidden */
  101242. _boundingInfo: Nullable<BoundingInfo>;
  101243. /** @hidden */
  101244. _renderId: number;
  101245. /**
  101246. * Gets or sets the list of subMeshes
  101247. * @see http://doc.babylonjs.com/how_to/multi_materials
  101248. */
  101249. subMeshes: SubMesh[];
  101250. /** @hidden */
  101251. _intersectionsInProgress: AbstractMesh[];
  101252. /** @hidden */
  101253. _unIndexed: boolean;
  101254. /** @hidden */
  101255. _lightSources: Light[];
  101256. /** Gets the list of lights affecting that mesh */
  101257. get lightSources(): Light[];
  101258. /** @hidden */
  101259. get _positions(): Nullable<Vector3[]>;
  101260. /** @hidden */
  101261. _waitingData: {
  101262. lods: Nullable<any>;
  101263. actions: Nullable<any>;
  101264. freezeWorldMatrix: Nullable<boolean>;
  101265. };
  101266. /** @hidden */
  101267. _bonesTransformMatrices: Nullable<Float32Array>;
  101268. /** @hidden */
  101269. _transformMatrixTexture: Nullable<RawTexture>;
  101270. /**
  101271. * Gets or sets a skeleton to apply skining transformations
  101272. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101273. */
  101274. set skeleton(value: Nullable<Skeleton>);
  101275. get skeleton(): Nullable<Skeleton>;
  101276. /**
  101277. * An event triggered when the mesh is rebuilt.
  101278. */
  101279. onRebuildObservable: Observable<AbstractMesh>;
  101280. /**
  101281. * Creates a new AbstractMesh
  101282. * @param name defines the name of the mesh
  101283. * @param scene defines the hosting scene
  101284. */
  101285. constructor(name: string, scene?: Nullable<Scene>);
  101286. /**
  101287. * Returns the string "AbstractMesh"
  101288. * @returns "AbstractMesh"
  101289. */
  101290. getClassName(): string;
  101291. /**
  101292. * Gets a string representation of the current mesh
  101293. * @param fullDetails defines a boolean indicating if full details must be included
  101294. * @returns a string representation of the current mesh
  101295. */
  101296. toString(fullDetails?: boolean): string;
  101297. /**
  101298. * @hidden
  101299. */
  101300. protected _getEffectiveParent(): Nullable<Node>;
  101301. /** @hidden */
  101302. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101303. /** @hidden */
  101304. _rebuild(): void;
  101305. /** @hidden */
  101306. _resyncLightSources(): void;
  101307. /** @hidden */
  101308. _resyncLightSource(light: Light): void;
  101309. /** @hidden */
  101310. _unBindEffect(): void;
  101311. /** @hidden */
  101312. _removeLightSource(light: Light, dispose: boolean): void;
  101313. private _markSubMeshesAsDirty;
  101314. /** @hidden */
  101315. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101316. /** @hidden */
  101317. _markSubMeshesAsAttributesDirty(): void;
  101318. /** @hidden */
  101319. _markSubMeshesAsMiscDirty(): void;
  101320. /**
  101321. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101322. */
  101323. get scaling(): Vector3;
  101324. set scaling(newScaling: Vector3);
  101325. /**
  101326. * Returns true if the mesh is blocked. Implemented by child classes
  101327. */
  101328. get isBlocked(): boolean;
  101329. /**
  101330. * Returns the mesh itself by default. Implemented by child classes
  101331. * @param camera defines the camera to use to pick the right LOD level
  101332. * @returns the currentAbstractMesh
  101333. */
  101334. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101335. /**
  101336. * Returns 0 by default. Implemented by child classes
  101337. * @returns an integer
  101338. */
  101339. getTotalVertices(): number;
  101340. /**
  101341. * Returns a positive integer : the total number of indices in this mesh geometry.
  101342. * @returns the numner of indices or zero if the mesh has no geometry.
  101343. */
  101344. getTotalIndices(): number;
  101345. /**
  101346. * Returns null by default. Implemented by child classes
  101347. * @returns null
  101348. */
  101349. getIndices(): Nullable<IndicesArray>;
  101350. /**
  101351. * Returns the array of the requested vertex data kind. Implemented by child classes
  101352. * @param kind defines the vertex data kind to use
  101353. * @returns null
  101354. */
  101355. getVerticesData(kind: string): Nullable<FloatArray>;
  101356. /**
  101357. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101358. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101359. * Note that a new underlying VertexBuffer object is created each call.
  101360. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101361. * @param kind defines vertex data kind:
  101362. * * VertexBuffer.PositionKind
  101363. * * VertexBuffer.UVKind
  101364. * * VertexBuffer.UV2Kind
  101365. * * VertexBuffer.UV3Kind
  101366. * * VertexBuffer.UV4Kind
  101367. * * VertexBuffer.UV5Kind
  101368. * * VertexBuffer.UV6Kind
  101369. * * VertexBuffer.ColorKind
  101370. * * VertexBuffer.MatricesIndicesKind
  101371. * * VertexBuffer.MatricesIndicesExtraKind
  101372. * * VertexBuffer.MatricesWeightsKind
  101373. * * VertexBuffer.MatricesWeightsExtraKind
  101374. * @param data defines the data source
  101375. * @param updatable defines if the data must be flagged as updatable (or static)
  101376. * @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
  101377. * @returns the current mesh
  101378. */
  101379. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101380. /**
  101381. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101382. * If the mesh has no geometry, it is simply returned as it is.
  101383. * @param kind defines vertex data kind:
  101384. * * VertexBuffer.PositionKind
  101385. * * VertexBuffer.UVKind
  101386. * * VertexBuffer.UV2Kind
  101387. * * VertexBuffer.UV3Kind
  101388. * * VertexBuffer.UV4Kind
  101389. * * VertexBuffer.UV5Kind
  101390. * * VertexBuffer.UV6Kind
  101391. * * VertexBuffer.ColorKind
  101392. * * VertexBuffer.MatricesIndicesKind
  101393. * * VertexBuffer.MatricesIndicesExtraKind
  101394. * * VertexBuffer.MatricesWeightsKind
  101395. * * VertexBuffer.MatricesWeightsExtraKind
  101396. * @param data defines the data source
  101397. * @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
  101398. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101399. * @returns the current mesh
  101400. */
  101401. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101402. /**
  101403. * Sets the mesh indices,
  101404. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101405. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101406. * @param totalVertices Defines the total number of vertices
  101407. * @returns the current mesh
  101408. */
  101409. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101410. /**
  101411. * Gets a boolean indicating if specific vertex data is present
  101412. * @param kind defines the vertex data kind to use
  101413. * @returns true is data kind is present
  101414. */
  101415. isVerticesDataPresent(kind: string): boolean;
  101416. /**
  101417. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101418. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101419. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101420. * @returns a BoundingInfo
  101421. */
  101422. getBoundingInfo(): BoundingInfo;
  101423. /**
  101424. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101425. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101426. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101427. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101428. * @returns the current mesh
  101429. */
  101430. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101431. /**
  101432. * Overwrite the current bounding info
  101433. * @param boundingInfo defines the new bounding info
  101434. * @returns the current mesh
  101435. */
  101436. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101437. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101438. get useBones(): boolean;
  101439. /** @hidden */
  101440. _preActivate(): void;
  101441. /** @hidden */
  101442. _preActivateForIntermediateRendering(renderId: number): void;
  101443. /** @hidden */
  101444. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101445. /** @hidden */
  101446. _postActivate(): void;
  101447. /** @hidden */
  101448. _freeze(): void;
  101449. /** @hidden */
  101450. _unFreeze(): void;
  101451. /**
  101452. * Gets the current world matrix
  101453. * @returns a Matrix
  101454. */
  101455. getWorldMatrix(): Matrix;
  101456. /** @hidden */
  101457. _getWorldMatrixDeterminant(): number;
  101458. /**
  101459. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101460. */
  101461. get isAnInstance(): boolean;
  101462. /**
  101463. * Gets a boolean indicating if this mesh has instances
  101464. */
  101465. get hasInstances(): boolean;
  101466. /**
  101467. * Perform relative position change from the point of view of behind the front of the mesh.
  101468. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101469. * Supports definition of mesh facing forward or backward
  101470. * @param amountRight defines the distance on the right axis
  101471. * @param amountUp defines the distance on the up axis
  101472. * @param amountForward defines the distance on the forward axis
  101473. * @returns the current mesh
  101474. */
  101475. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101476. /**
  101477. * Calculate relative position change from the point of view of behind the front of the mesh.
  101478. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101479. * Supports definition of mesh facing forward or backward
  101480. * @param amountRight defines the distance on the right axis
  101481. * @param amountUp defines the distance on the up axis
  101482. * @param amountForward defines the distance on the forward axis
  101483. * @returns the new displacement vector
  101484. */
  101485. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101486. /**
  101487. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101488. * Supports definition of mesh facing forward or backward
  101489. * @param flipBack defines the flip
  101490. * @param twirlClockwise defines the twirl
  101491. * @param tiltRight defines the tilt
  101492. * @returns the current mesh
  101493. */
  101494. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101495. /**
  101496. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101497. * Supports definition of mesh facing forward or backward.
  101498. * @param flipBack defines the flip
  101499. * @param twirlClockwise defines the twirl
  101500. * @param tiltRight defines the tilt
  101501. * @returns the new rotation vector
  101502. */
  101503. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101504. /**
  101505. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101506. * This means the mesh underlying bounding box and sphere are recomputed.
  101507. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101508. * @returns the current mesh
  101509. */
  101510. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101511. /** @hidden */
  101512. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101513. /** @hidden */
  101514. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101515. /** @hidden */
  101516. _updateBoundingInfo(): AbstractMesh;
  101517. /** @hidden */
  101518. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101519. /** @hidden */
  101520. protected _afterComputeWorldMatrix(): void;
  101521. /** @hidden */
  101522. get _effectiveMesh(): AbstractMesh;
  101523. /**
  101524. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101525. * A mesh is in the frustum if its bounding box intersects the frustum
  101526. * @param frustumPlanes defines the frustum to test
  101527. * @returns true if the mesh is in the frustum planes
  101528. */
  101529. isInFrustum(frustumPlanes: Plane[]): boolean;
  101530. /**
  101531. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101532. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101533. * @param frustumPlanes defines the frustum to test
  101534. * @returns true if the mesh is completely in the frustum planes
  101535. */
  101536. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101537. /**
  101538. * True if the mesh intersects another mesh or a SolidParticle object
  101539. * @param mesh defines a target mesh or SolidParticle to test
  101540. * @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)
  101541. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101542. * @returns true if there is an intersection
  101543. */
  101544. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101545. /**
  101546. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101547. * @param point defines the point to test
  101548. * @returns true if there is an intersection
  101549. */
  101550. intersectsPoint(point: Vector3): boolean;
  101551. /**
  101552. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101554. */
  101555. get checkCollisions(): boolean;
  101556. set checkCollisions(collisionEnabled: boolean);
  101557. /**
  101558. * Gets Collider object used to compute collisions (not physics)
  101559. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101560. */
  101561. get collider(): Nullable<Collider>;
  101562. /**
  101563. * Move the mesh using collision engine
  101564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101565. * @param displacement defines the requested displacement vector
  101566. * @returns the current mesh
  101567. */
  101568. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101569. private _onCollisionPositionChange;
  101570. /** @hidden */
  101571. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101572. /** @hidden */
  101573. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101574. /** @hidden */
  101575. _checkCollision(collider: Collider): AbstractMesh;
  101576. /** @hidden */
  101577. _generatePointsArray(): boolean;
  101578. /**
  101579. * Checks if the passed Ray intersects with the mesh
  101580. * @param ray defines the ray to use
  101581. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101582. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101583. * @returns the picking info
  101584. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101585. */
  101586. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101587. /**
  101588. * Clones the current mesh
  101589. * @param name defines the mesh name
  101590. * @param newParent defines the new mesh parent
  101591. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101592. * @returns the new mesh
  101593. */
  101594. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101595. /**
  101596. * Disposes all the submeshes of the current meshnp
  101597. * @returns the current mesh
  101598. */
  101599. releaseSubMeshes(): AbstractMesh;
  101600. /**
  101601. * Releases resources associated with this abstract mesh.
  101602. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101603. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101604. */
  101605. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101606. /**
  101607. * Adds the passed mesh as a child to the current mesh
  101608. * @param mesh defines the child mesh
  101609. * @returns the current mesh
  101610. */
  101611. addChild(mesh: AbstractMesh): AbstractMesh;
  101612. /**
  101613. * Removes the passed mesh from the current mesh children list
  101614. * @param mesh defines the child mesh
  101615. * @returns the current mesh
  101616. */
  101617. removeChild(mesh: AbstractMesh): AbstractMesh;
  101618. /** @hidden */
  101619. private _initFacetData;
  101620. /**
  101621. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101622. * This method can be called within the render loop.
  101623. * 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
  101624. * @returns the current mesh
  101625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101626. */
  101627. updateFacetData(): AbstractMesh;
  101628. /**
  101629. * Returns the facetLocalNormals array.
  101630. * The normals are expressed in the mesh local spac
  101631. * @returns an array of Vector3
  101632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101633. */
  101634. getFacetLocalNormals(): Vector3[];
  101635. /**
  101636. * Returns the facetLocalPositions array.
  101637. * The facet positions are expressed in the mesh local space
  101638. * @returns an array of Vector3
  101639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101640. */
  101641. getFacetLocalPositions(): Vector3[];
  101642. /**
  101643. * Returns the facetLocalPartioning array
  101644. * @returns an array of array of numbers
  101645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101646. */
  101647. getFacetLocalPartitioning(): number[][];
  101648. /**
  101649. * Returns the i-th facet position in the world system.
  101650. * This method allocates a new Vector3 per call
  101651. * @param i defines the facet index
  101652. * @returns a new Vector3
  101653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101654. */
  101655. getFacetPosition(i: number): Vector3;
  101656. /**
  101657. * Sets the reference Vector3 with the i-th facet position in the world system
  101658. * @param i defines the facet index
  101659. * @param ref defines the target vector
  101660. * @returns the current mesh
  101661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101662. */
  101663. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101664. /**
  101665. * Returns the i-th facet normal in the world system.
  101666. * This method allocates a new Vector3 per call
  101667. * @param i defines the facet index
  101668. * @returns a new Vector3
  101669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101670. */
  101671. getFacetNormal(i: number): Vector3;
  101672. /**
  101673. * Sets the reference Vector3 with the i-th facet normal in the world system
  101674. * @param i defines the facet index
  101675. * @param ref defines the target vector
  101676. * @returns the current mesh
  101677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101678. */
  101679. getFacetNormalToRef(i: number, ref: Vector3): this;
  101680. /**
  101681. * 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)
  101682. * @param x defines x coordinate
  101683. * @param y defines y coordinate
  101684. * @param z defines z coordinate
  101685. * @returns the array of facet indexes
  101686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101687. */
  101688. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101689. /**
  101690. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101691. * @param projected sets as the (x,y,z) world projection on the facet
  101692. * @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
  101693. * @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
  101694. * @param x defines x coordinate
  101695. * @param y defines y coordinate
  101696. * @param z defines z coordinate
  101697. * @returns the face index if found (or null instead)
  101698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101699. */
  101700. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101701. /**
  101702. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101703. * @param projected sets as the (x,y,z) local projection on the facet
  101704. * @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
  101705. * @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
  101706. * @param x defines x coordinate
  101707. * @param y defines y coordinate
  101708. * @param z defines z coordinate
  101709. * @returns the face index if found (or null instead)
  101710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101711. */
  101712. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101713. /**
  101714. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101715. * @returns the parameters
  101716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101717. */
  101718. getFacetDataParameters(): any;
  101719. /**
  101720. * Disables the feature FacetData and frees the related memory
  101721. * @returns the current mesh
  101722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101723. */
  101724. disableFacetData(): AbstractMesh;
  101725. /**
  101726. * Updates the AbstractMesh indices array
  101727. * @param indices defines the data source
  101728. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101729. * @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)
  101730. * @returns the current mesh
  101731. */
  101732. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101733. /**
  101734. * Creates new normals data for the mesh
  101735. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101736. * @returns the current mesh
  101737. */
  101738. createNormals(updatable: boolean): AbstractMesh;
  101739. /**
  101740. * Align the mesh with a normal
  101741. * @param normal defines the normal to use
  101742. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101743. * @returns the current mesh
  101744. */
  101745. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101746. /** @hidden */
  101747. _checkOcclusionQuery(): boolean;
  101748. /**
  101749. * Disables the mesh edge rendering mode
  101750. * @returns the currentAbstractMesh
  101751. */
  101752. disableEdgesRendering(): AbstractMesh;
  101753. /**
  101754. * Enables the edge rendering mode on the mesh.
  101755. * This mode makes the mesh edges visible
  101756. * @param epsilon defines the maximal distance between two angles to detect a face
  101757. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101758. * @returns the currentAbstractMesh
  101759. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101760. */
  101761. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101762. }
  101763. }
  101764. declare module BABYLON {
  101765. /**
  101766. * Interface used to define ActionEvent
  101767. */
  101768. export interface IActionEvent {
  101769. /** The mesh or sprite that triggered the action */
  101770. source: any;
  101771. /** The X mouse cursor position at the time of the event */
  101772. pointerX: number;
  101773. /** The Y mouse cursor position at the time of the event */
  101774. pointerY: number;
  101775. /** The mesh that is currently pointed at (can be null) */
  101776. meshUnderPointer: Nullable<AbstractMesh>;
  101777. /** the original (browser) event that triggered the ActionEvent */
  101778. sourceEvent?: any;
  101779. /** additional data for the event */
  101780. additionalData?: any;
  101781. }
  101782. /**
  101783. * ActionEvent is the event being sent when an action is triggered.
  101784. */
  101785. export class ActionEvent implements IActionEvent {
  101786. /** The mesh or sprite that triggered the action */
  101787. source: any;
  101788. /** The X mouse cursor position at the time of the event */
  101789. pointerX: number;
  101790. /** The Y mouse cursor position at the time of the event */
  101791. pointerY: number;
  101792. /** The mesh that is currently pointed at (can be null) */
  101793. meshUnderPointer: Nullable<AbstractMesh>;
  101794. /** the original (browser) event that triggered the ActionEvent */
  101795. sourceEvent?: any;
  101796. /** additional data for the event */
  101797. additionalData?: any;
  101798. /**
  101799. * Creates a new ActionEvent
  101800. * @param source The mesh or sprite that triggered the action
  101801. * @param pointerX The X mouse cursor position at the time of the event
  101802. * @param pointerY The Y mouse cursor position at the time of the event
  101803. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101804. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101805. * @param additionalData additional data for the event
  101806. */
  101807. constructor(
  101808. /** The mesh or sprite that triggered the action */
  101809. source: any,
  101810. /** The X mouse cursor position at the time of the event */
  101811. pointerX: number,
  101812. /** The Y mouse cursor position at the time of the event */
  101813. pointerY: number,
  101814. /** The mesh that is currently pointed at (can be null) */
  101815. meshUnderPointer: Nullable<AbstractMesh>,
  101816. /** the original (browser) event that triggered the ActionEvent */
  101817. sourceEvent?: any,
  101818. /** additional data for the event */
  101819. additionalData?: any);
  101820. /**
  101821. * Helper function to auto-create an ActionEvent from a source mesh.
  101822. * @param source The source mesh that triggered the event
  101823. * @param evt The original (browser) event
  101824. * @param additionalData additional data for the event
  101825. * @returns the new ActionEvent
  101826. */
  101827. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101828. /**
  101829. * Helper function to auto-create an ActionEvent from a source sprite
  101830. * @param source The source sprite that triggered the event
  101831. * @param scene Scene associated with the sprite
  101832. * @param evt The original (browser) event
  101833. * @param additionalData additional data for the event
  101834. * @returns the new ActionEvent
  101835. */
  101836. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101837. /**
  101838. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101839. * @param scene the scene where the event occurred
  101840. * @param evt The original (browser) event
  101841. * @returns the new ActionEvent
  101842. */
  101843. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101844. /**
  101845. * Helper function to auto-create an ActionEvent from a primitive
  101846. * @param prim defines the target primitive
  101847. * @param pointerPos defines the pointer position
  101848. * @param evt The original (browser) event
  101849. * @param additionalData additional data for the event
  101850. * @returns the new ActionEvent
  101851. */
  101852. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101853. }
  101854. }
  101855. declare module BABYLON {
  101856. /**
  101857. * Abstract class used to decouple action Manager from scene and meshes.
  101858. * Do not instantiate.
  101859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101860. */
  101861. export abstract class AbstractActionManager implements IDisposable {
  101862. /** Gets the list of active triggers */
  101863. static Triggers: {
  101864. [key: string]: number;
  101865. };
  101866. /** Gets the cursor to use when hovering items */
  101867. hoverCursor: string;
  101868. /** Gets the list of actions */
  101869. actions: IAction[];
  101870. /**
  101871. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101872. */
  101873. isRecursive: boolean;
  101874. /**
  101875. * Releases all associated resources
  101876. */
  101877. abstract dispose(): void;
  101878. /**
  101879. * Does this action manager has pointer triggers
  101880. */
  101881. abstract get hasPointerTriggers(): boolean;
  101882. /**
  101883. * Does this action manager has pick triggers
  101884. */
  101885. abstract get hasPickTriggers(): boolean;
  101886. /**
  101887. * Process a specific trigger
  101888. * @param trigger defines the trigger to process
  101889. * @param evt defines the event details to be processed
  101890. */
  101891. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101892. /**
  101893. * Does this action manager handles actions of any of the given triggers
  101894. * @param triggers defines the triggers to be tested
  101895. * @return a boolean indicating whether one (or more) of the triggers is handled
  101896. */
  101897. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101898. /**
  101899. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101900. * speed.
  101901. * @param triggerA defines the trigger to be tested
  101902. * @param triggerB defines the trigger to be tested
  101903. * @return a boolean indicating whether one (or more) of the triggers is handled
  101904. */
  101905. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101906. /**
  101907. * Does this action manager handles actions of a given trigger
  101908. * @param trigger defines the trigger to be tested
  101909. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101910. * @return whether the trigger is handled
  101911. */
  101912. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101913. /**
  101914. * Serialize this manager to a JSON object
  101915. * @param name defines the property name to store this manager
  101916. * @returns a JSON representation of this manager
  101917. */
  101918. abstract serialize(name: string): any;
  101919. /**
  101920. * Registers an action to this action manager
  101921. * @param action defines the action to be registered
  101922. * @return the action amended (prepared) after registration
  101923. */
  101924. abstract registerAction(action: IAction): Nullable<IAction>;
  101925. /**
  101926. * Unregisters an action to this action manager
  101927. * @param action defines the action to be unregistered
  101928. * @return a boolean indicating whether the action has been unregistered
  101929. */
  101930. abstract unregisterAction(action: IAction): Boolean;
  101931. /**
  101932. * Does exist one action manager with at least one trigger
  101933. **/
  101934. static get HasTriggers(): boolean;
  101935. /**
  101936. * Does exist one action manager with at least one pick trigger
  101937. **/
  101938. static get HasPickTriggers(): boolean;
  101939. /**
  101940. * Does exist one action manager that handles actions of a given trigger
  101941. * @param trigger defines the trigger to be tested
  101942. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101943. **/
  101944. static HasSpecificTrigger(trigger: number): boolean;
  101945. }
  101946. }
  101947. declare module BABYLON {
  101948. /**
  101949. * Defines how a node can be built from a string name.
  101950. */
  101951. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101952. /**
  101953. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101954. */
  101955. export class Node implements IBehaviorAware<Node> {
  101956. /** @hidden */
  101957. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101958. private static _NodeConstructors;
  101959. /**
  101960. * Add a new node constructor
  101961. * @param type defines the type name of the node to construct
  101962. * @param constructorFunc defines the constructor function
  101963. */
  101964. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101965. /**
  101966. * Returns a node constructor based on type name
  101967. * @param type defines the type name
  101968. * @param name defines the new node name
  101969. * @param scene defines the hosting scene
  101970. * @param options defines optional options to transmit to constructors
  101971. * @returns the new constructor or null
  101972. */
  101973. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101974. /**
  101975. * Gets or sets the name of the node
  101976. */
  101977. name: string;
  101978. /**
  101979. * Gets or sets the id of the node
  101980. */
  101981. id: string;
  101982. /**
  101983. * Gets or sets the unique id of the node
  101984. */
  101985. uniqueId: number;
  101986. /**
  101987. * Gets or sets a string used to store user defined state for the node
  101988. */
  101989. state: string;
  101990. /**
  101991. * Gets or sets an object used to store user defined information for the node
  101992. */
  101993. metadata: any;
  101994. /**
  101995. * For internal use only. Please do not use.
  101996. */
  101997. reservedDataStore: any;
  101998. /**
  101999. * List of inspectable custom properties (used by the Inspector)
  102000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102001. */
  102002. inspectableCustomProperties: IInspectable[];
  102003. private _doNotSerialize;
  102004. /**
  102005. * Gets or sets a boolean used to define if the node must be serialized
  102006. */
  102007. get doNotSerialize(): boolean;
  102008. set doNotSerialize(value: boolean);
  102009. /** @hidden */
  102010. _isDisposed: boolean;
  102011. /**
  102012. * Gets a list of Animations associated with the node
  102013. */
  102014. animations: Animation[];
  102015. protected _ranges: {
  102016. [name: string]: Nullable<AnimationRange>;
  102017. };
  102018. /**
  102019. * Callback raised when the node is ready to be used
  102020. */
  102021. onReady: Nullable<(node: Node) => void>;
  102022. private _isEnabled;
  102023. private _isParentEnabled;
  102024. private _isReady;
  102025. /** @hidden */
  102026. _currentRenderId: number;
  102027. private _parentUpdateId;
  102028. /** @hidden */
  102029. _childUpdateId: number;
  102030. /** @hidden */
  102031. _waitingParentId: Nullable<string>;
  102032. /** @hidden */
  102033. _scene: Scene;
  102034. /** @hidden */
  102035. _cache: any;
  102036. private _parentNode;
  102037. private _children;
  102038. /** @hidden */
  102039. _worldMatrix: Matrix;
  102040. /** @hidden */
  102041. _worldMatrixDeterminant: number;
  102042. /** @hidden */
  102043. _worldMatrixDeterminantIsDirty: boolean;
  102044. /** @hidden */
  102045. private _sceneRootNodesIndex;
  102046. /**
  102047. * Gets a boolean indicating if the node has been disposed
  102048. * @returns true if the node was disposed
  102049. */
  102050. isDisposed(): boolean;
  102051. /**
  102052. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102053. * @see https://doc.babylonjs.com/how_to/parenting
  102054. */
  102055. set parent(parent: Nullable<Node>);
  102056. get parent(): Nullable<Node>;
  102057. /** @hidden */
  102058. _addToSceneRootNodes(): void;
  102059. /** @hidden */
  102060. _removeFromSceneRootNodes(): void;
  102061. private _animationPropertiesOverride;
  102062. /**
  102063. * Gets or sets the animation properties override
  102064. */
  102065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102067. /**
  102068. * Gets a string idenfifying the name of the class
  102069. * @returns "Node" string
  102070. */
  102071. getClassName(): string;
  102072. /** @hidden */
  102073. readonly _isNode: boolean;
  102074. /**
  102075. * An event triggered when the mesh is disposed
  102076. */
  102077. onDisposeObservable: Observable<Node>;
  102078. private _onDisposeObserver;
  102079. /**
  102080. * Sets a callback that will be raised when the node will be disposed
  102081. */
  102082. set onDispose(callback: () => void);
  102083. /**
  102084. * Creates a new Node
  102085. * @param name the name and id to be given to this node
  102086. * @param scene the scene this node will be added to
  102087. */
  102088. constructor(name: string, scene?: Nullable<Scene>);
  102089. /**
  102090. * Gets the scene of the node
  102091. * @returns a scene
  102092. */
  102093. getScene(): Scene;
  102094. /**
  102095. * Gets the engine of the node
  102096. * @returns a Engine
  102097. */
  102098. getEngine(): Engine;
  102099. private _behaviors;
  102100. /**
  102101. * Attach a behavior to the node
  102102. * @see http://doc.babylonjs.com/features/behaviour
  102103. * @param behavior defines the behavior to attach
  102104. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102105. * @returns the current Node
  102106. */
  102107. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102108. /**
  102109. * Remove an attached behavior
  102110. * @see http://doc.babylonjs.com/features/behaviour
  102111. * @param behavior defines the behavior to attach
  102112. * @returns the current Node
  102113. */
  102114. removeBehavior(behavior: Behavior<Node>): Node;
  102115. /**
  102116. * Gets the list of attached behaviors
  102117. * @see http://doc.babylonjs.com/features/behaviour
  102118. */
  102119. get behaviors(): Behavior<Node>[];
  102120. /**
  102121. * Gets an attached behavior by name
  102122. * @param name defines the name of the behavior to look for
  102123. * @see http://doc.babylonjs.com/features/behaviour
  102124. * @returns null if behavior was not found else the requested behavior
  102125. */
  102126. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102127. /**
  102128. * Returns the latest update of the World matrix
  102129. * @returns a Matrix
  102130. */
  102131. getWorldMatrix(): Matrix;
  102132. /** @hidden */
  102133. _getWorldMatrixDeterminant(): number;
  102134. /**
  102135. * Returns directly the latest state of the mesh World matrix.
  102136. * A Matrix is returned.
  102137. */
  102138. get worldMatrixFromCache(): Matrix;
  102139. /** @hidden */
  102140. _initCache(): void;
  102141. /** @hidden */
  102142. updateCache(force?: boolean): void;
  102143. /** @hidden */
  102144. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102145. /** @hidden */
  102146. _updateCache(ignoreParentClass?: boolean): void;
  102147. /** @hidden */
  102148. _isSynchronized(): boolean;
  102149. /** @hidden */
  102150. _markSyncedWithParent(): void;
  102151. /** @hidden */
  102152. isSynchronizedWithParent(): boolean;
  102153. /** @hidden */
  102154. isSynchronized(): boolean;
  102155. /**
  102156. * Is this node ready to be used/rendered
  102157. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102158. * @return true if the node is ready
  102159. */
  102160. isReady(completeCheck?: boolean): boolean;
  102161. /**
  102162. * Is this node enabled?
  102163. * 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
  102164. * @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
  102165. * @return whether this node (and its parent) is enabled
  102166. */
  102167. isEnabled(checkAncestors?: boolean): boolean;
  102168. /** @hidden */
  102169. protected _syncParentEnabledState(): void;
  102170. /**
  102171. * Set the enabled state of this node
  102172. * @param value defines the new enabled state
  102173. */
  102174. setEnabled(value: boolean): void;
  102175. /**
  102176. * Is this node a descendant of the given node?
  102177. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102178. * @param ancestor defines the parent node to inspect
  102179. * @returns a boolean indicating if this node is a descendant of the given node
  102180. */
  102181. isDescendantOf(ancestor: Node): boolean;
  102182. /** @hidden */
  102183. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102184. /**
  102185. * Will return all nodes that have this node as ascendant
  102186. * @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
  102187. * @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
  102188. * @return all children nodes of all types
  102189. */
  102190. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102191. /**
  102192. * Get all child-meshes of this node
  102193. * @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)
  102194. * @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
  102195. * @returns an array of AbstractMesh
  102196. */
  102197. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102198. /**
  102199. * Get all direct children of this node
  102200. * @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
  102201. * @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)
  102202. * @returns an array of Node
  102203. */
  102204. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102205. /** @hidden */
  102206. _setReady(state: boolean): void;
  102207. /**
  102208. * Get an animation by name
  102209. * @param name defines the name of the animation to look for
  102210. * @returns null if not found else the requested animation
  102211. */
  102212. getAnimationByName(name: string): Nullable<Animation>;
  102213. /**
  102214. * Creates an animation range for this node
  102215. * @param name defines the name of the range
  102216. * @param from defines the starting key
  102217. * @param to defines the end key
  102218. */
  102219. createAnimationRange(name: string, from: number, to: number): void;
  102220. /**
  102221. * Delete a specific animation range
  102222. * @param name defines the name of the range to delete
  102223. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102224. */
  102225. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102226. /**
  102227. * Get an animation range by name
  102228. * @param name defines the name of the animation range to look for
  102229. * @returns null if not found else the requested animation range
  102230. */
  102231. getAnimationRange(name: string): Nullable<AnimationRange>;
  102232. /**
  102233. * Gets the list of all animation ranges defined on this node
  102234. * @returns an array
  102235. */
  102236. getAnimationRanges(): Nullable<AnimationRange>[];
  102237. /**
  102238. * Will start the animation sequence
  102239. * @param name defines the range frames for animation sequence
  102240. * @param loop defines if the animation should loop (false by default)
  102241. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102242. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102243. * @returns the object created for this animation. If range does not exist, it will return null
  102244. */
  102245. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102246. /**
  102247. * Serialize animation ranges into a JSON compatible object
  102248. * @returns serialization object
  102249. */
  102250. serializeAnimationRanges(): any;
  102251. /**
  102252. * Computes the world matrix of the node
  102253. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102254. * @returns the world matrix
  102255. */
  102256. computeWorldMatrix(force?: boolean): Matrix;
  102257. /**
  102258. * Releases resources associated with this node.
  102259. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102260. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102261. */
  102262. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102263. /**
  102264. * Parse animation range data from a serialization object and store them into a given node
  102265. * @param node defines where to store the animation ranges
  102266. * @param parsedNode defines the serialization object to read data from
  102267. * @param scene defines the hosting scene
  102268. */
  102269. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102270. /**
  102271. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102272. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102273. * @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
  102274. * @returns the new bounding vectors
  102275. */
  102276. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102277. min: Vector3;
  102278. max: Vector3;
  102279. };
  102280. }
  102281. }
  102282. declare module BABYLON {
  102283. /**
  102284. * @hidden
  102285. */
  102286. export class _IAnimationState {
  102287. key: number;
  102288. repeatCount: number;
  102289. workValue?: any;
  102290. loopMode?: number;
  102291. offsetValue?: any;
  102292. highLimitValue?: any;
  102293. }
  102294. /**
  102295. * Class used to store any kind of animation
  102296. */
  102297. export class Animation {
  102298. /**Name of the animation */
  102299. name: string;
  102300. /**Property to animate */
  102301. targetProperty: string;
  102302. /**The frames per second of the animation */
  102303. framePerSecond: number;
  102304. /**The data type of the animation */
  102305. dataType: number;
  102306. /**The loop mode of the animation */
  102307. loopMode?: number | undefined;
  102308. /**Specifies if blending should be enabled */
  102309. enableBlending?: boolean | undefined;
  102310. /**
  102311. * Use matrix interpolation instead of using direct key value when animating matrices
  102312. */
  102313. static AllowMatricesInterpolation: boolean;
  102314. /**
  102315. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102316. */
  102317. static AllowMatrixDecomposeForInterpolation: boolean;
  102318. /**
  102319. * Stores the key frames of the animation
  102320. */
  102321. private _keys;
  102322. /**
  102323. * Stores the easing function of the animation
  102324. */
  102325. private _easingFunction;
  102326. /**
  102327. * @hidden Internal use only
  102328. */
  102329. _runtimeAnimations: RuntimeAnimation[];
  102330. /**
  102331. * The set of event that will be linked to this animation
  102332. */
  102333. private _events;
  102334. /**
  102335. * Stores an array of target property paths
  102336. */
  102337. targetPropertyPath: string[];
  102338. /**
  102339. * Stores the blending speed of the animation
  102340. */
  102341. blendingSpeed: number;
  102342. /**
  102343. * Stores the animation ranges for the animation
  102344. */
  102345. private _ranges;
  102346. /**
  102347. * @hidden Internal use
  102348. */
  102349. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102350. /**
  102351. * Sets up an animation
  102352. * @param property The property to animate
  102353. * @param animationType The animation type to apply
  102354. * @param framePerSecond The frames per second of the animation
  102355. * @param easingFunction The easing function used in the animation
  102356. * @returns The created animation
  102357. */
  102358. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102359. /**
  102360. * Create and start an animation on a node
  102361. * @param name defines the name of the global animation that will be run on all nodes
  102362. * @param node defines the root node where the animation will take place
  102363. * @param targetProperty defines property to animate
  102364. * @param framePerSecond defines the number of frame per second yo use
  102365. * @param totalFrame defines the number of frames in total
  102366. * @param from defines the initial value
  102367. * @param to defines the final value
  102368. * @param loopMode defines which loop mode you want to use (off by default)
  102369. * @param easingFunction defines the easing function to use (linear by default)
  102370. * @param onAnimationEnd defines the callback to call when animation end
  102371. * @returns the animatable created for this animation
  102372. */
  102373. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102374. /**
  102375. * Create and start an animation on a node and its descendants
  102376. * @param name defines the name of the global animation that will be run on all nodes
  102377. * @param node defines the root node where the animation will take place
  102378. * @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
  102379. * @param targetProperty defines property to animate
  102380. * @param framePerSecond defines the number of frame per second to use
  102381. * @param totalFrame defines the number of frames in total
  102382. * @param from defines the initial value
  102383. * @param to defines the final value
  102384. * @param loopMode defines which loop mode you want to use (off by default)
  102385. * @param easingFunction defines the easing function to use (linear by default)
  102386. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102387. * @returns the list of animatables created for all nodes
  102388. * @example https://www.babylonjs-playground.com/#MH0VLI
  102389. */
  102390. 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[]>;
  102391. /**
  102392. * Creates a new animation, merges it with the existing animations and starts it
  102393. * @param name Name of the animation
  102394. * @param node Node which contains the scene that begins the animations
  102395. * @param targetProperty Specifies which property to animate
  102396. * @param framePerSecond The frames per second of the animation
  102397. * @param totalFrame The total number of frames
  102398. * @param from The frame at the beginning of the animation
  102399. * @param to The frame at the end of the animation
  102400. * @param loopMode Specifies the loop mode of the animation
  102401. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102402. * @param onAnimationEnd Callback to run once the animation is complete
  102403. * @returns Nullable animation
  102404. */
  102405. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102406. /**
  102407. * Transition property of an host to the target Value
  102408. * @param property The property to transition
  102409. * @param targetValue The target Value of the property
  102410. * @param host The object where the property to animate belongs
  102411. * @param scene Scene used to run the animation
  102412. * @param frameRate Framerate (in frame/s) to use
  102413. * @param transition The transition type we want to use
  102414. * @param duration The duration of the animation, in milliseconds
  102415. * @param onAnimationEnd Callback trigger at the end of the animation
  102416. * @returns Nullable animation
  102417. */
  102418. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102419. /**
  102420. * Return the array of runtime animations currently using this animation
  102421. */
  102422. get runtimeAnimations(): RuntimeAnimation[];
  102423. /**
  102424. * Specifies if any of the runtime animations are currently running
  102425. */
  102426. get hasRunningRuntimeAnimations(): boolean;
  102427. /**
  102428. * Initializes the animation
  102429. * @param name Name of the animation
  102430. * @param targetProperty Property to animate
  102431. * @param framePerSecond The frames per second of the animation
  102432. * @param dataType The data type of the animation
  102433. * @param loopMode The loop mode of the animation
  102434. * @param enableBlending Specifies if blending should be enabled
  102435. */
  102436. constructor(
  102437. /**Name of the animation */
  102438. name: string,
  102439. /**Property to animate */
  102440. targetProperty: string,
  102441. /**The frames per second of the animation */
  102442. framePerSecond: number,
  102443. /**The data type of the animation */
  102444. dataType: number,
  102445. /**The loop mode of the animation */
  102446. loopMode?: number | undefined,
  102447. /**Specifies if blending should be enabled */
  102448. enableBlending?: boolean | undefined);
  102449. /**
  102450. * Converts the animation to a string
  102451. * @param fullDetails support for multiple levels of logging within scene loading
  102452. * @returns String form of the animation
  102453. */
  102454. toString(fullDetails?: boolean): string;
  102455. /**
  102456. * Add an event to this animation
  102457. * @param event Event to add
  102458. */
  102459. addEvent(event: AnimationEvent): void;
  102460. /**
  102461. * Remove all events found at the given frame
  102462. * @param frame The frame to remove events from
  102463. */
  102464. removeEvents(frame: number): void;
  102465. /**
  102466. * Retrieves all the events from the animation
  102467. * @returns Events from the animation
  102468. */
  102469. getEvents(): AnimationEvent[];
  102470. /**
  102471. * Creates an animation range
  102472. * @param name Name of the animation range
  102473. * @param from Starting frame of the animation range
  102474. * @param to Ending frame of the animation
  102475. */
  102476. createRange(name: string, from: number, to: number): void;
  102477. /**
  102478. * Deletes an animation range by name
  102479. * @param name Name of the animation range to delete
  102480. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102481. */
  102482. deleteRange(name: string, deleteFrames?: boolean): void;
  102483. /**
  102484. * Gets the animation range by name, or null if not defined
  102485. * @param name Name of the animation range
  102486. * @returns Nullable animation range
  102487. */
  102488. getRange(name: string): Nullable<AnimationRange>;
  102489. /**
  102490. * Gets the key frames from the animation
  102491. * @returns The key frames of the animation
  102492. */
  102493. getKeys(): Array<IAnimationKey>;
  102494. /**
  102495. * Gets the highest frame rate of the animation
  102496. * @returns Highest frame rate of the animation
  102497. */
  102498. getHighestFrame(): number;
  102499. /**
  102500. * Gets the easing function of the animation
  102501. * @returns Easing function of the animation
  102502. */
  102503. getEasingFunction(): IEasingFunction;
  102504. /**
  102505. * Sets the easing function of the animation
  102506. * @param easingFunction A custom mathematical formula for animation
  102507. */
  102508. setEasingFunction(easingFunction: EasingFunction): void;
  102509. /**
  102510. * Interpolates a scalar linearly
  102511. * @param startValue Start value of the animation curve
  102512. * @param endValue End value of the animation curve
  102513. * @param gradient Scalar amount to interpolate
  102514. * @returns Interpolated scalar value
  102515. */
  102516. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102517. /**
  102518. * Interpolates a scalar cubically
  102519. * @param startValue Start value of the animation curve
  102520. * @param outTangent End tangent of the animation
  102521. * @param endValue End value of the animation curve
  102522. * @param inTangent Start tangent of the animation curve
  102523. * @param gradient Scalar amount to interpolate
  102524. * @returns Interpolated scalar value
  102525. */
  102526. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102527. /**
  102528. * Interpolates a quaternion using a spherical linear interpolation
  102529. * @param startValue Start value of the animation curve
  102530. * @param endValue End value of the animation curve
  102531. * @param gradient Scalar amount to interpolate
  102532. * @returns Interpolated quaternion value
  102533. */
  102534. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102535. /**
  102536. * Interpolates a quaternion cubically
  102537. * @param startValue Start value of the animation curve
  102538. * @param outTangent End tangent of the animation curve
  102539. * @param endValue End value of the animation curve
  102540. * @param inTangent Start tangent of the animation curve
  102541. * @param gradient Scalar amount to interpolate
  102542. * @returns Interpolated quaternion value
  102543. */
  102544. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102545. /**
  102546. * Interpolates a Vector3 linearl
  102547. * @param startValue Start value of the animation curve
  102548. * @param endValue End value of the animation curve
  102549. * @param gradient Scalar amount to interpolate
  102550. * @returns Interpolated scalar value
  102551. */
  102552. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102553. /**
  102554. * Interpolates a Vector3 cubically
  102555. * @param startValue Start value of the animation curve
  102556. * @param outTangent End tangent of the animation
  102557. * @param endValue End value of the animation curve
  102558. * @param inTangent Start tangent of the animation curve
  102559. * @param gradient Scalar amount to interpolate
  102560. * @returns InterpolatedVector3 value
  102561. */
  102562. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102563. /**
  102564. * Interpolates a Vector2 linearly
  102565. * @param startValue Start value of the animation curve
  102566. * @param endValue End value of the animation curve
  102567. * @param gradient Scalar amount to interpolate
  102568. * @returns Interpolated Vector2 value
  102569. */
  102570. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102571. /**
  102572. * Interpolates a Vector2 cubically
  102573. * @param startValue Start value of the animation curve
  102574. * @param outTangent End tangent of the animation
  102575. * @param endValue End value of the animation curve
  102576. * @param inTangent Start tangent of the animation curve
  102577. * @param gradient Scalar amount to interpolate
  102578. * @returns Interpolated Vector2 value
  102579. */
  102580. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102581. /**
  102582. * Interpolates a size linearly
  102583. * @param startValue Start value of the animation curve
  102584. * @param endValue End value of the animation curve
  102585. * @param gradient Scalar amount to interpolate
  102586. * @returns Interpolated Size value
  102587. */
  102588. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102589. /**
  102590. * Interpolates a Color3 linearly
  102591. * @param startValue Start value of the animation curve
  102592. * @param endValue End value of the animation curve
  102593. * @param gradient Scalar amount to interpolate
  102594. * @returns Interpolated Color3 value
  102595. */
  102596. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102597. /**
  102598. * Interpolates a Color4 linearly
  102599. * @param startValue Start value of the animation curve
  102600. * @param endValue End value of the animation curve
  102601. * @param gradient Scalar amount to interpolate
  102602. * @returns Interpolated Color3 value
  102603. */
  102604. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102605. /**
  102606. * @hidden Internal use only
  102607. */
  102608. _getKeyValue(value: any): any;
  102609. /**
  102610. * @hidden Internal use only
  102611. */
  102612. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102613. /**
  102614. * Defines the function to use to interpolate matrices
  102615. * @param startValue defines the start matrix
  102616. * @param endValue defines the end matrix
  102617. * @param gradient defines the gradient between both matrices
  102618. * @param result defines an optional target matrix where to store the interpolation
  102619. * @returns the interpolated matrix
  102620. */
  102621. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102622. /**
  102623. * Makes a copy of the animation
  102624. * @returns Cloned animation
  102625. */
  102626. clone(): Animation;
  102627. /**
  102628. * Sets the key frames of the animation
  102629. * @param values The animation key frames to set
  102630. */
  102631. setKeys(values: Array<IAnimationKey>): void;
  102632. /**
  102633. * Serializes the animation to an object
  102634. * @returns Serialized object
  102635. */
  102636. serialize(): any;
  102637. /**
  102638. * Float animation type
  102639. */
  102640. static readonly ANIMATIONTYPE_FLOAT: number;
  102641. /**
  102642. * Vector3 animation type
  102643. */
  102644. static readonly ANIMATIONTYPE_VECTOR3: number;
  102645. /**
  102646. * Quaternion animation type
  102647. */
  102648. static readonly ANIMATIONTYPE_QUATERNION: number;
  102649. /**
  102650. * Matrix animation type
  102651. */
  102652. static readonly ANIMATIONTYPE_MATRIX: number;
  102653. /**
  102654. * Color3 animation type
  102655. */
  102656. static readonly ANIMATIONTYPE_COLOR3: number;
  102657. /**
  102658. * Color3 animation type
  102659. */
  102660. static readonly ANIMATIONTYPE_COLOR4: number;
  102661. /**
  102662. * Vector2 animation type
  102663. */
  102664. static readonly ANIMATIONTYPE_VECTOR2: number;
  102665. /**
  102666. * Size animation type
  102667. */
  102668. static readonly ANIMATIONTYPE_SIZE: number;
  102669. /**
  102670. * Relative Loop Mode
  102671. */
  102672. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102673. /**
  102674. * Cycle Loop Mode
  102675. */
  102676. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102677. /**
  102678. * Constant Loop Mode
  102679. */
  102680. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102681. /** @hidden */
  102682. static _UniversalLerp(left: any, right: any, amount: number): any;
  102683. /**
  102684. * Parses an animation object and creates an animation
  102685. * @param parsedAnimation Parsed animation object
  102686. * @returns Animation object
  102687. */
  102688. static Parse(parsedAnimation: any): Animation;
  102689. /**
  102690. * Appends the serialized animations from the source animations
  102691. * @param source Source containing the animations
  102692. * @param destination Target to store the animations
  102693. */
  102694. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102695. }
  102696. }
  102697. declare module BABYLON {
  102698. /**
  102699. * Interface containing an array of animations
  102700. */
  102701. export interface IAnimatable {
  102702. /**
  102703. * Array of animations
  102704. */
  102705. animations: Nullable<Array<Animation>>;
  102706. }
  102707. }
  102708. declare module BABYLON {
  102709. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102710. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102711. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102712. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102713. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102714. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102715. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102716. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102717. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102718. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102719. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102720. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102721. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102722. /**
  102723. * Decorator used to define property that can be serialized as reference to a camera
  102724. * @param sourceName defines the name of the property to decorate
  102725. */
  102726. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102727. /**
  102728. * Class used to help serialization objects
  102729. */
  102730. export class SerializationHelper {
  102731. /** @hidden */
  102732. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102733. /** @hidden */
  102734. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102735. /** @hidden */
  102736. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102737. /** @hidden */
  102738. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102739. /**
  102740. * Appends the serialized animations from the source animations
  102741. * @param source Source containing the animations
  102742. * @param destination Target to store the animations
  102743. */
  102744. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102745. /**
  102746. * Static function used to serialized a specific entity
  102747. * @param entity defines the entity to serialize
  102748. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102749. * @returns a JSON compatible object representing the serialization of the entity
  102750. */
  102751. static Serialize<T>(entity: T, serializationObject?: any): any;
  102752. /**
  102753. * Creates a new entity from a serialization data object
  102754. * @param creationFunction defines a function used to instanciated the new entity
  102755. * @param source defines the source serialization data
  102756. * @param scene defines the hosting scene
  102757. * @param rootUrl defines the root url for resources
  102758. * @returns a new entity
  102759. */
  102760. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102761. /**
  102762. * Clones an object
  102763. * @param creationFunction defines the function used to instanciate the new object
  102764. * @param source defines the source object
  102765. * @returns the cloned object
  102766. */
  102767. static Clone<T>(creationFunction: () => T, source: T): T;
  102768. /**
  102769. * Instanciates a new object based on a source one (some data will be shared between both object)
  102770. * @param creationFunction defines the function used to instanciate the new object
  102771. * @param source defines the source object
  102772. * @returns the new object
  102773. */
  102774. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102775. }
  102776. }
  102777. declare module BABYLON {
  102778. /**
  102779. * Class used to manipulate GUIDs
  102780. */
  102781. export class GUID {
  102782. /**
  102783. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102784. * Be aware Math.random() could cause collisions, but:
  102785. * "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"
  102786. * @returns a pseudo random id
  102787. */
  102788. static RandomId(): string;
  102789. }
  102790. }
  102791. declare module BABYLON {
  102792. /**
  102793. * Base class of all the textures in babylon.
  102794. * It groups all the common properties the materials, post process, lights... might need
  102795. * in order to make a correct use of the texture.
  102796. */
  102797. export class BaseTexture implements IAnimatable {
  102798. /**
  102799. * Default anisotropic filtering level for the application.
  102800. * It is set to 4 as a good tradeoff between perf and quality.
  102801. */
  102802. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102803. /**
  102804. * Gets or sets the unique id of the texture
  102805. */
  102806. uniqueId: number;
  102807. /**
  102808. * Define the name of the texture.
  102809. */
  102810. name: string;
  102811. /**
  102812. * Gets or sets an object used to store user defined information.
  102813. */
  102814. metadata: any;
  102815. /**
  102816. * For internal use only. Please do not use.
  102817. */
  102818. reservedDataStore: any;
  102819. private _hasAlpha;
  102820. /**
  102821. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102822. */
  102823. set hasAlpha(value: boolean);
  102824. get hasAlpha(): boolean;
  102825. /**
  102826. * Defines if the alpha value should be determined via the rgb values.
  102827. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102828. */
  102829. getAlphaFromRGB: boolean;
  102830. /**
  102831. * Intensity or strength of the texture.
  102832. * It is commonly used by materials to fine tune the intensity of the texture
  102833. */
  102834. level: number;
  102835. /**
  102836. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102837. * This is part of the texture as textures usually maps to one uv set.
  102838. */
  102839. coordinatesIndex: number;
  102840. private _coordinatesMode;
  102841. /**
  102842. * How a texture is mapped.
  102843. *
  102844. * | Value | Type | Description |
  102845. * | ----- | ----------------------------------- | ----------- |
  102846. * | 0 | EXPLICIT_MODE | |
  102847. * | 1 | SPHERICAL_MODE | |
  102848. * | 2 | PLANAR_MODE | |
  102849. * | 3 | CUBIC_MODE | |
  102850. * | 4 | PROJECTION_MODE | |
  102851. * | 5 | SKYBOX_MODE | |
  102852. * | 6 | INVCUBIC_MODE | |
  102853. * | 7 | EQUIRECTANGULAR_MODE | |
  102854. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102855. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102856. */
  102857. set coordinatesMode(value: number);
  102858. get coordinatesMode(): number;
  102859. /**
  102860. * | Value | Type | Description |
  102861. * | ----- | ------------------ | ----------- |
  102862. * | 0 | CLAMP_ADDRESSMODE | |
  102863. * | 1 | WRAP_ADDRESSMODE | |
  102864. * | 2 | MIRROR_ADDRESSMODE | |
  102865. */
  102866. wrapU: number;
  102867. /**
  102868. * | Value | Type | Description |
  102869. * | ----- | ------------------ | ----------- |
  102870. * | 0 | CLAMP_ADDRESSMODE | |
  102871. * | 1 | WRAP_ADDRESSMODE | |
  102872. * | 2 | MIRROR_ADDRESSMODE | |
  102873. */
  102874. wrapV: number;
  102875. /**
  102876. * | Value | Type | Description |
  102877. * | ----- | ------------------ | ----------- |
  102878. * | 0 | CLAMP_ADDRESSMODE | |
  102879. * | 1 | WRAP_ADDRESSMODE | |
  102880. * | 2 | MIRROR_ADDRESSMODE | |
  102881. */
  102882. wrapR: number;
  102883. /**
  102884. * With compliant hardware and browser (supporting anisotropic filtering)
  102885. * this defines the level of anisotropic filtering in the texture.
  102886. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102887. */
  102888. anisotropicFilteringLevel: number;
  102889. /**
  102890. * Define if the texture is a cube texture or if false a 2d texture.
  102891. */
  102892. get isCube(): boolean;
  102893. set isCube(value: boolean);
  102894. /**
  102895. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102896. */
  102897. get is3D(): boolean;
  102898. set is3D(value: boolean);
  102899. /**
  102900. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102901. */
  102902. get is2DArray(): boolean;
  102903. set is2DArray(value: boolean);
  102904. /**
  102905. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102906. * HDR texture are usually stored in linear space.
  102907. * This only impacts the PBR and Background materials
  102908. */
  102909. gammaSpace: boolean;
  102910. /**
  102911. * Gets or sets whether or not the texture contains RGBD data.
  102912. */
  102913. get isRGBD(): boolean;
  102914. set isRGBD(value: boolean);
  102915. /**
  102916. * Is Z inverted in the texture (useful in a cube texture).
  102917. */
  102918. invertZ: boolean;
  102919. /**
  102920. * Are mip maps generated for this texture or not.
  102921. */
  102922. get noMipmap(): boolean;
  102923. /**
  102924. * @hidden
  102925. */
  102926. lodLevelInAlpha: boolean;
  102927. /**
  102928. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102929. */
  102930. get lodGenerationOffset(): number;
  102931. set lodGenerationOffset(value: number);
  102932. /**
  102933. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102934. */
  102935. get lodGenerationScale(): number;
  102936. set lodGenerationScale(value: number);
  102937. /**
  102938. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102939. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102940. * average roughness values.
  102941. */
  102942. get linearSpecularLOD(): boolean;
  102943. set linearSpecularLOD(value: boolean);
  102944. /**
  102945. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102946. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102947. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102948. */
  102949. get irradianceTexture(): Nullable<BaseTexture>;
  102950. set irradianceTexture(value: Nullable<BaseTexture>);
  102951. /**
  102952. * Define if the texture is a render target.
  102953. */
  102954. isRenderTarget: boolean;
  102955. /**
  102956. * Define the unique id of the texture in the scene.
  102957. */
  102958. get uid(): string;
  102959. /**
  102960. * Return a string representation of the texture.
  102961. * @returns the texture as a string
  102962. */
  102963. toString(): string;
  102964. /**
  102965. * Get the class name of the texture.
  102966. * @returns "BaseTexture"
  102967. */
  102968. getClassName(): string;
  102969. /**
  102970. * Define the list of animation attached to the texture.
  102971. */
  102972. animations: Animation[];
  102973. /**
  102974. * An event triggered when the texture is disposed.
  102975. */
  102976. onDisposeObservable: Observable<BaseTexture>;
  102977. private _onDisposeObserver;
  102978. /**
  102979. * Callback triggered when the texture has been disposed.
  102980. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102981. */
  102982. set onDispose(callback: () => void);
  102983. /**
  102984. * Define the current state of the loading sequence when in delayed load mode.
  102985. */
  102986. delayLoadState: number;
  102987. private _scene;
  102988. /** @hidden */
  102989. _texture: Nullable<InternalTexture>;
  102990. private _uid;
  102991. /**
  102992. * Define if the texture is preventinga material to render or not.
  102993. * If not and the texture is not ready, the engine will use a default black texture instead.
  102994. */
  102995. get isBlocking(): boolean;
  102996. /**
  102997. * Instantiates a new BaseTexture.
  102998. * Base class of all the textures in babylon.
  102999. * It groups all the common properties the materials, post process, lights... might need
  103000. * in order to make a correct use of the texture.
  103001. * @param scene Define the scene the texture blongs to
  103002. */
  103003. constructor(scene: Nullable<Scene>);
  103004. /**
  103005. * Get the scene the texture belongs to.
  103006. * @returns the scene or null if undefined
  103007. */
  103008. getScene(): Nullable<Scene>;
  103009. /**
  103010. * Get the texture transform matrix used to offset tile the texture for istance.
  103011. * @returns the transformation matrix
  103012. */
  103013. getTextureMatrix(): Matrix;
  103014. /**
  103015. * Get the texture reflection matrix used to rotate/transform the reflection.
  103016. * @returns the reflection matrix
  103017. */
  103018. getReflectionTextureMatrix(): Matrix;
  103019. /**
  103020. * Get the underlying lower level texture from Babylon.
  103021. * @returns the insternal texture
  103022. */
  103023. getInternalTexture(): Nullable<InternalTexture>;
  103024. /**
  103025. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103026. * @returns true if ready or not blocking
  103027. */
  103028. isReadyOrNotBlocking(): boolean;
  103029. /**
  103030. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103031. * @returns true if fully ready
  103032. */
  103033. isReady(): boolean;
  103034. private _cachedSize;
  103035. /**
  103036. * Get the size of the texture.
  103037. * @returns the texture size.
  103038. */
  103039. getSize(): ISize;
  103040. /**
  103041. * Get the base size of the texture.
  103042. * It can be different from the size if the texture has been resized for POT for instance
  103043. * @returns the base size
  103044. */
  103045. getBaseSize(): ISize;
  103046. /**
  103047. * Update the sampling mode of the texture.
  103048. * Default is Trilinear mode.
  103049. *
  103050. * | Value | Type | Description |
  103051. * | ----- | ------------------ | ----------- |
  103052. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103053. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103054. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103055. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103056. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103057. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103058. * | 7 | NEAREST_LINEAR | |
  103059. * | 8 | NEAREST_NEAREST | |
  103060. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103061. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103062. * | 11 | LINEAR_LINEAR | |
  103063. * | 12 | LINEAR_NEAREST | |
  103064. *
  103065. * > _mag_: magnification filter (close to the viewer)
  103066. * > _min_: minification filter (far from the viewer)
  103067. * > _mip_: filter used between mip map levels
  103068. *@param samplingMode Define the new sampling mode of the texture
  103069. */
  103070. updateSamplingMode(samplingMode: number): void;
  103071. /**
  103072. * Scales the texture if is `canRescale()`
  103073. * @param ratio the resize factor we want to use to rescale
  103074. */
  103075. scale(ratio: number): void;
  103076. /**
  103077. * Get if the texture can rescale.
  103078. */
  103079. get canRescale(): boolean;
  103080. /** @hidden */
  103081. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103082. /** @hidden */
  103083. _rebuild(): void;
  103084. /**
  103085. * Triggers the load sequence in delayed load mode.
  103086. */
  103087. delayLoad(): void;
  103088. /**
  103089. * Clones the texture.
  103090. * @returns the cloned texture
  103091. */
  103092. clone(): Nullable<BaseTexture>;
  103093. /**
  103094. * Get the texture underlying type (INT, FLOAT...)
  103095. */
  103096. get textureType(): number;
  103097. /**
  103098. * Get the texture underlying format (RGB, RGBA...)
  103099. */
  103100. get textureFormat(): number;
  103101. /**
  103102. * Indicates that textures need to be re-calculated for all materials
  103103. */
  103104. protected _markAllSubMeshesAsTexturesDirty(): void;
  103105. /**
  103106. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103107. * This will returns an RGBA array buffer containing either in values (0-255) or
  103108. * float values (0-1) depending of the underlying buffer type.
  103109. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103110. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103111. * @param buffer defines a user defined buffer to fill with data (can be null)
  103112. * @returns The Array buffer containing the pixels data.
  103113. */
  103114. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103115. /**
  103116. * Release and destroy the underlying lower level texture aka internalTexture.
  103117. */
  103118. releaseInternalTexture(): void;
  103119. /** @hidden */
  103120. get _lodTextureHigh(): Nullable<BaseTexture>;
  103121. /** @hidden */
  103122. get _lodTextureMid(): Nullable<BaseTexture>;
  103123. /** @hidden */
  103124. get _lodTextureLow(): Nullable<BaseTexture>;
  103125. /**
  103126. * Dispose the texture and release its associated resources.
  103127. */
  103128. dispose(): void;
  103129. /**
  103130. * Serialize the texture into a JSON representation that can be parsed later on.
  103131. * @returns the JSON representation of the texture
  103132. */
  103133. serialize(): any;
  103134. /**
  103135. * Helper function to be called back once a list of texture contains only ready textures.
  103136. * @param textures Define the list of textures to wait for
  103137. * @param callback Define the callback triggered once the entire list will be ready
  103138. */
  103139. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103140. }
  103141. }
  103142. declare module BABYLON {
  103143. /**
  103144. * Options to be used when creating an effect.
  103145. */
  103146. export interface IEffectCreationOptions {
  103147. /**
  103148. * Atrributes that will be used in the shader.
  103149. */
  103150. attributes: string[];
  103151. /**
  103152. * Uniform varible names that will be set in the shader.
  103153. */
  103154. uniformsNames: string[];
  103155. /**
  103156. * Uniform buffer variable names that will be set in the shader.
  103157. */
  103158. uniformBuffersNames: string[];
  103159. /**
  103160. * Sampler texture variable names that will be set in the shader.
  103161. */
  103162. samplers: string[];
  103163. /**
  103164. * Define statements that will be set in the shader.
  103165. */
  103166. defines: any;
  103167. /**
  103168. * Possible fallbacks for this effect to improve performance when needed.
  103169. */
  103170. fallbacks: Nullable<IEffectFallbacks>;
  103171. /**
  103172. * Callback that will be called when the shader is compiled.
  103173. */
  103174. onCompiled: Nullable<(effect: Effect) => void>;
  103175. /**
  103176. * Callback that will be called if an error occurs during shader compilation.
  103177. */
  103178. onError: Nullable<(effect: Effect, errors: string) => void>;
  103179. /**
  103180. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103181. */
  103182. indexParameters?: any;
  103183. /**
  103184. * Max number of lights that can be used in the shader.
  103185. */
  103186. maxSimultaneousLights?: number;
  103187. /**
  103188. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103189. */
  103190. transformFeedbackVaryings?: Nullable<string[]>;
  103191. }
  103192. /**
  103193. * Effect containing vertex and fragment shader that can be executed on an object.
  103194. */
  103195. export class Effect implements IDisposable {
  103196. /**
  103197. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103198. */
  103199. static ShadersRepository: string;
  103200. /**
  103201. * Name of the effect.
  103202. */
  103203. name: any;
  103204. /**
  103205. * String container all the define statements that should be set on the shader.
  103206. */
  103207. defines: string;
  103208. /**
  103209. * Callback that will be called when the shader is compiled.
  103210. */
  103211. onCompiled: Nullable<(effect: Effect) => void>;
  103212. /**
  103213. * Callback that will be called if an error occurs during shader compilation.
  103214. */
  103215. onError: Nullable<(effect: Effect, errors: string) => void>;
  103216. /**
  103217. * Callback that will be called when effect is bound.
  103218. */
  103219. onBind: Nullable<(effect: Effect) => void>;
  103220. /**
  103221. * Unique ID of the effect.
  103222. */
  103223. uniqueId: number;
  103224. /**
  103225. * Observable that will be called when the shader is compiled.
  103226. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103227. */
  103228. onCompileObservable: Observable<Effect>;
  103229. /**
  103230. * Observable that will be called if an error occurs during shader compilation.
  103231. */
  103232. onErrorObservable: Observable<Effect>;
  103233. /** @hidden */
  103234. _onBindObservable: Nullable<Observable<Effect>>;
  103235. /**
  103236. * @hidden
  103237. * Specifies if the effect was previously ready
  103238. */
  103239. _wasPreviouslyReady: boolean;
  103240. /**
  103241. * Observable that will be called when effect is bound.
  103242. */
  103243. get onBindObservable(): Observable<Effect>;
  103244. /** @hidden */
  103245. _bonesComputationForcedToCPU: boolean;
  103246. private static _uniqueIdSeed;
  103247. private _engine;
  103248. private _uniformBuffersNames;
  103249. private _uniformsNames;
  103250. private _samplerList;
  103251. private _samplers;
  103252. private _isReady;
  103253. private _compilationError;
  103254. private _allFallbacksProcessed;
  103255. private _attributesNames;
  103256. private _attributes;
  103257. private _attributeLocationByName;
  103258. private _uniforms;
  103259. /**
  103260. * Key for the effect.
  103261. * @hidden
  103262. */
  103263. _key: string;
  103264. private _indexParameters;
  103265. private _fallbacks;
  103266. private _vertexSourceCode;
  103267. private _fragmentSourceCode;
  103268. private _vertexSourceCodeOverride;
  103269. private _fragmentSourceCodeOverride;
  103270. private _transformFeedbackVaryings;
  103271. /**
  103272. * Compiled shader to webGL program.
  103273. * @hidden
  103274. */
  103275. _pipelineContext: Nullable<IPipelineContext>;
  103276. private _valueCache;
  103277. private static _baseCache;
  103278. /**
  103279. * Instantiates an effect.
  103280. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103281. * @param baseName Name of the effect.
  103282. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103283. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103284. * @param samplers List of sampler variables that will be passed to the shader.
  103285. * @param engine Engine to be used to render the effect
  103286. * @param defines Define statements to be added to the shader.
  103287. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103288. * @param onCompiled Callback that will be called when the shader is compiled.
  103289. * @param onError Callback that will be called if an error occurs during shader compilation.
  103290. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103291. */
  103292. 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);
  103293. private _useFinalCode;
  103294. /**
  103295. * Unique key for this effect
  103296. */
  103297. get key(): string;
  103298. /**
  103299. * If the effect has been compiled and prepared.
  103300. * @returns if the effect is compiled and prepared.
  103301. */
  103302. isReady(): boolean;
  103303. private _isReadyInternal;
  103304. /**
  103305. * The engine the effect was initialized with.
  103306. * @returns the engine.
  103307. */
  103308. getEngine(): Engine;
  103309. /**
  103310. * The pipeline context for this effect
  103311. * @returns the associated pipeline context
  103312. */
  103313. getPipelineContext(): Nullable<IPipelineContext>;
  103314. /**
  103315. * The set of names of attribute variables for the shader.
  103316. * @returns An array of attribute names.
  103317. */
  103318. getAttributesNames(): string[];
  103319. /**
  103320. * Returns the attribute at the given index.
  103321. * @param index The index of the attribute.
  103322. * @returns The location of the attribute.
  103323. */
  103324. getAttributeLocation(index: number): number;
  103325. /**
  103326. * Returns the attribute based on the name of the variable.
  103327. * @param name of the attribute to look up.
  103328. * @returns the attribute location.
  103329. */
  103330. getAttributeLocationByName(name: string): number;
  103331. /**
  103332. * The number of attributes.
  103333. * @returns the numnber of attributes.
  103334. */
  103335. getAttributesCount(): number;
  103336. /**
  103337. * Gets the index of a uniform variable.
  103338. * @param uniformName of the uniform to look up.
  103339. * @returns the index.
  103340. */
  103341. getUniformIndex(uniformName: string): number;
  103342. /**
  103343. * Returns the attribute based on the name of the variable.
  103344. * @param uniformName of the uniform to look up.
  103345. * @returns the location of the uniform.
  103346. */
  103347. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103348. /**
  103349. * Returns an array of sampler variable names
  103350. * @returns The array of sampler variable neames.
  103351. */
  103352. getSamplers(): string[];
  103353. /**
  103354. * The error from the last compilation.
  103355. * @returns the error string.
  103356. */
  103357. getCompilationError(): string;
  103358. /**
  103359. * Gets a boolean indicating that all fallbacks were used during compilation
  103360. * @returns true if all fallbacks were used
  103361. */
  103362. allFallbacksProcessed(): boolean;
  103363. /**
  103364. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103365. * @param func The callback to be used.
  103366. */
  103367. executeWhenCompiled(func: (effect: Effect) => void): void;
  103368. private _checkIsReady;
  103369. private _loadShader;
  103370. /**
  103371. * Recompiles the webGL program
  103372. * @param vertexSourceCode The source code for the vertex shader.
  103373. * @param fragmentSourceCode The source code for the fragment shader.
  103374. * @param onCompiled Callback called when completed.
  103375. * @param onError Callback called on error.
  103376. * @hidden
  103377. */
  103378. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103379. /**
  103380. * Prepares the effect
  103381. * @hidden
  103382. */
  103383. _prepareEffect(): void;
  103384. private _processCompilationErrors;
  103385. /**
  103386. * Checks if the effect is supported. (Must be called after compilation)
  103387. */
  103388. get isSupported(): boolean;
  103389. /**
  103390. * Binds a texture to the engine to be used as output of the shader.
  103391. * @param channel Name of the output variable.
  103392. * @param texture Texture to bind.
  103393. * @hidden
  103394. */
  103395. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103396. /**
  103397. * Sets a texture on the engine to be used in the shader.
  103398. * @param channel Name of the sampler variable.
  103399. * @param texture Texture to set.
  103400. */
  103401. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103402. /**
  103403. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103404. * @param channel Name of the sampler variable.
  103405. * @param texture Texture to set.
  103406. */
  103407. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103408. /**
  103409. * Sets an array of textures on the engine to be used in the shader.
  103410. * @param channel Name of the variable.
  103411. * @param textures Textures to set.
  103412. */
  103413. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103414. /**
  103415. * 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)
  103416. * @param channel Name of the sampler variable.
  103417. * @param postProcess Post process to get the input texture from.
  103418. */
  103419. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103420. /**
  103421. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103422. * 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)
  103423. * @param channel Name of the sampler variable.
  103424. * @param postProcess Post process to get the output texture from.
  103425. */
  103426. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103427. /** @hidden */
  103428. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103429. /** @hidden */
  103430. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103431. /** @hidden */
  103432. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103433. /** @hidden */
  103434. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103435. /**
  103436. * Binds a buffer to a uniform.
  103437. * @param buffer Buffer to bind.
  103438. * @param name Name of the uniform variable to bind to.
  103439. */
  103440. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103441. /**
  103442. * Binds block to a uniform.
  103443. * @param blockName Name of the block to bind.
  103444. * @param index Index to bind.
  103445. */
  103446. bindUniformBlock(blockName: string, index: number): void;
  103447. /**
  103448. * Sets an interger value on a uniform variable.
  103449. * @param uniformName Name of the variable.
  103450. * @param value Value to be set.
  103451. * @returns this effect.
  103452. */
  103453. setInt(uniformName: string, value: number): Effect;
  103454. /**
  103455. * Sets an int array on a uniform variable.
  103456. * @param uniformName Name of the variable.
  103457. * @param array array to be set.
  103458. * @returns this effect.
  103459. */
  103460. setIntArray(uniformName: string, array: Int32Array): Effect;
  103461. /**
  103462. * 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)
  103463. * @param uniformName Name of the variable.
  103464. * @param array array to be set.
  103465. * @returns this effect.
  103466. */
  103467. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103468. /**
  103469. * 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)
  103470. * @param uniformName Name of the variable.
  103471. * @param array array to be set.
  103472. * @returns this effect.
  103473. */
  103474. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103475. /**
  103476. * 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)
  103477. * @param uniformName Name of the variable.
  103478. * @param array array to be set.
  103479. * @returns this effect.
  103480. */
  103481. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103482. /**
  103483. * Sets an float array on a uniform variable.
  103484. * @param uniformName Name of the variable.
  103485. * @param array array to be set.
  103486. * @returns this effect.
  103487. */
  103488. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103489. /**
  103490. * 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)
  103491. * @param uniformName Name of the variable.
  103492. * @param array array to be set.
  103493. * @returns this effect.
  103494. */
  103495. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103496. /**
  103497. * 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)
  103498. * @param uniformName Name of the variable.
  103499. * @param array array to be set.
  103500. * @returns this effect.
  103501. */
  103502. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103503. /**
  103504. * 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)
  103505. * @param uniformName Name of the variable.
  103506. * @param array array to be set.
  103507. * @returns this effect.
  103508. */
  103509. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103510. /**
  103511. * Sets an array on a uniform variable.
  103512. * @param uniformName Name of the variable.
  103513. * @param array array to be set.
  103514. * @returns this effect.
  103515. */
  103516. setArray(uniformName: string, array: number[]): Effect;
  103517. /**
  103518. * 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)
  103519. * @param uniformName Name of the variable.
  103520. * @param array array to be set.
  103521. * @returns this effect.
  103522. */
  103523. setArray2(uniformName: string, array: number[]): Effect;
  103524. /**
  103525. * 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)
  103526. * @param uniformName Name of the variable.
  103527. * @param array array to be set.
  103528. * @returns this effect.
  103529. */
  103530. setArray3(uniformName: string, array: number[]): Effect;
  103531. /**
  103532. * 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)
  103533. * @param uniformName Name of the variable.
  103534. * @param array array to be set.
  103535. * @returns this effect.
  103536. */
  103537. setArray4(uniformName: string, array: number[]): Effect;
  103538. /**
  103539. * Sets matrices on a uniform variable.
  103540. * @param uniformName Name of the variable.
  103541. * @param matrices matrices to be set.
  103542. * @returns this effect.
  103543. */
  103544. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103545. /**
  103546. * Sets matrix on a uniform variable.
  103547. * @param uniformName Name of the variable.
  103548. * @param matrix matrix to be set.
  103549. * @returns this effect.
  103550. */
  103551. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103552. /**
  103553. * 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)
  103554. * @param uniformName Name of the variable.
  103555. * @param matrix matrix to be set.
  103556. * @returns this effect.
  103557. */
  103558. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103559. /**
  103560. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103561. * @param uniformName Name of the variable.
  103562. * @param matrix matrix to be set.
  103563. * @returns this effect.
  103564. */
  103565. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103566. /**
  103567. * Sets a float on a uniform variable.
  103568. * @param uniformName Name of the variable.
  103569. * @param value value to be set.
  103570. * @returns this effect.
  103571. */
  103572. setFloat(uniformName: string, value: number): Effect;
  103573. /**
  103574. * Sets a boolean on a uniform variable.
  103575. * @param uniformName Name of the variable.
  103576. * @param bool value to be set.
  103577. * @returns this effect.
  103578. */
  103579. setBool(uniformName: string, bool: boolean): Effect;
  103580. /**
  103581. * Sets a Vector2 on a uniform variable.
  103582. * @param uniformName Name of the variable.
  103583. * @param vector2 vector2 to be set.
  103584. * @returns this effect.
  103585. */
  103586. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103587. /**
  103588. * Sets a float2 on a uniform variable.
  103589. * @param uniformName Name of the variable.
  103590. * @param x First float in float2.
  103591. * @param y Second float in float2.
  103592. * @returns this effect.
  103593. */
  103594. setFloat2(uniformName: string, x: number, y: number): Effect;
  103595. /**
  103596. * Sets a Vector3 on a uniform variable.
  103597. * @param uniformName Name of the variable.
  103598. * @param vector3 Value to be set.
  103599. * @returns this effect.
  103600. */
  103601. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103602. /**
  103603. * Sets a float3 on a uniform variable.
  103604. * @param uniformName Name of the variable.
  103605. * @param x First float in float3.
  103606. * @param y Second float in float3.
  103607. * @param z Third float in float3.
  103608. * @returns this effect.
  103609. */
  103610. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103611. /**
  103612. * Sets a Vector4 on a uniform variable.
  103613. * @param uniformName Name of the variable.
  103614. * @param vector4 Value to be set.
  103615. * @returns this effect.
  103616. */
  103617. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103618. /**
  103619. * Sets a float4 on a uniform variable.
  103620. * @param uniformName Name of the variable.
  103621. * @param x First float in float4.
  103622. * @param y Second float in float4.
  103623. * @param z Third float in float4.
  103624. * @param w Fourth float in float4.
  103625. * @returns this effect.
  103626. */
  103627. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103628. /**
  103629. * Sets a Color3 on a uniform variable.
  103630. * @param uniformName Name of the variable.
  103631. * @param color3 Value to be set.
  103632. * @returns this effect.
  103633. */
  103634. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103635. /**
  103636. * Sets a Color4 on a uniform variable.
  103637. * @param uniformName Name of the variable.
  103638. * @param color3 Value to be set.
  103639. * @param alpha Alpha value to be set.
  103640. * @returns this effect.
  103641. */
  103642. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103643. /**
  103644. * Sets a Color4 on a uniform variable
  103645. * @param uniformName defines the name of the variable
  103646. * @param color4 defines the value to be set
  103647. * @returns this effect.
  103648. */
  103649. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103650. /** Release all associated resources */
  103651. dispose(): void;
  103652. /**
  103653. * This function will add a new shader to the shader store
  103654. * @param name the name of the shader
  103655. * @param pixelShader optional pixel shader content
  103656. * @param vertexShader optional vertex shader content
  103657. */
  103658. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103659. /**
  103660. * Store of each shader (The can be looked up using effect.key)
  103661. */
  103662. static ShadersStore: {
  103663. [key: string]: string;
  103664. };
  103665. /**
  103666. * Store of each included file for a shader (The can be looked up using effect.key)
  103667. */
  103668. static IncludesShadersStore: {
  103669. [key: string]: string;
  103670. };
  103671. /**
  103672. * Resets the cache of effects.
  103673. */
  103674. static ResetCache(): void;
  103675. }
  103676. }
  103677. declare module BABYLON {
  103678. /**
  103679. * Interface used to describe the capabilities of the engine relatively to the current browser
  103680. */
  103681. export interface EngineCapabilities {
  103682. /** Maximum textures units per fragment shader */
  103683. maxTexturesImageUnits: number;
  103684. /** Maximum texture units per vertex shader */
  103685. maxVertexTextureImageUnits: number;
  103686. /** Maximum textures units in the entire pipeline */
  103687. maxCombinedTexturesImageUnits: number;
  103688. /** Maximum texture size */
  103689. maxTextureSize: number;
  103690. /** Maximum texture samples */
  103691. maxSamples?: number;
  103692. /** Maximum cube texture size */
  103693. maxCubemapTextureSize: number;
  103694. /** Maximum render texture size */
  103695. maxRenderTextureSize: number;
  103696. /** Maximum number of vertex attributes */
  103697. maxVertexAttribs: number;
  103698. /** Maximum number of varyings */
  103699. maxVaryingVectors: number;
  103700. /** Maximum number of uniforms per vertex shader */
  103701. maxVertexUniformVectors: number;
  103702. /** Maximum number of uniforms per fragment shader */
  103703. maxFragmentUniformVectors: number;
  103704. /** Defines if standard derivates (dx/dy) are supported */
  103705. standardDerivatives: boolean;
  103706. /** Defines if s3tc texture compression is supported */
  103707. s3tc?: WEBGL_compressed_texture_s3tc;
  103708. /** Defines if pvrtc texture compression is supported */
  103709. pvrtc: any;
  103710. /** Defines if etc1 texture compression is supported */
  103711. etc1: any;
  103712. /** Defines if etc2 texture compression is supported */
  103713. etc2: any;
  103714. /** Defines if astc texture compression is supported */
  103715. astc: any;
  103716. /** Defines if float textures are supported */
  103717. textureFloat: boolean;
  103718. /** Defines if vertex array objects are supported */
  103719. vertexArrayObject: boolean;
  103720. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103721. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103722. /** Gets the maximum level of anisotropy supported */
  103723. maxAnisotropy: number;
  103724. /** Defines if instancing is supported */
  103725. instancedArrays: boolean;
  103726. /** Defines if 32 bits indices are supported */
  103727. uintIndices: boolean;
  103728. /** Defines if high precision shaders are supported */
  103729. highPrecisionShaderSupported: boolean;
  103730. /** Defines if depth reading in the fragment shader is supported */
  103731. fragmentDepthSupported: boolean;
  103732. /** Defines if float texture linear filtering is supported*/
  103733. textureFloatLinearFiltering: boolean;
  103734. /** Defines if rendering to float textures is supported */
  103735. textureFloatRender: boolean;
  103736. /** Defines if half float textures are supported*/
  103737. textureHalfFloat: boolean;
  103738. /** Defines if half float texture linear filtering is supported*/
  103739. textureHalfFloatLinearFiltering: boolean;
  103740. /** Defines if rendering to half float textures is supported */
  103741. textureHalfFloatRender: boolean;
  103742. /** Defines if textureLOD shader command is supported */
  103743. textureLOD: boolean;
  103744. /** Defines if draw buffers extension is supported */
  103745. drawBuffersExtension: boolean;
  103746. /** Defines if depth textures are supported */
  103747. depthTextureExtension: boolean;
  103748. /** Defines if float color buffer are supported */
  103749. colorBufferFloat: boolean;
  103750. /** Gets disjoint timer query extension (null if not supported) */
  103751. timerQuery?: EXT_disjoint_timer_query;
  103752. /** Defines if timestamp can be used with timer query */
  103753. canUseTimestampForTimerQuery: boolean;
  103754. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103755. multiview?: any;
  103756. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103757. oculusMultiview?: any;
  103758. /** Function used to let the system compiles shaders in background */
  103759. parallelShaderCompile?: {
  103760. COMPLETION_STATUS_KHR: number;
  103761. };
  103762. /** Max number of texture samples for MSAA */
  103763. maxMSAASamples: number;
  103764. /** Defines if the blend min max extension is supported */
  103765. blendMinMax: boolean;
  103766. }
  103767. }
  103768. declare module BABYLON {
  103769. /**
  103770. * @hidden
  103771. **/
  103772. export class DepthCullingState {
  103773. private _isDepthTestDirty;
  103774. private _isDepthMaskDirty;
  103775. private _isDepthFuncDirty;
  103776. private _isCullFaceDirty;
  103777. private _isCullDirty;
  103778. private _isZOffsetDirty;
  103779. private _isFrontFaceDirty;
  103780. private _depthTest;
  103781. private _depthMask;
  103782. private _depthFunc;
  103783. private _cull;
  103784. private _cullFace;
  103785. private _zOffset;
  103786. private _frontFace;
  103787. /**
  103788. * Initializes the state.
  103789. */
  103790. constructor();
  103791. get isDirty(): boolean;
  103792. get zOffset(): number;
  103793. set zOffset(value: number);
  103794. get cullFace(): Nullable<number>;
  103795. set cullFace(value: Nullable<number>);
  103796. get cull(): Nullable<boolean>;
  103797. set cull(value: Nullable<boolean>);
  103798. get depthFunc(): Nullable<number>;
  103799. set depthFunc(value: Nullable<number>);
  103800. get depthMask(): boolean;
  103801. set depthMask(value: boolean);
  103802. get depthTest(): boolean;
  103803. set depthTest(value: boolean);
  103804. get frontFace(): Nullable<number>;
  103805. set frontFace(value: Nullable<number>);
  103806. reset(): void;
  103807. apply(gl: WebGLRenderingContext): void;
  103808. }
  103809. }
  103810. declare module BABYLON {
  103811. /**
  103812. * @hidden
  103813. **/
  103814. export class StencilState {
  103815. /** 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 */
  103816. static readonly ALWAYS: number;
  103817. /** Passed to stencilOperation to specify that stencil value must be kept */
  103818. static readonly KEEP: number;
  103819. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103820. static readonly REPLACE: number;
  103821. private _isStencilTestDirty;
  103822. private _isStencilMaskDirty;
  103823. private _isStencilFuncDirty;
  103824. private _isStencilOpDirty;
  103825. private _stencilTest;
  103826. private _stencilMask;
  103827. private _stencilFunc;
  103828. private _stencilFuncRef;
  103829. private _stencilFuncMask;
  103830. private _stencilOpStencilFail;
  103831. private _stencilOpDepthFail;
  103832. private _stencilOpStencilDepthPass;
  103833. get isDirty(): boolean;
  103834. get stencilFunc(): number;
  103835. set stencilFunc(value: number);
  103836. get stencilFuncRef(): number;
  103837. set stencilFuncRef(value: number);
  103838. get stencilFuncMask(): number;
  103839. set stencilFuncMask(value: number);
  103840. get stencilOpStencilFail(): number;
  103841. set stencilOpStencilFail(value: number);
  103842. get stencilOpDepthFail(): number;
  103843. set stencilOpDepthFail(value: number);
  103844. get stencilOpStencilDepthPass(): number;
  103845. set stencilOpStencilDepthPass(value: number);
  103846. get stencilMask(): number;
  103847. set stencilMask(value: number);
  103848. get stencilTest(): boolean;
  103849. set stencilTest(value: boolean);
  103850. constructor();
  103851. reset(): void;
  103852. apply(gl: WebGLRenderingContext): void;
  103853. }
  103854. }
  103855. declare module BABYLON {
  103856. /**
  103857. * @hidden
  103858. **/
  103859. export class AlphaState {
  103860. private _isAlphaBlendDirty;
  103861. private _isBlendFunctionParametersDirty;
  103862. private _isBlendEquationParametersDirty;
  103863. private _isBlendConstantsDirty;
  103864. private _alphaBlend;
  103865. private _blendFunctionParameters;
  103866. private _blendEquationParameters;
  103867. private _blendConstants;
  103868. /**
  103869. * Initializes the state.
  103870. */
  103871. constructor();
  103872. get isDirty(): boolean;
  103873. get alphaBlend(): boolean;
  103874. set alphaBlend(value: boolean);
  103875. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103876. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103877. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103878. reset(): void;
  103879. apply(gl: WebGLRenderingContext): void;
  103880. }
  103881. }
  103882. declare module BABYLON {
  103883. /** @hidden */
  103884. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103885. attributeProcessor(attribute: string): string;
  103886. varyingProcessor(varying: string, isFragment: boolean): string;
  103887. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103888. }
  103889. }
  103890. declare module BABYLON {
  103891. /**
  103892. * Interface for attribute information associated with buffer instanciation
  103893. */
  103894. export interface InstancingAttributeInfo {
  103895. /**
  103896. * Name of the GLSL attribute
  103897. * if attribute index is not specified, this is used to retrieve the index from the effect
  103898. */
  103899. attributeName: string;
  103900. /**
  103901. * Index/offset of the attribute in the vertex shader
  103902. * if not specified, this will be computes from the name.
  103903. */
  103904. index?: number;
  103905. /**
  103906. * size of the attribute, 1, 2, 3 or 4
  103907. */
  103908. attributeSize: number;
  103909. /**
  103910. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103911. */
  103912. offset: number;
  103913. /**
  103914. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103915. * default to 1
  103916. */
  103917. divisor?: number;
  103918. /**
  103919. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103920. * default is FLOAT
  103921. */
  103922. attributeType?: number;
  103923. /**
  103924. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103925. */
  103926. normalized?: boolean;
  103927. }
  103928. }
  103929. declare module BABYLON {
  103930. interface ThinEngine {
  103931. /**
  103932. * Update a video texture
  103933. * @param texture defines the texture to update
  103934. * @param video defines the video element to use
  103935. * @param invertY defines if data must be stored with Y axis inverted
  103936. */
  103937. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103938. }
  103939. }
  103940. declare module BABYLON {
  103941. /**
  103942. * Settings for finer control over video usage
  103943. */
  103944. export interface VideoTextureSettings {
  103945. /**
  103946. * Applies `autoplay` to video, if specified
  103947. */
  103948. autoPlay?: boolean;
  103949. /**
  103950. * Applies `loop` to video, if specified
  103951. */
  103952. loop?: boolean;
  103953. /**
  103954. * Automatically updates internal texture from video at every frame in the render loop
  103955. */
  103956. autoUpdateTexture: boolean;
  103957. /**
  103958. * Image src displayed during the video loading or until the user interacts with the video.
  103959. */
  103960. poster?: string;
  103961. }
  103962. /**
  103963. * If you want to display a video in your scene, this is the special texture for that.
  103964. * This special texture works similar to other textures, with the exception of a few parameters.
  103965. * @see https://doc.babylonjs.com/how_to/video_texture
  103966. */
  103967. export class VideoTexture extends Texture {
  103968. /**
  103969. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103970. */
  103971. readonly autoUpdateTexture: boolean;
  103972. /**
  103973. * The video instance used by the texture internally
  103974. */
  103975. readonly video: HTMLVideoElement;
  103976. private _onUserActionRequestedObservable;
  103977. /**
  103978. * Event triggerd when a dom action is required by the user to play the video.
  103979. * This happens due to recent changes in browser policies preventing video to auto start.
  103980. */
  103981. get onUserActionRequestedObservable(): Observable<Texture>;
  103982. private _generateMipMaps;
  103983. private _engine;
  103984. private _stillImageCaptured;
  103985. private _displayingPosterTexture;
  103986. private _settings;
  103987. private _createInternalTextureOnEvent;
  103988. private _frameId;
  103989. private _currentSrc;
  103990. /**
  103991. * Creates a video texture.
  103992. * If you want to display a video in your scene, this is the special texture for that.
  103993. * This special texture works similar to other textures, with the exception of a few parameters.
  103994. * @see https://doc.babylonjs.com/how_to/video_texture
  103995. * @param name optional name, will detect from video source, if not defined
  103996. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103997. * @param scene is obviously the current scene.
  103998. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103999. * @param invertY is false by default but can be used to invert video on Y axis
  104000. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104001. * @param settings allows finer control over video usage
  104002. */
  104003. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104004. private _getName;
  104005. private _getVideo;
  104006. private _createInternalTexture;
  104007. private reset;
  104008. /**
  104009. * @hidden Internal method to initiate `update`.
  104010. */
  104011. _rebuild(): void;
  104012. /**
  104013. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104014. */
  104015. update(): void;
  104016. /**
  104017. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104018. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104019. */
  104020. updateTexture(isVisible: boolean): void;
  104021. protected _updateInternalTexture: () => void;
  104022. /**
  104023. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104024. * @param url New url.
  104025. */
  104026. updateURL(url: string): void;
  104027. /**
  104028. * Clones the texture.
  104029. * @returns the cloned texture
  104030. */
  104031. clone(): VideoTexture;
  104032. /**
  104033. * Dispose the texture and release its associated resources.
  104034. */
  104035. dispose(): void;
  104036. /**
  104037. * Creates a video texture straight from a stream.
  104038. * @param scene Define the scene the texture should be created in
  104039. * @param stream Define the stream the texture should be created from
  104040. * @returns The created video texture as a promise
  104041. */
  104042. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104043. /**
  104044. * Creates a video texture straight from your WebCam video feed.
  104045. * @param scene Define the scene the texture should be created in
  104046. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104047. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104048. * @returns The created video texture as a promise
  104049. */
  104050. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104051. minWidth: number;
  104052. maxWidth: number;
  104053. minHeight: number;
  104054. maxHeight: number;
  104055. deviceId: string;
  104056. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104057. /**
  104058. * Creates a video texture straight from your WebCam video feed.
  104059. * @param scene Define the scene the texture should be created in
  104060. * @param onReady Define a callback to triggered once the texture will be ready
  104061. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104062. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104063. */
  104064. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104065. minWidth: number;
  104066. maxWidth: number;
  104067. minHeight: number;
  104068. maxHeight: number;
  104069. deviceId: string;
  104070. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104071. }
  104072. }
  104073. declare module BABYLON {
  104074. /**
  104075. * Defines the interface used by objects working like Scene
  104076. * @hidden
  104077. */
  104078. export interface ISceneLike {
  104079. _addPendingData(data: any): void;
  104080. _removePendingData(data: any): void;
  104081. offlineProvider: IOfflineProvider;
  104082. }
  104083. /** Interface defining initialization parameters for Engine class */
  104084. export interface EngineOptions extends WebGLContextAttributes {
  104085. /**
  104086. * Defines if the engine should no exceed a specified device ratio
  104087. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104088. */
  104089. limitDeviceRatio?: number;
  104090. /**
  104091. * Defines if webvr should be enabled automatically
  104092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104093. */
  104094. autoEnableWebVR?: boolean;
  104095. /**
  104096. * Defines if webgl2 should be turned off even if supported
  104097. * @see http://doc.babylonjs.com/features/webgl2
  104098. */
  104099. disableWebGL2Support?: boolean;
  104100. /**
  104101. * Defines if webaudio should be initialized as well
  104102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104103. */
  104104. audioEngine?: boolean;
  104105. /**
  104106. * Defines if animations should run using a deterministic lock step
  104107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104108. */
  104109. deterministicLockstep?: boolean;
  104110. /** Defines the maximum steps to use with deterministic lock step mode */
  104111. lockstepMaxSteps?: number;
  104112. /** Defines the seconds between each deterministic lock step */
  104113. timeStep?: number;
  104114. /**
  104115. * Defines that engine should ignore context lost events
  104116. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104117. */
  104118. doNotHandleContextLost?: boolean;
  104119. /**
  104120. * Defines that engine should ignore modifying touch action attribute and style
  104121. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104122. */
  104123. doNotHandleTouchAction?: boolean;
  104124. /**
  104125. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104126. */
  104127. useHighPrecisionFloats?: boolean;
  104128. }
  104129. /**
  104130. * The base engine class (root of all engines)
  104131. */
  104132. export class ThinEngine {
  104133. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104134. static ExceptionList: ({
  104135. key: string;
  104136. capture: string;
  104137. captureConstraint: number;
  104138. targets: string[];
  104139. } | {
  104140. key: string;
  104141. capture: null;
  104142. captureConstraint: null;
  104143. targets: string[];
  104144. })[];
  104145. /** @hidden */
  104146. static _TextureLoaders: IInternalTextureLoader[];
  104147. /**
  104148. * Returns the current npm package of the sdk
  104149. */
  104150. static get NpmPackage(): string;
  104151. /**
  104152. * Returns the current version of the framework
  104153. */
  104154. static get Version(): string;
  104155. /**
  104156. * Returns a string describing the current engine
  104157. */
  104158. get description(): string;
  104159. /**
  104160. * Gets or sets the epsilon value used by collision engine
  104161. */
  104162. static CollisionsEpsilon: number;
  104163. /**
  104164. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104165. */
  104166. static get ShadersRepository(): string;
  104167. static set ShadersRepository(value: string);
  104168. /** @hidden */
  104169. _shaderProcessor: IShaderProcessor;
  104170. /**
  104171. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104172. */
  104173. forcePOTTextures: boolean;
  104174. /**
  104175. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104176. */
  104177. isFullscreen: boolean;
  104178. /**
  104179. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104180. */
  104181. cullBackFaces: boolean;
  104182. /**
  104183. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104184. */
  104185. renderEvenInBackground: boolean;
  104186. /**
  104187. * Gets or sets a boolean indicating that cache can be kept between frames
  104188. */
  104189. preventCacheWipeBetweenFrames: boolean;
  104190. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104191. validateShaderPrograms: boolean;
  104192. /**
  104193. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104194. * This can provide greater z depth for distant objects.
  104195. */
  104196. useReverseDepthBuffer: boolean;
  104197. /**
  104198. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104199. */
  104200. disableUniformBuffers: boolean;
  104201. /** @hidden */
  104202. _uniformBuffers: UniformBuffer[];
  104203. /**
  104204. * Gets a boolean indicating that the engine supports uniform buffers
  104205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104206. */
  104207. get supportsUniformBuffers(): boolean;
  104208. /** @hidden */
  104209. _gl: WebGLRenderingContext;
  104210. /** @hidden */
  104211. _webGLVersion: number;
  104212. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104213. protected _windowIsBackground: boolean;
  104214. protected _creationOptions: EngineOptions;
  104215. protected _highPrecisionShadersAllowed: boolean;
  104216. /** @hidden */
  104217. get _shouldUseHighPrecisionShader(): boolean;
  104218. /**
  104219. * Gets a boolean indicating that only power of 2 textures are supported
  104220. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104221. */
  104222. get needPOTTextures(): boolean;
  104223. /** @hidden */
  104224. _badOS: boolean;
  104225. /** @hidden */
  104226. _badDesktopOS: boolean;
  104227. private _hardwareScalingLevel;
  104228. /** @hidden */
  104229. _caps: EngineCapabilities;
  104230. private _isStencilEnable;
  104231. private _glVersion;
  104232. private _glRenderer;
  104233. private _glVendor;
  104234. /** @hidden */
  104235. _videoTextureSupported: boolean;
  104236. protected _renderingQueueLaunched: boolean;
  104237. protected _activeRenderLoops: (() => void)[];
  104238. /**
  104239. * Observable signaled when a context lost event is raised
  104240. */
  104241. onContextLostObservable: Observable<ThinEngine>;
  104242. /**
  104243. * Observable signaled when a context restored event is raised
  104244. */
  104245. onContextRestoredObservable: Observable<ThinEngine>;
  104246. private _onContextLost;
  104247. private _onContextRestored;
  104248. protected _contextWasLost: boolean;
  104249. /** @hidden */
  104250. _doNotHandleContextLost: boolean;
  104251. /**
  104252. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104254. */
  104255. get doNotHandleContextLost(): boolean;
  104256. set doNotHandleContextLost(value: boolean);
  104257. /**
  104258. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104259. */
  104260. disableVertexArrayObjects: boolean;
  104261. /** @hidden */
  104262. protected _colorWrite: boolean;
  104263. /** @hidden */
  104264. protected _colorWriteChanged: boolean;
  104265. /** @hidden */
  104266. protected _depthCullingState: DepthCullingState;
  104267. /** @hidden */
  104268. protected _stencilState: StencilState;
  104269. /** @hidden */
  104270. _alphaState: AlphaState;
  104271. /** @hidden */
  104272. _alphaMode: number;
  104273. /** @hidden */
  104274. _alphaEquation: number;
  104275. /** @hidden */
  104276. _internalTexturesCache: InternalTexture[];
  104277. /** @hidden */
  104278. protected _activeChannel: number;
  104279. private _currentTextureChannel;
  104280. /** @hidden */
  104281. protected _boundTexturesCache: {
  104282. [key: string]: Nullable<InternalTexture>;
  104283. };
  104284. /** @hidden */
  104285. protected _currentEffect: Nullable<Effect>;
  104286. /** @hidden */
  104287. protected _currentProgram: Nullable<WebGLProgram>;
  104288. private _compiledEffects;
  104289. private _vertexAttribArraysEnabled;
  104290. /** @hidden */
  104291. protected _cachedViewport: Nullable<IViewportLike>;
  104292. private _cachedVertexArrayObject;
  104293. /** @hidden */
  104294. protected _cachedVertexBuffers: any;
  104295. /** @hidden */
  104296. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104297. /** @hidden */
  104298. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104299. /** @hidden */
  104300. _currentRenderTarget: Nullable<InternalTexture>;
  104301. private _uintIndicesCurrentlySet;
  104302. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104303. /** @hidden */
  104304. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104305. private _currentBufferPointers;
  104306. private _currentInstanceLocations;
  104307. private _currentInstanceBuffers;
  104308. private _textureUnits;
  104309. /** @hidden */
  104310. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104311. /** @hidden */
  104312. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104313. /** @hidden */
  104314. _boundRenderFunction: any;
  104315. private _vaoRecordInProgress;
  104316. private _mustWipeVertexAttributes;
  104317. private _emptyTexture;
  104318. private _emptyCubeTexture;
  104319. private _emptyTexture3D;
  104320. private _emptyTexture2DArray;
  104321. /** @hidden */
  104322. _frameHandler: number;
  104323. private _nextFreeTextureSlots;
  104324. private _maxSimultaneousTextures;
  104325. private _activeRequests;
  104326. protected _texturesSupported: string[];
  104327. /** @hidden */
  104328. _textureFormatInUse: Nullable<string>;
  104329. protected get _supportsHardwareTextureRescaling(): boolean;
  104330. /**
  104331. * Gets the list of texture formats supported
  104332. */
  104333. get texturesSupported(): Array<string>;
  104334. /**
  104335. * Gets the list of texture formats in use
  104336. */
  104337. get textureFormatInUse(): Nullable<string>;
  104338. /**
  104339. * Gets the current viewport
  104340. */
  104341. get currentViewport(): Nullable<IViewportLike>;
  104342. /**
  104343. * Gets the default empty texture
  104344. */
  104345. get emptyTexture(): InternalTexture;
  104346. /**
  104347. * Gets the default empty 3D texture
  104348. */
  104349. get emptyTexture3D(): InternalTexture;
  104350. /**
  104351. * Gets the default empty 2D array texture
  104352. */
  104353. get emptyTexture2DArray(): InternalTexture;
  104354. /**
  104355. * Gets the default empty cube texture
  104356. */
  104357. get emptyCubeTexture(): InternalTexture;
  104358. /**
  104359. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104360. */
  104361. readonly premultipliedAlpha: boolean;
  104362. /**
  104363. * Observable event triggered before each texture is initialized
  104364. */
  104365. onBeforeTextureInitObservable: Observable<Texture>;
  104366. /**
  104367. * Creates a new engine
  104368. * @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
  104369. * @param antialias defines enable antialiasing (default: false)
  104370. * @param options defines further options to be sent to the getContext() function
  104371. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104372. */
  104373. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104374. private _rebuildInternalTextures;
  104375. private _rebuildEffects;
  104376. /**
  104377. * Gets a boolean indicating if all created effects are ready
  104378. * @returns true if all effects are ready
  104379. */
  104380. areAllEffectsReady(): boolean;
  104381. protected _rebuildBuffers(): void;
  104382. private _initGLContext;
  104383. /**
  104384. * Gets version of the current webGL context
  104385. */
  104386. get webGLVersion(): number;
  104387. /**
  104388. * Gets a string idenfifying the name of the class
  104389. * @returns "Engine" string
  104390. */
  104391. getClassName(): string;
  104392. /**
  104393. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104394. */
  104395. get isStencilEnable(): boolean;
  104396. /** @hidden */
  104397. _prepareWorkingCanvas(): void;
  104398. /**
  104399. * Reset the texture cache to empty state
  104400. */
  104401. resetTextureCache(): void;
  104402. /**
  104403. * Gets an object containing information about the current webGL context
  104404. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104405. */
  104406. getGlInfo(): {
  104407. vendor: string;
  104408. renderer: string;
  104409. version: string;
  104410. };
  104411. /**
  104412. * Defines the hardware scaling level.
  104413. * By default the hardware scaling level is computed from the window device ratio.
  104414. * 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.
  104415. * @param level defines the level to use
  104416. */
  104417. setHardwareScalingLevel(level: number): void;
  104418. /**
  104419. * Gets the current hardware scaling level.
  104420. * By default the hardware scaling level is computed from the window device ratio.
  104421. * 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.
  104422. * @returns a number indicating the current hardware scaling level
  104423. */
  104424. getHardwareScalingLevel(): number;
  104425. /**
  104426. * Gets the list of loaded textures
  104427. * @returns an array containing all loaded textures
  104428. */
  104429. getLoadedTexturesCache(): InternalTexture[];
  104430. /**
  104431. * Gets the object containing all engine capabilities
  104432. * @returns the EngineCapabilities object
  104433. */
  104434. getCaps(): EngineCapabilities;
  104435. /**
  104436. * stop executing a render loop function and remove it from the execution array
  104437. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104438. */
  104439. stopRenderLoop(renderFunction?: () => void): void;
  104440. /** @hidden */
  104441. _renderLoop(): void;
  104442. /**
  104443. * Gets the HTML canvas attached with the current webGL context
  104444. * @returns a HTML canvas
  104445. */
  104446. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104447. /**
  104448. * Gets host window
  104449. * @returns the host window object
  104450. */
  104451. getHostWindow(): Nullable<Window>;
  104452. /**
  104453. * Gets the current render width
  104454. * @param useScreen defines if screen size must be used (or the current render target if any)
  104455. * @returns a number defining the current render width
  104456. */
  104457. getRenderWidth(useScreen?: boolean): number;
  104458. /**
  104459. * Gets the current render height
  104460. * @param useScreen defines if screen size must be used (or the current render target if any)
  104461. * @returns a number defining the current render height
  104462. */
  104463. getRenderHeight(useScreen?: boolean): number;
  104464. /**
  104465. * Can be used to override the current requestAnimationFrame requester.
  104466. * @hidden
  104467. */
  104468. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104469. /**
  104470. * Register and execute a render loop. The engine can have more than one render function
  104471. * @param renderFunction defines the function to continuously execute
  104472. */
  104473. runRenderLoop(renderFunction: () => void): void;
  104474. /**
  104475. * Clear the current render buffer or the current render target (if any is set up)
  104476. * @param color defines the color to use
  104477. * @param backBuffer defines if the back buffer must be cleared
  104478. * @param depth defines if the depth buffer must be cleared
  104479. * @param stencil defines if the stencil buffer must be cleared
  104480. */
  104481. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104482. private _viewportCached;
  104483. /** @hidden */
  104484. _viewport(x: number, y: number, width: number, height: number): void;
  104485. /**
  104486. * Set the WebGL's viewport
  104487. * @param viewport defines the viewport element to be used
  104488. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104489. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104490. */
  104491. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104492. /**
  104493. * Begin a new frame
  104494. */
  104495. beginFrame(): void;
  104496. /**
  104497. * Enf the current frame
  104498. */
  104499. endFrame(): void;
  104500. /**
  104501. * Resize the view according to the canvas' size
  104502. */
  104503. resize(): void;
  104504. /**
  104505. * Force a specific size of the canvas
  104506. * @param width defines the new canvas' width
  104507. * @param height defines the new canvas' height
  104508. */
  104509. setSize(width: number, height: number): void;
  104510. /**
  104511. * Binds the frame buffer to the specified texture.
  104512. * @param texture The texture to render to or null for the default canvas
  104513. * @param faceIndex The face of the texture to render to in case of cube texture
  104514. * @param requiredWidth The width of the target to render to
  104515. * @param requiredHeight The height of the target to render to
  104516. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104517. * @param lodLevel defines the lod level to bind to the frame buffer
  104518. * @param layer defines the 2d array index to bind to frame buffer to
  104519. */
  104520. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104521. /** @hidden */
  104522. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104523. /**
  104524. * Unbind the current render target texture from the webGL context
  104525. * @param texture defines the render target texture to unbind
  104526. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104527. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104528. */
  104529. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104530. /**
  104531. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104532. */
  104533. flushFramebuffer(): void;
  104534. /**
  104535. * Unbind the current render target and bind the default framebuffer
  104536. */
  104537. restoreDefaultFramebuffer(): void;
  104538. /** @hidden */
  104539. protected _resetVertexBufferBinding(): void;
  104540. /**
  104541. * Creates a vertex buffer
  104542. * @param data the data for the vertex buffer
  104543. * @returns the new WebGL static buffer
  104544. */
  104545. createVertexBuffer(data: DataArray): DataBuffer;
  104546. private _createVertexBuffer;
  104547. /**
  104548. * Creates a dynamic vertex buffer
  104549. * @param data the data for the dynamic vertex buffer
  104550. * @returns the new WebGL dynamic buffer
  104551. */
  104552. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104553. protected _resetIndexBufferBinding(): void;
  104554. /**
  104555. * Creates a new index buffer
  104556. * @param indices defines the content of the index buffer
  104557. * @param updatable defines if the index buffer must be updatable
  104558. * @returns a new webGL buffer
  104559. */
  104560. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104561. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104562. /**
  104563. * Bind a webGL buffer to the webGL context
  104564. * @param buffer defines the buffer to bind
  104565. */
  104566. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104567. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104568. private bindBuffer;
  104569. /**
  104570. * update the bound buffer with the given data
  104571. * @param data defines the data to update
  104572. */
  104573. updateArrayBuffer(data: Float32Array): void;
  104574. private _vertexAttribPointer;
  104575. /** @hidden */
  104576. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104577. private _bindVertexBuffersAttributes;
  104578. /**
  104579. * Records a vertex array object
  104580. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104581. * @param vertexBuffers defines the list of vertex buffers to store
  104582. * @param indexBuffer defines the index buffer to store
  104583. * @param effect defines the effect to store
  104584. * @returns the new vertex array object
  104585. */
  104586. recordVertexArrayObject(vertexBuffers: {
  104587. [key: string]: VertexBuffer;
  104588. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104589. /**
  104590. * Bind a specific vertex array object
  104591. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104592. * @param vertexArrayObject defines the vertex array object to bind
  104593. * @param indexBuffer defines the index buffer to bind
  104594. */
  104595. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104596. /**
  104597. * Bind webGl buffers directly to the webGL context
  104598. * @param vertexBuffer defines the vertex buffer to bind
  104599. * @param indexBuffer defines the index buffer to bind
  104600. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104601. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104602. * @param effect defines the effect associated with the vertex buffer
  104603. */
  104604. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104605. private _unbindVertexArrayObject;
  104606. /**
  104607. * Bind a list of vertex buffers to the webGL context
  104608. * @param vertexBuffers defines the list of vertex buffers to bind
  104609. * @param indexBuffer defines the index buffer to bind
  104610. * @param effect defines the effect associated with the vertex buffers
  104611. */
  104612. bindBuffers(vertexBuffers: {
  104613. [key: string]: Nullable<VertexBuffer>;
  104614. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104615. /**
  104616. * Unbind all instance attributes
  104617. */
  104618. unbindInstanceAttributes(): void;
  104619. /**
  104620. * Release and free the memory of a vertex array object
  104621. * @param vao defines the vertex array object to delete
  104622. */
  104623. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104624. /** @hidden */
  104625. _releaseBuffer(buffer: DataBuffer): boolean;
  104626. protected _deleteBuffer(buffer: DataBuffer): void;
  104627. /**
  104628. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104629. * @param instancesBuffer defines the webGL buffer to update and bind
  104630. * @param data defines the data to store in the buffer
  104631. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104632. */
  104633. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104634. /**
  104635. * Bind the content of a webGL buffer used with instantiation
  104636. * @param instancesBuffer defines the webGL buffer to bind
  104637. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104638. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104639. */
  104640. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104641. /**
  104642. * Disable the instance attribute corresponding to the name in parameter
  104643. * @param name defines the name of the attribute to disable
  104644. */
  104645. disableInstanceAttributeByName(name: string): void;
  104646. /**
  104647. * Disable the instance attribute corresponding to the location in parameter
  104648. * @param attributeLocation defines the attribute location of the attribute to disable
  104649. */
  104650. disableInstanceAttribute(attributeLocation: number): void;
  104651. /**
  104652. * Disable the attribute corresponding to the location in parameter
  104653. * @param attributeLocation defines the attribute location of the attribute to disable
  104654. */
  104655. disableAttributeByIndex(attributeLocation: number): void;
  104656. /**
  104657. * Send a draw order
  104658. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104659. * @param indexStart defines the starting index
  104660. * @param indexCount defines the number of index to draw
  104661. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104662. */
  104663. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104664. /**
  104665. * Draw a list of points
  104666. * @param verticesStart defines the index of first vertex to draw
  104667. * @param verticesCount defines the count of vertices to draw
  104668. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104669. */
  104670. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104671. /**
  104672. * Draw a list of unindexed primitives
  104673. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104674. * @param verticesStart defines the index of first vertex to draw
  104675. * @param verticesCount defines the count of vertices to draw
  104676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104677. */
  104678. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104679. /**
  104680. * Draw a list of indexed primitives
  104681. * @param fillMode defines the primitive to use
  104682. * @param indexStart defines the starting index
  104683. * @param indexCount defines the number of index to draw
  104684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104685. */
  104686. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104687. /**
  104688. * Draw a list of unindexed primitives
  104689. * @param fillMode defines the primitive to use
  104690. * @param verticesStart defines the index of first vertex to draw
  104691. * @param verticesCount defines the count of vertices to draw
  104692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104693. */
  104694. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104695. private _drawMode;
  104696. /** @hidden */
  104697. protected _reportDrawCall(): void;
  104698. /** @hidden */
  104699. _releaseEffect(effect: Effect): void;
  104700. /** @hidden */
  104701. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104702. /**
  104703. * Create a new effect (used to store vertex/fragment shaders)
  104704. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104705. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104706. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104707. * @param samplers defines an array of string used to represent textures
  104708. * @param defines defines the string containing the defines to use to compile the shaders
  104709. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104710. * @param onCompiled defines a function to call when the effect creation is successful
  104711. * @param onError defines a function to call when the effect creation has failed
  104712. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104713. * @returns the new Effect
  104714. */
  104715. 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;
  104716. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104717. private _compileShader;
  104718. private _compileRawShader;
  104719. /**
  104720. * Directly creates a webGL program
  104721. * @param pipelineContext defines the pipeline context to attach to
  104722. * @param vertexCode defines the vertex shader code to use
  104723. * @param fragmentCode defines the fragment shader code to use
  104724. * @param context defines the webGL context to use (if not set, the current one will be used)
  104725. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104726. * @returns the new webGL program
  104727. */
  104728. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104729. /**
  104730. * Creates a webGL program
  104731. * @param pipelineContext defines the pipeline context to attach to
  104732. * @param vertexCode defines the vertex shader code to use
  104733. * @param fragmentCode defines the fragment shader code to use
  104734. * @param defines defines the string containing the defines to use to compile the shaders
  104735. * @param context defines the webGL context to use (if not set, the current one will be used)
  104736. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104737. * @returns the new webGL program
  104738. */
  104739. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104740. /**
  104741. * Creates a new pipeline context
  104742. * @returns the new pipeline
  104743. */
  104744. createPipelineContext(): IPipelineContext;
  104745. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104746. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104747. /** @hidden */
  104748. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104749. /** @hidden */
  104750. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104751. /** @hidden */
  104752. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104753. /**
  104754. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104755. * @param pipelineContext defines the pipeline context to use
  104756. * @param uniformsNames defines the list of uniform names
  104757. * @returns an array of webGL uniform locations
  104758. */
  104759. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104760. /**
  104761. * Gets the lsit of active attributes for a given webGL program
  104762. * @param pipelineContext defines the pipeline context to use
  104763. * @param attributesNames defines the list of attribute names to get
  104764. * @returns an array of indices indicating the offset of each attribute
  104765. */
  104766. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104767. /**
  104768. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104769. * @param effect defines the effect to activate
  104770. */
  104771. enableEffect(effect: Nullable<Effect>): void;
  104772. /**
  104773. * Set the value of an uniform to a number (int)
  104774. * @param uniform defines the webGL uniform location where to store the value
  104775. * @param value defines the int number to store
  104776. */
  104777. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104778. /**
  104779. * Set the value of an uniform to an array of int32
  104780. * @param uniform defines the webGL uniform location where to store the value
  104781. * @param array defines the array of int32 to store
  104782. */
  104783. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104784. /**
  104785. * Set the value of an uniform to an array of int32 (stored as vec2)
  104786. * @param uniform defines the webGL uniform location where to store the value
  104787. * @param array defines the array of int32 to store
  104788. */
  104789. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104790. /**
  104791. * Set the value of an uniform to an array of int32 (stored as vec3)
  104792. * @param uniform defines the webGL uniform location where to store the value
  104793. * @param array defines the array of int32 to store
  104794. */
  104795. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104796. /**
  104797. * Set the value of an uniform to an array of int32 (stored as vec4)
  104798. * @param uniform defines the webGL uniform location where to store the value
  104799. * @param array defines the array of int32 to store
  104800. */
  104801. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104802. /**
  104803. * Set the value of an uniform to an array of number
  104804. * @param uniform defines the webGL uniform location where to store the value
  104805. * @param array defines the array of number to store
  104806. */
  104807. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104808. /**
  104809. * Set the value of an uniform to an array of number (stored as vec2)
  104810. * @param uniform defines the webGL uniform location where to store the value
  104811. * @param array defines the array of number to store
  104812. */
  104813. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104814. /**
  104815. * Set the value of an uniform to an array of number (stored as vec3)
  104816. * @param uniform defines the webGL uniform location where to store the value
  104817. * @param array defines the array of number to store
  104818. */
  104819. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104820. /**
  104821. * Set the value of an uniform to an array of number (stored as vec4)
  104822. * @param uniform defines the webGL uniform location where to store the value
  104823. * @param array defines the array of number to store
  104824. */
  104825. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104826. /**
  104827. * Set the value of an uniform to an array of float32 (stored as matrices)
  104828. * @param uniform defines the webGL uniform location where to store the value
  104829. * @param matrices defines the array of float32 to store
  104830. */
  104831. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104832. /**
  104833. * Set the value of an uniform to a matrix (3x3)
  104834. * @param uniform defines the webGL uniform location where to store the value
  104835. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104836. */
  104837. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104838. /**
  104839. * Set the value of an uniform to a matrix (2x2)
  104840. * @param uniform defines the webGL uniform location where to store the value
  104841. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104842. */
  104843. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104844. /**
  104845. * Set the value of an uniform to a number (float)
  104846. * @param uniform defines the webGL uniform location where to store the value
  104847. * @param value defines the float number to store
  104848. */
  104849. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104850. /**
  104851. * Set the value of an uniform to a vec2
  104852. * @param uniform defines the webGL uniform location where to store the value
  104853. * @param x defines the 1st component of the value
  104854. * @param y defines the 2nd component of the value
  104855. */
  104856. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104857. /**
  104858. * Set the value of an uniform to a vec3
  104859. * @param uniform defines the webGL uniform location where to store the value
  104860. * @param x defines the 1st component of the value
  104861. * @param y defines the 2nd component of the value
  104862. * @param z defines the 3rd component of the value
  104863. */
  104864. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104865. /**
  104866. * Set the value of an uniform to a vec4
  104867. * @param uniform defines the webGL uniform location where to store the value
  104868. * @param x defines the 1st component of the value
  104869. * @param y defines the 2nd component of the value
  104870. * @param z defines the 3rd component of the value
  104871. * @param w defines the 4th component of the value
  104872. */
  104873. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104874. /**
  104875. * Apply all cached states (depth, culling, stencil and alpha)
  104876. */
  104877. applyStates(): void;
  104878. /**
  104879. * Enable or disable color writing
  104880. * @param enable defines the state to set
  104881. */
  104882. setColorWrite(enable: boolean): void;
  104883. /**
  104884. * Gets a boolean indicating if color writing is enabled
  104885. * @returns the current color writing state
  104886. */
  104887. getColorWrite(): boolean;
  104888. /**
  104889. * Gets the depth culling state manager
  104890. */
  104891. get depthCullingState(): DepthCullingState;
  104892. /**
  104893. * Gets the alpha state manager
  104894. */
  104895. get alphaState(): AlphaState;
  104896. /**
  104897. * Gets the stencil state manager
  104898. */
  104899. get stencilState(): StencilState;
  104900. /**
  104901. * Clears the list of texture accessible through engine.
  104902. * This can help preventing texture load conflict due to name collision.
  104903. */
  104904. clearInternalTexturesCache(): void;
  104905. /**
  104906. * Force the entire cache to be cleared
  104907. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104908. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104909. */
  104910. wipeCaches(bruteForce?: boolean): void;
  104911. /** @hidden */
  104912. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104913. min: number;
  104914. mag: number;
  104915. };
  104916. /** @hidden */
  104917. _createTexture(): WebGLTexture;
  104918. /**
  104919. * Usually called from Texture.ts.
  104920. * Passed information to create a WebGLTexture
  104921. * @param urlArg defines a value which contains one of the following:
  104922. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104923. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104924. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104925. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104926. * @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)
  104927. * @param scene needed for loading to the correct scene
  104928. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104929. * @param onLoad optional callback to be called upon successful completion
  104930. * @param onError optional callback to be called upon failure
  104931. * @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
  104932. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104933. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104934. * @param forcedExtension defines the extension to use to pick the right loader
  104935. * @param mimeType defines an optional mime type
  104936. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104937. */
  104938. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  104939. /**
  104940. * Loads an image as an HTMLImageElement.
  104941. * @param input url string, ArrayBuffer, or Blob to load
  104942. * @param onLoad callback called when the image successfully loads
  104943. * @param onError callback called when the image fails to load
  104944. * @param offlineProvider offline provider for caching
  104945. * @param mimeType optional mime type
  104946. * @returns the HTMLImageElement of the loaded image
  104947. * @hidden
  104948. */
  104949. 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>;
  104950. /**
  104951. * @hidden
  104952. */
  104953. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104954. /**
  104955. * Creates a raw texture
  104956. * @param data defines the data to store in the texture
  104957. * @param width defines the width of the texture
  104958. * @param height defines the height of the texture
  104959. * @param format defines the format of the data
  104960. * @param generateMipMaps defines if the engine should generate the mip levels
  104961. * @param invertY defines if data must be stored with Y axis inverted
  104962. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104963. * @param compression defines the compression used (null by default)
  104964. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104965. * @returns the raw texture inside an InternalTexture
  104966. */
  104967. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104968. /**
  104969. * Creates a new raw cube texture
  104970. * @param data defines the array of data to use to create each face
  104971. * @param size defines the size of the textures
  104972. * @param format defines the format of the data
  104973. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104974. * @param generateMipMaps defines if the engine should generate the mip levels
  104975. * @param invertY defines if data must be stored with Y axis inverted
  104976. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104977. * @param compression defines the compression used (null by default)
  104978. * @returns the cube texture as an InternalTexture
  104979. */
  104980. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104981. /**
  104982. * Creates a new raw 3D texture
  104983. * @param data defines the data used to create the texture
  104984. * @param width defines the width of the texture
  104985. * @param height defines the height of the texture
  104986. * @param depth defines the depth of the texture
  104987. * @param format defines the format of the texture
  104988. * @param generateMipMaps defines if the engine must generate mip levels
  104989. * @param invertY defines if data must be stored with Y axis inverted
  104990. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104991. * @param compression defines the compressed used (can be null)
  104992. * @param textureType defines the compressed used (can be null)
  104993. * @returns a new raw 3D texture (stored in an InternalTexture)
  104994. */
  104995. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104996. /**
  104997. * Creates a new raw 2D array texture
  104998. * @param data defines the data used to create the texture
  104999. * @param width defines the width of the texture
  105000. * @param height defines the height of the texture
  105001. * @param depth defines the number of layers of the texture
  105002. * @param format defines the format of the texture
  105003. * @param generateMipMaps defines if the engine must generate mip levels
  105004. * @param invertY defines if data must be stored with Y axis inverted
  105005. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105006. * @param compression defines the compressed used (can be null)
  105007. * @param textureType defines the compressed used (can be null)
  105008. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105009. */
  105010. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105011. private _unpackFlipYCached;
  105012. /**
  105013. * In case you are sharing the context with other applications, it might
  105014. * be interested to not cache the unpack flip y state to ensure a consistent
  105015. * value would be set.
  105016. */
  105017. enableUnpackFlipYCached: boolean;
  105018. /** @hidden */
  105019. _unpackFlipY(value: boolean): void;
  105020. /** @hidden */
  105021. _getUnpackAlignement(): number;
  105022. private _getTextureTarget;
  105023. /**
  105024. * Update the sampling mode of a given texture
  105025. * @param samplingMode defines the required sampling mode
  105026. * @param texture defines the texture to update
  105027. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105028. */
  105029. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105030. /**
  105031. * Update the sampling mode of a given texture
  105032. * @param texture defines the texture to update
  105033. * @param wrapU defines the texture wrap mode of the u coordinates
  105034. * @param wrapV defines the texture wrap mode of the v coordinates
  105035. * @param wrapR defines the texture wrap mode of the r coordinates
  105036. */
  105037. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105038. /** @hidden */
  105039. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105040. width: number;
  105041. height: number;
  105042. layers?: number;
  105043. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105044. /** @hidden */
  105045. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105046. /** @hidden */
  105047. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105048. /**
  105049. * Update a portion of an internal texture
  105050. * @param texture defines the texture to update
  105051. * @param imageData defines the data to store into the texture
  105052. * @param xOffset defines the x coordinates of the update rectangle
  105053. * @param yOffset defines the y coordinates of the update rectangle
  105054. * @param width defines the width of the update rectangle
  105055. * @param height defines the height of the update rectangle
  105056. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105057. * @param lod defines the lod level to update (0 by default)
  105058. */
  105059. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105060. /** @hidden */
  105061. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105062. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105063. private _prepareWebGLTexture;
  105064. /** @hidden */
  105065. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105066. private _getDepthStencilBuffer;
  105067. /** @hidden */
  105068. _releaseFramebufferObjects(texture: InternalTexture): void;
  105069. /** @hidden */
  105070. _releaseTexture(texture: InternalTexture): void;
  105071. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105072. protected _setProgram(program: WebGLProgram): void;
  105073. protected _boundUniforms: {
  105074. [key: number]: WebGLUniformLocation;
  105075. };
  105076. /**
  105077. * Binds an effect to the webGL context
  105078. * @param effect defines the effect to bind
  105079. */
  105080. bindSamplers(effect: Effect): void;
  105081. private _activateCurrentTexture;
  105082. /** @hidden */
  105083. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105084. /** @hidden */
  105085. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105086. /**
  105087. * Unbind all textures from the webGL context
  105088. */
  105089. unbindAllTextures(): void;
  105090. /**
  105091. * Sets a texture to the according uniform.
  105092. * @param channel The texture channel
  105093. * @param uniform The uniform to set
  105094. * @param texture The texture to apply
  105095. */
  105096. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105097. private _bindSamplerUniformToChannel;
  105098. private _getTextureWrapMode;
  105099. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105100. /**
  105101. * Sets an array of texture to the webGL context
  105102. * @param channel defines the channel where the texture array must be set
  105103. * @param uniform defines the associated uniform location
  105104. * @param textures defines the array of textures to bind
  105105. */
  105106. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105107. /** @hidden */
  105108. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105109. private _setTextureParameterFloat;
  105110. private _setTextureParameterInteger;
  105111. /**
  105112. * Unbind all vertex attributes from the webGL context
  105113. */
  105114. unbindAllAttributes(): void;
  105115. /**
  105116. * 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
  105117. */
  105118. releaseEffects(): void;
  105119. /**
  105120. * Dispose and release all associated resources
  105121. */
  105122. dispose(): void;
  105123. /**
  105124. * Attach a new callback raised when context lost event is fired
  105125. * @param callback defines the callback to call
  105126. */
  105127. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105128. /**
  105129. * Attach a new callback raised when context restored event is fired
  105130. * @param callback defines the callback to call
  105131. */
  105132. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105133. /**
  105134. * Get the current error code of the webGL context
  105135. * @returns the error code
  105136. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105137. */
  105138. getError(): number;
  105139. private _canRenderToFloatFramebuffer;
  105140. private _canRenderToHalfFloatFramebuffer;
  105141. private _canRenderToFramebuffer;
  105142. /** @hidden */
  105143. _getWebGLTextureType(type: number): number;
  105144. /** @hidden */
  105145. _getInternalFormat(format: number): number;
  105146. /** @hidden */
  105147. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105148. /** @hidden */
  105149. _getRGBAMultiSampleBufferFormat(type: number): number;
  105150. /** @hidden */
  105151. _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;
  105152. /**
  105153. * Loads a file from a url
  105154. * @param url url to load
  105155. * @param onSuccess callback called when the file successfully loads
  105156. * @param onProgress callback called while file is loading (if the server supports this mode)
  105157. * @param offlineProvider defines the offline provider for caching
  105158. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105159. * @param onError callback called when the file fails to load
  105160. * @returns a file request object
  105161. * @hidden
  105162. */
  105163. 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;
  105164. /**
  105165. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105166. * @param x defines the x coordinate of the rectangle where pixels must be read
  105167. * @param y defines the y coordinate of the rectangle where pixels must be read
  105168. * @param width defines the width of the rectangle where pixels must be read
  105169. * @param height defines the height of the rectangle where pixels must be read
  105170. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105171. * @returns a Uint8Array containing RGBA colors
  105172. */
  105173. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105174. private static _isSupported;
  105175. /**
  105176. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105177. * @returns true if the engine can be created
  105178. * @ignorenaming
  105179. */
  105180. static isSupported(): boolean;
  105181. /**
  105182. * Find the next highest power of two.
  105183. * @param x Number to start search from.
  105184. * @return Next highest power of two.
  105185. */
  105186. static CeilingPOT(x: number): number;
  105187. /**
  105188. * Find the next lowest power of two.
  105189. * @param x Number to start search from.
  105190. * @return Next lowest power of two.
  105191. */
  105192. static FloorPOT(x: number): number;
  105193. /**
  105194. * Find the nearest power of two.
  105195. * @param x Number to start search from.
  105196. * @return Next nearest power of two.
  105197. */
  105198. static NearestPOT(x: number): number;
  105199. /**
  105200. * Get the closest exponent of two
  105201. * @param value defines the value to approximate
  105202. * @param max defines the maximum value to return
  105203. * @param mode defines how to define the closest value
  105204. * @returns closest exponent of two of the given value
  105205. */
  105206. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105207. /**
  105208. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105209. * @param func - the function to be called
  105210. * @param requester - the object that will request the next frame. Falls back to window.
  105211. * @returns frame number
  105212. */
  105213. static QueueNewFrame(func: () => void, requester?: any): number;
  105214. /**
  105215. * Gets host document
  105216. * @returns the host document object
  105217. */
  105218. getHostDocument(): Nullable<Document>;
  105219. }
  105220. }
  105221. declare module BABYLON {
  105222. /**
  105223. * Class representing spherical harmonics coefficients to the 3rd degree
  105224. */
  105225. export class SphericalHarmonics {
  105226. /**
  105227. * Defines whether or not the harmonics have been prescaled for rendering.
  105228. */
  105229. preScaled: boolean;
  105230. /**
  105231. * The l0,0 coefficients of the spherical harmonics
  105232. */
  105233. l00: Vector3;
  105234. /**
  105235. * The l1,-1 coefficients of the spherical harmonics
  105236. */
  105237. l1_1: Vector3;
  105238. /**
  105239. * The l1,0 coefficients of the spherical harmonics
  105240. */
  105241. l10: Vector3;
  105242. /**
  105243. * The l1,1 coefficients of the spherical harmonics
  105244. */
  105245. l11: Vector3;
  105246. /**
  105247. * The l2,-2 coefficients of the spherical harmonics
  105248. */
  105249. l2_2: Vector3;
  105250. /**
  105251. * The l2,-1 coefficients of the spherical harmonics
  105252. */
  105253. l2_1: Vector3;
  105254. /**
  105255. * The l2,0 coefficients of the spherical harmonics
  105256. */
  105257. l20: Vector3;
  105258. /**
  105259. * The l2,1 coefficients of the spherical harmonics
  105260. */
  105261. l21: Vector3;
  105262. /**
  105263. * The l2,2 coefficients of the spherical harmonics
  105264. */
  105265. l22: Vector3;
  105266. /**
  105267. * Adds a light to the spherical harmonics
  105268. * @param direction the direction of the light
  105269. * @param color the color of the light
  105270. * @param deltaSolidAngle the delta solid angle of the light
  105271. */
  105272. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105273. /**
  105274. * Scales the spherical harmonics by the given amount
  105275. * @param scale the amount to scale
  105276. */
  105277. scaleInPlace(scale: number): void;
  105278. /**
  105279. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105280. *
  105281. * ```
  105282. * E_lm = A_l * L_lm
  105283. * ```
  105284. *
  105285. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105286. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105287. * the scaling factors are given in equation 9.
  105288. */
  105289. convertIncidentRadianceToIrradiance(): void;
  105290. /**
  105291. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105292. *
  105293. * ```
  105294. * L = (1/pi) * E * rho
  105295. * ```
  105296. *
  105297. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105298. */
  105299. convertIrradianceToLambertianRadiance(): void;
  105300. /**
  105301. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105302. * required operations at run time.
  105303. *
  105304. * This is simply done by scaling back the SH with Ylm constants parameter.
  105305. * The trigonometric part being applied by the shader at run time.
  105306. */
  105307. preScaleForRendering(): void;
  105308. /**
  105309. * Constructs a spherical harmonics from an array.
  105310. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105311. * @returns the spherical harmonics
  105312. */
  105313. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105314. /**
  105315. * Gets the spherical harmonics from polynomial
  105316. * @param polynomial the spherical polynomial
  105317. * @returns the spherical harmonics
  105318. */
  105319. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105320. }
  105321. /**
  105322. * Class representing spherical polynomial coefficients to the 3rd degree
  105323. */
  105324. export class SphericalPolynomial {
  105325. private _harmonics;
  105326. /**
  105327. * The spherical harmonics used to create the polynomials.
  105328. */
  105329. get preScaledHarmonics(): SphericalHarmonics;
  105330. /**
  105331. * The x coefficients of the spherical polynomial
  105332. */
  105333. x: Vector3;
  105334. /**
  105335. * The y coefficients of the spherical polynomial
  105336. */
  105337. y: Vector3;
  105338. /**
  105339. * The z coefficients of the spherical polynomial
  105340. */
  105341. z: Vector3;
  105342. /**
  105343. * The xx coefficients of the spherical polynomial
  105344. */
  105345. xx: Vector3;
  105346. /**
  105347. * The yy coefficients of the spherical polynomial
  105348. */
  105349. yy: Vector3;
  105350. /**
  105351. * The zz coefficients of the spherical polynomial
  105352. */
  105353. zz: Vector3;
  105354. /**
  105355. * The xy coefficients of the spherical polynomial
  105356. */
  105357. xy: Vector3;
  105358. /**
  105359. * The yz coefficients of the spherical polynomial
  105360. */
  105361. yz: Vector3;
  105362. /**
  105363. * The zx coefficients of the spherical polynomial
  105364. */
  105365. zx: Vector3;
  105366. /**
  105367. * Adds an ambient color to the spherical polynomial
  105368. * @param color the color to add
  105369. */
  105370. addAmbient(color: Color3): void;
  105371. /**
  105372. * Scales the spherical polynomial by the given amount
  105373. * @param scale the amount to scale
  105374. */
  105375. scaleInPlace(scale: number): void;
  105376. /**
  105377. * Gets the spherical polynomial from harmonics
  105378. * @param harmonics the spherical harmonics
  105379. * @returns the spherical polynomial
  105380. */
  105381. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105382. /**
  105383. * Constructs a spherical polynomial from an array.
  105384. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105385. * @returns the spherical polynomial
  105386. */
  105387. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105388. }
  105389. }
  105390. declare module BABYLON {
  105391. /**
  105392. * Defines the source of the internal texture
  105393. */
  105394. export enum InternalTextureSource {
  105395. /**
  105396. * The source of the texture data is unknown
  105397. */
  105398. Unknown = 0,
  105399. /**
  105400. * Texture data comes from an URL
  105401. */
  105402. Url = 1,
  105403. /**
  105404. * Texture data is only used for temporary storage
  105405. */
  105406. Temp = 2,
  105407. /**
  105408. * Texture data comes from raw data (ArrayBuffer)
  105409. */
  105410. Raw = 3,
  105411. /**
  105412. * Texture content is dynamic (video or dynamic texture)
  105413. */
  105414. Dynamic = 4,
  105415. /**
  105416. * Texture content is generated by rendering to it
  105417. */
  105418. RenderTarget = 5,
  105419. /**
  105420. * Texture content is part of a multi render target process
  105421. */
  105422. MultiRenderTarget = 6,
  105423. /**
  105424. * Texture data comes from a cube data file
  105425. */
  105426. Cube = 7,
  105427. /**
  105428. * Texture data comes from a raw cube data
  105429. */
  105430. CubeRaw = 8,
  105431. /**
  105432. * Texture data come from a prefiltered cube data file
  105433. */
  105434. CubePrefiltered = 9,
  105435. /**
  105436. * Texture content is raw 3D data
  105437. */
  105438. Raw3D = 10,
  105439. /**
  105440. * Texture content is raw 2D array data
  105441. */
  105442. Raw2DArray = 11,
  105443. /**
  105444. * Texture content is a depth texture
  105445. */
  105446. Depth = 12,
  105447. /**
  105448. * Texture data comes from a raw cube data encoded with RGBD
  105449. */
  105450. CubeRawRGBD = 13
  105451. }
  105452. /**
  105453. * Class used to store data associated with WebGL texture data for the engine
  105454. * This class should not be used directly
  105455. */
  105456. export class InternalTexture {
  105457. /** @hidden */
  105458. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105459. /**
  105460. * Defines if the texture is ready
  105461. */
  105462. isReady: boolean;
  105463. /**
  105464. * Defines if the texture is a cube texture
  105465. */
  105466. isCube: boolean;
  105467. /**
  105468. * Defines if the texture contains 3D data
  105469. */
  105470. is3D: boolean;
  105471. /**
  105472. * Defines if the texture contains 2D array data
  105473. */
  105474. is2DArray: boolean;
  105475. /**
  105476. * Defines if the texture contains multiview data
  105477. */
  105478. isMultiview: boolean;
  105479. /**
  105480. * Gets the URL used to load this texture
  105481. */
  105482. url: string;
  105483. /**
  105484. * Gets the sampling mode of the texture
  105485. */
  105486. samplingMode: number;
  105487. /**
  105488. * Gets a boolean indicating if the texture needs mipmaps generation
  105489. */
  105490. generateMipMaps: boolean;
  105491. /**
  105492. * Gets the number of samples used by the texture (WebGL2+ only)
  105493. */
  105494. samples: number;
  105495. /**
  105496. * Gets the type of the texture (int, float...)
  105497. */
  105498. type: number;
  105499. /**
  105500. * Gets the format of the texture (RGB, RGBA...)
  105501. */
  105502. format: number;
  105503. /**
  105504. * Observable called when the texture is loaded
  105505. */
  105506. onLoadedObservable: Observable<InternalTexture>;
  105507. /**
  105508. * Gets the width of the texture
  105509. */
  105510. width: number;
  105511. /**
  105512. * Gets the height of the texture
  105513. */
  105514. height: number;
  105515. /**
  105516. * Gets the depth of the texture
  105517. */
  105518. depth: number;
  105519. /**
  105520. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105521. */
  105522. baseWidth: number;
  105523. /**
  105524. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105525. */
  105526. baseHeight: number;
  105527. /**
  105528. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105529. */
  105530. baseDepth: number;
  105531. /**
  105532. * Gets a boolean indicating if the texture is inverted on Y axis
  105533. */
  105534. invertY: boolean;
  105535. /** @hidden */
  105536. _invertVScale: boolean;
  105537. /** @hidden */
  105538. _associatedChannel: number;
  105539. /** @hidden */
  105540. _source: InternalTextureSource;
  105541. /** @hidden */
  105542. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105543. /** @hidden */
  105544. _bufferView: Nullable<ArrayBufferView>;
  105545. /** @hidden */
  105546. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105547. /** @hidden */
  105548. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105549. /** @hidden */
  105550. _size: number;
  105551. /** @hidden */
  105552. _extension: string;
  105553. /** @hidden */
  105554. _files: Nullable<string[]>;
  105555. /** @hidden */
  105556. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105557. /** @hidden */
  105558. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105559. /** @hidden */
  105560. _framebuffer: Nullable<WebGLFramebuffer>;
  105561. /** @hidden */
  105562. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105563. /** @hidden */
  105564. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105565. /** @hidden */
  105566. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105567. /** @hidden */
  105568. _attachments: Nullable<number[]>;
  105569. /** @hidden */
  105570. _cachedCoordinatesMode: Nullable<number>;
  105571. /** @hidden */
  105572. _cachedWrapU: Nullable<number>;
  105573. /** @hidden */
  105574. _cachedWrapV: Nullable<number>;
  105575. /** @hidden */
  105576. _cachedWrapR: Nullable<number>;
  105577. /** @hidden */
  105578. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105579. /** @hidden */
  105580. _isDisabled: boolean;
  105581. /** @hidden */
  105582. _compression: Nullable<string>;
  105583. /** @hidden */
  105584. _generateStencilBuffer: boolean;
  105585. /** @hidden */
  105586. _generateDepthBuffer: boolean;
  105587. /** @hidden */
  105588. _comparisonFunction: number;
  105589. /** @hidden */
  105590. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105591. /** @hidden */
  105592. _lodGenerationScale: number;
  105593. /** @hidden */
  105594. _lodGenerationOffset: number;
  105595. /** @hidden */
  105596. _depthStencilTexture: Nullable<InternalTexture>;
  105597. /** @hidden */
  105598. _colorTextureArray: Nullable<WebGLTexture>;
  105599. /** @hidden */
  105600. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105601. /** @hidden */
  105602. _lodTextureHigh: Nullable<BaseTexture>;
  105603. /** @hidden */
  105604. _lodTextureMid: Nullable<BaseTexture>;
  105605. /** @hidden */
  105606. _lodTextureLow: Nullable<BaseTexture>;
  105607. /** @hidden */
  105608. _isRGBD: boolean;
  105609. /** @hidden */
  105610. _linearSpecularLOD: boolean;
  105611. /** @hidden */
  105612. _irradianceTexture: Nullable<BaseTexture>;
  105613. /** @hidden */
  105614. _webGLTexture: Nullable<WebGLTexture>;
  105615. /** @hidden */
  105616. _references: number;
  105617. private _engine;
  105618. /**
  105619. * Gets the Engine the texture belongs to.
  105620. * @returns The babylon engine
  105621. */
  105622. getEngine(): ThinEngine;
  105623. /**
  105624. * Gets the data source type of the texture
  105625. */
  105626. get source(): InternalTextureSource;
  105627. /**
  105628. * Creates a new InternalTexture
  105629. * @param engine defines the engine to use
  105630. * @param source defines the type of data that will be used
  105631. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105632. */
  105633. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105634. /**
  105635. * Increments the number of references (ie. the number of Texture that point to it)
  105636. */
  105637. incrementReferences(): void;
  105638. /**
  105639. * Change the size of the texture (not the size of the content)
  105640. * @param width defines the new width
  105641. * @param height defines the new height
  105642. * @param depth defines the new depth (1 by default)
  105643. */
  105644. updateSize(width: int, height: int, depth?: int): void;
  105645. /** @hidden */
  105646. _rebuild(): void;
  105647. /** @hidden */
  105648. _swapAndDie(target: InternalTexture): void;
  105649. /**
  105650. * Dispose the current allocated resources
  105651. */
  105652. dispose(): void;
  105653. }
  105654. }
  105655. declare module BABYLON {
  105656. /**
  105657. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105659. */
  105660. export class Analyser {
  105661. /**
  105662. * Gets or sets the smoothing
  105663. * @ignorenaming
  105664. */
  105665. SMOOTHING: number;
  105666. /**
  105667. * Gets or sets the FFT table size
  105668. * @ignorenaming
  105669. */
  105670. FFT_SIZE: number;
  105671. /**
  105672. * Gets or sets the bar graph amplitude
  105673. * @ignorenaming
  105674. */
  105675. BARGRAPHAMPLITUDE: number;
  105676. /**
  105677. * Gets or sets the position of the debug canvas
  105678. * @ignorenaming
  105679. */
  105680. DEBUGCANVASPOS: {
  105681. x: number;
  105682. y: number;
  105683. };
  105684. /**
  105685. * Gets or sets the debug canvas size
  105686. * @ignorenaming
  105687. */
  105688. DEBUGCANVASSIZE: {
  105689. width: number;
  105690. height: number;
  105691. };
  105692. private _byteFreqs;
  105693. private _byteTime;
  105694. private _floatFreqs;
  105695. private _webAudioAnalyser;
  105696. private _debugCanvas;
  105697. private _debugCanvasContext;
  105698. private _scene;
  105699. private _registerFunc;
  105700. private _audioEngine;
  105701. /**
  105702. * Creates a new analyser
  105703. * @param scene defines hosting scene
  105704. */
  105705. constructor(scene: Scene);
  105706. /**
  105707. * Get the number of data values you will have to play with for the visualization
  105708. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105709. * @returns a number
  105710. */
  105711. getFrequencyBinCount(): number;
  105712. /**
  105713. * Gets the current frequency data as a byte array
  105714. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105715. * @returns a Uint8Array
  105716. */
  105717. getByteFrequencyData(): Uint8Array;
  105718. /**
  105719. * Gets the current waveform as a byte array
  105720. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105721. * @returns a Uint8Array
  105722. */
  105723. getByteTimeDomainData(): Uint8Array;
  105724. /**
  105725. * Gets the current frequency data as a float array
  105726. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105727. * @returns a Float32Array
  105728. */
  105729. getFloatFrequencyData(): Float32Array;
  105730. /**
  105731. * Renders the debug canvas
  105732. */
  105733. drawDebugCanvas(): void;
  105734. /**
  105735. * Stops rendering the debug canvas and removes it
  105736. */
  105737. stopDebugCanvas(): void;
  105738. /**
  105739. * Connects two audio nodes
  105740. * @param inputAudioNode defines first node to connect
  105741. * @param outputAudioNode defines second node to connect
  105742. */
  105743. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105744. /**
  105745. * Releases all associated resources
  105746. */
  105747. dispose(): void;
  105748. }
  105749. }
  105750. declare module BABYLON {
  105751. /**
  105752. * This represents an audio engine and it is responsible
  105753. * to play, synchronize and analyse sounds throughout the application.
  105754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105755. */
  105756. export interface IAudioEngine extends IDisposable {
  105757. /**
  105758. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105759. */
  105760. readonly canUseWebAudio: boolean;
  105761. /**
  105762. * Gets the current AudioContext if available.
  105763. */
  105764. readonly audioContext: Nullable<AudioContext>;
  105765. /**
  105766. * The master gain node defines the global audio volume of your audio engine.
  105767. */
  105768. readonly masterGain: GainNode;
  105769. /**
  105770. * Gets whether or not mp3 are supported by your browser.
  105771. */
  105772. readonly isMP3supported: boolean;
  105773. /**
  105774. * Gets whether or not ogg are supported by your browser.
  105775. */
  105776. readonly isOGGsupported: boolean;
  105777. /**
  105778. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105779. * @ignoreNaming
  105780. */
  105781. WarnedWebAudioUnsupported: boolean;
  105782. /**
  105783. * Defines if the audio engine relies on a custom unlocked button.
  105784. * In this case, the embedded button will not be displayed.
  105785. */
  105786. useCustomUnlockedButton: boolean;
  105787. /**
  105788. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105789. */
  105790. readonly unlocked: boolean;
  105791. /**
  105792. * Event raised when audio has been unlocked on the browser.
  105793. */
  105794. onAudioUnlockedObservable: Observable<AudioEngine>;
  105795. /**
  105796. * Event raised when audio has been locked on the browser.
  105797. */
  105798. onAudioLockedObservable: Observable<AudioEngine>;
  105799. /**
  105800. * Flags the audio engine in Locked state.
  105801. * This happens due to new browser policies preventing audio to autoplay.
  105802. */
  105803. lock(): void;
  105804. /**
  105805. * Unlocks the audio engine once a user action has been done on the dom.
  105806. * This is helpful to resume play once browser policies have been satisfied.
  105807. */
  105808. unlock(): void;
  105809. }
  105810. /**
  105811. * This represents the default audio engine used in babylon.
  105812. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105814. */
  105815. export class AudioEngine implements IAudioEngine {
  105816. private _audioContext;
  105817. private _audioContextInitialized;
  105818. private _muteButton;
  105819. private _hostElement;
  105820. /**
  105821. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105822. */
  105823. canUseWebAudio: boolean;
  105824. /**
  105825. * The master gain node defines the global audio volume of your audio engine.
  105826. */
  105827. masterGain: GainNode;
  105828. /**
  105829. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105830. * @ignoreNaming
  105831. */
  105832. WarnedWebAudioUnsupported: boolean;
  105833. /**
  105834. * Gets whether or not mp3 are supported by your browser.
  105835. */
  105836. isMP3supported: boolean;
  105837. /**
  105838. * Gets whether or not ogg are supported by your browser.
  105839. */
  105840. isOGGsupported: boolean;
  105841. /**
  105842. * Gets whether audio has been unlocked on the device.
  105843. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105844. * a user interaction has happened.
  105845. */
  105846. unlocked: boolean;
  105847. /**
  105848. * Defines if the audio engine relies on a custom unlocked button.
  105849. * In this case, the embedded button will not be displayed.
  105850. */
  105851. useCustomUnlockedButton: boolean;
  105852. /**
  105853. * Event raised when audio has been unlocked on the browser.
  105854. */
  105855. onAudioUnlockedObservable: Observable<AudioEngine>;
  105856. /**
  105857. * Event raised when audio has been locked on the browser.
  105858. */
  105859. onAudioLockedObservable: Observable<AudioEngine>;
  105860. /**
  105861. * Gets the current AudioContext if available.
  105862. */
  105863. get audioContext(): Nullable<AudioContext>;
  105864. private _connectedAnalyser;
  105865. /**
  105866. * Instantiates a new audio engine.
  105867. *
  105868. * There should be only one per page as some browsers restrict the number
  105869. * of audio contexts you can create.
  105870. * @param hostElement defines the host element where to display the mute icon if necessary
  105871. */
  105872. constructor(hostElement?: Nullable<HTMLElement>);
  105873. /**
  105874. * Flags the audio engine in Locked state.
  105875. * This happens due to new browser policies preventing audio to autoplay.
  105876. */
  105877. lock(): void;
  105878. /**
  105879. * Unlocks the audio engine once a user action has been done on the dom.
  105880. * This is helpful to resume play once browser policies have been satisfied.
  105881. */
  105882. unlock(): void;
  105883. private _resumeAudioContext;
  105884. private _initializeAudioContext;
  105885. private _tryToRun;
  105886. private _triggerRunningState;
  105887. private _triggerSuspendedState;
  105888. private _displayMuteButton;
  105889. private _moveButtonToTopLeft;
  105890. private _onResize;
  105891. private _hideMuteButton;
  105892. /**
  105893. * Destroy and release the resources associated with the audio ccontext.
  105894. */
  105895. dispose(): void;
  105896. /**
  105897. * Gets the global volume sets on the master gain.
  105898. * @returns the global volume if set or -1 otherwise
  105899. */
  105900. getGlobalVolume(): number;
  105901. /**
  105902. * Sets the global volume of your experience (sets on the master gain).
  105903. * @param newVolume Defines the new global volume of the application
  105904. */
  105905. setGlobalVolume(newVolume: number): void;
  105906. /**
  105907. * Connect the audio engine to an audio analyser allowing some amazing
  105908. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105910. * @param analyser The analyser to connect to the engine
  105911. */
  105912. connectToAnalyser(analyser: Analyser): void;
  105913. }
  105914. }
  105915. declare module BABYLON {
  105916. /**
  105917. * Interface used to present a loading screen while loading a scene
  105918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105919. */
  105920. export interface ILoadingScreen {
  105921. /**
  105922. * Function called to display the loading screen
  105923. */
  105924. displayLoadingUI: () => void;
  105925. /**
  105926. * Function called to hide the loading screen
  105927. */
  105928. hideLoadingUI: () => void;
  105929. /**
  105930. * Gets or sets the color to use for the background
  105931. */
  105932. loadingUIBackgroundColor: string;
  105933. /**
  105934. * Gets or sets the text to display while loading
  105935. */
  105936. loadingUIText: string;
  105937. }
  105938. /**
  105939. * Class used for the default loading screen
  105940. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105941. */
  105942. export class DefaultLoadingScreen implements ILoadingScreen {
  105943. private _renderingCanvas;
  105944. private _loadingText;
  105945. private _loadingDivBackgroundColor;
  105946. private _loadingDiv;
  105947. private _loadingTextDiv;
  105948. /** Gets or sets the logo url to use for the default loading screen */
  105949. static DefaultLogoUrl: string;
  105950. /** Gets or sets the spinner url to use for the default loading screen */
  105951. static DefaultSpinnerUrl: string;
  105952. /**
  105953. * Creates a new default loading screen
  105954. * @param _renderingCanvas defines the canvas used to render the scene
  105955. * @param _loadingText defines the default text to display
  105956. * @param _loadingDivBackgroundColor defines the default background color
  105957. */
  105958. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105959. /**
  105960. * Function called to display the loading screen
  105961. */
  105962. displayLoadingUI(): void;
  105963. /**
  105964. * Function called to hide the loading screen
  105965. */
  105966. hideLoadingUI(): void;
  105967. /**
  105968. * Gets or sets the text to display while loading
  105969. */
  105970. set loadingUIText(text: string);
  105971. get loadingUIText(): string;
  105972. /**
  105973. * Gets or sets the color to use for the background
  105974. */
  105975. get loadingUIBackgroundColor(): string;
  105976. set loadingUIBackgroundColor(color: string);
  105977. private _resizeLoadingUI;
  105978. }
  105979. }
  105980. declare module BABYLON {
  105981. /**
  105982. * Interface for any object that can request an animation frame
  105983. */
  105984. export interface ICustomAnimationFrameRequester {
  105985. /**
  105986. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105987. */
  105988. renderFunction?: Function;
  105989. /**
  105990. * Called to request the next frame to render to
  105991. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105992. */
  105993. requestAnimationFrame: Function;
  105994. /**
  105995. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105996. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105997. */
  105998. requestID?: number;
  105999. }
  106000. }
  106001. declare module BABYLON {
  106002. /**
  106003. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106004. */
  106005. export class PerformanceMonitor {
  106006. private _enabled;
  106007. private _rollingFrameTime;
  106008. private _lastFrameTimeMs;
  106009. /**
  106010. * constructor
  106011. * @param frameSampleSize The number of samples required to saturate the sliding window
  106012. */
  106013. constructor(frameSampleSize?: number);
  106014. /**
  106015. * Samples current frame
  106016. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106017. */
  106018. sampleFrame(timeMs?: number): void;
  106019. /**
  106020. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106021. */
  106022. get averageFrameTime(): number;
  106023. /**
  106024. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106025. */
  106026. get averageFrameTimeVariance(): number;
  106027. /**
  106028. * Returns the frame time of the most recent frame
  106029. */
  106030. get instantaneousFrameTime(): number;
  106031. /**
  106032. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106033. */
  106034. get averageFPS(): number;
  106035. /**
  106036. * Returns the average framerate in frames per second using the most recent frame time
  106037. */
  106038. get instantaneousFPS(): number;
  106039. /**
  106040. * Returns true if enough samples have been taken to completely fill the sliding window
  106041. */
  106042. get isSaturated(): boolean;
  106043. /**
  106044. * Enables contributions to the sliding window sample set
  106045. */
  106046. enable(): void;
  106047. /**
  106048. * Disables contributions to the sliding window sample set
  106049. * Samples will not be interpolated over the disabled period
  106050. */
  106051. disable(): void;
  106052. /**
  106053. * Returns true if sampling is enabled
  106054. */
  106055. get isEnabled(): boolean;
  106056. /**
  106057. * Resets performance monitor
  106058. */
  106059. reset(): void;
  106060. }
  106061. /**
  106062. * RollingAverage
  106063. *
  106064. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106065. */
  106066. export class RollingAverage {
  106067. /**
  106068. * Current average
  106069. */
  106070. average: number;
  106071. /**
  106072. * Current variance
  106073. */
  106074. variance: number;
  106075. protected _samples: Array<number>;
  106076. protected _sampleCount: number;
  106077. protected _pos: number;
  106078. protected _m2: number;
  106079. /**
  106080. * constructor
  106081. * @param length The number of samples required to saturate the sliding window
  106082. */
  106083. constructor(length: number);
  106084. /**
  106085. * Adds a sample to the sample set
  106086. * @param v The sample value
  106087. */
  106088. add(v: number): void;
  106089. /**
  106090. * Returns previously added values or null if outside of history or outside the sliding window domain
  106091. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106092. * @return Value previously recorded with add() or null if outside of range
  106093. */
  106094. history(i: number): number;
  106095. /**
  106096. * Returns true if enough samples have been taken to completely fill the sliding window
  106097. * @return true if sample-set saturated
  106098. */
  106099. isSaturated(): boolean;
  106100. /**
  106101. * Resets the rolling average (equivalent to 0 samples taken so far)
  106102. */
  106103. reset(): void;
  106104. /**
  106105. * Wraps a value around the sample range boundaries
  106106. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106107. * @return Wrapped position in sample range
  106108. */
  106109. protected _wrapPosition(i: number): number;
  106110. }
  106111. }
  106112. declare module BABYLON {
  106113. /**
  106114. * This class is used to track a performance counter which is number based.
  106115. * The user has access to many properties which give statistics of different nature.
  106116. *
  106117. * The implementer can track two kinds of Performance Counter: time and count.
  106118. * 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.
  106119. * 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.
  106120. */
  106121. export class PerfCounter {
  106122. /**
  106123. * Gets or sets a global boolean to turn on and off all the counters
  106124. */
  106125. static Enabled: boolean;
  106126. /**
  106127. * Returns the smallest value ever
  106128. */
  106129. get min(): number;
  106130. /**
  106131. * Returns the biggest value ever
  106132. */
  106133. get max(): number;
  106134. /**
  106135. * Returns the average value since the performance counter is running
  106136. */
  106137. get average(): number;
  106138. /**
  106139. * Returns the average value of the last second the counter was monitored
  106140. */
  106141. get lastSecAverage(): number;
  106142. /**
  106143. * Returns the current value
  106144. */
  106145. get current(): number;
  106146. /**
  106147. * Gets the accumulated total
  106148. */
  106149. get total(): number;
  106150. /**
  106151. * Gets the total value count
  106152. */
  106153. get count(): number;
  106154. /**
  106155. * Creates a new counter
  106156. */
  106157. constructor();
  106158. /**
  106159. * Call this method to start monitoring a new frame.
  106160. * 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.
  106161. */
  106162. fetchNewFrame(): void;
  106163. /**
  106164. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106165. * @param newCount the count value to add to the monitored count
  106166. * @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.
  106167. */
  106168. addCount(newCount: number, fetchResult: boolean): void;
  106169. /**
  106170. * Start monitoring this performance counter
  106171. */
  106172. beginMonitoring(): void;
  106173. /**
  106174. * Compute the time lapsed since the previous beginMonitoring() call.
  106175. * @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
  106176. */
  106177. endMonitoring(newFrame?: boolean): void;
  106178. private _fetchResult;
  106179. private _startMonitoringTime;
  106180. private _min;
  106181. private _max;
  106182. private _average;
  106183. private _current;
  106184. private _totalValueCount;
  106185. private _totalAccumulated;
  106186. private _lastSecAverage;
  106187. private _lastSecAccumulated;
  106188. private _lastSecTime;
  106189. private _lastSecValueCount;
  106190. }
  106191. }
  106192. declare module BABYLON {
  106193. interface ThinEngine {
  106194. /**
  106195. * Sets alpha constants used by some alpha blending modes
  106196. * @param r defines the red component
  106197. * @param g defines the green component
  106198. * @param b defines the blue component
  106199. * @param a defines the alpha component
  106200. */
  106201. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106202. /**
  106203. * Sets the current alpha mode
  106204. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106205. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106206. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106207. */
  106208. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106209. /**
  106210. * Gets the current alpha mode
  106211. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106212. * @returns the current alpha mode
  106213. */
  106214. getAlphaMode(): number;
  106215. /**
  106216. * Sets the current alpha equation
  106217. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106218. */
  106219. setAlphaEquation(equation: number): void;
  106220. /**
  106221. * Gets the current alpha equation.
  106222. * @returns the current alpha equation
  106223. */
  106224. getAlphaEquation(): number;
  106225. }
  106226. }
  106227. declare module BABYLON {
  106228. /**
  106229. * Defines the interface used by display changed events
  106230. */
  106231. export interface IDisplayChangedEventArgs {
  106232. /** Gets the vrDisplay object (if any) */
  106233. vrDisplay: Nullable<any>;
  106234. /** Gets a boolean indicating if webVR is supported */
  106235. vrSupported: boolean;
  106236. }
  106237. /**
  106238. * Defines the interface used by objects containing a viewport (like a camera)
  106239. */
  106240. interface IViewportOwnerLike {
  106241. /**
  106242. * Gets or sets the viewport
  106243. */
  106244. viewport: IViewportLike;
  106245. }
  106246. /**
  106247. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106248. */
  106249. export class Engine extends ThinEngine {
  106250. /** Defines that alpha blending is disabled */
  106251. static readonly ALPHA_DISABLE: number;
  106252. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106253. static readonly ALPHA_ADD: number;
  106254. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106255. static readonly ALPHA_COMBINE: number;
  106256. /** Defines that alpha blending to DEST - SRC * DEST */
  106257. static readonly ALPHA_SUBTRACT: number;
  106258. /** Defines that alpha blending to SRC * DEST */
  106259. static readonly ALPHA_MULTIPLY: number;
  106260. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106261. static readonly ALPHA_MAXIMIZED: number;
  106262. /** Defines that alpha blending to SRC + DEST */
  106263. static readonly ALPHA_ONEONE: number;
  106264. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106265. static readonly ALPHA_PREMULTIPLIED: number;
  106266. /**
  106267. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106268. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106269. */
  106270. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106271. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106272. static readonly ALPHA_INTERPOLATE: number;
  106273. /**
  106274. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106275. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106276. */
  106277. static readonly ALPHA_SCREENMODE: number;
  106278. /** Defines that the ressource is not delayed*/
  106279. static readonly DELAYLOADSTATE_NONE: number;
  106280. /** Defines that the ressource was successfully delay loaded */
  106281. static readonly DELAYLOADSTATE_LOADED: number;
  106282. /** Defines that the ressource is currently delay loading */
  106283. static readonly DELAYLOADSTATE_LOADING: number;
  106284. /** Defines that the ressource is delayed and has not started loading */
  106285. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106286. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106287. static readonly NEVER: number;
  106288. /** 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 */
  106289. static readonly ALWAYS: number;
  106290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106291. static readonly LESS: number;
  106292. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106293. static readonly EQUAL: number;
  106294. /** 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 */
  106295. static readonly LEQUAL: number;
  106296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106297. static readonly GREATER: number;
  106298. /** 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 */
  106299. static readonly GEQUAL: number;
  106300. /** 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 */
  106301. static readonly NOTEQUAL: number;
  106302. /** Passed to stencilOperation to specify that stencil value must be kept */
  106303. static readonly KEEP: number;
  106304. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106305. static readonly REPLACE: number;
  106306. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106307. static readonly INCR: number;
  106308. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106309. static readonly DECR: number;
  106310. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106311. static readonly INVERT: number;
  106312. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106313. static readonly INCR_WRAP: number;
  106314. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106315. static readonly DECR_WRAP: number;
  106316. /** Texture is not repeating outside of 0..1 UVs */
  106317. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106318. /** Texture is repeating outside of 0..1 UVs */
  106319. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106320. /** Texture is repeating and mirrored */
  106321. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106322. /** ALPHA */
  106323. static readonly TEXTUREFORMAT_ALPHA: number;
  106324. /** LUMINANCE */
  106325. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106326. /** LUMINANCE_ALPHA */
  106327. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106328. /** RGB */
  106329. static readonly TEXTUREFORMAT_RGB: number;
  106330. /** RGBA */
  106331. static readonly TEXTUREFORMAT_RGBA: number;
  106332. /** RED */
  106333. static readonly TEXTUREFORMAT_RED: number;
  106334. /** RED (2nd reference) */
  106335. static readonly TEXTUREFORMAT_R: number;
  106336. /** RG */
  106337. static readonly TEXTUREFORMAT_RG: number;
  106338. /** RED_INTEGER */
  106339. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106340. /** RED_INTEGER (2nd reference) */
  106341. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106342. /** RG_INTEGER */
  106343. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106344. /** RGB_INTEGER */
  106345. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106346. /** RGBA_INTEGER */
  106347. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106348. /** UNSIGNED_BYTE */
  106349. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106350. /** UNSIGNED_BYTE (2nd reference) */
  106351. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106352. /** FLOAT */
  106353. static readonly TEXTURETYPE_FLOAT: number;
  106354. /** HALF_FLOAT */
  106355. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106356. /** BYTE */
  106357. static readonly TEXTURETYPE_BYTE: number;
  106358. /** SHORT */
  106359. static readonly TEXTURETYPE_SHORT: number;
  106360. /** UNSIGNED_SHORT */
  106361. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106362. /** INT */
  106363. static readonly TEXTURETYPE_INT: number;
  106364. /** UNSIGNED_INT */
  106365. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106366. /** UNSIGNED_SHORT_4_4_4_4 */
  106367. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106368. /** UNSIGNED_SHORT_5_5_5_1 */
  106369. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106370. /** UNSIGNED_SHORT_5_6_5 */
  106371. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106372. /** UNSIGNED_INT_2_10_10_10_REV */
  106373. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106374. /** UNSIGNED_INT_24_8 */
  106375. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106376. /** UNSIGNED_INT_10F_11F_11F_REV */
  106377. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106378. /** UNSIGNED_INT_5_9_9_9_REV */
  106379. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106380. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106381. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106382. /** nearest is mag = nearest and min = nearest and mip = linear */
  106383. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106384. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106385. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106386. /** Trilinear is mag = linear and min = linear and mip = linear */
  106387. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106388. /** nearest is mag = nearest and min = nearest and mip = linear */
  106389. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106390. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106391. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106392. /** Trilinear is mag = linear and min = linear and mip = linear */
  106393. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106394. /** mag = nearest and min = nearest and mip = nearest */
  106395. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106396. /** mag = nearest and min = linear and mip = nearest */
  106397. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106398. /** mag = nearest and min = linear and mip = linear */
  106399. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106400. /** mag = nearest and min = linear and mip = none */
  106401. static readonly TEXTURE_NEAREST_LINEAR: number;
  106402. /** mag = nearest and min = nearest and mip = none */
  106403. static readonly TEXTURE_NEAREST_NEAREST: number;
  106404. /** mag = linear and min = nearest and mip = nearest */
  106405. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106406. /** mag = linear and min = nearest and mip = linear */
  106407. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106408. /** mag = linear and min = linear and mip = none */
  106409. static readonly TEXTURE_LINEAR_LINEAR: number;
  106410. /** mag = linear and min = nearest and mip = none */
  106411. static readonly TEXTURE_LINEAR_NEAREST: number;
  106412. /** Explicit coordinates mode */
  106413. static readonly TEXTURE_EXPLICIT_MODE: number;
  106414. /** Spherical coordinates mode */
  106415. static readonly TEXTURE_SPHERICAL_MODE: number;
  106416. /** Planar coordinates mode */
  106417. static readonly TEXTURE_PLANAR_MODE: number;
  106418. /** Cubic coordinates mode */
  106419. static readonly TEXTURE_CUBIC_MODE: number;
  106420. /** Projection coordinates mode */
  106421. static readonly TEXTURE_PROJECTION_MODE: number;
  106422. /** Skybox coordinates mode */
  106423. static readonly TEXTURE_SKYBOX_MODE: number;
  106424. /** Inverse Cubic coordinates mode */
  106425. static readonly TEXTURE_INVCUBIC_MODE: number;
  106426. /** Equirectangular coordinates mode */
  106427. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106428. /** Equirectangular Fixed coordinates mode */
  106429. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106430. /** Equirectangular Fixed Mirrored coordinates mode */
  106431. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106432. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106433. static readonly SCALEMODE_FLOOR: number;
  106434. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106435. static readonly SCALEMODE_NEAREST: number;
  106436. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106437. static readonly SCALEMODE_CEILING: number;
  106438. /**
  106439. * Returns the current npm package of the sdk
  106440. */
  106441. static get NpmPackage(): string;
  106442. /**
  106443. * Returns the current version of the framework
  106444. */
  106445. static get Version(): string;
  106446. /** Gets the list of created engines */
  106447. static get Instances(): Engine[];
  106448. /**
  106449. * Gets the latest created engine
  106450. */
  106451. static get LastCreatedEngine(): Nullable<Engine>;
  106452. /**
  106453. * Gets the latest created scene
  106454. */
  106455. static get LastCreatedScene(): Nullable<Scene>;
  106456. /**
  106457. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106458. * @param flag defines which part of the materials must be marked as dirty
  106459. * @param predicate defines a predicate used to filter which materials should be affected
  106460. */
  106461. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106462. /**
  106463. * Method called to create the default loading screen.
  106464. * This can be overriden in your own app.
  106465. * @param canvas The rendering canvas element
  106466. * @returns The loading screen
  106467. */
  106468. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106469. /**
  106470. * Method called to create the default rescale post process on each engine.
  106471. */
  106472. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106473. /**
  106474. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106475. **/
  106476. enableOfflineSupport: boolean;
  106477. /**
  106478. * 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)
  106479. **/
  106480. disableManifestCheck: boolean;
  106481. /**
  106482. * Gets the list of created scenes
  106483. */
  106484. scenes: Scene[];
  106485. /**
  106486. * Event raised when a new scene is created
  106487. */
  106488. onNewSceneAddedObservable: Observable<Scene>;
  106489. /**
  106490. * Gets the list of created postprocesses
  106491. */
  106492. postProcesses: PostProcess[];
  106493. /**
  106494. * Gets a boolean indicating if the pointer is currently locked
  106495. */
  106496. isPointerLock: boolean;
  106497. /**
  106498. * Observable event triggered each time the rendering canvas is resized
  106499. */
  106500. onResizeObservable: Observable<Engine>;
  106501. /**
  106502. * Observable event triggered each time the canvas loses focus
  106503. */
  106504. onCanvasBlurObservable: Observable<Engine>;
  106505. /**
  106506. * Observable event triggered each time the canvas gains focus
  106507. */
  106508. onCanvasFocusObservable: Observable<Engine>;
  106509. /**
  106510. * Observable event triggered each time the canvas receives pointerout event
  106511. */
  106512. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106513. /**
  106514. * Observable raised when the engine begins a new frame
  106515. */
  106516. onBeginFrameObservable: Observable<Engine>;
  106517. /**
  106518. * If set, will be used to request the next animation frame for the render loop
  106519. */
  106520. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106521. /**
  106522. * Observable raised when the engine ends the current frame
  106523. */
  106524. onEndFrameObservable: Observable<Engine>;
  106525. /**
  106526. * Observable raised when the engine is about to compile a shader
  106527. */
  106528. onBeforeShaderCompilationObservable: Observable<Engine>;
  106529. /**
  106530. * Observable raised when the engine has jsut compiled a shader
  106531. */
  106532. onAfterShaderCompilationObservable: Observable<Engine>;
  106533. /**
  106534. * Gets the audio engine
  106535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106536. * @ignorenaming
  106537. */
  106538. static audioEngine: IAudioEngine;
  106539. /**
  106540. * Default AudioEngine factory responsible of creating the Audio Engine.
  106541. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106542. */
  106543. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106544. /**
  106545. * Default offline support factory responsible of creating a tool used to store data locally.
  106546. * By default, this will create a Database object if the workload has been embedded.
  106547. */
  106548. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106549. private _loadingScreen;
  106550. private _pointerLockRequested;
  106551. private _dummyFramebuffer;
  106552. private _rescalePostProcess;
  106553. private _deterministicLockstep;
  106554. private _lockstepMaxSteps;
  106555. private _timeStep;
  106556. protected get _supportsHardwareTextureRescaling(): boolean;
  106557. private _fps;
  106558. private _deltaTime;
  106559. /** @hidden */
  106560. _drawCalls: PerfCounter;
  106561. /** 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 */
  106562. canvasTabIndex: number;
  106563. /**
  106564. * Turn this value on if you want to pause FPS computation when in background
  106565. */
  106566. disablePerformanceMonitorInBackground: boolean;
  106567. private _performanceMonitor;
  106568. /**
  106569. * Gets the performance monitor attached to this engine
  106570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106571. */
  106572. get performanceMonitor(): PerformanceMonitor;
  106573. private _onFocus;
  106574. private _onBlur;
  106575. private _onCanvasPointerOut;
  106576. private _onCanvasBlur;
  106577. private _onCanvasFocus;
  106578. private _onFullscreenChange;
  106579. private _onPointerLockChange;
  106580. /**
  106581. * Gets the HTML element used to attach event listeners
  106582. * @returns a HTML element
  106583. */
  106584. getInputElement(): Nullable<HTMLElement>;
  106585. /**
  106586. * Creates a new engine
  106587. * @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
  106588. * @param antialias defines enable antialiasing (default: false)
  106589. * @param options defines further options to be sent to the getContext() function
  106590. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106591. */
  106592. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106593. /**
  106594. * Gets current aspect ratio
  106595. * @param viewportOwner defines the camera to use to get the aspect ratio
  106596. * @param useScreen defines if screen size must be used (or the current render target if any)
  106597. * @returns a number defining the aspect ratio
  106598. */
  106599. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106600. /**
  106601. * Gets current screen aspect ratio
  106602. * @returns a number defining the aspect ratio
  106603. */
  106604. getScreenAspectRatio(): number;
  106605. /**
  106606. * Gets the client rect of the HTML canvas attached with the current webGL context
  106607. * @returns a client rectanglee
  106608. */
  106609. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106610. /**
  106611. * Gets the client rect of the HTML element used for events
  106612. * @returns a client rectanglee
  106613. */
  106614. getInputElementClientRect(): Nullable<ClientRect>;
  106615. /**
  106616. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106618. * @returns true if engine is in deterministic lock step mode
  106619. */
  106620. isDeterministicLockStep(): boolean;
  106621. /**
  106622. * Gets the max steps when engine is running in deterministic lock step
  106623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106624. * @returns the max steps
  106625. */
  106626. getLockstepMaxSteps(): number;
  106627. /**
  106628. * Returns the time in ms between steps when using deterministic lock step.
  106629. * @returns time step in (ms)
  106630. */
  106631. getTimeStep(): number;
  106632. /**
  106633. * Force the mipmap generation for the given render target texture
  106634. * @param texture defines the render target texture to use
  106635. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106636. */
  106637. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106638. /** States */
  106639. /**
  106640. * Set various states to the webGL context
  106641. * @param culling defines backface culling state
  106642. * @param zOffset defines the value to apply to zOffset (0 by default)
  106643. * @param force defines if states must be applied even if cache is up to date
  106644. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106645. */
  106646. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106647. /**
  106648. * Set the z offset to apply to current rendering
  106649. * @param value defines the offset to apply
  106650. */
  106651. setZOffset(value: number): void;
  106652. /**
  106653. * Gets the current value of the zOffset
  106654. * @returns the current zOffset state
  106655. */
  106656. getZOffset(): number;
  106657. /**
  106658. * Enable or disable depth buffering
  106659. * @param enable defines the state to set
  106660. */
  106661. setDepthBuffer(enable: boolean): void;
  106662. /**
  106663. * Gets a boolean indicating if depth writing is enabled
  106664. * @returns the current depth writing state
  106665. */
  106666. getDepthWrite(): boolean;
  106667. /**
  106668. * Enable or disable depth writing
  106669. * @param enable defines the state to set
  106670. */
  106671. setDepthWrite(enable: boolean): void;
  106672. /**
  106673. * Gets a boolean indicating if stencil buffer is enabled
  106674. * @returns the current stencil buffer state
  106675. */
  106676. getStencilBuffer(): boolean;
  106677. /**
  106678. * Enable or disable the stencil buffer
  106679. * @param enable defines if the stencil buffer must be enabled or disabled
  106680. */
  106681. setStencilBuffer(enable: boolean): void;
  106682. /**
  106683. * Gets the current stencil mask
  106684. * @returns a number defining the new stencil mask to use
  106685. */
  106686. getStencilMask(): number;
  106687. /**
  106688. * Sets the current stencil mask
  106689. * @param mask defines the new stencil mask to use
  106690. */
  106691. setStencilMask(mask: number): void;
  106692. /**
  106693. * Gets the current stencil function
  106694. * @returns a number defining the stencil function to use
  106695. */
  106696. getStencilFunction(): number;
  106697. /**
  106698. * Gets the current stencil reference value
  106699. * @returns a number defining the stencil reference value to use
  106700. */
  106701. getStencilFunctionReference(): number;
  106702. /**
  106703. * Gets the current stencil mask
  106704. * @returns a number defining the stencil mask to use
  106705. */
  106706. getStencilFunctionMask(): number;
  106707. /**
  106708. * Sets the current stencil function
  106709. * @param stencilFunc defines the new stencil function to use
  106710. */
  106711. setStencilFunction(stencilFunc: number): void;
  106712. /**
  106713. * Sets the current stencil reference
  106714. * @param reference defines the new stencil reference to use
  106715. */
  106716. setStencilFunctionReference(reference: number): void;
  106717. /**
  106718. * Sets the current stencil mask
  106719. * @param mask defines the new stencil mask to use
  106720. */
  106721. setStencilFunctionMask(mask: number): void;
  106722. /**
  106723. * Gets the current stencil operation when stencil fails
  106724. * @returns a number defining stencil operation to use when stencil fails
  106725. */
  106726. getStencilOperationFail(): number;
  106727. /**
  106728. * Gets the current stencil operation when depth fails
  106729. * @returns a number defining stencil operation to use when depth fails
  106730. */
  106731. getStencilOperationDepthFail(): number;
  106732. /**
  106733. * Gets the current stencil operation when stencil passes
  106734. * @returns a number defining stencil operation to use when stencil passes
  106735. */
  106736. getStencilOperationPass(): number;
  106737. /**
  106738. * Sets the stencil operation to use when stencil fails
  106739. * @param operation defines the stencil operation to use when stencil fails
  106740. */
  106741. setStencilOperationFail(operation: number): void;
  106742. /**
  106743. * Sets the stencil operation to use when depth fails
  106744. * @param operation defines the stencil operation to use when depth fails
  106745. */
  106746. setStencilOperationDepthFail(operation: number): void;
  106747. /**
  106748. * Sets the stencil operation to use when stencil passes
  106749. * @param operation defines the stencil operation to use when stencil passes
  106750. */
  106751. setStencilOperationPass(operation: number): void;
  106752. /**
  106753. * Sets a boolean indicating if the dithering state is enabled or disabled
  106754. * @param value defines the dithering state
  106755. */
  106756. setDitheringState(value: boolean): void;
  106757. /**
  106758. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106759. * @param value defines the rasterizer state
  106760. */
  106761. setRasterizerState(value: boolean): void;
  106762. /**
  106763. * Gets the current depth function
  106764. * @returns a number defining the depth function
  106765. */
  106766. getDepthFunction(): Nullable<number>;
  106767. /**
  106768. * Sets the current depth function
  106769. * @param depthFunc defines the function to use
  106770. */
  106771. setDepthFunction(depthFunc: number): void;
  106772. /**
  106773. * Sets the current depth function to GREATER
  106774. */
  106775. setDepthFunctionToGreater(): void;
  106776. /**
  106777. * Sets the current depth function to GEQUAL
  106778. */
  106779. setDepthFunctionToGreaterOrEqual(): void;
  106780. /**
  106781. * Sets the current depth function to LESS
  106782. */
  106783. setDepthFunctionToLess(): void;
  106784. /**
  106785. * Sets the current depth function to LEQUAL
  106786. */
  106787. setDepthFunctionToLessOrEqual(): void;
  106788. private _cachedStencilBuffer;
  106789. private _cachedStencilFunction;
  106790. private _cachedStencilMask;
  106791. private _cachedStencilOperationPass;
  106792. private _cachedStencilOperationFail;
  106793. private _cachedStencilOperationDepthFail;
  106794. private _cachedStencilReference;
  106795. /**
  106796. * Caches the the state of the stencil buffer
  106797. */
  106798. cacheStencilState(): void;
  106799. /**
  106800. * Restores the state of the stencil buffer
  106801. */
  106802. restoreStencilState(): void;
  106803. /**
  106804. * Directly set the WebGL Viewport
  106805. * @param x defines the x coordinate of the viewport (in screen space)
  106806. * @param y defines the y coordinate of the viewport (in screen space)
  106807. * @param width defines the width of the viewport (in screen space)
  106808. * @param height defines the height of the viewport (in screen space)
  106809. * @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
  106810. */
  106811. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106812. /**
  106813. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106814. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106815. * @param y defines the y-coordinate of the corner of the clear rectangle
  106816. * @param width defines the width of the clear rectangle
  106817. * @param height defines the height of the clear rectangle
  106818. * @param clearColor defines the clear color
  106819. */
  106820. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106821. /**
  106822. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106823. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106824. * @param y defines the y-coordinate of the corner of the clear rectangle
  106825. * @param width defines the width of the clear rectangle
  106826. * @param height defines the height of the clear rectangle
  106827. */
  106828. enableScissor(x: number, y: number, width: number, height: number): void;
  106829. /**
  106830. * Disable previously set scissor test rectangle
  106831. */
  106832. disableScissor(): void;
  106833. protected _reportDrawCall(): void;
  106834. /**
  106835. * Initializes a webVR display and starts listening to display change events
  106836. * The onVRDisplayChangedObservable will be notified upon these changes
  106837. * @returns The onVRDisplayChangedObservable
  106838. */
  106839. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106840. /** @hidden */
  106841. _prepareVRComponent(): void;
  106842. /** @hidden */
  106843. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106844. /** @hidden */
  106845. _submitVRFrame(): void;
  106846. /**
  106847. * Call this function to leave webVR mode
  106848. * Will do nothing if webVR is not supported or if there is no webVR device
  106849. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106850. */
  106851. disableVR(): void;
  106852. /**
  106853. * Gets a boolean indicating that the system is in VR mode and is presenting
  106854. * @returns true if VR mode is engaged
  106855. */
  106856. isVRPresenting(): boolean;
  106857. /** @hidden */
  106858. _requestVRFrame(): void;
  106859. /** @hidden */
  106860. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106861. /**
  106862. * Gets the source code of the vertex shader associated with a specific webGL program
  106863. * @param program defines the program to use
  106864. * @returns a string containing the source code of the vertex shader associated with the program
  106865. */
  106866. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106867. /**
  106868. * Gets the source code of the fragment shader associated with a specific webGL program
  106869. * @param program defines the program to use
  106870. * @returns a string containing the source code of the fragment shader associated with the program
  106871. */
  106872. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106873. /**
  106874. * Sets a depth stencil texture from a render target to the according uniform.
  106875. * @param channel The texture channel
  106876. * @param uniform The uniform to set
  106877. * @param texture The render target texture containing the depth stencil texture to apply
  106878. */
  106879. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106880. /**
  106881. * Sets a texture to the webGL context from a postprocess
  106882. * @param channel defines the channel to use
  106883. * @param postProcess defines the source postprocess
  106884. */
  106885. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106886. /**
  106887. * Binds the output of the passed in post process to the texture channel specified
  106888. * @param channel The channel the texture should be bound to
  106889. * @param postProcess The post process which's output should be bound
  106890. */
  106891. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106892. /** @hidden */
  106893. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106894. protected _rebuildBuffers(): void;
  106895. /** @hidden */
  106896. _renderFrame(): void;
  106897. _renderLoop(): void;
  106898. /** @hidden */
  106899. _renderViews(): boolean;
  106900. /**
  106901. * Toggle full screen mode
  106902. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106903. */
  106904. switchFullscreen(requestPointerLock: boolean): void;
  106905. /**
  106906. * Enters full screen mode
  106907. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106908. */
  106909. enterFullscreen(requestPointerLock: boolean): void;
  106910. /**
  106911. * Exits full screen mode
  106912. */
  106913. exitFullscreen(): void;
  106914. /**
  106915. * Enters Pointerlock mode
  106916. */
  106917. enterPointerlock(): void;
  106918. /**
  106919. * Exits Pointerlock mode
  106920. */
  106921. exitPointerlock(): void;
  106922. /**
  106923. * Begin a new frame
  106924. */
  106925. beginFrame(): void;
  106926. /**
  106927. * Enf the current frame
  106928. */
  106929. endFrame(): void;
  106930. resize(): void;
  106931. /**
  106932. * Force a specific size of the canvas
  106933. * @param width defines the new canvas' width
  106934. * @param height defines the new canvas' height
  106935. */
  106936. setSize(width: number, height: number): void;
  106937. /**
  106938. * Updates a dynamic vertex buffer.
  106939. * @param vertexBuffer the vertex buffer to update
  106940. * @param data the data used to update the vertex buffer
  106941. * @param byteOffset the byte offset of the data
  106942. * @param byteLength the byte length of the data
  106943. */
  106944. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106945. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106946. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106947. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106948. _releaseTexture(texture: InternalTexture): void;
  106949. /**
  106950. * @hidden
  106951. * Rescales a texture
  106952. * @param source input texutre
  106953. * @param destination destination texture
  106954. * @param scene scene to use to render the resize
  106955. * @param internalFormat format to use when resizing
  106956. * @param onComplete callback to be called when resize has completed
  106957. */
  106958. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106959. /**
  106960. * Gets the current framerate
  106961. * @returns a number representing the framerate
  106962. */
  106963. getFps(): number;
  106964. /**
  106965. * Gets the time spent between current and previous frame
  106966. * @returns a number representing the delta time in ms
  106967. */
  106968. getDeltaTime(): number;
  106969. private _measureFps;
  106970. /** @hidden */
  106971. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106972. /**
  106973. * Update a dynamic index buffer
  106974. * @param indexBuffer defines the target index buffer
  106975. * @param indices defines the data to update
  106976. * @param offset defines the offset in the target index buffer where update should start
  106977. */
  106978. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106979. /**
  106980. * Updates the sample count of a render target texture
  106981. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106982. * @param texture defines the texture to update
  106983. * @param samples defines the sample count to set
  106984. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106985. */
  106986. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106987. /**
  106988. * Updates a depth texture Comparison Mode and Function.
  106989. * If the comparison Function is equal to 0, the mode will be set to none.
  106990. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106991. * @param texture The texture to set the comparison function for
  106992. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106993. */
  106994. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106995. /**
  106996. * Creates a webGL buffer to use with instanciation
  106997. * @param capacity defines the size of the buffer
  106998. * @returns the webGL buffer
  106999. */
  107000. createInstancesBuffer(capacity: number): DataBuffer;
  107001. /**
  107002. * Delete a webGL buffer used with instanciation
  107003. * @param buffer defines the webGL buffer to delete
  107004. */
  107005. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107006. private _clientWaitAsync;
  107007. /** @hidden */
  107008. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107009. /** @hidden */
  107010. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107011. dispose(): void;
  107012. private _disableTouchAction;
  107013. /**
  107014. * Display the loading screen
  107015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107016. */
  107017. displayLoadingUI(): void;
  107018. /**
  107019. * Hide the loading screen
  107020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107021. */
  107022. hideLoadingUI(): void;
  107023. /**
  107024. * Gets the current loading screen object
  107025. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107026. */
  107027. get loadingScreen(): ILoadingScreen;
  107028. /**
  107029. * Sets the current loading screen object
  107030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107031. */
  107032. set loadingScreen(loadingScreen: ILoadingScreen);
  107033. /**
  107034. * Sets the current loading screen text
  107035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107036. */
  107037. set loadingUIText(text: string);
  107038. /**
  107039. * Sets the current loading screen background color
  107040. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107041. */
  107042. set loadingUIBackgroundColor(color: string);
  107043. /** Pointerlock and fullscreen */
  107044. /**
  107045. * Ask the browser to promote the current element to pointerlock mode
  107046. * @param element defines the DOM element to promote
  107047. */
  107048. static _RequestPointerlock(element: HTMLElement): void;
  107049. /**
  107050. * Asks the browser to exit pointerlock mode
  107051. */
  107052. static _ExitPointerlock(): void;
  107053. /**
  107054. * Ask the browser to promote the current element to fullscreen rendering mode
  107055. * @param element defines the DOM element to promote
  107056. */
  107057. static _RequestFullscreen(element: HTMLElement): void;
  107058. /**
  107059. * Asks the browser to exit fullscreen mode
  107060. */
  107061. static _ExitFullscreen(): void;
  107062. }
  107063. }
  107064. declare module BABYLON {
  107065. /**
  107066. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107067. * during the life time of the application.
  107068. */
  107069. export class EngineStore {
  107070. /** Gets the list of created engines */
  107071. static Instances: Engine[];
  107072. /** @hidden */
  107073. static _LastCreatedScene: Nullable<Scene>;
  107074. /**
  107075. * Gets the latest created engine
  107076. */
  107077. static get LastCreatedEngine(): Nullable<Engine>;
  107078. /**
  107079. * Gets the latest created scene
  107080. */
  107081. static get LastCreatedScene(): Nullable<Scene>;
  107082. /**
  107083. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107084. * @ignorenaming
  107085. */
  107086. static UseFallbackTexture: boolean;
  107087. /**
  107088. * Texture content used if a texture cannot loaded
  107089. * @ignorenaming
  107090. */
  107091. static FallbackTexture: string;
  107092. }
  107093. }
  107094. declare module BABYLON {
  107095. /**
  107096. * Helper class that provides a small promise polyfill
  107097. */
  107098. export class PromisePolyfill {
  107099. /**
  107100. * Static function used to check if the polyfill is required
  107101. * If this is the case then the function will inject the polyfill to window.Promise
  107102. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107103. */
  107104. static Apply(force?: boolean): void;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * Interface for screenshot methods with describe argument called `size` as object with options
  107110. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107111. */
  107112. export interface IScreenshotSize {
  107113. /**
  107114. * number in pixels for canvas height
  107115. */
  107116. height?: number;
  107117. /**
  107118. * multiplier allowing render at a higher or lower resolution
  107119. * If value is defined then height and width will be ignored and taken from camera
  107120. */
  107121. precision?: number;
  107122. /**
  107123. * number in pixels for canvas width
  107124. */
  107125. width?: number;
  107126. }
  107127. }
  107128. declare module BABYLON {
  107129. interface IColor4Like {
  107130. r: float;
  107131. g: float;
  107132. b: float;
  107133. a: float;
  107134. }
  107135. /**
  107136. * Class containing a set of static utilities functions
  107137. */
  107138. export class Tools {
  107139. /**
  107140. * Gets or sets the base URL to use to load assets
  107141. */
  107142. static get BaseUrl(): string;
  107143. static set BaseUrl(value: string);
  107144. /**
  107145. * Enable/Disable Custom HTTP Request Headers globally.
  107146. * default = false
  107147. * @see CustomRequestHeaders
  107148. */
  107149. static UseCustomRequestHeaders: boolean;
  107150. /**
  107151. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107152. * i.e. when loading files, where the server/service expects an Authorization header
  107153. */
  107154. static CustomRequestHeaders: {
  107155. [key: string]: string;
  107156. };
  107157. /**
  107158. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107159. */
  107160. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107161. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107162. /**
  107163. * Default behaviour for cors in the application.
  107164. * It can be a string if the expected behavior is identical in the entire app.
  107165. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107166. */
  107167. static CorsBehavior: string | ((url: string | string[]) => string);
  107168. /**
  107169. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107170. * @ignorenaming
  107171. */
  107172. static get UseFallbackTexture(): boolean;
  107173. static set UseFallbackTexture(value: boolean);
  107174. /**
  107175. * Use this object to register external classes like custom textures or material
  107176. * to allow the laoders to instantiate them
  107177. */
  107178. static get RegisteredExternalClasses(): {
  107179. [key: string]: Object;
  107180. };
  107181. static set RegisteredExternalClasses(classes: {
  107182. [key: string]: Object;
  107183. });
  107184. /**
  107185. * Texture content used if a texture cannot loaded
  107186. * @ignorenaming
  107187. */
  107188. static get fallbackTexture(): string;
  107189. static set fallbackTexture(value: string);
  107190. /**
  107191. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107192. * @param u defines the coordinate on X axis
  107193. * @param v defines the coordinate on Y axis
  107194. * @param width defines the width of the source data
  107195. * @param height defines the height of the source data
  107196. * @param pixels defines the source byte array
  107197. * @param color defines the output color
  107198. */
  107199. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107200. /**
  107201. * Interpolates between a and b via alpha
  107202. * @param a The lower value (returned when alpha = 0)
  107203. * @param b The upper value (returned when alpha = 1)
  107204. * @param alpha The interpolation-factor
  107205. * @return The mixed value
  107206. */
  107207. static Mix(a: number, b: number, alpha: number): number;
  107208. /**
  107209. * Tries to instantiate a new object from a given class name
  107210. * @param className defines the class name to instantiate
  107211. * @returns the new object or null if the system was not able to do the instantiation
  107212. */
  107213. static Instantiate(className: string): any;
  107214. /**
  107215. * Provides a slice function that will work even on IE
  107216. * @param data defines the array to slice
  107217. * @param start defines the start of the data (optional)
  107218. * @param end defines the end of the data (optional)
  107219. * @returns the new sliced array
  107220. */
  107221. static Slice<T>(data: T, start?: number, end?: number): T;
  107222. /**
  107223. * Polyfill for setImmediate
  107224. * @param action defines the action to execute after the current execution block
  107225. */
  107226. static SetImmediate(action: () => void): void;
  107227. /**
  107228. * Function indicating if a number is an exponent of 2
  107229. * @param value defines the value to test
  107230. * @returns true if the value is an exponent of 2
  107231. */
  107232. static IsExponentOfTwo(value: number): boolean;
  107233. private static _tmpFloatArray;
  107234. /**
  107235. * Returns the nearest 32-bit single precision float representation of a Number
  107236. * @param value A Number. If the parameter is of a different type, it will get converted
  107237. * to a number or to NaN if it cannot be converted
  107238. * @returns number
  107239. */
  107240. static FloatRound(value: number): number;
  107241. /**
  107242. * Extracts the filename from a path
  107243. * @param path defines the path to use
  107244. * @returns the filename
  107245. */
  107246. static GetFilename(path: string): string;
  107247. /**
  107248. * Extracts the "folder" part of a path (everything before the filename).
  107249. * @param uri The URI to extract the info from
  107250. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107251. * @returns The "folder" part of the path
  107252. */
  107253. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107254. /**
  107255. * Extracts text content from a DOM element hierarchy
  107256. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107257. */
  107258. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107259. /**
  107260. * Convert an angle in radians to degrees
  107261. * @param angle defines the angle to convert
  107262. * @returns the angle in degrees
  107263. */
  107264. static ToDegrees(angle: number): number;
  107265. /**
  107266. * Convert an angle in degrees to radians
  107267. * @param angle defines the angle to convert
  107268. * @returns the angle in radians
  107269. */
  107270. static ToRadians(angle: number): number;
  107271. /**
  107272. * Returns an array if obj is not an array
  107273. * @param obj defines the object to evaluate as an array
  107274. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107275. * @returns either obj directly if obj is an array or a new array containing obj
  107276. */
  107277. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107278. /**
  107279. * Gets the pointer prefix to use
  107280. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107281. */
  107282. static GetPointerPrefix(): string;
  107283. /**
  107284. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107285. * @param url define the url we are trying
  107286. * @param element define the dom element where to configure the cors policy
  107287. */
  107288. static SetCorsBehavior(url: string | string[], element: {
  107289. crossOrigin: string | null;
  107290. }): void;
  107291. /**
  107292. * Removes unwanted characters from an url
  107293. * @param url defines the url to clean
  107294. * @returns the cleaned url
  107295. */
  107296. static CleanUrl(url: string): string;
  107297. /**
  107298. * Gets or sets a function used to pre-process url before using them to load assets
  107299. */
  107300. static get PreprocessUrl(): (url: string) => string;
  107301. static set PreprocessUrl(processor: (url: string) => string);
  107302. /**
  107303. * Loads an image as an HTMLImageElement.
  107304. * @param input url string, ArrayBuffer, or Blob to load
  107305. * @param onLoad callback called when the image successfully loads
  107306. * @param onError callback called when the image fails to load
  107307. * @param offlineProvider offline provider for caching
  107308. * @param mimeType optional mime type
  107309. * @returns the HTMLImageElement of the loaded image
  107310. */
  107311. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107312. /**
  107313. * Loads a file from a url
  107314. * @param url url string, ArrayBuffer, or Blob to load
  107315. * @param onSuccess callback called when the file successfully loads
  107316. * @param onProgress callback called while file is loading (if the server supports this mode)
  107317. * @param offlineProvider defines the offline provider for caching
  107318. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107319. * @param onError callback called when the file fails to load
  107320. * @returns a file request object
  107321. */
  107322. 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;
  107323. /**
  107324. * Loads a file from a url
  107325. * @param url the file url to load
  107326. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107327. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107328. */
  107329. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107330. /**
  107331. * Load a script (identified by an url). When the url returns, the
  107332. * content of this file is added into a new script element, attached to the DOM (body element)
  107333. * @param scriptUrl defines the url of the script to laod
  107334. * @param onSuccess defines the callback called when the script is loaded
  107335. * @param onError defines the callback to call if an error occurs
  107336. * @param scriptId defines the id of the script element
  107337. */
  107338. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107339. /**
  107340. * Load an asynchronous script (identified by an url). When the url returns, the
  107341. * content of this file is added into a new script element, attached to the DOM (body element)
  107342. * @param scriptUrl defines the url of the script to laod
  107343. * @param scriptId defines the id of the script element
  107344. * @returns a promise request object
  107345. */
  107346. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107347. /**
  107348. * Loads a file from a blob
  107349. * @param fileToLoad defines the blob to use
  107350. * @param callback defines the callback to call when data is loaded
  107351. * @param progressCallback defines the callback to call during loading process
  107352. * @returns a file request object
  107353. */
  107354. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107355. /**
  107356. * Reads a file from a File object
  107357. * @param file defines the file to load
  107358. * @param onSuccess defines the callback to call when data is loaded
  107359. * @param onProgress defines the callback to call during loading process
  107360. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107361. * @param onError defines the callback to call when an error occurs
  107362. * @returns a file request object
  107363. */
  107364. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107365. /**
  107366. * Creates a data url from a given string content
  107367. * @param content defines the content to convert
  107368. * @returns the new data url link
  107369. */
  107370. static FileAsURL(content: string): string;
  107371. /**
  107372. * Format the given number to a specific decimal format
  107373. * @param value defines the number to format
  107374. * @param decimals defines the number of decimals to use
  107375. * @returns the formatted string
  107376. */
  107377. static Format(value: number, decimals?: number): string;
  107378. /**
  107379. * Tries to copy an object by duplicating every property
  107380. * @param source defines the source object
  107381. * @param destination defines the target object
  107382. * @param doNotCopyList defines a list of properties to avoid
  107383. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107384. */
  107385. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107386. /**
  107387. * Gets a boolean indicating if the given object has no own property
  107388. * @param obj defines the object to test
  107389. * @returns true if object has no own property
  107390. */
  107391. static IsEmpty(obj: any): boolean;
  107392. /**
  107393. * Function used to register events at window level
  107394. * @param windowElement defines the Window object to use
  107395. * @param events defines the events to register
  107396. */
  107397. static RegisterTopRootEvents(windowElement: Window, events: {
  107398. name: string;
  107399. handler: Nullable<(e: FocusEvent) => any>;
  107400. }[]): void;
  107401. /**
  107402. * Function used to unregister events from window level
  107403. * @param windowElement defines the Window object to use
  107404. * @param events defines the events to unregister
  107405. */
  107406. static UnregisterTopRootEvents(windowElement: Window, events: {
  107407. name: string;
  107408. handler: Nullable<(e: FocusEvent) => any>;
  107409. }[]): void;
  107410. /**
  107411. * @ignore
  107412. */
  107413. static _ScreenshotCanvas: HTMLCanvasElement;
  107414. /**
  107415. * Dumps the current bound framebuffer
  107416. * @param width defines the rendering width
  107417. * @param height defines the rendering height
  107418. * @param engine defines the hosting engine
  107419. * @param successCallback defines the callback triggered once the data are available
  107420. * @param mimeType defines the mime type of the result
  107421. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107422. */
  107423. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107424. /**
  107425. * Converts the canvas data to blob.
  107426. * This acts as a polyfill for browsers not supporting the to blob function.
  107427. * @param canvas Defines the canvas to extract the data from
  107428. * @param successCallback Defines the callback triggered once the data are available
  107429. * @param mimeType Defines the mime type of the result
  107430. */
  107431. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107432. /**
  107433. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107434. * @param successCallback defines the callback triggered once the data are available
  107435. * @param mimeType defines the mime type of the result
  107436. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107437. */
  107438. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107439. /**
  107440. * Downloads a blob in the browser
  107441. * @param blob defines the blob to download
  107442. * @param fileName defines the name of the downloaded file
  107443. */
  107444. static Download(blob: Blob, fileName: string): void;
  107445. /**
  107446. * Captures a screenshot of the current rendering
  107447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107448. * @param engine defines the rendering engine
  107449. * @param camera defines the source camera
  107450. * @param size This parameter can be set to a single number or to an object with the
  107451. * following (optional) properties: precision, width, height. If a single number is passed,
  107452. * it will be used for both width and height. If an object is passed, the screenshot size
  107453. * will be derived from the parameters. The precision property is a multiplier allowing
  107454. * rendering at a higher or lower resolution
  107455. * @param successCallback defines the callback receives a single parameter which contains the
  107456. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107457. * src parameter of an <img> to display it
  107458. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107459. * Check your browser for supported MIME types
  107460. */
  107461. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107462. /**
  107463. * Captures a screenshot of the current rendering
  107464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107465. * @param engine defines the rendering engine
  107466. * @param camera defines the source camera
  107467. * @param size This parameter can be set to a single number or to an object with the
  107468. * following (optional) properties: precision, width, height. If a single number is passed,
  107469. * it will be used for both width and height. If an object is passed, the screenshot size
  107470. * will be derived from the parameters. The precision property is a multiplier allowing
  107471. * rendering at a higher or lower resolution
  107472. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107473. * Check your browser for supported MIME types
  107474. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107475. * to the src parameter of an <img> to display it
  107476. */
  107477. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107478. /**
  107479. * Generates an image screenshot from the specified camera.
  107480. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107481. * @param engine The engine to use for rendering
  107482. * @param camera The camera to use for rendering
  107483. * @param size This parameter can be set to a single number or to an object with the
  107484. * following (optional) properties: precision, width, height. If a single number is passed,
  107485. * it will be used for both width and height. If an object is passed, the screenshot size
  107486. * will be derived from the parameters. The precision property is a multiplier allowing
  107487. * rendering at a higher or lower resolution
  107488. * @param successCallback The callback receives a single parameter which contains the
  107489. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107490. * src parameter of an <img> to display it
  107491. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107492. * Check your browser for supported MIME types
  107493. * @param samples Texture samples (default: 1)
  107494. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107495. * @param fileName A name for for the downloaded file.
  107496. */
  107497. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107498. /**
  107499. * Generates an image screenshot from the specified camera.
  107500. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107501. * @param engine The engine to use for rendering
  107502. * @param camera The camera to use for rendering
  107503. * @param size This parameter can be set to a single number or to an object with the
  107504. * following (optional) properties: precision, width, height. If a single number is passed,
  107505. * it will be used for both width and height. If an object is passed, the screenshot size
  107506. * will be derived from the parameters. The precision property is a multiplier allowing
  107507. * rendering at a higher or lower resolution
  107508. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107509. * Check your browser for supported MIME types
  107510. * @param samples Texture samples (default: 1)
  107511. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107512. * @param fileName A name for for the downloaded file.
  107513. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107514. * to the src parameter of an <img> to display it
  107515. */
  107516. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107517. /**
  107518. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107519. * Be aware Math.random() could cause collisions, but:
  107520. * "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"
  107521. * @returns a pseudo random id
  107522. */
  107523. static RandomId(): string;
  107524. /**
  107525. * Test if the given uri is a base64 string
  107526. * @param uri The uri to test
  107527. * @return True if the uri is a base64 string or false otherwise
  107528. */
  107529. static IsBase64(uri: string): boolean;
  107530. /**
  107531. * Decode the given base64 uri.
  107532. * @param uri The uri to decode
  107533. * @return The decoded base64 data.
  107534. */
  107535. static DecodeBase64(uri: string): ArrayBuffer;
  107536. /**
  107537. * Gets the absolute url.
  107538. * @param url the input url
  107539. * @return the absolute url
  107540. */
  107541. static GetAbsoluteUrl(url: string): string;
  107542. /**
  107543. * No log
  107544. */
  107545. static readonly NoneLogLevel: number;
  107546. /**
  107547. * Only message logs
  107548. */
  107549. static readonly MessageLogLevel: number;
  107550. /**
  107551. * Only warning logs
  107552. */
  107553. static readonly WarningLogLevel: number;
  107554. /**
  107555. * Only error logs
  107556. */
  107557. static readonly ErrorLogLevel: number;
  107558. /**
  107559. * All logs
  107560. */
  107561. static readonly AllLogLevel: number;
  107562. /**
  107563. * Gets a value indicating the number of loading errors
  107564. * @ignorenaming
  107565. */
  107566. static get errorsCount(): number;
  107567. /**
  107568. * Callback called when a new log is added
  107569. */
  107570. static OnNewCacheEntry: (entry: string) => void;
  107571. /**
  107572. * Log a message to the console
  107573. * @param message defines the message to log
  107574. */
  107575. static Log(message: string): void;
  107576. /**
  107577. * Write a warning message to the console
  107578. * @param message defines the message to log
  107579. */
  107580. static Warn(message: string): void;
  107581. /**
  107582. * Write an error message to the console
  107583. * @param message defines the message to log
  107584. */
  107585. static Error(message: string): void;
  107586. /**
  107587. * Gets current log cache (list of logs)
  107588. */
  107589. static get LogCache(): string;
  107590. /**
  107591. * Clears the log cache
  107592. */
  107593. static ClearLogCache(): void;
  107594. /**
  107595. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107596. */
  107597. static set LogLevels(level: number);
  107598. /**
  107599. * Checks if the window object exists
  107600. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107601. */
  107602. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107603. /**
  107604. * No performance log
  107605. */
  107606. static readonly PerformanceNoneLogLevel: number;
  107607. /**
  107608. * Use user marks to log performance
  107609. */
  107610. static readonly PerformanceUserMarkLogLevel: number;
  107611. /**
  107612. * Log performance to the console
  107613. */
  107614. static readonly PerformanceConsoleLogLevel: number;
  107615. private static _performance;
  107616. /**
  107617. * Sets the current performance log level
  107618. */
  107619. static set PerformanceLogLevel(level: number);
  107620. private static _StartPerformanceCounterDisabled;
  107621. private static _EndPerformanceCounterDisabled;
  107622. private static _StartUserMark;
  107623. private static _EndUserMark;
  107624. private static _StartPerformanceConsole;
  107625. private static _EndPerformanceConsole;
  107626. /**
  107627. * Starts a performance counter
  107628. */
  107629. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107630. /**
  107631. * Ends a specific performance coutner
  107632. */
  107633. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107634. /**
  107635. * Gets either window.performance.now() if supported or Date.now() else
  107636. */
  107637. static get Now(): number;
  107638. /**
  107639. * This method will return the name of the class used to create the instance of the given object.
  107640. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107641. * @param object the object to get the class name from
  107642. * @param isType defines if the object is actually a type
  107643. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107644. */
  107645. static GetClassName(object: any, isType?: boolean): string;
  107646. /**
  107647. * Gets the first element of an array satisfying a given predicate
  107648. * @param array defines the array to browse
  107649. * @param predicate defines the predicate to use
  107650. * @returns null if not found or the element
  107651. */
  107652. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107653. /**
  107654. * This method will return the name of the full name of the class, including its owning module (if any).
  107655. * 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).
  107656. * @param object the object to get the class name from
  107657. * @param isType defines if the object is actually a type
  107658. * @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.
  107659. * @ignorenaming
  107660. */
  107661. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107662. /**
  107663. * Returns a promise that resolves after the given amount of time.
  107664. * @param delay Number of milliseconds to delay
  107665. * @returns Promise that resolves after the given amount of time
  107666. */
  107667. static DelayAsync(delay: number): Promise<void>;
  107668. /**
  107669. * Utility function to detect if the current user agent is Safari
  107670. * @returns whether or not the current user agent is safari
  107671. */
  107672. static IsSafari(): boolean;
  107673. }
  107674. /**
  107675. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107676. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107677. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107678. * @param name The name of the class, case should be preserved
  107679. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107680. */
  107681. export function className(name: string, module?: string): (target: Object) => void;
  107682. /**
  107683. * An implementation of a loop for asynchronous functions.
  107684. */
  107685. export class AsyncLoop {
  107686. /**
  107687. * Defines the number of iterations for the loop
  107688. */
  107689. iterations: number;
  107690. /**
  107691. * Defines the current index of the loop.
  107692. */
  107693. index: number;
  107694. private _done;
  107695. private _fn;
  107696. private _successCallback;
  107697. /**
  107698. * Constructor.
  107699. * @param iterations the number of iterations.
  107700. * @param func the function to run each iteration
  107701. * @param successCallback the callback that will be called upon succesful execution
  107702. * @param offset starting offset.
  107703. */
  107704. constructor(
  107705. /**
  107706. * Defines the number of iterations for the loop
  107707. */
  107708. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107709. /**
  107710. * Execute the next iteration. Must be called after the last iteration was finished.
  107711. */
  107712. executeNext(): void;
  107713. /**
  107714. * Break the loop and run the success callback.
  107715. */
  107716. breakLoop(): void;
  107717. /**
  107718. * Create and run an async loop.
  107719. * @param iterations the number of iterations.
  107720. * @param fn the function to run each iteration
  107721. * @param successCallback the callback that will be called upon succesful execution
  107722. * @param offset starting offset.
  107723. * @returns the created async loop object
  107724. */
  107725. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107726. /**
  107727. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107728. * @param iterations total number of iterations
  107729. * @param syncedIterations number of synchronous iterations in each async iteration.
  107730. * @param fn the function to call each iteration.
  107731. * @param callback a success call back that will be called when iterating stops.
  107732. * @param breakFunction a break condition (optional)
  107733. * @param timeout timeout settings for the setTimeout function. default - 0.
  107734. * @returns the created async loop object
  107735. */
  107736. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107737. }
  107738. }
  107739. declare module BABYLON {
  107740. /**
  107741. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107742. * The underlying implementation relies on an associative array to ensure the best performances.
  107743. * The value can be anything including 'null' but except 'undefined'
  107744. */
  107745. export class StringDictionary<T> {
  107746. /**
  107747. * This will clear this dictionary and copy the content from the 'source' one.
  107748. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107749. * @param source the dictionary to take the content from and copy to this dictionary
  107750. */
  107751. copyFrom(source: StringDictionary<T>): void;
  107752. /**
  107753. * Get a value based from its key
  107754. * @param key the given key to get the matching value from
  107755. * @return the value if found, otherwise undefined is returned
  107756. */
  107757. get(key: string): T | undefined;
  107758. /**
  107759. * Get a value from its key or add it if it doesn't exist.
  107760. * This method will ensure you that a given key/data will be present in the dictionary.
  107761. * @param key the given key to get the matching value from
  107762. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107763. * The factory will only be invoked if there's no data for the given key.
  107764. * @return the value corresponding to the key.
  107765. */
  107766. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107767. /**
  107768. * Get a value from its key if present in the dictionary otherwise add it
  107769. * @param key the key to get the value from
  107770. * @param val if there's no such key/value pair in the dictionary add it with this value
  107771. * @return the value corresponding to the key
  107772. */
  107773. getOrAdd(key: string, val: T): T;
  107774. /**
  107775. * Check if there's a given key in the dictionary
  107776. * @param key the key to check for
  107777. * @return true if the key is present, false otherwise
  107778. */
  107779. contains(key: string): boolean;
  107780. /**
  107781. * Add a new key and its corresponding value
  107782. * @param key the key to add
  107783. * @param value the value corresponding to the key
  107784. * @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
  107785. */
  107786. add(key: string, value: T): boolean;
  107787. /**
  107788. * Update a specific value associated to a key
  107789. * @param key defines the key to use
  107790. * @param value defines the value to store
  107791. * @returns true if the value was updated (or false if the key was not found)
  107792. */
  107793. set(key: string, value: T): boolean;
  107794. /**
  107795. * Get the element of the given key and remove it from the dictionary
  107796. * @param key defines the key to search
  107797. * @returns the value associated with the key or null if not found
  107798. */
  107799. getAndRemove(key: string): Nullable<T>;
  107800. /**
  107801. * Remove a key/value from the dictionary.
  107802. * @param key the key to remove
  107803. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107804. */
  107805. remove(key: string): boolean;
  107806. /**
  107807. * Clear the whole content of the dictionary
  107808. */
  107809. clear(): void;
  107810. /**
  107811. * Gets the current count
  107812. */
  107813. get count(): number;
  107814. /**
  107815. * Execute a callback on each key/val of the dictionary.
  107816. * Note that you can remove any element in this dictionary in the callback implementation
  107817. * @param callback the callback to execute on a given key/value pair
  107818. */
  107819. forEach(callback: (key: string, val: T) => void): void;
  107820. /**
  107821. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107822. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107823. * Note that you can remove any element in this dictionary in the callback implementation
  107824. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107825. * @returns the first item
  107826. */
  107827. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107828. private _count;
  107829. private _data;
  107830. }
  107831. }
  107832. declare module BABYLON {
  107833. /** @hidden */
  107834. export interface ICollisionCoordinator {
  107835. createCollider(): Collider;
  107836. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107837. init(scene: Scene): void;
  107838. }
  107839. /** @hidden */
  107840. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107841. private _scene;
  107842. private _scaledPosition;
  107843. private _scaledVelocity;
  107844. private _finalPosition;
  107845. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107846. createCollider(): Collider;
  107847. init(scene: Scene): void;
  107848. private _collideWithWorld;
  107849. }
  107850. }
  107851. declare module BABYLON {
  107852. /**
  107853. * Class used to manage all inputs for the scene.
  107854. */
  107855. export class InputManager {
  107856. /** The distance in pixel that you have to move to prevent some events */
  107857. static DragMovementThreshold: number;
  107858. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107859. static LongPressDelay: number;
  107860. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107861. static DoubleClickDelay: number;
  107862. /** If you need to check double click without raising a single click at first click, enable this flag */
  107863. static ExclusiveDoubleClickMode: boolean;
  107864. private _wheelEventName;
  107865. private _onPointerMove;
  107866. private _onPointerDown;
  107867. private _onPointerUp;
  107868. private _initClickEvent;
  107869. private _initActionManager;
  107870. private _delayedSimpleClick;
  107871. private _delayedSimpleClickTimeout;
  107872. private _previousDelayedSimpleClickTimeout;
  107873. private _meshPickProceed;
  107874. private _previousButtonPressed;
  107875. private _currentPickResult;
  107876. private _previousPickResult;
  107877. private _totalPointersPressed;
  107878. private _doubleClickOccured;
  107879. private _pointerOverMesh;
  107880. private _pickedDownMesh;
  107881. private _pickedUpMesh;
  107882. private _pointerX;
  107883. private _pointerY;
  107884. private _unTranslatedPointerX;
  107885. private _unTranslatedPointerY;
  107886. private _startingPointerPosition;
  107887. private _previousStartingPointerPosition;
  107888. private _startingPointerTime;
  107889. private _previousStartingPointerTime;
  107890. private _pointerCaptures;
  107891. private _onKeyDown;
  107892. private _onKeyUp;
  107893. private _onCanvasFocusObserver;
  107894. private _onCanvasBlurObserver;
  107895. private _scene;
  107896. /**
  107897. * Creates a new InputManager
  107898. * @param scene defines the hosting scene
  107899. */
  107900. constructor(scene: Scene);
  107901. /**
  107902. * Gets the mesh that is currently under the pointer
  107903. */
  107904. get meshUnderPointer(): Nullable<AbstractMesh>;
  107905. /**
  107906. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107907. */
  107908. get unTranslatedPointer(): Vector2;
  107909. /**
  107910. * Gets or sets the current on-screen X position of the pointer
  107911. */
  107912. get pointerX(): number;
  107913. set pointerX(value: number);
  107914. /**
  107915. * Gets or sets the current on-screen Y position of the pointer
  107916. */
  107917. get pointerY(): number;
  107918. set pointerY(value: number);
  107919. private _updatePointerPosition;
  107920. private _processPointerMove;
  107921. private _setRayOnPointerInfo;
  107922. private _checkPrePointerObservable;
  107923. /**
  107924. * Use this method to simulate a pointer move on a mesh
  107925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107928. */
  107929. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107930. /**
  107931. * Use this method to simulate a pointer down on a mesh
  107932. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107933. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107934. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107935. */
  107936. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107937. private _processPointerDown;
  107938. /** @hidden */
  107939. _isPointerSwiping(): boolean;
  107940. /**
  107941. * Use this method to simulate a pointer up on a mesh
  107942. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107943. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107944. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107945. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107946. */
  107947. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107948. private _processPointerUp;
  107949. /**
  107950. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107951. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107952. * @returns true if the pointer was captured
  107953. */
  107954. isPointerCaptured(pointerId?: number): boolean;
  107955. /**
  107956. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107957. * @param attachUp defines if you want to attach events to pointerup
  107958. * @param attachDown defines if you want to attach events to pointerdown
  107959. * @param attachMove defines if you want to attach events to pointermove
  107960. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107961. */
  107962. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107963. /**
  107964. * Detaches all event handlers
  107965. */
  107966. detachControl(): void;
  107967. /**
  107968. * Force the value of meshUnderPointer
  107969. * @param mesh defines the mesh to use
  107970. */
  107971. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107972. /**
  107973. * Gets the mesh under the pointer
  107974. * @returns a Mesh or null if no mesh is under the pointer
  107975. */
  107976. getPointerOverMesh(): Nullable<AbstractMesh>;
  107977. }
  107978. }
  107979. declare module BABYLON {
  107980. /**
  107981. * Helper class used to generate session unique ID
  107982. */
  107983. export class UniqueIdGenerator {
  107984. private static _UniqueIdCounter;
  107985. /**
  107986. * Gets an unique (relatively to the current scene) Id
  107987. */
  107988. static get UniqueId(): number;
  107989. }
  107990. }
  107991. declare module BABYLON {
  107992. /**
  107993. * This class defines the direct association between an animation and a target
  107994. */
  107995. export class TargetedAnimation {
  107996. /**
  107997. * Animation to perform
  107998. */
  107999. animation: Animation;
  108000. /**
  108001. * Target to animate
  108002. */
  108003. target: any;
  108004. /**
  108005. * Serialize the object
  108006. * @returns the JSON object representing the current entity
  108007. */
  108008. serialize(): any;
  108009. }
  108010. /**
  108011. * Use this class to create coordinated animations on multiple targets
  108012. */
  108013. export class AnimationGroup implements IDisposable {
  108014. /** The name of the animation group */
  108015. name: string;
  108016. private _scene;
  108017. private _targetedAnimations;
  108018. private _animatables;
  108019. private _from;
  108020. private _to;
  108021. private _isStarted;
  108022. private _isPaused;
  108023. private _speedRatio;
  108024. private _loopAnimation;
  108025. /**
  108026. * Gets or sets the unique id of the node
  108027. */
  108028. uniqueId: number;
  108029. /**
  108030. * This observable will notify when one animation have ended
  108031. */
  108032. onAnimationEndObservable: Observable<TargetedAnimation>;
  108033. /**
  108034. * Observer raised when one animation loops
  108035. */
  108036. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108037. /**
  108038. * Observer raised when all animations have looped
  108039. */
  108040. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108041. /**
  108042. * This observable will notify when all animations have ended.
  108043. */
  108044. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108045. /**
  108046. * This observable will notify when all animations have paused.
  108047. */
  108048. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108049. /**
  108050. * This observable will notify when all animations are playing.
  108051. */
  108052. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108053. /**
  108054. * Gets the first frame
  108055. */
  108056. get from(): number;
  108057. /**
  108058. * Gets the last frame
  108059. */
  108060. get to(): number;
  108061. /**
  108062. * Define if the animations are started
  108063. */
  108064. get isStarted(): boolean;
  108065. /**
  108066. * Gets a value indicating that the current group is playing
  108067. */
  108068. get isPlaying(): boolean;
  108069. /**
  108070. * Gets or sets the speed ratio to use for all animations
  108071. */
  108072. get speedRatio(): number;
  108073. /**
  108074. * Gets or sets the speed ratio to use for all animations
  108075. */
  108076. set speedRatio(value: number);
  108077. /**
  108078. * Gets or sets if all animations should loop or not
  108079. */
  108080. get loopAnimation(): boolean;
  108081. set loopAnimation(value: boolean);
  108082. /**
  108083. * Gets the targeted animations for this animation group
  108084. */
  108085. get targetedAnimations(): Array<TargetedAnimation>;
  108086. /**
  108087. * returning the list of animatables controlled by this animation group.
  108088. */
  108089. get animatables(): Array<Animatable>;
  108090. /**
  108091. * Instantiates a new Animation Group.
  108092. * This helps managing several animations at once.
  108093. * @see http://doc.babylonjs.com/how_to/group
  108094. * @param name Defines the name of the group
  108095. * @param scene Defines the scene the group belongs to
  108096. */
  108097. constructor(
  108098. /** The name of the animation group */
  108099. name: string, scene?: Nullable<Scene>);
  108100. /**
  108101. * Add an animation (with its target) in the group
  108102. * @param animation defines the animation we want to add
  108103. * @param target defines the target of the animation
  108104. * @returns the TargetedAnimation object
  108105. */
  108106. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108107. /**
  108108. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108109. * It can add constant keys at begin or end
  108110. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108111. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108112. * @returns the animation group
  108113. */
  108114. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108115. private _animationLoopCount;
  108116. private _animationLoopFlags;
  108117. private _processLoop;
  108118. /**
  108119. * Start all animations on given targets
  108120. * @param loop defines if animations must loop
  108121. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108122. * @param from defines the from key (optional)
  108123. * @param to defines the to key (optional)
  108124. * @returns the current animation group
  108125. */
  108126. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108127. /**
  108128. * Pause all animations
  108129. * @returns the animation group
  108130. */
  108131. pause(): AnimationGroup;
  108132. /**
  108133. * Play all animations to initial state
  108134. * This function will start() the animations if they were not started or will restart() them if they were paused
  108135. * @param loop defines if animations must loop
  108136. * @returns the animation group
  108137. */
  108138. play(loop?: boolean): AnimationGroup;
  108139. /**
  108140. * Reset all animations to initial state
  108141. * @returns the animation group
  108142. */
  108143. reset(): AnimationGroup;
  108144. /**
  108145. * Restart animations from key 0
  108146. * @returns the animation group
  108147. */
  108148. restart(): AnimationGroup;
  108149. /**
  108150. * Stop all animations
  108151. * @returns the animation group
  108152. */
  108153. stop(): AnimationGroup;
  108154. /**
  108155. * Set animation weight for all animatables
  108156. * @param weight defines the weight to use
  108157. * @return the animationGroup
  108158. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108159. */
  108160. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108161. /**
  108162. * Synchronize and normalize all animatables with a source animatable
  108163. * @param root defines the root animatable to synchronize with
  108164. * @return the animationGroup
  108165. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108166. */
  108167. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108168. /**
  108169. * Goes to a specific frame in this animation group
  108170. * @param frame the frame number to go to
  108171. * @return the animationGroup
  108172. */
  108173. goToFrame(frame: number): AnimationGroup;
  108174. /**
  108175. * Dispose all associated resources
  108176. */
  108177. dispose(): void;
  108178. private _checkAnimationGroupEnded;
  108179. /**
  108180. * Clone the current animation group and returns a copy
  108181. * @param newName defines the name of the new group
  108182. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108183. * @returns the new aniamtion group
  108184. */
  108185. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108186. /**
  108187. * Serializes the animationGroup to an object
  108188. * @returns Serialized object
  108189. */
  108190. serialize(): any;
  108191. /**
  108192. * Returns a new AnimationGroup object parsed from the source provided.
  108193. * @param parsedAnimationGroup defines the source
  108194. * @param scene defines the scene that will receive the animationGroup
  108195. * @returns a new AnimationGroup
  108196. */
  108197. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108198. /**
  108199. * Returns the string "AnimationGroup"
  108200. * @returns "AnimationGroup"
  108201. */
  108202. getClassName(): string;
  108203. /**
  108204. * Creates a detailled string about the object
  108205. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108206. * @returns a string representing the object
  108207. */
  108208. toString(fullDetails?: boolean): string;
  108209. }
  108210. }
  108211. declare module BABYLON {
  108212. /**
  108213. * Define an interface for all classes that will hold resources
  108214. */
  108215. export interface IDisposable {
  108216. /**
  108217. * Releases all held resources
  108218. */
  108219. dispose(): void;
  108220. }
  108221. /** Interface defining initialization parameters for Scene class */
  108222. export interface SceneOptions {
  108223. /**
  108224. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108225. * It will improve performance when the number of geometries becomes important.
  108226. */
  108227. useGeometryUniqueIdsMap?: boolean;
  108228. /**
  108229. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108230. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108231. */
  108232. useMaterialMeshMap?: boolean;
  108233. /**
  108234. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108235. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108236. */
  108237. useClonedMeshMap?: boolean;
  108238. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108239. virtual?: boolean;
  108240. }
  108241. /**
  108242. * Represents a scene to be rendered by the engine.
  108243. * @see http://doc.babylonjs.com/features/scene
  108244. */
  108245. export class Scene extends AbstractScene implements IAnimatable {
  108246. /** The fog is deactivated */
  108247. static readonly FOGMODE_NONE: number;
  108248. /** The fog density is following an exponential function */
  108249. static readonly FOGMODE_EXP: number;
  108250. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108251. static readonly FOGMODE_EXP2: number;
  108252. /** The fog density is following a linear function. */
  108253. static readonly FOGMODE_LINEAR: number;
  108254. /**
  108255. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108257. */
  108258. static MinDeltaTime: number;
  108259. /**
  108260. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108261. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108262. */
  108263. static MaxDeltaTime: number;
  108264. /**
  108265. * Factory used to create the default material.
  108266. * @param name The name of the material to create
  108267. * @param scene The scene to create the material for
  108268. * @returns The default material
  108269. */
  108270. static DefaultMaterialFactory(scene: Scene): Material;
  108271. /**
  108272. * Factory used to create the a collision coordinator.
  108273. * @returns The collision coordinator
  108274. */
  108275. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108276. /** @hidden */
  108277. _inputManager: InputManager;
  108278. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108279. cameraToUseForPointers: Nullable<Camera>;
  108280. /** @hidden */
  108281. readonly _isScene: boolean;
  108282. /** @hidden */
  108283. _blockEntityCollection: boolean;
  108284. /**
  108285. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108286. */
  108287. autoClear: boolean;
  108288. /**
  108289. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108290. */
  108291. autoClearDepthAndStencil: boolean;
  108292. /**
  108293. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108294. */
  108295. clearColor: Color4;
  108296. /**
  108297. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108298. */
  108299. ambientColor: Color3;
  108300. /**
  108301. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108302. * It should only be one of the following (if not the default embedded one):
  108303. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108304. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108305. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108306. * The material properties need to be setup according to the type of texture in use.
  108307. */
  108308. environmentBRDFTexture: BaseTexture;
  108309. /** @hidden */
  108310. protected _environmentTexture: Nullable<BaseTexture>;
  108311. /**
  108312. * Texture used in all pbr material as the reflection texture.
  108313. * As in the majority of the scene they are the same (exception for multi room and so on),
  108314. * this is easier to reference from here than from all the materials.
  108315. */
  108316. get environmentTexture(): Nullable<BaseTexture>;
  108317. /**
  108318. * Texture used in all pbr material as the reflection texture.
  108319. * As in the majority of the scene they are the same (exception for multi room and so on),
  108320. * this is easier to set here than in all the materials.
  108321. */
  108322. set environmentTexture(value: Nullable<BaseTexture>);
  108323. /** @hidden */
  108324. protected _environmentIntensity: number;
  108325. /**
  108326. * Intensity of the environment in all pbr material.
  108327. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108328. * As in the majority of the scene they are the same (exception for multi room and so on),
  108329. * this is easier to reference from here than from all the materials.
  108330. */
  108331. get environmentIntensity(): number;
  108332. /**
  108333. * Intensity of the environment in all pbr material.
  108334. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108335. * As in the majority of the scene they are the same (exception for multi room and so on),
  108336. * this is easier to set here than in all the materials.
  108337. */
  108338. set environmentIntensity(value: number);
  108339. /** @hidden */
  108340. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108341. /**
  108342. * Default image processing configuration used either in the rendering
  108343. * Forward main pass or through the imageProcessingPostProcess if present.
  108344. * As in the majority of the scene they are the same (exception for multi camera),
  108345. * this is easier to reference from here than from all the materials and post process.
  108346. *
  108347. * No setter as we it is a shared configuration, you can set the values instead.
  108348. */
  108349. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108350. private _forceWireframe;
  108351. /**
  108352. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108353. */
  108354. set forceWireframe(value: boolean);
  108355. get forceWireframe(): boolean;
  108356. private _skipFrustumClipping;
  108357. /**
  108358. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108359. */
  108360. set skipFrustumClipping(value: boolean);
  108361. get skipFrustumClipping(): boolean;
  108362. private _forcePointsCloud;
  108363. /**
  108364. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108365. */
  108366. set forcePointsCloud(value: boolean);
  108367. get forcePointsCloud(): boolean;
  108368. /**
  108369. * Gets or sets the active clipplane 1
  108370. */
  108371. clipPlane: Nullable<Plane>;
  108372. /**
  108373. * Gets or sets the active clipplane 2
  108374. */
  108375. clipPlane2: Nullable<Plane>;
  108376. /**
  108377. * Gets or sets the active clipplane 3
  108378. */
  108379. clipPlane3: Nullable<Plane>;
  108380. /**
  108381. * Gets or sets the active clipplane 4
  108382. */
  108383. clipPlane4: Nullable<Plane>;
  108384. /**
  108385. * Gets or sets the active clipplane 5
  108386. */
  108387. clipPlane5: Nullable<Plane>;
  108388. /**
  108389. * Gets or sets the active clipplane 6
  108390. */
  108391. clipPlane6: Nullable<Plane>;
  108392. /**
  108393. * Gets or sets a boolean indicating if animations are enabled
  108394. */
  108395. animationsEnabled: boolean;
  108396. private _animationPropertiesOverride;
  108397. /**
  108398. * Gets or sets the animation properties override
  108399. */
  108400. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108401. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108402. /**
  108403. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108404. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108405. */
  108406. useConstantAnimationDeltaTime: boolean;
  108407. /**
  108408. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108409. * Please note that it requires to run a ray cast through the scene on every frame
  108410. */
  108411. constantlyUpdateMeshUnderPointer: boolean;
  108412. /**
  108413. * Defines the HTML cursor to use when hovering over interactive elements
  108414. */
  108415. hoverCursor: string;
  108416. /**
  108417. * Defines the HTML default cursor to use (empty by default)
  108418. */
  108419. defaultCursor: string;
  108420. /**
  108421. * Defines whether cursors are handled by the scene.
  108422. */
  108423. doNotHandleCursors: boolean;
  108424. /**
  108425. * This is used to call preventDefault() on pointer down
  108426. * in order to block unwanted artifacts like system double clicks
  108427. */
  108428. preventDefaultOnPointerDown: boolean;
  108429. /**
  108430. * This is used to call preventDefault() on pointer up
  108431. * in order to block unwanted artifacts like system double clicks
  108432. */
  108433. preventDefaultOnPointerUp: boolean;
  108434. /**
  108435. * Gets or sets user defined metadata
  108436. */
  108437. metadata: any;
  108438. /**
  108439. * For internal use only. Please do not use.
  108440. */
  108441. reservedDataStore: any;
  108442. /**
  108443. * Gets the name of the plugin used to load this scene (null by default)
  108444. */
  108445. loadingPluginName: string;
  108446. /**
  108447. * Use this array to add regular expressions used to disable offline support for specific urls
  108448. */
  108449. disableOfflineSupportExceptionRules: RegExp[];
  108450. /**
  108451. * An event triggered when the scene is disposed.
  108452. */
  108453. onDisposeObservable: Observable<Scene>;
  108454. private _onDisposeObserver;
  108455. /** Sets a function to be executed when this scene is disposed. */
  108456. set onDispose(callback: () => void);
  108457. /**
  108458. * An event triggered before rendering the scene (right after animations and physics)
  108459. */
  108460. onBeforeRenderObservable: Observable<Scene>;
  108461. private _onBeforeRenderObserver;
  108462. /** Sets a function to be executed before rendering this scene */
  108463. set beforeRender(callback: Nullable<() => void>);
  108464. /**
  108465. * An event triggered after rendering the scene
  108466. */
  108467. onAfterRenderObservable: Observable<Scene>;
  108468. /**
  108469. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108470. */
  108471. onAfterRenderCameraObservable: Observable<Camera>;
  108472. private _onAfterRenderObserver;
  108473. /** Sets a function to be executed after rendering this scene */
  108474. set afterRender(callback: Nullable<() => void>);
  108475. /**
  108476. * An event triggered before animating the scene
  108477. */
  108478. onBeforeAnimationsObservable: Observable<Scene>;
  108479. /**
  108480. * An event triggered after animations processing
  108481. */
  108482. onAfterAnimationsObservable: Observable<Scene>;
  108483. /**
  108484. * An event triggered before draw calls are ready to be sent
  108485. */
  108486. onBeforeDrawPhaseObservable: Observable<Scene>;
  108487. /**
  108488. * An event triggered after draw calls have been sent
  108489. */
  108490. onAfterDrawPhaseObservable: Observable<Scene>;
  108491. /**
  108492. * An event triggered when the scene is ready
  108493. */
  108494. onReadyObservable: Observable<Scene>;
  108495. /**
  108496. * An event triggered before rendering a camera
  108497. */
  108498. onBeforeCameraRenderObservable: Observable<Camera>;
  108499. private _onBeforeCameraRenderObserver;
  108500. /** Sets a function to be executed before rendering a camera*/
  108501. set beforeCameraRender(callback: () => void);
  108502. /**
  108503. * An event triggered after rendering a camera
  108504. */
  108505. onAfterCameraRenderObservable: Observable<Camera>;
  108506. private _onAfterCameraRenderObserver;
  108507. /** Sets a function to be executed after rendering a camera*/
  108508. set afterCameraRender(callback: () => void);
  108509. /**
  108510. * An event triggered when active meshes evaluation is about to start
  108511. */
  108512. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108513. /**
  108514. * An event triggered when active meshes evaluation is done
  108515. */
  108516. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108517. /**
  108518. * An event triggered when particles rendering is about to start
  108519. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108520. */
  108521. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108522. /**
  108523. * An event triggered when particles rendering is done
  108524. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108525. */
  108526. onAfterParticlesRenderingObservable: Observable<Scene>;
  108527. /**
  108528. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108529. */
  108530. onDataLoadedObservable: Observable<Scene>;
  108531. /**
  108532. * An event triggered when a camera is created
  108533. */
  108534. onNewCameraAddedObservable: Observable<Camera>;
  108535. /**
  108536. * An event triggered when a camera is removed
  108537. */
  108538. onCameraRemovedObservable: Observable<Camera>;
  108539. /**
  108540. * An event triggered when a light is created
  108541. */
  108542. onNewLightAddedObservable: Observable<Light>;
  108543. /**
  108544. * An event triggered when a light is removed
  108545. */
  108546. onLightRemovedObservable: Observable<Light>;
  108547. /**
  108548. * An event triggered when a geometry is created
  108549. */
  108550. onNewGeometryAddedObservable: Observable<Geometry>;
  108551. /**
  108552. * An event triggered when a geometry is removed
  108553. */
  108554. onGeometryRemovedObservable: Observable<Geometry>;
  108555. /**
  108556. * An event triggered when a transform node is created
  108557. */
  108558. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108559. /**
  108560. * An event triggered when a transform node is removed
  108561. */
  108562. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108563. /**
  108564. * An event triggered when a mesh is created
  108565. */
  108566. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108567. /**
  108568. * An event triggered when a mesh is removed
  108569. */
  108570. onMeshRemovedObservable: Observable<AbstractMesh>;
  108571. /**
  108572. * An event triggered when a skeleton is created
  108573. */
  108574. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108575. /**
  108576. * An event triggered when a skeleton is removed
  108577. */
  108578. onSkeletonRemovedObservable: Observable<Skeleton>;
  108579. /**
  108580. * An event triggered when a material is created
  108581. */
  108582. onNewMaterialAddedObservable: Observable<Material>;
  108583. /**
  108584. * An event triggered when a material is removed
  108585. */
  108586. onMaterialRemovedObservable: Observable<Material>;
  108587. /**
  108588. * An event triggered when a texture is created
  108589. */
  108590. onNewTextureAddedObservable: Observable<BaseTexture>;
  108591. /**
  108592. * An event triggered when a texture is removed
  108593. */
  108594. onTextureRemovedObservable: Observable<BaseTexture>;
  108595. /**
  108596. * An event triggered when render targets are about to be rendered
  108597. * Can happen multiple times per frame.
  108598. */
  108599. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108600. /**
  108601. * An event triggered when render targets were rendered.
  108602. * Can happen multiple times per frame.
  108603. */
  108604. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108605. /**
  108606. * An event triggered before calculating deterministic simulation step
  108607. */
  108608. onBeforeStepObservable: Observable<Scene>;
  108609. /**
  108610. * An event triggered after calculating deterministic simulation step
  108611. */
  108612. onAfterStepObservable: Observable<Scene>;
  108613. /**
  108614. * An event triggered when the activeCamera property is updated
  108615. */
  108616. onActiveCameraChanged: Observable<Scene>;
  108617. /**
  108618. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108619. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108620. * 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)
  108621. */
  108622. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108623. /**
  108624. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108625. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108626. * 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)
  108627. */
  108628. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108629. /**
  108630. * This Observable will when a mesh has been imported into the scene.
  108631. */
  108632. onMeshImportedObservable: Observable<AbstractMesh>;
  108633. /**
  108634. * This Observable will when an animation file has been imported into the scene.
  108635. */
  108636. onAnimationFileImportedObservable: Observable<Scene>;
  108637. /**
  108638. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108639. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108640. */
  108641. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108642. /** @hidden */
  108643. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108644. /**
  108645. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108646. */
  108647. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108648. /**
  108649. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108650. */
  108651. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108652. /**
  108653. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108654. */
  108655. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108656. /** Callback called when a pointer move is detected */
  108657. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108658. /** Callback called when a pointer down is detected */
  108659. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108660. /** Callback called when a pointer up is detected */
  108661. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108662. /** Callback called when a pointer pick is detected */
  108663. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108664. /**
  108665. * 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).
  108666. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108667. */
  108668. onPrePointerObservable: Observable<PointerInfoPre>;
  108669. /**
  108670. * Observable event triggered each time an input event is received from the rendering canvas
  108671. */
  108672. onPointerObservable: Observable<PointerInfo>;
  108673. /**
  108674. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108675. */
  108676. get unTranslatedPointer(): Vector2;
  108677. /**
  108678. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108679. */
  108680. static get DragMovementThreshold(): number;
  108681. static set DragMovementThreshold(value: number);
  108682. /**
  108683. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108684. */
  108685. static get LongPressDelay(): number;
  108686. static set LongPressDelay(value: number);
  108687. /**
  108688. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108689. */
  108690. static get DoubleClickDelay(): number;
  108691. static set DoubleClickDelay(value: number);
  108692. /** If you need to check double click without raising a single click at first click, enable this flag */
  108693. static get ExclusiveDoubleClickMode(): boolean;
  108694. static set ExclusiveDoubleClickMode(value: boolean);
  108695. /** @hidden */
  108696. _mirroredCameraPosition: Nullable<Vector3>;
  108697. /**
  108698. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108699. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108700. */
  108701. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108702. /**
  108703. * Observable event triggered each time an keyboard event is received from the hosting window
  108704. */
  108705. onKeyboardObservable: Observable<KeyboardInfo>;
  108706. private _useRightHandedSystem;
  108707. /**
  108708. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108709. */
  108710. set useRightHandedSystem(value: boolean);
  108711. get useRightHandedSystem(): boolean;
  108712. private _timeAccumulator;
  108713. private _currentStepId;
  108714. private _currentInternalStep;
  108715. /**
  108716. * Sets the step Id used by deterministic lock step
  108717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108718. * @param newStepId defines the step Id
  108719. */
  108720. setStepId(newStepId: number): void;
  108721. /**
  108722. * Gets the step Id used by deterministic lock step
  108723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108724. * @returns the step Id
  108725. */
  108726. getStepId(): number;
  108727. /**
  108728. * Gets the internal step used by deterministic lock step
  108729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108730. * @returns the internal step
  108731. */
  108732. getInternalStep(): number;
  108733. private _fogEnabled;
  108734. /**
  108735. * Gets or sets a boolean indicating if fog is enabled on this scene
  108736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108737. * (Default is true)
  108738. */
  108739. set fogEnabled(value: boolean);
  108740. get fogEnabled(): boolean;
  108741. private _fogMode;
  108742. /**
  108743. * Gets or sets the fog mode to use
  108744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108745. * | mode | value |
  108746. * | --- | --- |
  108747. * | FOGMODE_NONE | 0 |
  108748. * | FOGMODE_EXP | 1 |
  108749. * | FOGMODE_EXP2 | 2 |
  108750. * | FOGMODE_LINEAR | 3 |
  108751. */
  108752. set fogMode(value: number);
  108753. get fogMode(): number;
  108754. /**
  108755. * Gets or sets the fog color to use
  108756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108757. * (Default is Color3(0.2, 0.2, 0.3))
  108758. */
  108759. fogColor: Color3;
  108760. /**
  108761. * Gets or sets the fog density to use
  108762. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108763. * (Default is 0.1)
  108764. */
  108765. fogDensity: number;
  108766. /**
  108767. * Gets or sets the fog start distance to use
  108768. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108769. * (Default is 0)
  108770. */
  108771. fogStart: number;
  108772. /**
  108773. * Gets or sets the fog end distance to use
  108774. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108775. * (Default is 1000)
  108776. */
  108777. fogEnd: number;
  108778. private _shadowsEnabled;
  108779. /**
  108780. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108781. */
  108782. set shadowsEnabled(value: boolean);
  108783. get shadowsEnabled(): boolean;
  108784. private _lightsEnabled;
  108785. /**
  108786. * Gets or sets a boolean indicating if lights are enabled on this scene
  108787. */
  108788. set lightsEnabled(value: boolean);
  108789. get lightsEnabled(): boolean;
  108790. /** All of the active cameras added to this scene. */
  108791. activeCameras: Camera[];
  108792. /** @hidden */
  108793. _activeCamera: Nullable<Camera>;
  108794. /** Gets or sets the current active camera */
  108795. get activeCamera(): Nullable<Camera>;
  108796. set activeCamera(value: Nullable<Camera>);
  108797. private _defaultMaterial;
  108798. /** The default material used on meshes when no material is affected */
  108799. get defaultMaterial(): Material;
  108800. /** The default material used on meshes when no material is affected */
  108801. set defaultMaterial(value: Material);
  108802. private _texturesEnabled;
  108803. /**
  108804. * Gets or sets a boolean indicating if textures are enabled on this scene
  108805. */
  108806. set texturesEnabled(value: boolean);
  108807. get texturesEnabled(): boolean;
  108808. /**
  108809. * Gets or sets a boolean indicating if particles are enabled on this scene
  108810. */
  108811. particlesEnabled: boolean;
  108812. /**
  108813. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108814. */
  108815. spritesEnabled: boolean;
  108816. private _skeletonsEnabled;
  108817. /**
  108818. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108819. */
  108820. set skeletonsEnabled(value: boolean);
  108821. get skeletonsEnabled(): boolean;
  108822. /**
  108823. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108824. */
  108825. lensFlaresEnabled: boolean;
  108826. /**
  108827. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108829. */
  108830. collisionsEnabled: boolean;
  108831. private _collisionCoordinator;
  108832. /** @hidden */
  108833. get collisionCoordinator(): ICollisionCoordinator;
  108834. /**
  108835. * Defines the gravity applied to this scene (used only for collisions)
  108836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108837. */
  108838. gravity: Vector3;
  108839. /**
  108840. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108841. */
  108842. postProcessesEnabled: boolean;
  108843. /**
  108844. * The list of postprocesses added to the scene
  108845. */
  108846. postProcesses: PostProcess[];
  108847. /**
  108848. * Gets the current postprocess manager
  108849. */
  108850. postProcessManager: PostProcessManager;
  108851. /**
  108852. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108853. */
  108854. renderTargetsEnabled: boolean;
  108855. /**
  108856. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108857. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108858. */
  108859. dumpNextRenderTargets: boolean;
  108860. /**
  108861. * The list of user defined render targets added to the scene
  108862. */
  108863. customRenderTargets: RenderTargetTexture[];
  108864. /**
  108865. * Defines if texture loading must be delayed
  108866. * If true, textures will only be loaded when they need to be rendered
  108867. */
  108868. useDelayedTextureLoading: boolean;
  108869. /**
  108870. * Gets the list of meshes imported to the scene through SceneLoader
  108871. */
  108872. importedMeshesFiles: String[];
  108873. /**
  108874. * Gets or sets a boolean indicating if probes are enabled on this scene
  108875. */
  108876. probesEnabled: boolean;
  108877. /**
  108878. * Gets or sets the current offline provider to use to store scene data
  108879. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108880. */
  108881. offlineProvider: IOfflineProvider;
  108882. /**
  108883. * Gets or sets the action manager associated with the scene
  108884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108885. */
  108886. actionManager: AbstractActionManager;
  108887. private _meshesForIntersections;
  108888. /**
  108889. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108890. */
  108891. proceduralTexturesEnabled: boolean;
  108892. private _engine;
  108893. private _totalVertices;
  108894. /** @hidden */
  108895. _activeIndices: PerfCounter;
  108896. /** @hidden */
  108897. _activeParticles: PerfCounter;
  108898. /** @hidden */
  108899. _activeBones: PerfCounter;
  108900. private _animationRatio;
  108901. /** @hidden */
  108902. _animationTimeLast: number;
  108903. /** @hidden */
  108904. _animationTime: number;
  108905. /**
  108906. * Gets or sets a general scale for animation speed
  108907. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108908. */
  108909. animationTimeScale: number;
  108910. /** @hidden */
  108911. _cachedMaterial: Nullable<Material>;
  108912. /** @hidden */
  108913. _cachedEffect: Nullable<Effect>;
  108914. /** @hidden */
  108915. _cachedVisibility: Nullable<number>;
  108916. private _renderId;
  108917. private _frameId;
  108918. private _executeWhenReadyTimeoutId;
  108919. private _intermediateRendering;
  108920. private _viewUpdateFlag;
  108921. private _projectionUpdateFlag;
  108922. /** @hidden */
  108923. _toBeDisposed: Nullable<IDisposable>[];
  108924. private _activeRequests;
  108925. /** @hidden */
  108926. _pendingData: any[];
  108927. private _isDisposed;
  108928. /**
  108929. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108930. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108931. */
  108932. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108933. private _activeMeshes;
  108934. private _processedMaterials;
  108935. private _renderTargets;
  108936. /** @hidden */
  108937. _activeParticleSystems: SmartArray<IParticleSystem>;
  108938. private _activeSkeletons;
  108939. private _softwareSkinnedMeshes;
  108940. private _renderingManager;
  108941. /** @hidden */
  108942. _activeAnimatables: Animatable[];
  108943. private _transformMatrix;
  108944. private _sceneUbo;
  108945. /** @hidden */
  108946. _viewMatrix: Matrix;
  108947. private _projectionMatrix;
  108948. /** @hidden */
  108949. _forcedViewPosition: Nullable<Vector3>;
  108950. /** @hidden */
  108951. _frustumPlanes: Plane[];
  108952. /**
  108953. * Gets the list of frustum planes (built from the active camera)
  108954. */
  108955. get frustumPlanes(): Plane[];
  108956. /**
  108957. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108958. * This is useful if there are more lights that the maximum simulteanous authorized
  108959. */
  108960. requireLightSorting: boolean;
  108961. /** @hidden */
  108962. readonly useMaterialMeshMap: boolean;
  108963. /** @hidden */
  108964. readonly useClonedMeshMap: boolean;
  108965. private _externalData;
  108966. private _uid;
  108967. /**
  108968. * @hidden
  108969. * Backing store of defined scene components.
  108970. */
  108971. _components: ISceneComponent[];
  108972. /**
  108973. * @hidden
  108974. * Backing store of defined scene components.
  108975. */
  108976. _serializableComponents: ISceneSerializableComponent[];
  108977. /**
  108978. * List of components to register on the next registration step.
  108979. */
  108980. private _transientComponents;
  108981. /**
  108982. * Registers the transient components if needed.
  108983. */
  108984. private _registerTransientComponents;
  108985. /**
  108986. * @hidden
  108987. * Add a component to the scene.
  108988. * Note that the ccomponent could be registered on th next frame if this is called after
  108989. * the register component stage.
  108990. * @param component Defines the component to add to the scene
  108991. */
  108992. _addComponent(component: ISceneComponent): void;
  108993. /**
  108994. * @hidden
  108995. * Gets a component from the scene.
  108996. * @param name defines the name of the component to retrieve
  108997. * @returns the component or null if not present
  108998. */
  108999. _getComponent(name: string): Nullable<ISceneComponent>;
  109000. /**
  109001. * @hidden
  109002. * Defines the actions happening before camera updates.
  109003. */
  109004. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109005. /**
  109006. * @hidden
  109007. * Defines the actions happening before clear the canvas.
  109008. */
  109009. _beforeClearStage: Stage<SimpleStageAction>;
  109010. /**
  109011. * @hidden
  109012. * Defines the actions when collecting render targets for the frame.
  109013. */
  109014. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109015. /**
  109016. * @hidden
  109017. * Defines the actions happening for one camera in the frame.
  109018. */
  109019. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109020. /**
  109021. * @hidden
  109022. * Defines the actions happening during the per mesh ready checks.
  109023. */
  109024. _isReadyForMeshStage: Stage<MeshStageAction>;
  109025. /**
  109026. * @hidden
  109027. * Defines the actions happening before evaluate active mesh checks.
  109028. */
  109029. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109030. /**
  109031. * @hidden
  109032. * Defines the actions happening during the evaluate sub mesh checks.
  109033. */
  109034. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109035. /**
  109036. * @hidden
  109037. * Defines the actions happening during the active mesh stage.
  109038. */
  109039. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109040. /**
  109041. * @hidden
  109042. * Defines the actions happening during the per camera render target step.
  109043. */
  109044. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109045. /**
  109046. * @hidden
  109047. * Defines the actions happening just before the active camera is drawing.
  109048. */
  109049. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109050. /**
  109051. * @hidden
  109052. * Defines the actions happening just before a render target is drawing.
  109053. */
  109054. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109055. /**
  109056. * @hidden
  109057. * Defines the actions happening just before a rendering group is drawing.
  109058. */
  109059. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109060. /**
  109061. * @hidden
  109062. * Defines the actions happening just before a mesh is drawing.
  109063. */
  109064. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109065. /**
  109066. * @hidden
  109067. * Defines the actions happening just after a mesh has been drawn.
  109068. */
  109069. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109070. /**
  109071. * @hidden
  109072. * Defines the actions happening just after a rendering group has been drawn.
  109073. */
  109074. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109075. /**
  109076. * @hidden
  109077. * Defines the actions happening just after the active camera has been drawn.
  109078. */
  109079. _afterCameraDrawStage: Stage<CameraStageAction>;
  109080. /**
  109081. * @hidden
  109082. * Defines the actions happening just after a render target has been drawn.
  109083. */
  109084. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109085. /**
  109086. * @hidden
  109087. * Defines the actions happening just after rendering all cameras and computing intersections.
  109088. */
  109089. _afterRenderStage: Stage<SimpleStageAction>;
  109090. /**
  109091. * @hidden
  109092. * Defines the actions happening when a pointer move event happens.
  109093. */
  109094. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109095. /**
  109096. * @hidden
  109097. * Defines the actions happening when a pointer down event happens.
  109098. */
  109099. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109100. /**
  109101. * @hidden
  109102. * Defines the actions happening when a pointer up event happens.
  109103. */
  109104. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109105. /**
  109106. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109107. */
  109108. private geometriesByUniqueId;
  109109. /**
  109110. * Creates a new Scene
  109111. * @param engine defines the engine to use to render this scene
  109112. * @param options defines the scene options
  109113. */
  109114. constructor(engine: Engine, options?: SceneOptions);
  109115. /**
  109116. * Gets a string idenfifying the name of the class
  109117. * @returns "Scene" string
  109118. */
  109119. getClassName(): string;
  109120. private _defaultMeshCandidates;
  109121. /**
  109122. * @hidden
  109123. */
  109124. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109125. private _defaultSubMeshCandidates;
  109126. /**
  109127. * @hidden
  109128. */
  109129. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109130. /**
  109131. * Sets the default candidate providers for the scene.
  109132. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109133. * and getCollidingSubMeshCandidates to their default function
  109134. */
  109135. setDefaultCandidateProviders(): void;
  109136. /**
  109137. * Gets the mesh that is currently under the pointer
  109138. */
  109139. get meshUnderPointer(): Nullable<AbstractMesh>;
  109140. /**
  109141. * Gets or sets the current on-screen X position of the pointer
  109142. */
  109143. get pointerX(): number;
  109144. set pointerX(value: number);
  109145. /**
  109146. * Gets or sets the current on-screen Y position of the pointer
  109147. */
  109148. get pointerY(): number;
  109149. set pointerY(value: number);
  109150. /**
  109151. * Gets the cached material (ie. the latest rendered one)
  109152. * @returns the cached material
  109153. */
  109154. getCachedMaterial(): Nullable<Material>;
  109155. /**
  109156. * Gets the cached effect (ie. the latest rendered one)
  109157. * @returns the cached effect
  109158. */
  109159. getCachedEffect(): Nullable<Effect>;
  109160. /**
  109161. * Gets the cached visibility state (ie. the latest rendered one)
  109162. * @returns the cached visibility state
  109163. */
  109164. getCachedVisibility(): Nullable<number>;
  109165. /**
  109166. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109167. * @param material defines the current material
  109168. * @param effect defines the current effect
  109169. * @param visibility defines the current visibility state
  109170. * @returns true if one parameter is not cached
  109171. */
  109172. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109173. /**
  109174. * Gets the engine associated with the scene
  109175. * @returns an Engine
  109176. */
  109177. getEngine(): Engine;
  109178. /**
  109179. * Gets the total number of vertices rendered per frame
  109180. * @returns the total number of vertices rendered per frame
  109181. */
  109182. getTotalVertices(): number;
  109183. /**
  109184. * Gets the performance counter for total vertices
  109185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109186. */
  109187. get totalVerticesPerfCounter(): PerfCounter;
  109188. /**
  109189. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109190. * @returns the total number of active indices rendered per frame
  109191. */
  109192. getActiveIndices(): number;
  109193. /**
  109194. * Gets the performance counter for active indices
  109195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109196. */
  109197. get totalActiveIndicesPerfCounter(): PerfCounter;
  109198. /**
  109199. * Gets the total number of active particles rendered per frame
  109200. * @returns the total number of active particles rendered per frame
  109201. */
  109202. getActiveParticles(): number;
  109203. /**
  109204. * Gets the performance counter for active particles
  109205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109206. */
  109207. get activeParticlesPerfCounter(): PerfCounter;
  109208. /**
  109209. * Gets the total number of active bones rendered per frame
  109210. * @returns the total number of active bones rendered per frame
  109211. */
  109212. getActiveBones(): number;
  109213. /**
  109214. * Gets the performance counter for active bones
  109215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109216. */
  109217. get activeBonesPerfCounter(): PerfCounter;
  109218. /**
  109219. * Gets the array of active meshes
  109220. * @returns an array of AbstractMesh
  109221. */
  109222. getActiveMeshes(): SmartArray<AbstractMesh>;
  109223. /**
  109224. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109225. * @returns a number
  109226. */
  109227. getAnimationRatio(): number;
  109228. /**
  109229. * Gets an unique Id for the current render phase
  109230. * @returns a number
  109231. */
  109232. getRenderId(): number;
  109233. /**
  109234. * Gets an unique Id for the current frame
  109235. * @returns a number
  109236. */
  109237. getFrameId(): number;
  109238. /** Call this function if you want to manually increment the render Id*/
  109239. incrementRenderId(): void;
  109240. private _createUbo;
  109241. /**
  109242. * Use this method to simulate a pointer move on a mesh
  109243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109246. * @returns the current scene
  109247. */
  109248. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109249. /**
  109250. * Use this method to simulate a pointer down on a mesh
  109251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109254. * @returns the current scene
  109255. */
  109256. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109257. /**
  109258. * Use this method to simulate a pointer up on a mesh
  109259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109262. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109263. * @returns the current scene
  109264. */
  109265. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109266. /**
  109267. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109268. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109269. * @returns true if the pointer was captured
  109270. */
  109271. isPointerCaptured(pointerId?: number): boolean;
  109272. /**
  109273. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109274. * @param attachUp defines if you want to attach events to pointerup
  109275. * @param attachDown defines if you want to attach events to pointerdown
  109276. * @param attachMove defines if you want to attach events to pointermove
  109277. */
  109278. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109279. /** Detaches all event handlers*/
  109280. detachControl(): void;
  109281. /**
  109282. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109283. * Delay loaded resources are not taking in account
  109284. * @return true if all required resources are ready
  109285. */
  109286. isReady(): boolean;
  109287. /** Resets all cached information relative to material (including effect and visibility) */
  109288. resetCachedMaterial(): void;
  109289. /**
  109290. * Registers a function to be called before every frame render
  109291. * @param func defines the function to register
  109292. */
  109293. registerBeforeRender(func: () => void): void;
  109294. /**
  109295. * Unregisters a function called before every frame render
  109296. * @param func defines the function to unregister
  109297. */
  109298. unregisterBeforeRender(func: () => void): void;
  109299. /**
  109300. * Registers a function to be called after every frame render
  109301. * @param func defines the function to register
  109302. */
  109303. registerAfterRender(func: () => void): void;
  109304. /**
  109305. * Unregisters a function called after every frame render
  109306. * @param func defines the function to unregister
  109307. */
  109308. unregisterAfterRender(func: () => void): void;
  109309. private _executeOnceBeforeRender;
  109310. /**
  109311. * The provided function will run before render once and will be disposed afterwards.
  109312. * A timeout delay can be provided so that the function will be executed in N ms.
  109313. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109314. * @param func The function to be executed.
  109315. * @param timeout optional delay in ms
  109316. */
  109317. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109318. /** @hidden */
  109319. _addPendingData(data: any): void;
  109320. /** @hidden */
  109321. _removePendingData(data: any): void;
  109322. /**
  109323. * Returns the number of items waiting to be loaded
  109324. * @returns the number of items waiting to be loaded
  109325. */
  109326. getWaitingItemsCount(): number;
  109327. /**
  109328. * Returns a boolean indicating if the scene is still loading data
  109329. */
  109330. get isLoading(): boolean;
  109331. /**
  109332. * Registers a function to be executed when the scene is ready
  109333. * @param {Function} func - the function to be executed
  109334. */
  109335. executeWhenReady(func: () => void): void;
  109336. /**
  109337. * Returns a promise that resolves when the scene is ready
  109338. * @returns A promise that resolves when the scene is ready
  109339. */
  109340. whenReadyAsync(): Promise<void>;
  109341. /** @hidden */
  109342. _checkIsReady(): void;
  109343. /**
  109344. * Gets all animatable attached to the scene
  109345. */
  109346. get animatables(): Animatable[];
  109347. /**
  109348. * Resets the last animation time frame.
  109349. * Useful to override when animations start running when loading a scene for the first time.
  109350. */
  109351. resetLastAnimationTimeFrame(): void;
  109352. /**
  109353. * Gets the current view matrix
  109354. * @returns a Matrix
  109355. */
  109356. getViewMatrix(): Matrix;
  109357. /**
  109358. * Gets the current projection matrix
  109359. * @returns a Matrix
  109360. */
  109361. getProjectionMatrix(): Matrix;
  109362. /**
  109363. * Gets the current transform matrix
  109364. * @returns a Matrix made of View * Projection
  109365. */
  109366. getTransformMatrix(): Matrix;
  109367. /**
  109368. * Sets the current transform matrix
  109369. * @param viewL defines the View matrix to use
  109370. * @param projectionL defines the Projection matrix to use
  109371. * @param viewR defines the right View matrix to use (if provided)
  109372. * @param projectionR defines the right Projection matrix to use (if provided)
  109373. */
  109374. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109375. /**
  109376. * Gets the uniform buffer used to store scene data
  109377. * @returns a UniformBuffer
  109378. */
  109379. getSceneUniformBuffer(): UniformBuffer;
  109380. /**
  109381. * Gets an unique (relatively to the current scene) Id
  109382. * @returns an unique number for the scene
  109383. */
  109384. getUniqueId(): number;
  109385. /**
  109386. * Add a mesh to the list of scene's meshes
  109387. * @param newMesh defines the mesh to add
  109388. * @param recursive if all child meshes should also be added to the scene
  109389. */
  109390. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109391. /**
  109392. * Remove a mesh for the list of scene's meshes
  109393. * @param toRemove defines the mesh to remove
  109394. * @param recursive if all child meshes should also be removed from the scene
  109395. * @returns the index where the mesh was in the mesh list
  109396. */
  109397. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109398. /**
  109399. * Add a transform node to the list of scene's transform nodes
  109400. * @param newTransformNode defines the transform node to add
  109401. */
  109402. addTransformNode(newTransformNode: TransformNode): void;
  109403. /**
  109404. * Remove a transform node for the list of scene's transform nodes
  109405. * @param toRemove defines the transform node to remove
  109406. * @returns the index where the transform node was in the transform node list
  109407. */
  109408. removeTransformNode(toRemove: TransformNode): number;
  109409. /**
  109410. * Remove a skeleton for the list of scene's skeletons
  109411. * @param toRemove defines the skeleton to remove
  109412. * @returns the index where the skeleton was in the skeleton list
  109413. */
  109414. removeSkeleton(toRemove: Skeleton): number;
  109415. /**
  109416. * Remove a morph target for the list of scene's morph targets
  109417. * @param toRemove defines the morph target to remove
  109418. * @returns the index where the morph target was in the morph target list
  109419. */
  109420. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109421. /**
  109422. * Remove a light for the list of scene's lights
  109423. * @param toRemove defines the light to remove
  109424. * @returns the index where the light was in the light list
  109425. */
  109426. removeLight(toRemove: Light): number;
  109427. /**
  109428. * Remove a camera for the list of scene's cameras
  109429. * @param toRemove defines the camera to remove
  109430. * @returns the index where the camera was in the camera list
  109431. */
  109432. removeCamera(toRemove: Camera): number;
  109433. /**
  109434. * Remove a particle system for the list of scene's particle systems
  109435. * @param toRemove defines the particle system to remove
  109436. * @returns the index where the particle system was in the particle system list
  109437. */
  109438. removeParticleSystem(toRemove: IParticleSystem): number;
  109439. /**
  109440. * Remove a animation for the list of scene's animations
  109441. * @param toRemove defines the animation to remove
  109442. * @returns the index where the animation was in the animation list
  109443. */
  109444. removeAnimation(toRemove: Animation): number;
  109445. /**
  109446. * Will stop the animation of the given target
  109447. * @param target - the target
  109448. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109449. * @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)
  109450. */
  109451. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109452. /**
  109453. * Removes the given animation group from this scene.
  109454. * @param toRemove The animation group to remove
  109455. * @returns The index of the removed animation group
  109456. */
  109457. removeAnimationGroup(toRemove: AnimationGroup): number;
  109458. /**
  109459. * Removes the given multi-material from this scene.
  109460. * @param toRemove The multi-material to remove
  109461. * @returns The index of the removed multi-material
  109462. */
  109463. removeMultiMaterial(toRemove: MultiMaterial): number;
  109464. /**
  109465. * Removes the given material from this scene.
  109466. * @param toRemove The material to remove
  109467. * @returns The index of the removed material
  109468. */
  109469. removeMaterial(toRemove: Material): number;
  109470. /**
  109471. * Removes the given action manager from this scene.
  109472. * @param toRemove The action manager to remove
  109473. * @returns The index of the removed action manager
  109474. */
  109475. removeActionManager(toRemove: AbstractActionManager): number;
  109476. /**
  109477. * Removes the given texture from this scene.
  109478. * @param toRemove The texture to remove
  109479. * @returns The index of the removed texture
  109480. */
  109481. removeTexture(toRemove: BaseTexture): number;
  109482. /**
  109483. * Adds the given light to this scene
  109484. * @param newLight The light to add
  109485. */
  109486. addLight(newLight: Light): void;
  109487. /**
  109488. * Sorts the list list based on light priorities
  109489. */
  109490. sortLightsByPriority(): void;
  109491. /**
  109492. * Adds the given camera to this scene
  109493. * @param newCamera The camera to add
  109494. */
  109495. addCamera(newCamera: Camera): void;
  109496. /**
  109497. * Adds the given skeleton to this scene
  109498. * @param newSkeleton The skeleton to add
  109499. */
  109500. addSkeleton(newSkeleton: Skeleton): void;
  109501. /**
  109502. * Adds the given particle system to this scene
  109503. * @param newParticleSystem The particle system to add
  109504. */
  109505. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109506. /**
  109507. * Adds the given animation to this scene
  109508. * @param newAnimation The animation to add
  109509. */
  109510. addAnimation(newAnimation: Animation): void;
  109511. /**
  109512. * Adds the given animation group to this scene.
  109513. * @param newAnimationGroup The animation group to add
  109514. */
  109515. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109516. /**
  109517. * Adds the given multi-material to this scene
  109518. * @param newMultiMaterial The multi-material to add
  109519. */
  109520. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109521. /**
  109522. * Adds the given material to this scene
  109523. * @param newMaterial The material to add
  109524. */
  109525. addMaterial(newMaterial: Material): void;
  109526. /**
  109527. * Adds the given morph target to this scene
  109528. * @param newMorphTargetManager The morph target to add
  109529. */
  109530. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109531. /**
  109532. * Adds the given geometry to this scene
  109533. * @param newGeometry The geometry to add
  109534. */
  109535. addGeometry(newGeometry: Geometry): void;
  109536. /**
  109537. * Adds the given action manager to this scene
  109538. * @param newActionManager The action manager to add
  109539. */
  109540. addActionManager(newActionManager: AbstractActionManager): void;
  109541. /**
  109542. * Adds the given texture to this scene.
  109543. * @param newTexture The texture to add
  109544. */
  109545. addTexture(newTexture: BaseTexture): void;
  109546. /**
  109547. * Switch active camera
  109548. * @param newCamera defines the new active camera
  109549. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109550. */
  109551. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109552. /**
  109553. * sets the active camera of the scene using its ID
  109554. * @param id defines the camera's ID
  109555. * @return the new active camera or null if none found.
  109556. */
  109557. setActiveCameraByID(id: string): Nullable<Camera>;
  109558. /**
  109559. * sets the active camera of the scene using its name
  109560. * @param name defines the camera's name
  109561. * @returns the new active camera or null if none found.
  109562. */
  109563. setActiveCameraByName(name: string): Nullable<Camera>;
  109564. /**
  109565. * get an animation group using its name
  109566. * @param name defines the material's name
  109567. * @return the animation group or null if none found.
  109568. */
  109569. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109570. /**
  109571. * Get a material using its unique id
  109572. * @param uniqueId defines the material's unique id
  109573. * @return the material or null if none found.
  109574. */
  109575. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109576. /**
  109577. * get a material using its id
  109578. * @param id defines the material's ID
  109579. * @return the material or null if none found.
  109580. */
  109581. getMaterialByID(id: string): Nullable<Material>;
  109582. /**
  109583. * Gets a the last added material using a given id
  109584. * @param id defines the material's ID
  109585. * @return the last material with the given id or null if none found.
  109586. */
  109587. getLastMaterialByID(id: string): Nullable<Material>;
  109588. /**
  109589. * Gets a material using its name
  109590. * @param name defines the material's name
  109591. * @return the material or null if none found.
  109592. */
  109593. getMaterialByName(name: string): Nullable<Material>;
  109594. /**
  109595. * Get a texture using its unique id
  109596. * @param uniqueId defines the texture's unique id
  109597. * @return the texture or null if none found.
  109598. */
  109599. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109600. /**
  109601. * Gets a camera using its id
  109602. * @param id defines the id to look for
  109603. * @returns the camera or null if not found
  109604. */
  109605. getCameraByID(id: string): Nullable<Camera>;
  109606. /**
  109607. * Gets a camera using its unique id
  109608. * @param uniqueId defines the unique id to look for
  109609. * @returns the camera or null if not found
  109610. */
  109611. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109612. /**
  109613. * Gets a camera using its name
  109614. * @param name defines the camera's name
  109615. * @return the camera or null if none found.
  109616. */
  109617. getCameraByName(name: string): Nullable<Camera>;
  109618. /**
  109619. * Gets a bone using its id
  109620. * @param id defines the bone's id
  109621. * @return the bone or null if not found
  109622. */
  109623. getBoneByID(id: string): Nullable<Bone>;
  109624. /**
  109625. * Gets a bone using its id
  109626. * @param name defines the bone's name
  109627. * @return the bone or null if not found
  109628. */
  109629. getBoneByName(name: string): Nullable<Bone>;
  109630. /**
  109631. * Gets a light node using its name
  109632. * @param name defines the the light's name
  109633. * @return the light or null if none found.
  109634. */
  109635. getLightByName(name: string): Nullable<Light>;
  109636. /**
  109637. * Gets a light node using its id
  109638. * @param id defines the light's id
  109639. * @return the light or null if none found.
  109640. */
  109641. getLightByID(id: string): Nullable<Light>;
  109642. /**
  109643. * Gets a light node using its scene-generated unique ID
  109644. * @param uniqueId defines the light's unique id
  109645. * @return the light or null if none found.
  109646. */
  109647. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109648. /**
  109649. * Gets a particle system by id
  109650. * @param id defines the particle system id
  109651. * @return the corresponding system or null if none found
  109652. */
  109653. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109654. /**
  109655. * Gets a geometry using its ID
  109656. * @param id defines the geometry's id
  109657. * @return the geometry or null if none found.
  109658. */
  109659. getGeometryByID(id: string): Nullable<Geometry>;
  109660. private _getGeometryByUniqueID;
  109661. /**
  109662. * Add a new geometry to this scene
  109663. * @param geometry defines the geometry to be added to the scene.
  109664. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109665. * @return a boolean defining if the geometry was added or not
  109666. */
  109667. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109668. /**
  109669. * Removes an existing geometry
  109670. * @param geometry defines the geometry to be removed from the scene
  109671. * @return a boolean defining if the geometry was removed or not
  109672. */
  109673. removeGeometry(geometry: Geometry): boolean;
  109674. /**
  109675. * Gets the list of geometries attached to the scene
  109676. * @returns an array of Geometry
  109677. */
  109678. getGeometries(): Geometry[];
  109679. /**
  109680. * Gets the first added mesh found of a given ID
  109681. * @param id defines the id to search for
  109682. * @return the mesh found or null if not found at all
  109683. */
  109684. getMeshByID(id: string): Nullable<AbstractMesh>;
  109685. /**
  109686. * Gets a list of meshes using their id
  109687. * @param id defines the id to search for
  109688. * @returns a list of meshes
  109689. */
  109690. getMeshesByID(id: string): Array<AbstractMesh>;
  109691. /**
  109692. * Gets the first added transform node found of a given ID
  109693. * @param id defines the id to search for
  109694. * @return the found transform node or null if not found at all.
  109695. */
  109696. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109697. /**
  109698. * Gets a transform node with its auto-generated unique id
  109699. * @param uniqueId efines the unique id to search for
  109700. * @return the found transform node or null if not found at all.
  109701. */
  109702. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109703. /**
  109704. * Gets a list of transform nodes using their id
  109705. * @param id defines the id to search for
  109706. * @returns a list of transform nodes
  109707. */
  109708. getTransformNodesByID(id: string): Array<TransformNode>;
  109709. /**
  109710. * Gets a mesh with its auto-generated unique id
  109711. * @param uniqueId defines the unique id to search for
  109712. * @return the found mesh or null if not found at all.
  109713. */
  109714. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109715. /**
  109716. * Gets a the last added mesh using a given id
  109717. * @param id defines the id to search for
  109718. * @return the found mesh or null if not found at all.
  109719. */
  109720. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109721. /**
  109722. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109723. * @param id defines the id to search for
  109724. * @return the found node or null if not found at all
  109725. */
  109726. getLastEntryByID(id: string): Nullable<Node>;
  109727. /**
  109728. * Gets a node (Mesh, Camera, Light) using a given id
  109729. * @param id defines the id to search for
  109730. * @return the found node or null if not found at all
  109731. */
  109732. getNodeByID(id: string): Nullable<Node>;
  109733. /**
  109734. * Gets a node (Mesh, Camera, Light) using a given name
  109735. * @param name defines the name to search for
  109736. * @return the found node or null if not found at all.
  109737. */
  109738. getNodeByName(name: string): Nullable<Node>;
  109739. /**
  109740. * Gets a mesh using a given name
  109741. * @param name defines the name to search for
  109742. * @return the found mesh or null if not found at all.
  109743. */
  109744. getMeshByName(name: string): Nullable<AbstractMesh>;
  109745. /**
  109746. * Gets a transform node using a given name
  109747. * @param name defines the name to search for
  109748. * @return the found transform node or null if not found at all.
  109749. */
  109750. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109751. /**
  109752. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109753. * @param id defines the id to search for
  109754. * @return the found skeleton or null if not found at all.
  109755. */
  109756. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109757. /**
  109758. * Gets a skeleton using a given auto generated unique id
  109759. * @param uniqueId defines the unique id to search for
  109760. * @return the found skeleton or null if not found at all.
  109761. */
  109762. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109763. /**
  109764. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109765. * @param id defines the id to search for
  109766. * @return the found skeleton or null if not found at all.
  109767. */
  109768. getSkeletonById(id: string): Nullable<Skeleton>;
  109769. /**
  109770. * Gets a skeleton using a given name
  109771. * @param name defines the name to search for
  109772. * @return the found skeleton or null if not found at all.
  109773. */
  109774. getSkeletonByName(name: string): Nullable<Skeleton>;
  109775. /**
  109776. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109777. * @param id defines the id to search for
  109778. * @return the found morph target manager or null if not found at all.
  109779. */
  109780. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109781. /**
  109782. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109783. * @param id defines the id to search for
  109784. * @return the found morph target or null if not found at all.
  109785. */
  109786. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109787. /**
  109788. * Gets a boolean indicating if the given mesh is active
  109789. * @param mesh defines the mesh to look for
  109790. * @returns true if the mesh is in the active list
  109791. */
  109792. isActiveMesh(mesh: AbstractMesh): boolean;
  109793. /**
  109794. * Return a unique id as a string which can serve as an identifier for the scene
  109795. */
  109796. get uid(): string;
  109797. /**
  109798. * Add an externaly attached data from its key.
  109799. * This method call will fail and return false, if such key already exists.
  109800. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109801. * @param key the unique key that identifies the data
  109802. * @param data the data object to associate to the key for this Engine instance
  109803. * @return true if no such key were already present and the data was added successfully, false otherwise
  109804. */
  109805. addExternalData<T>(key: string, data: T): boolean;
  109806. /**
  109807. * Get an externaly attached data from its key
  109808. * @param key the unique key that identifies the data
  109809. * @return the associated data, if present (can be null), or undefined if not present
  109810. */
  109811. getExternalData<T>(key: string): Nullable<T>;
  109812. /**
  109813. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109814. * @param key the unique key that identifies the data
  109815. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109816. * @return the associated data, can be null if the factory returned null.
  109817. */
  109818. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109819. /**
  109820. * Remove an externaly attached data from the Engine instance
  109821. * @param key the unique key that identifies the data
  109822. * @return true if the data was successfully removed, false if it doesn't exist
  109823. */
  109824. removeExternalData(key: string): boolean;
  109825. private _evaluateSubMesh;
  109826. /**
  109827. * Clear the processed materials smart array preventing retention point in material dispose.
  109828. */
  109829. freeProcessedMaterials(): void;
  109830. private _preventFreeActiveMeshesAndRenderingGroups;
  109831. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109832. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109833. * when disposing several meshes in a row or a hierarchy of meshes.
  109834. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109835. */
  109836. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109837. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109838. /**
  109839. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109840. */
  109841. freeActiveMeshes(): void;
  109842. /**
  109843. * Clear the info related to rendering groups preventing retention points during dispose.
  109844. */
  109845. freeRenderingGroups(): void;
  109846. /** @hidden */
  109847. _isInIntermediateRendering(): boolean;
  109848. /**
  109849. * Lambda returning the list of potentially active meshes.
  109850. */
  109851. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109852. /**
  109853. * Lambda returning the list of potentially active sub meshes.
  109854. */
  109855. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109856. /**
  109857. * Lambda returning the list of potentially intersecting sub meshes.
  109858. */
  109859. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109860. /**
  109861. * Lambda returning the list of potentially colliding sub meshes.
  109862. */
  109863. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109864. private _activeMeshesFrozen;
  109865. private _skipEvaluateActiveMeshesCompletely;
  109866. /**
  109867. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109868. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109869. * @returns the current scene
  109870. */
  109871. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109872. /**
  109873. * Use this function to restart evaluating active meshes on every frame
  109874. * @returns the current scene
  109875. */
  109876. unfreezeActiveMeshes(): Scene;
  109877. private _evaluateActiveMeshes;
  109878. private _activeMesh;
  109879. /**
  109880. * Update the transform matrix to update from the current active camera
  109881. * @param force defines a boolean used to force the update even if cache is up to date
  109882. */
  109883. updateTransformMatrix(force?: boolean): void;
  109884. private _bindFrameBuffer;
  109885. /** @hidden */
  109886. _allowPostProcessClearColor: boolean;
  109887. /** @hidden */
  109888. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109889. private _processSubCameras;
  109890. private _checkIntersections;
  109891. /** @hidden */
  109892. _advancePhysicsEngineStep(step: number): void;
  109893. /**
  109894. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109895. */
  109896. getDeterministicFrameTime: () => number;
  109897. /** @hidden */
  109898. _animate(): void;
  109899. /** Execute all animations (for a frame) */
  109900. animate(): void;
  109901. /**
  109902. * Render the scene
  109903. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109904. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109905. */
  109906. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109907. /**
  109908. * Freeze all materials
  109909. * A frozen material will not be updatable but should be faster to render
  109910. */
  109911. freezeMaterials(): void;
  109912. /**
  109913. * Unfreeze all materials
  109914. * A frozen material will not be updatable but should be faster to render
  109915. */
  109916. unfreezeMaterials(): void;
  109917. /**
  109918. * Releases all held ressources
  109919. */
  109920. dispose(): void;
  109921. /**
  109922. * Gets if the scene is already disposed
  109923. */
  109924. get isDisposed(): boolean;
  109925. /**
  109926. * Call this function to reduce memory footprint of the scene.
  109927. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109928. */
  109929. clearCachedVertexData(): void;
  109930. /**
  109931. * This function will remove the local cached buffer data from texture.
  109932. * It will save memory but will prevent the texture from being rebuilt
  109933. */
  109934. cleanCachedTextureBuffer(): void;
  109935. /**
  109936. * Get the world extend vectors with an optional filter
  109937. *
  109938. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109939. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109940. */
  109941. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109942. min: Vector3;
  109943. max: Vector3;
  109944. };
  109945. /**
  109946. * Creates a ray that can be used to pick in the scene
  109947. * @param x defines the x coordinate of the origin (on-screen)
  109948. * @param y defines the y coordinate of the origin (on-screen)
  109949. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109950. * @param camera defines the camera to use for the picking
  109951. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109952. * @returns a Ray
  109953. */
  109954. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109955. /**
  109956. * Creates a ray that can be used to pick in the scene
  109957. * @param x defines the x coordinate of the origin (on-screen)
  109958. * @param y defines the y coordinate of the origin (on-screen)
  109959. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109960. * @param result defines the ray where to store the picking ray
  109961. * @param camera defines the camera to use for the picking
  109962. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109963. * @returns the current scene
  109964. */
  109965. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109966. /**
  109967. * Creates a ray that can be used to pick in the scene
  109968. * @param x defines the x coordinate of the origin (on-screen)
  109969. * @param y defines the y coordinate of the origin (on-screen)
  109970. * @param camera defines the camera to use for the picking
  109971. * @returns a Ray
  109972. */
  109973. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109974. /**
  109975. * Creates a ray that can be used to pick in the scene
  109976. * @param x defines the x coordinate of the origin (on-screen)
  109977. * @param y defines the y coordinate of the origin (on-screen)
  109978. * @param result defines the ray where to store the picking ray
  109979. * @param camera defines the camera to use for the picking
  109980. * @returns the current scene
  109981. */
  109982. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109983. /** Launch a ray to try to pick a mesh in the scene
  109984. * @param x position on screen
  109985. * @param y position on screen
  109986. * @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
  109987. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109988. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109990. * @returns a PickingInfo
  109991. */
  109992. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109993. /** Use the given ray to pick a mesh in the scene
  109994. * @param ray The ray to use to pick meshes
  109995. * @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
  109996. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109997. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109998. * @returns a PickingInfo
  109999. */
  110000. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110001. /**
  110002. * Launch a ray to try to pick a mesh in the scene
  110003. * @param x X position on screen
  110004. * @param y Y position on screen
  110005. * @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
  110006. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110008. * @returns an array of PickingInfo
  110009. */
  110010. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110011. /**
  110012. * Launch a ray to try to pick a mesh in the scene
  110013. * @param ray Ray to use
  110014. * @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
  110015. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110016. * @returns an array of PickingInfo
  110017. */
  110018. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110019. /**
  110020. * Force the value of meshUnderPointer
  110021. * @param mesh defines the mesh to use
  110022. */
  110023. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110024. /**
  110025. * Gets the mesh under the pointer
  110026. * @returns a Mesh or null if no mesh is under the pointer
  110027. */
  110028. getPointerOverMesh(): Nullable<AbstractMesh>;
  110029. /** @hidden */
  110030. _rebuildGeometries(): void;
  110031. /** @hidden */
  110032. _rebuildTextures(): void;
  110033. private _getByTags;
  110034. /**
  110035. * Get a list of meshes by tags
  110036. * @param tagsQuery defines the tags query to use
  110037. * @param forEach defines a predicate used to filter results
  110038. * @returns an array of Mesh
  110039. */
  110040. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110041. /**
  110042. * Get a list of cameras by tags
  110043. * @param tagsQuery defines the tags query to use
  110044. * @param forEach defines a predicate used to filter results
  110045. * @returns an array of Camera
  110046. */
  110047. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110048. /**
  110049. * Get a list of lights by tags
  110050. * @param tagsQuery defines the tags query to use
  110051. * @param forEach defines a predicate used to filter results
  110052. * @returns an array of Light
  110053. */
  110054. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110055. /**
  110056. * Get a list of materials by tags
  110057. * @param tagsQuery defines the tags query to use
  110058. * @param forEach defines a predicate used to filter results
  110059. * @returns an array of Material
  110060. */
  110061. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110062. /**
  110063. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110064. * This allowed control for front to back rendering or reversly depending of the special needs.
  110065. *
  110066. * @param renderingGroupId The rendering group id corresponding to its index
  110067. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110068. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110069. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110070. */
  110071. 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;
  110072. /**
  110073. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110074. *
  110075. * @param renderingGroupId The rendering group id corresponding to its index
  110076. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110077. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110078. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110079. */
  110080. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110081. /**
  110082. * Gets the current auto clear configuration for one rendering group of the rendering
  110083. * manager.
  110084. * @param index the rendering group index to get the information for
  110085. * @returns The auto clear setup for the requested rendering group
  110086. */
  110087. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110088. private _blockMaterialDirtyMechanism;
  110089. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110090. get blockMaterialDirtyMechanism(): boolean;
  110091. set blockMaterialDirtyMechanism(value: boolean);
  110092. /**
  110093. * Will flag all materials as dirty to trigger new shader compilation
  110094. * @param flag defines the flag used to specify which material part must be marked as dirty
  110095. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110096. */
  110097. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110098. /** @hidden */
  110099. _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;
  110100. /** @hidden */
  110101. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110102. /** @hidden */
  110103. _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;
  110104. /** @hidden */
  110105. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110106. /** @hidden */
  110107. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110108. /** @hidden */
  110109. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * Set of assets to keep when moving a scene into an asset container.
  110115. */
  110116. export class KeepAssets extends AbstractScene {
  110117. }
  110118. /**
  110119. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110120. */
  110121. export class InstantiatedEntries {
  110122. /**
  110123. * List of new root nodes (eg. nodes with no parent)
  110124. */
  110125. rootNodes: TransformNode[];
  110126. /**
  110127. * List of new skeletons
  110128. */
  110129. skeletons: Skeleton[];
  110130. /**
  110131. * List of new animation groups
  110132. */
  110133. animationGroups: AnimationGroup[];
  110134. }
  110135. /**
  110136. * Container with a set of assets that can be added or removed from a scene.
  110137. */
  110138. export class AssetContainer extends AbstractScene {
  110139. private _wasAddedToScene;
  110140. /**
  110141. * The scene the AssetContainer belongs to.
  110142. */
  110143. scene: Scene;
  110144. /**
  110145. * Instantiates an AssetContainer.
  110146. * @param scene The scene the AssetContainer belongs to.
  110147. */
  110148. constructor(scene: Scene);
  110149. /**
  110150. * Instantiate or clone all meshes and add the new ones to the scene.
  110151. * Skeletons and animation groups will all be cloned
  110152. * @param nameFunction defines an optional function used to get new names for clones
  110153. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110154. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110155. */
  110156. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110157. /**
  110158. * Adds all the assets from the container to the scene.
  110159. */
  110160. addAllToScene(): void;
  110161. /**
  110162. * Removes all the assets in the container from the scene
  110163. */
  110164. removeAllFromScene(): void;
  110165. /**
  110166. * Disposes all the assets in the container
  110167. */
  110168. dispose(): void;
  110169. private _moveAssets;
  110170. /**
  110171. * Removes all the assets contained in the scene and adds them to the container.
  110172. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110173. */
  110174. moveAllFromScene(keepAssets?: KeepAssets): void;
  110175. /**
  110176. * 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.
  110177. * @returns the root mesh
  110178. */
  110179. createRootMesh(): Mesh;
  110180. /**
  110181. * Merge animations from this asset container into a scene
  110182. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110183. * @param animatables set of animatables to retarget to a node from the scene
  110184. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110185. */
  110186. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110187. }
  110188. }
  110189. declare module BABYLON {
  110190. /**
  110191. * Defines how the parser contract is defined.
  110192. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110193. */
  110194. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110195. /**
  110196. * Defines how the individual parser contract is defined.
  110197. * These parser can parse an individual asset
  110198. */
  110199. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110200. /**
  110201. * Base class of the scene acting as a container for the different elements composing a scene.
  110202. * This class is dynamically extended by the different components of the scene increasing
  110203. * flexibility and reducing coupling
  110204. */
  110205. export abstract class AbstractScene {
  110206. /**
  110207. * Stores the list of available parsers in the application.
  110208. */
  110209. private static _BabylonFileParsers;
  110210. /**
  110211. * Stores the list of available individual parsers in the application.
  110212. */
  110213. private static _IndividualBabylonFileParsers;
  110214. /**
  110215. * Adds a parser in the list of available ones
  110216. * @param name Defines the name of the parser
  110217. * @param parser Defines the parser to add
  110218. */
  110219. static AddParser(name: string, parser: BabylonFileParser): void;
  110220. /**
  110221. * Gets a general parser from the list of avaialble ones
  110222. * @param name Defines the name of the parser
  110223. * @returns the requested parser or null
  110224. */
  110225. static GetParser(name: string): Nullable<BabylonFileParser>;
  110226. /**
  110227. * Adds n individual parser in the list of available ones
  110228. * @param name Defines the name of the parser
  110229. * @param parser Defines the parser to add
  110230. */
  110231. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110232. /**
  110233. * Gets an individual parser from the list of avaialble ones
  110234. * @param name Defines the name of the parser
  110235. * @returns the requested parser or null
  110236. */
  110237. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110238. /**
  110239. * Parser json data and populate both a scene and its associated container object
  110240. * @param jsonData Defines the data to parse
  110241. * @param scene Defines the scene to parse the data for
  110242. * @param container Defines the container attached to the parsing sequence
  110243. * @param rootUrl Defines the root url of the data
  110244. */
  110245. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110246. /**
  110247. * Gets the list of root nodes (ie. nodes with no parent)
  110248. */
  110249. rootNodes: Node[];
  110250. /** All of the cameras added to this scene
  110251. * @see http://doc.babylonjs.com/babylon101/cameras
  110252. */
  110253. cameras: Camera[];
  110254. /**
  110255. * All of the lights added to this scene
  110256. * @see http://doc.babylonjs.com/babylon101/lights
  110257. */
  110258. lights: Light[];
  110259. /**
  110260. * All of the (abstract) meshes added to this scene
  110261. */
  110262. meshes: AbstractMesh[];
  110263. /**
  110264. * The list of skeletons added to the scene
  110265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110266. */
  110267. skeletons: Skeleton[];
  110268. /**
  110269. * All of the particle systems added to this scene
  110270. * @see http://doc.babylonjs.com/babylon101/particles
  110271. */
  110272. particleSystems: IParticleSystem[];
  110273. /**
  110274. * Gets a list of Animations associated with the scene
  110275. */
  110276. animations: Animation[];
  110277. /**
  110278. * All of the animation groups added to this scene
  110279. * @see http://doc.babylonjs.com/how_to/group
  110280. */
  110281. animationGroups: AnimationGroup[];
  110282. /**
  110283. * All of the multi-materials added to this scene
  110284. * @see http://doc.babylonjs.com/how_to/multi_materials
  110285. */
  110286. multiMaterials: MultiMaterial[];
  110287. /**
  110288. * All of the materials added to this scene
  110289. * In the context of a Scene, it is not supposed to be modified manually.
  110290. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110291. * Note also that the order of the Material within the array is not significant and might change.
  110292. * @see http://doc.babylonjs.com/babylon101/materials
  110293. */
  110294. materials: Material[];
  110295. /**
  110296. * The list of morph target managers added to the scene
  110297. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110298. */
  110299. morphTargetManagers: MorphTargetManager[];
  110300. /**
  110301. * The list of geometries used in the scene.
  110302. */
  110303. geometries: Geometry[];
  110304. /**
  110305. * All of the tranform nodes added to this scene
  110306. * In the context of a Scene, it is not supposed to be modified manually.
  110307. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110308. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110309. * @see http://doc.babylonjs.com/how_to/transformnode
  110310. */
  110311. transformNodes: TransformNode[];
  110312. /**
  110313. * ActionManagers available on the scene.
  110314. */
  110315. actionManagers: AbstractActionManager[];
  110316. /**
  110317. * Textures to keep.
  110318. */
  110319. textures: BaseTexture[];
  110320. /**
  110321. * Environment texture for the scene
  110322. */
  110323. environmentTexture: Nullable<BaseTexture>;
  110324. /**
  110325. * @returns all meshes, lights, cameras, transformNodes and bones
  110326. */
  110327. getNodes(): Array<Node>;
  110328. }
  110329. }
  110330. declare module BABYLON {
  110331. /**
  110332. * Interface used to define options for Sound class
  110333. */
  110334. export interface ISoundOptions {
  110335. /**
  110336. * Does the sound autoplay once loaded.
  110337. */
  110338. autoplay?: boolean;
  110339. /**
  110340. * Does the sound loop after it finishes playing once.
  110341. */
  110342. loop?: boolean;
  110343. /**
  110344. * Sound's volume
  110345. */
  110346. volume?: number;
  110347. /**
  110348. * Is it a spatial sound?
  110349. */
  110350. spatialSound?: boolean;
  110351. /**
  110352. * Maximum distance to hear that sound
  110353. */
  110354. maxDistance?: number;
  110355. /**
  110356. * Uses user defined attenuation function
  110357. */
  110358. useCustomAttenuation?: boolean;
  110359. /**
  110360. * Define the roll off factor of spatial sounds.
  110361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110362. */
  110363. rolloffFactor?: number;
  110364. /**
  110365. * Define the reference distance the sound should be heard perfectly.
  110366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110367. */
  110368. refDistance?: number;
  110369. /**
  110370. * Define the distance attenuation model the sound will follow.
  110371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110372. */
  110373. distanceModel?: string;
  110374. /**
  110375. * Defines the playback speed (1 by default)
  110376. */
  110377. playbackRate?: number;
  110378. /**
  110379. * Defines if the sound is from a streaming source
  110380. */
  110381. streaming?: boolean;
  110382. /**
  110383. * Defines an optional length (in seconds) inside the sound file
  110384. */
  110385. length?: number;
  110386. /**
  110387. * Defines an optional offset (in seconds) inside the sound file
  110388. */
  110389. offset?: number;
  110390. /**
  110391. * If true, URLs will not be required to state the audio file codec to use.
  110392. */
  110393. skipCodecCheck?: boolean;
  110394. }
  110395. /**
  110396. * Defines a sound that can be played in the application.
  110397. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110399. */
  110400. export class Sound {
  110401. /**
  110402. * The name of the sound in the scene.
  110403. */
  110404. name: string;
  110405. /**
  110406. * Does the sound autoplay once loaded.
  110407. */
  110408. autoplay: boolean;
  110409. /**
  110410. * Does the sound loop after it finishes playing once.
  110411. */
  110412. loop: boolean;
  110413. /**
  110414. * Does the sound use a custom attenuation curve to simulate the falloff
  110415. * happening when the source gets further away from the camera.
  110416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110417. */
  110418. useCustomAttenuation: boolean;
  110419. /**
  110420. * The sound track id this sound belongs to.
  110421. */
  110422. soundTrackId: number;
  110423. /**
  110424. * Is this sound currently played.
  110425. */
  110426. isPlaying: boolean;
  110427. /**
  110428. * Is this sound currently paused.
  110429. */
  110430. isPaused: boolean;
  110431. /**
  110432. * Does this sound enables spatial sound.
  110433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110434. */
  110435. spatialSound: boolean;
  110436. /**
  110437. * Define the reference distance the sound should be heard perfectly.
  110438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110439. */
  110440. refDistance: number;
  110441. /**
  110442. * Define the roll off factor of spatial sounds.
  110443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110444. */
  110445. rolloffFactor: number;
  110446. /**
  110447. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110449. */
  110450. maxDistance: number;
  110451. /**
  110452. * Define the distance attenuation model the sound will follow.
  110453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110454. */
  110455. distanceModel: string;
  110456. /**
  110457. * @hidden
  110458. * Back Compat
  110459. **/
  110460. onended: () => any;
  110461. /**
  110462. * Observable event when the current playing sound finishes.
  110463. */
  110464. onEndedObservable: Observable<Sound>;
  110465. private _panningModel;
  110466. private _playbackRate;
  110467. private _streaming;
  110468. private _startTime;
  110469. private _startOffset;
  110470. private _position;
  110471. /** @hidden */
  110472. _positionInEmitterSpace: boolean;
  110473. private _localDirection;
  110474. private _volume;
  110475. private _isReadyToPlay;
  110476. private _isDirectional;
  110477. private _readyToPlayCallback;
  110478. private _audioBuffer;
  110479. private _soundSource;
  110480. private _streamingSource;
  110481. private _soundPanner;
  110482. private _soundGain;
  110483. private _inputAudioNode;
  110484. private _outputAudioNode;
  110485. private _coneInnerAngle;
  110486. private _coneOuterAngle;
  110487. private _coneOuterGain;
  110488. private _scene;
  110489. private _connectedTransformNode;
  110490. private _customAttenuationFunction;
  110491. private _registerFunc;
  110492. private _isOutputConnected;
  110493. private _htmlAudioElement;
  110494. private _urlType;
  110495. private _length?;
  110496. private _offset?;
  110497. /** @hidden */
  110498. static _SceneComponentInitialization: (scene: Scene) => void;
  110499. /**
  110500. * Create a sound and attach it to a scene
  110501. * @param name Name of your sound
  110502. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110503. * @param scene defines the scene the sound belongs to
  110504. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110505. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110506. */
  110507. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110508. /**
  110509. * Release the sound and its associated resources
  110510. */
  110511. dispose(): void;
  110512. /**
  110513. * Gets if the sounds is ready to be played or not.
  110514. * @returns true if ready, otherwise false
  110515. */
  110516. isReady(): boolean;
  110517. private _soundLoaded;
  110518. /**
  110519. * Sets the data of the sound from an audiobuffer
  110520. * @param audioBuffer The audioBuffer containing the data
  110521. */
  110522. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110523. /**
  110524. * Updates the current sounds options such as maxdistance, loop...
  110525. * @param options A JSON object containing values named as the object properties
  110526. */
  110527. updateOptions(options: ISoundOptions): void;
  110528. private _createSpatialParameters;
  110529. private _updateSpatialParameters;
  110530. /**
  110531. * Switch the panning model to HRTF:
  110532. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110534. */
  110535. switchPanningModelToHRTF(): void;
  110536. /**
  110537. * Switch the panning model to Equal Power:
  110538. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110540. */
  110541. switchPanningModelToEqualPower(): void;
  110542. private _switchPanningModel;
  110543. /**
  110544. * Connect this sound to a sound track audio node like gain...
  110545. * @param soundTrackAudioNode the sound track audio node to connect to
  110546. */
  110547. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110548. /**
  110549. * Transform this sound into a directional source
  110550. * @param coneInnerAngle Size of the inner cone in degree
  110551. * @param coneOuterAngle Size of the outer cone in degree
  110552. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110553. */
  110554. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110555. /**
  110556. * Gets or sets the inner angle for the directional cone.
  110557. */
  110558. get directionalConeInnerAngle(): number;
  110559. /**
  110560. * Gets or sets the inner angle for the directional cone.
  110561. */
  110562. set directionalConeInnerAngle(value: number);
  110563. /**
  110564. * Gets or sets the outer angle for the directional cone.
  110565. */
  110566. get directionalConeOuterAngle(): number;
  110567. /**
  110568. * Gets or sets the outer angle for the directional cone.
  110569. */
  110570. set directionalConeOuterAngle(value: number);
  110571. /**
  110572. * Sets the position of the emitter if spatial sound is enabled
  110573. * @param newPosition Defines the new posisiton
  110574. */
  110575. setPosition(newPosition: Vector3): void;
  110576. /**
  110577. * Sets the local direction of the emitter if spatial sound is enabled
  110578. * @param newLocalDirection Defines the new local direction
  110579. */
  110580. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110581. private _updateDirection;
  110582. /** @hidden */
  110583. updateDistanceFromListener(): void;
  110584. /**
  110585. * Sets a new custom attenuation function for the sound.
  110586. * @param callback Defines the function used for the attenuation
  110587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110588. */
  110589. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110590. /**
  110591. * Play the sound
  110592. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110593. * @param offset (optional) Start the sound at a specific time in seconds
  110594. * @param length (optional) Sound duration (in seconds)
  110595. */
  110596. play(time?: number, offset?: number, length?: number): void;
  110597. private _onended;
  110598. /**
  110599. * Stop the sound
  110600. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110601. */
  110602. stop(time?: number): void;
  110603. /**
  110604. * Put the sound in pause
  110605. */
  110606. pause(): void;
  110607. /**
  110608. * Sets a dedicated volume for this sounds
  110609. * @param newVolume Define the new volume of the sound
  110610. * @param time Define time for gradual change to new volume
  110611. */
  110612. setVolume(newVolume: number, time?: number): void;
  110613. /**
  110614. * Set the sound play back rate
  110615. * @param newPlaybackRate Define the playback rate the sound should be played at
  110616. */
  110617. setPlaybackRate(newPlaybackRate: number): void;
  110618. /**
  110619. * Gets the volume of the sound.
  110620. * @returns the volume of the sound
  110621. */
  110622. getVolume(): number;
  110623. /**
  110624. * Attach the sound to a dedicated mesh
  110625. * @param transformNode The transform node to connect the sound with
  110626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110627. */
  110628. attachToMesh(transformNode: TransformNode): void;
  110629. /**
  110630. * Detach the sound from the previously attached mesh
  110631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110632. */
  110633. detachFromMesh(): void;
  110634. private _onRegisterAfterWorldMatrixUpdate;
  110635. /**
  110636. * Clone the current sound in the scene.
  110637. * @returns the new sound clone
  110638. */
  110639. clone(): Nullable<Sound>;
  110640. /**
  110641. * Gets the current underlying audio buffer containing the data
  110642. * @returns the audio buffer
  110643. */
  110644. getAudioBuffer(): Nullable<AudioBuffer>;
  110645. /**
  110646. * Serializes the Sound in a JSON representation
  110647. * @returns the JSON representation of the sound
  110648. */
  110649. serialize(): any;
  110650. /**
  110651. * Parse a JSON representation of a sound to innstantiate in a given scene
  110652. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110653. * @param scene Define the scene the new parsed sound should be created in
  110654. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110655. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110656. * @returns the newly parsed sound
  110657. */
  110658. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110659. }
  110660. }
  110661. declare module BABYLON {
  110662. /**
  110663. * This defines an action helpful to play a defined sound on a triggered action.
  110664. */
  110665. export class PlaySoundAction extends Action {
  110666. private _sound;
  110667. /**
  110668. * Instantiate the action
  110669. * @param triggerOptions defines the trigger options
  110670. * @param sound defines the sound to play
  110671. * @param condition defines the trigger related conditions
  110672. */
  110673. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110674. /** @hidden */
  110675. _prepare(): void;
  110676. /**
  110677. * Execute the action and play the sound.
  110678. */
  110679. execute(): void;
  110680. /**
  110681. * Serializes the actions and its related information.
  110682. * @param parent defines the object to serialize in
  110683. * @returns the serialized object
  110684. */
  110685. serialize(parent: any): any;
  110686. }
  110687. /**
  110688. * This defines an action helpful to stop a defined sound on a triggered action.
  110689. */
  110690. export class StopSoundAction extends Action {
  110691. private _sound;
  110692. /**
  110693. * Instantiate the action
  110694. * @param triggerOptions defines the trigger options
  110695. * @param sound defines the sound to stop
  110696. * @param condition defines the trigger related conditions
  110697. */
  110698. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110699. /** @hidden */
  110700. _prepare(): void;
  110701. /**
  110702. * Execute the action and stop the sound.
  110703. */
  110704. execute(): void;
  110705. /**
  110706. * Serializes the actions and its related information.
  110707. * @param parent defines the object to serialize in
  110708. * @returns the serialized object
  110709. */
  110710. serialize(parent: any): any;
  110711. }
  110712. }
  110713. declare module BABYLON {
  110714. /**
  110715. * This defines an action responsible to change the value of a property
  110716. * by interpolating between its current value and the newly set one once triggered.
  110717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110718. */
  110719. export class InterpolateValueAction extends Action {
  110720. /**
  110721. * Defines the path of the property where the value should be interpolated
  110722. */
  110723. propertyPath: string;
  110724. /**
  110725. * Defines the target value at the end of the interpolation.
  110726. */
  110727. value: any;
  110728. /**
  110729. * Defines the time it will take for the property to interpolate to the value.
  110730. */
  110731. duration: number;
  110732. /**
  110733. * Defines if the other scene animations should be stopped when the action has been triggered
  110734. */
  110735. stopOtherAnimations?: boolean;
  110736. /**
  110737. * Defines a callback raised once the interpolation animation has been done.
  110738. */
  110739. onInterpolationDone?: () => void;
  110740. /**
  110741. * Observable triggered once the interpolation animation has been done.
  110742. */
  110743. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110744. private _target;
  110745. private _effectiveTarget;
  110746. private _property;
  110747. /**
  110748. * Instantiate the action
  110749. * @param triggerOptions defines the trigger options
  110750. * @param target defines the object containing the value to interpolate
  110751. * @param propertyPath defines the path to the property in the target object
  110752. * @param value defines the target value at the end of the interpolation
  110753. * @param duration deines the time it will take for the property to interpolate to the value.
  110754. * @param condition defines the trigger related conditions
  110755. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110756. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110757. */
  110758. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110759. /** @hidden */
  110760. _prepare(): void;
  110761. /**
  110762. * Execute the action starts the value interpolation.
  110763. */
  110764. execute(): void;
  110765. /**
  110766. * Serializes the actions and its related information.
  110767. * @param parent defines the object to serialize in
  110768. * @returns the serialized object
  110769. */
  110770. serialize(parent: any): any;
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /**
  110775. * Options allowed during the creation of a sound track.
  110776. */
  110777. export interface ISoundTrackOptions {
  110778. /**
  110779. * The volume the sound track should take during creation
  110780. */
  110781. volume?: number;
  110782. /**
  110783. * Define if the sound track is the main sound track of the scene
  110784. */
  110785. mainTrack?: boolean;
  110786. }
  110787. /**
  110788. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110789. * It will be also used in a future release to apply effects on a specific track.
  110790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110791. */
  110792. export class SoundTrack {
  110793. /**
  110794. * The unique identifier of the sound track in the scene.
  110795. */
  110796. id: number;
  110797. /**
  110798. * The list of sounds included in the sound track.
  110799. */
  110800. soundCollection: Array<Sound>;
  110801. private _outputAudioNode;
  110802. private _scene;
  110803. private _connectedAnalyser;
  110804. private _options;
  110805. private _isInitialized;
  110806. /**
  110807. * Creates a new sound track.
  110808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110809. * @param scene Define the scene the sound track belongs to
  110810. * @param options
  110811. */
  110812. constructor(scene: Scene, options?: ISoundTrackOptions);
  110813. private _initializeSoundTrackAudioGraph;
  110814. /**
  110815. * Release the sound track and its associated resources
  110816. */
  110817. dispose(): void;
  110818. /**
  110819. * Adds a sound to this sound track
  110820. * @param sound define the cound to add
  110821. * @ignoreNaming
  110822. */
  110823. AddSound(sound: Sound): void;
  110824. /**
  110825. * Removes a sound to this sound track
  110826. * @param sound define the cound to remove
  110827. * @ignoreNaming
  110828. */
  110829. RemoveSound(sound: Sound): void;
  110830. /**
  110831. * Set a global volume for the full sound track.
  110832. * @param newVolume Define the new volume of the sound track
  110833. */
  110834. setVolume(newVolume: number): void;
  110835. /**
  110836. * Switch the panning model to HRTF:
  110837. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110839. */
  110840. switchPanningModelToHRTF(): void;
  110841. /**
  110842. * Switch the panning model to Equal Power:
  110843. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110845. */
  110846. switchPanningModelToEqualPower(): void;
  110847. /**
  110848. * Connect the sound track to an audio analyser allowing some amazing
  110849. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110851. * @param analyser The analyser to connect to the engine
  110852. */
  110853. connectToAnalyser(analyser: Analyser): void;
  110854. }
  110855. }
  110856. declare module BABYLON {
  110857. interface AbstractScene {
  110858. /**
  110859. * The list of sounds used in the scene.
  110860. */
  110861. sounds: Nullable<Array<Sound>>;
  110862. }
  110863. interface Scene {
  110864. /**
  110865. * @hidden
  110866. * Backing field
  110867. */
  110868. _mainSoundTrack: SoundTrack;
  110869. /**
  110870. * The main sound track played by the scene.
  110871. * It cotains your primary collection of sounds.
  110872. */
  110873. mainSoundTrack: SoundTrack;
  110874. /**
  110875. * The list of sound tracks added to the scene
  110876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110877. */
  110878. soundTracks: Nullable<Array<SoundTrack>>;
  110879. /**
  110880. * Gets a sound using a given name
  110881. * @param name defines the name to search for
  110882. * @return the found sound or null if not found at all.
  110883. */
  110884. getSoundByName(name: string): Nullable<Sound>;
  110885. /**
  110886. * Gets or sets if audio support is enabled
  110887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110888. */
  110889. audioEnabled: boolean;
  110890. /**
  110891. * Gets or sets if audio will be output to headphones
  110892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110893. */
  110894. headphone: boolean;
  110895. /**
  110896. * Gets or sets custom audio listener position provider
  110897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110898. */
  110899. audioListenerPositionProvider: Nullable<() => Vector3>;
  110900. /**
  110901. * Gets or sets a refresh rate when using 3D audio positioning
  110902. */
  110903. audioPositioningRefreshRate: number;
  110904. }
  110905. /**
  110906. * Defines the sound scene component responsible to manage any sounds
  110907. * in a given scene.
  110908. */
  110909. export class AudioSceneComponent implements ISceneSerializableComponent {
  110910. /**
  110911. * The component name helpfull to identify the component in the list of scene components.
  110912. */
  110913. readonly name: string;
  110914. /**
  110915. * The scene the component belongs to.
  110916. */
  110917. scene: Scene;
  110918. private _audioEnabled;
  110919. /**
  110920. * Gets whether audio is enabled or not.
  110921. * Please use related enable/disable method to switch state.
  110922. */
  110923. get audioEnabled(): boolean;
  110924. private _headphone;
  110925. /**
  110926. * Gets whether audio is outputing to headphone or not.
  110927. * Please use the according Switch methods to change output.
  110928. */
  110929. get headphone(): boolean;
  110930. /**
  110931. * Gets or sets a refresh rate when using 3D audio positioning
  110932. */
  110933. audioPositioningRefreshRate: number;
  110934. private _audioListenerPositionProvider;
  110935. /**
  110936. * Gets the current audio listener position provider
  110937. */
  110938. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110939. /**
  110940. * Sets a custom listener position for all sounds in the scene
  110941. * By default, this is the position of the first active camera
  110942. */
  110943. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110944. /**
  110945. * Creates a new instance of the component for the given scene
  110946. * @param scene Defines the scene to register the component in
  110947. */
  110948. constructor(scene: Scene);
  110949. /**
  110950. * Registers the component in a given scene
  110951. */
  110952. register(): void;
  110953. /**
  110954. * Rebuilds the elements related to this component in case of
  110955. * context lost for instance.
  110956. */
  110957. rebuild(): void;
  110958. /**
  110959. * Serializes the component data to the specified json object
  110960. * @param serializationObject The object to serialize to
  110961. */
  110962. serialize(serializationObject: any): void;
  110963. /**
  110964. * Adds all the elements from the container to the scene
  110965. * @param container the container holding the elements
  110966. */
  110967. addFromContainer(container: AbstractScene): void;
  110968. /**
  110969. * Removes all the elements in the container from the scene
  110970. * @param container contains the elements to remove
  110971. * @param dispose if the removed element should be disposed (default: false)
  110972. */
  110973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110974. /**
  110975. * Disposes the component and the associated ressources.
  110976. */
  110977. dispose(): void;
  110978. /**
  110979. * Disables audio in the associated scene.
  110980. */
  110981. disableAudio(): void;
  110982. /**
  110983. * Enables audio in the associated scene.
  110984. */
  110985. enableAudio(): void;
  110986. /**
  110987. * Switch audio to headphone output.
  110988. */
  110989. switchAudioModeForHeadphones(): void;
  110990. /**
  110991. * Switch audio to normal speakers.
  110992. */
  110993. switchAudioModeForNormalSpeakers(): void;
  110994. private _cachedCameraDirection;
  110995. private _cachedCameraPosition;
  110996. private _lastCheck;
  110997. private _afterRender;
  110998. }
  110999. }
  111000. declare module BABYLON {
  111001. /**
  111002. * Wraps one or more Sound objects and selects one with random weight for playback.
  111003. */
  111004. export class WeightedSound {
  111005. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111006. loop: boolean;
  111007. private _coneInnerAngle;
  111008. private _coneOuterAngle;
  111009. private _volume;
  111010. /** A Sound is currently playing. */
  111011. isPlaying: boolean;
  111012. /** A Sound is currently paused. */
  111013. isPaused: boolean;
  111014. private _sounds;
  111015. private _weights;
  111016. private _currentIndex?;
  111017. /**
  111018. * Creates a new WeightedSound from the list of sounds given.
  111019. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111020. * @param sounds Array of Sounds that will be selected from.
  111021. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111022. */
  111023. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111024. /**
  111025. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111026. */
  111027. get directionalConeInnerAngle(): number;
  111028. /**
  111029. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111030. */
  111031. set directionalConeInnerAngle(value: number);
  111032. /**
  111033. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111034. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111035. */
  111036. get directionalConeOuterAngle(): number;
  111037. /**
  111038. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111039. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111040. */
  111041. set directionalConeOuterAngle(value: number);
  111042. /**
  111043. * Playback volume.
  111044. */
  111045. get volume(): number;
  111046. /**
  111047. * Playback volume.
  111048. */
  111049. set volume(value: number);
  111050. private _onended;
  111051. /**
  111052. * Suspend playback
  111053. */
  111054. pause(): void;
  111055. /**
  111056. * Stop playback
  111057. */
  111058. stop(): void;
  111059. /**
  111060. * Start playback.
  111061. * @param startOffset Position the clip head at a specific time in seconds.
  111062. */
  111063. play(startOffset?: number): void;
  111064. }
  111065. }
  111066. declare module BABYLON {
  111067. /**
  111068. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111069. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111070. */
  111071. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111072. /**
  111073. * Gets the name of the behavior.
  111074. */
  111075. get name(): string;
  111076. /**
  111077. * The easing function used by animations
  111078. */
  111079. static EasingFunction: BackEase;
  111080. /**
  111081. * The easing mode used by animations
  111082. */
  111083. static EasingMode: number;
  111084. /**
  111085. * The duration of the animation, in milliseconds
  111086. */
  111087. transitionDuration: number;
  111088. /**
  111089. * Length of the distance animated by the transition when lower radius is reached
  111090. */
  111091. lowerRadiusTransitionRange: number;
  111092. /**
  111093. * Length of the distance animated by the transition when upper radius is reached
  111094. */
  111095. upperRadiusTransitionRange: number;
  111096. private _autoTransitionRange;
  111097. /**
  111098. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111099. */
  111100. get autoTransitionRange(): boolean;
  111101. /**
  111102. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111103. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111104. */
  111105. set autoTransitionRange(value: boolean);
  111106. private _attachedCamera;
  111107. private _onAfterCheckInputsObserver;
  111108. private _onMeshTargetChangedObserver;
  111109. /**
  111110. * Initializes the behavior.
  111111. */
  111112. init(): void;
  111113. /**
  111114. * Attaches the behavior to its arc rotate camera.
  111115. * @param camera Defines the camera to attach the behavior to
  111116. */
  111117. attach(camera: ArcRotateCamera): void;
  111118. /**
  111119. * Detaches the behavior from its current arc rotate camera.
  111120. */
  111121. detach(): void;
  111122. private _radiusIsAnimating;
  111123. private _radiusBounceTransition;
  111124. private _animatables;
  111125. private _cachedWheelPrecision;
  111126. /**
  111127. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111128. * @param radiusLimit The limit to check against.
  111129. * @return Bool to indicate if at limit.
  111130. */
  111131. private _isRadiusAtLimit;
  111132. /**
  111133. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111134. * @param radiusDelta The delta by which to animate to. Can be negative.
  111135. */
  111136. private _applyBoundRadiusAnimation;
  111137. /**
  111138. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111139. */
  111140. protected _clearAnimationLocks(): void;
  111141. /**
  111142. * Stops and removes all animations that have been applied to the camera
  111143. */
  111144. stopAllAnimations(): void;
  111145. }
  111146. }
  111147. declare module BABYLON {
  111148. /**
  111149. * 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.
  111150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111151. */
  111152. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111153. /**
  111154. * Gets the name of the behavior.
  111155. */
  111156. get name(): string;
  111157. private _mode;
  111158. private _radiusScale;
  111159. private _positionScale;
  111160. private _defaultElevation;
  111161. private _elevationReturnTime;
  111162. private _elevationReturnWaitTime;
  111163. private _zoomStopsAnimation;
  111164. private _framingTime;
  111165. /**
  111166. * The easing function used by animations
  111167. */
  111168. static EasingFunction: ExponentialEase;
  111169. /**
  111170. * The easing mode used by animations
  111171. */
  111172. static EasingMode: number;
  111173. /**
  111174. * Sets the current mode used by the behavior
  111175. */
  111176. set mode(mode: number);
  111177. /**
  111178. * Gets current mode used by the behavior.
  111179. */
  111180. get mode(): number;
  111181. /**
  111182. * Sets the scale applied to the radius (1 by default)
  111183. */
  111184. set radiusScale(radius: number);
  111185. /**
  111186. * Gets the scale applied to the radius
  111187. */
  111188. get radiusScale(): number;
  111189. /**
  111190. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111191. */
  111192. set positionScale(scale: number);
  111193. /**
  111194. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111195. */
  111196. get positionScale(): number;
  111197. /**
  111198. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111199. * behaviour is triggered, in radians.
  111200. */
  111201. set defaultElevation(elevation: number);
  111202. /**
  111203. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111204. * behaviour is triggered, in radians.
  111205. */
  111206. get defaultElevation(): number;
  111207. /**
  111208. * Sets the time (in milliseconds) taken to return to the default beta position.
  111209. * Negative value indicates camera should not return to default.
  111210. */
  111211. set elevationReturnTime(speed: number);
  111212. /**
  111213. * Gets the time (in milliseconds) taken to return to the default beta position.
  111214. * Negative value indicates camera should not return to default.
  111215. */
  111216. get elevationReturnTime(): number;
  111217. /**
  111218. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111219. */
  111220. set elevationReturnWaitTime(time: number);
  111221. /**
  111222. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111223. */
  111224. get elevationReturnWaitTime(): number;
  111225. /**
  111226. * Sets the flag that indicates if user zooming should stop animation.
  111227. */
  111228. set zoomStopsAnimation(flag: boolean);
  111229. /**
  111230. * Gets the flag that indicates if user zooming should stop animation.
  111231. */
  111232. get zoomStopsAnimation(): boolean;
  111233. /**
  111234. * Sets the transition time when framing the mesh, in milliseconds
  111235. */
  111236. set framingTime(time: number);
  111237. /**
  111238. * Gets the transition time when framing the mesh, in milliseconds
  111239. */
  111240. get framingTime(): number;
  111241. /**
  111242. * Define if the behavior should automatically change the configured
  111243. * camera limits and sensibilities.
  111244. */
  111245. autoCorrectCameraLimitsAndSensibility: boolean;
  111246. private _onPrePointerObservableObserver;
  111247. private _onAfterCheckInputsObserver;
  111248. private _onMeshTargetChangedObserver;
  111249. private _attachedCamera;
  111250. private _isPointerDown;
  111251. private _lastInteractionTime;
  111252. /**
  111253. * Initializes the behavior.
  111254. */
  111255. init(): void;
  111256. /**
  111257. * Attaches the behavior to its arc rotate camera.
  111258. * @param camera Defines the camera to attach the behavior to
  111259. */
  111260. attach(camera: ArcRotateCamera): void;
  111261. /**
  111262. * Detaches the behavior from its current arc rotate camera.
  111263. */
  111264. detach(): void;
  111265. private _animatables;
  111266. private _betaIsAnimating;
  111267. private _betaTransition;
  111268. private _radiusTransition;
  111269. private _vectorTransition;
  111270. /**
  111271. * Targets the given mesh and updates zoom level accordingly.
  111272. * @param mesh The mesh to target.
  111273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111275. */
  111276. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111277. /**
  111278. * Targets the given mesh with its children and updates zoom level accordingly.
  111279. * @param mesh The mesh to target.
  111280. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111281. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111282. */
  111283. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111284. /**
  111285. * Targets the given meshes with their children and updates zoom level accordingly.
  111286. * @param meshes The mesh to target.
  111287. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111288. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111289. */
  111290. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111291. /**
  111292. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111293. * @param minimumWorld Determines the smaller position of the bounding box extend
  111294. * @param maximumWorld Determines the bigger position of the bounding box extend
  111295. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111296. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111297. */
  111298. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111299. /**
  111300. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111301. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111302. * frustum width.
  111303. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111304. * to fully enclose the mesh in the viewing frustum.
  111305. */
  111306. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111307. /**
  111308. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111309. * is automatically returned to its default position (expected to be above ground plane).
  111310. */
  111311. private _maintainCameraAboveGround;
  111312. /**
  111313. * Returns the frustum slope based on the canvas ratio and camera FOV
  111314. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111315. */
  111316. private _getFrustumSlope;
  111317. /**
  111318. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111319. */
  111320. private _clearAnimationLocks;
  111321. /**
  111322. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111323. */
  111324. private _applyUserInteraction;
  111325. /**
  111326. * Stops and removes all animations that have been applied to the camera
  111327. */
  111328. stopAllAnimations(): void;
  111329. /**
  111330. * Gets a value indicating if the user is moving the camera
  111331. */
  111332. get isUserIsMoving(): boolean;
  111333. /**
  111334. * The camera can move all the way towards the mesh.
  111335. */
  111336. static IgnoreBoundsSizeMode: number;
  111337. /**
  111338. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111339. */
  111340. static FitFrustumSidesMode: number;
  111341. }
  111342. }
  111343. declare module BABYLON {
  111344. /**
  111345. * Base class for Camera Pointer Inputs.
  111346. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111347. * for example usage.
  111348. */
  111349. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111350. /**
  111351. * Defines the camera the input is attached to.
  111352. */
  111353. abstract camera: Camera;
  111354. /**
  111355. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111356. */
  111357. protected _altKey: boolean;
  111358. protected _ctrlKey: boolean;
  111359. protected _metaKey: boolean;
  111360. protected _shiftKey: boolean;
  111361. /**
  111362. * Which mouse buttons were pressed at time of last mouse event.
  111363. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111364. */
  111365. protected _buttonsPressed: number;
  111366. /**
  111367. * Defines the buttons associated with the input to handle camera move.
  111368. */
  111369. buttons: number[];
  111370. /**
  111371. * Attach the input controls to a specific dom element to get the input from.
  111372. * @param element Defines the element the controls should be listened from
  111373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111374. */
  111375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111376. /**
  111377. * Detach the current controls from the specified dom element.
  111378. * @param element Defines the element to stop listening the inputs from
  111379. */
  111380. detachControl(element: Nullable<HTMLElement>): void;
  111381. /**
  111382. * Gets the class name of the current input.
  111383. * @returns the class name
  111384. */
  111385. getClassName(): string;
  111386. /**
  111387. * Get the friendly name associated with the input class.
  111388. * @returns the input friendly name
  111389. */
  111390. getSimpleName(): string;
  111391. /**
  111392. * Called on pointer POINTERDOUBLETAP event.
  111393. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111394. */
  111395. protected onDoubleTap(type: string): void;
  111396. /**
  111397. * Called on pointer POINTERMOVE event if only a single touch is active.
  111398. * Override this method to provide functionality.
  111399. */
  111400. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111401. /**
  111402. * Called on pointer POINTERMOVE event if multiple touches are active.
  111403. * Override this method to provide functionality.
  111404. */
  111405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111406. /**
  111407. * Called on JS contextmenu event.
  111408. * Override this method to provide functionality.
  111409. */
  111410. protected onContextMenu(evt: PointerEvent): void;
  111411. /**
  111412. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111413. * press.
  111414. * Override this method to provide functionality.
  111415. */
  111416. protected onButtonDown(evt: PointerEvent): void;
  111417. /**
  111418. * Called each time a new POINTERUP event occurs. Ie, for each button
  111419. * release.
  111420. * Override this method to provide functionality.
  111421. */
  111422. protected onButtonUp(evt: PointerEvent): void;
  111423. /**
  111424. * Called when window becomes inactive.
  111425. * Override this method to provide functionality.
  111426. */
  111427. protected onLostFocus(): void;
  111428. private _pointerInput;
  111429. private _observer;
  111430. private _onLostFocus;
  111431. private pointA;
  111432. private pointB;
  111433. }
  111434. }
  111435. declare module BABYLON {
  111436. /**
  111437. * Manage the pointers inputs to control an arc rotate camera.
  111438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111439. */
  111440. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111441. /**
  111442. * Defines the camera the input is attached to.
  111443. */
  111444. camera: ArcRotateCamera;
  111445. /**
  111446. * Gets the class name of the current input.
  111447. * @returns the class name
  111448. */
  111449. getClassName(): string;
  111450. /**
  111451. * Defines the buttons associated with the input to handle camera move.
  111452. */
  111453. buttons: number[];
  111454. /**
  111455. * Defines the pointer angular sensibility along the X axis or how fast is
  111456. * the camera rotating.
  111457. */
  111458. angularSensibilityX: number;
  111459. /**
  111460. * Defines the pointer angular sensibility along the Y axis or how fast is
  111461. * the camera rotating.
  111462. */
  111463. angularSensibilityY: number;
  111464. /**
  111465. * Defines the pointer pinch precision or how fast is the camera zooming.
  111466. */
  111467. pinchPrecision: number;
  111468. /**
  111469. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111470. * from 0.
  111471. * It defines the percentage of current camera.radius to use as delta when
  111472. * pinch zoom is used.
  111473. */
  111474. pinchDeltaPercentage: number;
  111475. /**
  111476. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111477. * that any object in the plane at the camera's target point will scale
  111478. * perfectly with finger motion.
  111479. * Overrides pinchDeltaPercentage and pinchPrecision.
  111480. */
  111481. useNaturalPinchZoom: boolean;
  111482. /**
  111483. * Defines the pointer panning sensibility or how fast is the camera moving.
  111484. */
  111485. panningSensibility: number;
  111486. /**
  111487. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111488. */
  111489. multiTouchPanning: boolean;
  111490. /**
  111491. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111492. * zoom (pinch) through multitouch.
  111493. */
  111494. multiTouchPanAndZoom: boolean;
  111495. /**
  111496. * Revers pinch action direction.
  111497. */
  111498. pinchInwards: boolean;
  111499. private _isPanClick;
  111500. private _twoFingerActivityCount;
  111501. private _isPinching;
  111502. /**
  111503. * Called on pointer POINTERMOVE event if only a single touch is active.
  111504. */
  111505. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111506. /**
  111507. * Called on pointer POINTERDOUBLETAP event.
  111508. */
  111509. protected onDoubleTap(type: string): void;
  111510. /**
  111511. * Called on pointer POINTERMOVE event if multiple touches are active.
  111512. */
  111513. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111514. /**
  111515. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111516. * press.
  111517. */
  111518. protected onButtonDown(evt: PointerEvent): void;
  111519. /**
  111520. * Called each time a new POINTERUP event occurs. Ie, for each button
  111521. * release.
  111522. */
  111523. protected onButtonUp(evt: PointerEvent): void;
  111524. /**
  111525. * Called when window becomes inactive.
  111526. */
  111527. protected onLostFocus(): void;
  111528. }
  111529. }
  111530. declare module BABYLON {
  111531. /**
  111532. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111534. */
  111535. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111536. /**
  111537. * Defines the camera the input is attached to.
  111538. */
  111539. camera: ArcRotateCamera;
  111540. /**
  111541. * Defines the list of key codes associated with the up action (increase alpha)
  111542. */
  111543. keysUp: number[];
  111544. /**
  111545. * Defines the list of key codes associated with the down action (decrease alpha)
  111546. */
  111547. keysDown: number[];
  111548. /**
  111549. * Defines the list of key codes associated with the left action (increase beta)
  111550. */
  111551. keysLeft: number[];
  111552. /**
  111553. * Defines the list of key codes associated with the right action (decrease beta)
  111554. */
  111555. keysRight: number[];
  111556. /**
  111557. * Defines the list of key codes associated with the reset action.
  111558. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111559. */
  111560. keysReset: number[];
  111561. /**
  111562. * Defines the panning sensibility of the inputs.
  111563. * (How fast is the camera panning)
  111564. */
  111565. panningSensibility: number;
  111566. /**
  111567. * Defines the zooming sensibility of the inputs.
  111568. * (How fast is the camera zooming)
  111569. */
  111570. zoomingSensibility: number;
  111571. /**
  111572. * Defines whether maintaining the alt key down switch the movement mode from
  111573. * orientation to zoom.
  111574. */
  111575. useAltToZoom: boolean;
  111576. /**
  111577. * Rotation speed of the camera
  111578. */
  111579. angularSpeed: number;
  111580. private _keys;
  111581. private _ctrlPressed;
  111582. private _altPressed;
  111583. private _onCanvasBlurObserver;
  111584. private _onKeyboardObserver;
  111585. private _engine;
  111586. private _scene;
  111587. /**
  111588. * Attach the input controls to a specific dom element to get the input from.
  111589. * @param element Defines the element the controls should be listened from
  111590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111591. */
  111592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111593. /**
  111594. * Detach the current controls from the specified dom element.
  111595. * @param element Defines the element to stop listening the inputs from
  111596. */
  111597. detachControl(element: Nullable<HTMLElement>): void;
  111598. /**
  111599. * Update the current camera state depending on the inputs that have been used this frame.
  111600. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111601. */
  111602. checkInputs(): void;
  111603. /**
  111604. * Gets the class name of the current intput.
  111605. * @returns the class name
  111606. */
  111607. getClassName(): string;
  111608. /**
  111609. * Get the friendly name associated with the input class.
  111610. * @returns the input friendly name
  111611. */
  111612. getSimpleName(): string;
  111613. }
  111614. }
  111615. declare module BABYLON {
  111616. /**
  111617. * Manage the mouse wheel inputs to control an arc rotate camera.
  111618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111619. */
  111620. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111621. /**
  111622. * Defines the camera the input is attached to.
  111623. */
  111624. camera: ArcRotateCamera;
  111625. /**
  111626. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111627. */
  111628. wheelPrecision: number;
  111629. /**
  111630. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111631. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111632. */
  111633. wheelDeltaPercentage: number;
  111634. private _wheel;
  111635. private _observer;
  111636. private computeDeltaFromMouseWheelLegacyEvent;
  111637. /**
  111638. * Attach the input controls to a specific dom element to get the input from.
  111639. * @param element Defines the element the controls should be listened from
  111640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111641. */
  111642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111643. /**
  111644. * Detach the current controls from the specified dom element.
  111645. * @param element Defines the element to stop listening the inputs from
  111646. */
  111647. detachControl(element: Nullable<HTMLElement>): void;
  111648. /**
  111649. * Gets the class name of the current intput.
  111650. * @returns the class name
  111651. */
  111652. getClassName(): string;
  111653. /**
  111654. * Get the friendly name associated with the input class.
  111655. * @returns the input friendly name
  111656. */
  111657. getSimpleName(): string;
  111658. }
  111659. }
  111660. declare module BABYLON {
  111661. /**
  111662. * Default Inputs manager for the ArcRotateCamera.
  111663. * It groups all the default supported inputs for ease of use.
  111664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111665. */
  111666. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111667. /**
  111668. * Instantiates a new ArcRotateCameraInputsManager.
  111669. * @param camera Defines the camera the inputs belong to
  111670. */
  111671. constructor(camera: ArcRotateCamera);
  111672. /**
  111673. * Add mouse wheel input support to the input manager.
  111674. * @returns the current input manager
  111675. */
  111676. addMouseWheel(): ArcRotateCameraInputsManager;
  111677. /**
  111678. * Add pointers input support to the input manager.
  111679. * @returns the current input manager
  111680. */
  111681. addPointers(): ArcRotateCameraInputsManager;
  111682. /**
  111683. * Add keyboard input support to the input manager.
  111684. * @returns the current input manager
  111685. */
  111686. addKeyboard(): ArcRotateCameraInputsManager;
  111687. }
  111688. }
  111689. declare module BABYLON {
  111690. /**
  111691. * This represents an orbital type of camera.
  111692. *
  111693. * 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.
  111694. * 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.
  111695. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111696. */
  111697. export class ArcRotateCamera extends TargetCamera {
  111698. /**
  111699. * Defines the rotation angle of the camera along the longitudinal axis.
  111700. */
  111701. alpha: number;
  111702. /**
  111703. * Defines the rotation angle of the camera along the latitudinal axis.
  111704. */
  111705. beta: number;
  111706. /**
  111707. * Defines the radius of the camera from it s target point.
  111708. */
  111709. radius: number;
  111710. protected _target: Vector3;
  111711. protected _targetHost: Nullable<AbstractMesh>;
  111712. /**
  111713. * Defines the target point of the camera.
  111714. * The camera looks towards it form the radius distance.
  111715. */
  111716. get target(): Vector3;
  111717. set target(value: Vector3);
  111718. /**
  111719. * Define the current local position of the camera in the scene
  111720. */
  111721. get position(): Vector3;
  111722. set position(newPosition: Vector3);
  111723. protected _upVector: Vector3;
  111724. protected _upToYMatrix: Matrix;
  111725. protected _YToUpMatrix: Matrix;
  111726. /**
  111727. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111728. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111729. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111730. */
  111731. set upVector(vec: Vector3);
  111732. get upVector(): Vector3;
  111733. /**
  111734. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111735. */
  111736. setMatUp(): void;
  111737. /**
  111738. * Current inertia value on the longitudinal axis.
  111739. * The bigger this number the longer it will take for the camera to stop.
  111740. */
  111741. inertialAlphaOffset: number;
  111742. /**
  111743. * Current inertia value on the latitudinal axis.
  111744. * The bigger this number the longer it will take for the camera to stop.
  111745. */
  111746. inertialBetaOffset: number;
  111747. /**
  111748. * Current inertia value on the radius axis.
  111749. * The bigger this number the longer it will take for the camera to stop.
  111750. */
  111751. inertialRadiusOffset: number;
  111752. /**
  111753. * Minimum allowed angle on the longitudinal axis.
  111754. * This can help limiting how the Camera is able to move in the scene.
  111755. */
  111756. lowerAlphaLimit: Nullable<number>;
  111757. /**
  111758. * Maximum allowed angle on the longitudinal axis.
  111759. * This can help limiting how the Camera is able to move in the scene.
  111760. */
  111761. upperAlphaLimit: Nullable<number>;
  111762. /**
  111763. * Minimum allowed angle on the latitudinal axis.
  111764. * This can help limiting how the Camera is able to move in the scene.
  111765. */
  111766. lowerBetaLimit: number;
  111767. /**
  111768. * Maximum allowed angle on the latitudinal axis.
  111769. * This can help limiting how the Camera is able to move in the scene.
  111770. */
  111771. upperBetaLimit: number;
  111772. /**
  111773. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111774. * This can help limiting how the Camera is able to move in the scene.
  111775. */
  111776. lowerRadiusLimit: Nullable<number>;
  111777. /**
  111778. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111779. * This can help limiting how the Camera is able to move in the scene.
  111780. */
  111781. upperRadiusLimit: Nullable<number>;
  111782. /**
  111783. * Defines the current inertia value used during panning of the camera along the X axis.
  111784. */
  111785. inertialPanningX: number;
  111786. /**
  111787. * Defines the current inertia value used during panning of the camera along the Y axis.
  111788. */
  111789. inertialPanningY: number;
  111790. /**
  111791. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111792. * Basically if your fingers moves away from more than this distance you will be considered
  111793. * in pinch mode.
  111794. */
  111795. pinchToPanMaxDistance: number;
  111796. /**
  111797. * Defines the maximum distance the camera can pan.
  111798. * This could help keeping the cammera always in your scene.
  111799. */
  111800. panningDistanceLimit: Nullable<number>;
  111801. /**
  111802. * Defines the target of the camera before paning.
  111803. */
  111804. panningOriginTarget: Vector3;
  111805. /**
  111806. * Defines the value of the inertia used during panning.
  111807. * 0 would mean stop inertia and one would mean no decelleration at all.
  111808. */
  111809. panningInertia: number;
  111810. /**
  111811. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111812. */
  111813. get angularSensibilityX(): number;
  111814. set angularSensibilityX(value: number);
  111815. /**
  111816. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111817. */
  111818. get angularSensibilityY(): number;
  111819. set angularSensibilityY(value: number);
  111820. /**
  111821. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111822. */
  111823. get pinchPrecision(): number;
  111824. set pinchPrecision(value: number);
  111825. /**
  111826. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111827. * It will be used instead of pinchDeltaPrecision if different from 0.
  111828. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111829. */
  111830. get pinchDeltaPercentage(): number;
  111831. set pinchDeltaPercentage(value: number);
  111832. /**
  111833. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111834. * and pinch delta percentage.
  111835. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111836. * that any object in the plane at the camera's target point will scale
  111837. * perfectly with finger motion.
  111838. */
  111839. get useNaturalPinchZoom(): boolean;
  111840. set useNaturalPinchZoom(value: boolean);
  111841. /**
  111842. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111843. */
  111844. get panningSensibility(): number;
  111845. set panningSensibility(value: number);
  111846. /**
  111847. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111848. */
  111849. get keysUp(): number[];
  111850. set keysUp(value: number[]);
  111851. /**
  111852. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111853. */
  111854. get keysDown(): number[];
  111855. set keysDown(value: number[]);
  111856. /**
  111857. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111858. */
  111859. get keysLeft(): number[];
  111860. set keysLeft(value: number[]);
  111861. /**
  111862. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111863. */
  111864. get keysRight(): number[];
  111865. set keysRight(value: number[]);
  111866. /**
  111867. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111868. */
  111869. get wheelPrecision(): number;
  111870. set wheelPrecision(value: number);
  111871. /**
  111872. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111873. * It will be used instead of pinchDeltaPrecision if different from 0.
  111874. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111875. */
  111876. get wheelDeltaPercentage(): number;
  111877. set wheelDeltaPercentage(value: number);
  111878. /**
  111879. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111880. */
  111881. zoomOnFactor: number;
  111882. /**
  111883. * Defines a screen offset for the camera position.
  111884. */
  111885. targetScreenOffset: Vector2;
  111886. /**
  111887. * Allows the camera to be completely reversed.
  111888. * If false the camera can not arrive upside down.
  111889. */
  111890. allowUpsideDown: boolean;
  111891. /**
  111892. * Define if double tap/click is used to restore the previously saved state of the camera.
  111893. */
  111894. useInputToRestoreState: boolean;
  111895. /** @hidden */
  111896. _viewMatrix: Matrix;
  111897. /** @hidden */
  111898. _useCtrlForPanning: boolean;
  111899. /** @hidden */
  111900. _panningMouseButton: number;
  111901. /**
  111902. * Defines the input associated to the camera.
  111903. */
  111904. inputs: ArcRotateCameraInputsManager;
  111905. /** @hidden */
  111906. _reset: () => void;
  111907. /**
  111908. * Defines the allowed panning axis.
  111909. */
  111910. panningAxis: Vector3;
  111911. protected _localDirection: Vector3;
  111912. protected _transformedDirection: Vector3;
  111913. private _bouncingBehavior;
  111914. /**
  111915. * Gets the bouncing behavior of the camera if it has been enabled.
  111916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111917. */
  111918. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111919. /**
  111920. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111922. */
  111923. get useBouncingBehavior(): boolean;
  111924. set useBouncingBehavior(value: boolean);
  111925. private _framingBehavior;
  111926. /**
  111927. * Gets the framing behavior of the camera if it has been enabled.
  111928. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111929. */
  111930. get framingBehavior(): Nullable<FramingBehavior>;
  111931. /**
  111932. * Defines if the framing behavior of the camera is enabled on the camera.
  111933. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111934. */
  111935. get useFramingBehavior(): boolean;
  111936. set useFramingBehavior(value: boolean);
  111937. private _autoRotationBehavior;
  111938. /**
  111939. * Gets the auto rotation behavior of the camera if it has been enabled.
  111940. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111941. */
  111942. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111943. /**
  111944. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111946. */
  111947. get useAutoRotationBehavior(): boolean;
  111948. set useAutoRotationBehavior(value: boolean);
  111949. /**
  111950. * Observable triggered when the mesh target has been changed on the camera.
  111951. */
  111952. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111953. /**
  111954. * Event raised when the camera is colliding with a mesh.
  111955. */
  111956. onCollide: (collidedMesh: AbstractMesh) => void;
  111957. /**
  111958. * Defines whether the camera should check collision with the objects oh the scene.
  111959. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111960. */
  111961. checkCollisions: boolean;
  111962. /**
  111963. * Defines the collision radius of the camera.
  111964. * This simulates a sphere around the camera.
  111965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111966. */
  111967. collisionRadius: Vector3;
  111968. protected _collider: Collider;
  111969. protected _previousPosition: Vector3;
  111970. protected _collisionVelocity: Vector3;
  111971. protected _newPosition: Vector3;
  111972. protected _previousAlpha: number;
  111973. protected _previousBeta: number;
  111974. protected _previousRadius: number;
  111975. protected _collisionTriggered: boolean;
  111976. protected _targetBoundingCenter: Nullable<Vector3>;
  111977. private _computationVector;
  111978. /**
  111979. * Instantiates a new ArcRotateCamera in a given scene
  111980. * @param name Defines the name of the camera
  111981. * @param alpha Defines the camera rotation along the logitudinal axis
  111982. * @param beta Defines the camera rotation along the latitudinal axis
  111983. * @param radius Defines the camera distance from its target
  111984. * @param target Defines the camera target
  111985. * @param scene Defines the scene the camera belongs to
  111986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111987. */
  111988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111989. /** @hidden */
  111990. _initCache(): void;
  111991. /** @hidden */
  111992. _updateCache(ignoreParentClass?: boolean): void;
  111993. protected _getTargetPosition(): Vector3;
  111994. private _storedAlpha;
  111995. private _storedBeta;
  111996. private _storedRadius;
  111997. private _storedTarget;
  111998. private _storedTargetScreenOffset;
  111999. /**
  112000. * Stores the current state of the camera (alpha, beta, radius and target)
  112001. * @returns the camera itself
  112002. */
  112003. storeState(): Camera;
  112004. /**
  112005. * @hidden
  112006. * Restored camera state. You must call storeState() first
  112007. */
  112008. _restoreStateValues(): boolean;
  112009. /** @hidden */
  112010. _isSynchronizedViewMatrix(): boolean;
  112011. /**
  112012. * Attached controls to the current camera.
  112013. * @param element Defines the element the controls should be listened from
  112014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112015. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112016. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112017. */
  112018. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112019. /**
  112020. * Detach the current controls from the camera.
  112021. * The camera will stop reacting to inputs.
  112022. * @param element Defines the element to stop listening the inputs from
  112023. */
  112024. detachControl(element: HTMLElement): void;
  112025. /** @hidden */
  112026. _checkInputs(): void;
  112027. protected _checkLimits(): void;
  112028. /**
  112029. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112030. */
  112031. rebuildAnglesAndRadius(): void;
  112032. /**
  112033. * Use a position to define the current camera related information like alpha, beta and radius
  112034. * @param position Defines the position to set the camera at
  112035. */
  112036. setPosition(position: Vector3): void;
  112037. /**
  112038. * Defines the target the camera should look at.
  112039. * This will automatically adapt alpha beta and radius to fit within the new target.
  112040. * @param target Defines the new target as a Vector or a mesh
  112041. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112042. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112043. */
  112044. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112045. /** @hidden */
  112046. _getViewMatrix(): Matrix;
  112047. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112048. /**
  112049. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112050. * @param meshes Defines the mesh to zoom on
  112051. * @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)
  112052. */
  112053. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112054. /**
  112055. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112056. * The target will be changed but the radius
  112057. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112058. * @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)
  112059. */
  112060. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112061. min: Vector3;
  112062. max: Vector3;
  112063. distance: number;
  112064. }, doNotUpdateMaxZ?: boolean): void;
  112065. /**
  112066. * @override
  112067. * Override Camera.createRigCamera
  112068. */
  112069. createRigCamera(name: string, cameraIndex: number): Camera;
  112070. /**
  112071. * @hidden
  112072. * @override
  112073. * Override Camera._updateRigCameras
  112074. */
  112075. _updateRigCameras(): void;
  112076. /**
  112077. * Destroy the camera and release the current resources hold by it.
  112078. */
  112079. dispose(): void;
  112080. /**
  112081. * Gets the current object class name.
  112082. * @return the class name
  112083. */
  112084. getClassName(): string;
  112085. }
  112086. }
  112087. declare module BABYLON {
  112088. /**
  112089. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112091. */
  112092. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112093. /**
  112094. * Gets the name of the behavior.
  112095. */
  112096. get name(): string;
  112097. private _zoomStopsAnimation;
  112098. private _idleRotationSpeed;
  112099. private _idleRotationWaitTime;
  112100. private _idleRotationSpinupTime;
  112101. /**
  112102. * Sets the flag that indicates if user zooming should stop animation.
  112103. */
  112104. set zoomStopsAnimation(flag: boolean);
  112105. /**
  112106. * Gets the flag that indicates if user zooming should stop animation.
  112107. */
  112108. get zoomStopsAnimation(): boolean;
  112109. /**
  112110. * Sets the default speed at which the camera rotates around the model.
  112111. */
  112112. set idleRotationSpeed(speed: number);
  112113. /**
  112114. * Gets the default speed at which the camera rotates around the model.
  112115. */
  112116. get idleRotationSpeed(): number;
  112117. /**
  112118. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112119. */
  112120. set idleRotationWaitTime(time: number);
  112121. /**
  112122. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112123. */
  112124. get idleRotationWaitTime(): number;
  112125. /**
  112126. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112127. */
  112128. set idleRotationSpinupTime(time: number);
  112129. /**
  112130. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112131. */
  112132. get idleRotationSpinupTime(): number;
  112133. /**
  112134. * Gets a value indicating if the camera is currently rotating because of this behavior
  112135. */
  112136. get rotationInProgress(): boolean;
  112137. private _onPrePointerObservableObserver;
  112138. private _onAfterCheckInputsObserver;
  112139. private _attachedCamera;
  112140. private _isPointerDown;
  112141. private _lastFrameTime;
  112142. private _lastInteractionTime;
  112143. private _cameraRotationSpeed;
  112144. /**
  112145. * Initializes the behavior.
  112146. */
  112147. init(): void;
  112148. /**
  112149. * Attaches the behavior to its arc rotate camera.
  112150. * @param camera Defines the camera to attach the behavior to
  112151. */
  112152. attach(camera: ArcRotateCamera): void;
  112153. /**
  112154. * Detaches the behavior from its current arc rotate camera.
  112155. */
  112156. detach(): void;
  112157. /**
  112158. * Returns true if user is scrolling.
  112159. * @return true if user is scrolling.
  112160. */
  112161. private _userIsZooming;
  112162. private _lastFrameRadius;
  112163. private _shouldAnimationStopForInteraction;
  112164. /**
  112165. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112166. */
  112167. private _applyUserInteraction;
  112168. private _userIsMoving;
  112169. }
  112170. }
  112171. declare module BABYLON {
  112172. /**
  112173. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112174. */
  112175. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112176. private ui;
  112177. /**
  112178. * The name of the behavior
  112179. */
  112180. name: string;
  112181. /**
  112182. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112183. */
  112184. distanceAwayFromFace: number;
  112185. /**
  112186. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112187. */
  112188. distanceAwayFromBottomOfFace: number;
  112189. private _faceVectors;
  112190. private _target;
  112191. private _scene;
  112192. private _onRenderObserver;
  112193. private _tmpMatrix;
  112194. private _tmpVector;
  112195. /**
  112196. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112197. * @param ui The transform node that should be attched to the mesh
  112198. */
  112199. constructor(ui: TransformNode);
  112200. /**
  112201. * Initializes the behavior
  112202. */
  112203. init(): void;
  112204. private _closestFace;
  112205. private _zeroVector;
  112206. private _lookAtTmpMatrix;
  112207. private _lookAtToRef;
  112208. /**
  112209. * Attaches the AttachToBoxBehavior to the passed in mesh
  112210. * @param target The mesh that the specified node will be attached to
  112211. */
  112212. attach(target: Mesh): void;
  112213. /**
  112214. * Detaches the behavior from the mesh
  112215. */
  112216. detach(): void;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112222. */
  112223. export class FadeInOutBehavior implements Behavior<Mesh> {
  112224. /**
  112225. * Time in milliseconds to delay before fading in (Default: 0)
  112226. */
  112227. delay: number;
  112228. /**
  112229. * Time in milliseconds for the mesh to fade in (Default: 300)
  112230. */
  112231. fadeInTime: number;
  112232. private _millisecondsPerFrame;
  112233. private _hovered;
  112234. private _hoverValue;
  112235. private _ownerNode;
  112236. /**
  112237. * Instatiates the FadeInOutBehavior
  112238. */
  112239. constructor();
  112240. /**
  112241. * The name of the behavior
  112242. */
  112243. get name(): string;
  112244. /**
  112245. * Initializes the behavior
  112246. */
  112247. init(): void;
  112248. /**
  112249. * Attaches the fade behavior on the passed in mesh
  112250. * @param ownerNode The mesh that will be faded in/out once attached
  112251. */
  112252. attach(ownerNode: Mesh): void;
  112253. /**
  112254. * Detaches the behavior from the mesh
  112255. */
  112256. detach(): void;
  112257. /**
  112258. * Triggers the mesh to begin fading in or out
  112259. * @param value if the object should fade in or out (true to fade in)
  112260. */
  112261. fadeIn(value: boolean): void;
  112262. private _update;
  112263. private _setAllVisibility;
  112264. }
  112265. }
  112266. declare module BABYLON {
  112267. /**
  112268. * Class containing a set of static utilities functions for managing Pivots
  112269. * @hidden
  112270. */
  112271. export class PivotTools {
  112272. private static _PivotCached;
  112273. private static _OldPivotPoint;
  112274. private static _PivotTranslation;
  112275. private static _PivotTmpVector;
  112276. /** @hidden */
  112277. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112278. /** @hidden */
  112279. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112280. }
  112281. }
  112282. declare module BABYLON {
  112283. /**
  112284. * Class containing static functions to help procedurally build meshes
  112285. */
  112286. export class PlaneBuilder {
  112287. /**
  112288. * Creates a plane mesh
  112289. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112290. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112291. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112295. * @param name defines the name of the mesh
  112296. * @param options defines the options used to create the mesh
  112297. * @param scene defines the hosting scene
  112298. * @returns the plane mesh
  112299. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112300. */
  112301. static CreatePlane(name: string, options: {
  112302. size?: number;
  112303. width?: number;
  112304. height?: number;
  112305. sideOrientation?: number;
  112306. frontUVs?: Vector4;
  112307. backUVs?: Vector4;
  112308. updatable?: boolean;
  112309. sourcePlane?: Plane;
  112310. }, scene?: Nullable<Scene>): Mesh;
  112311. }
  112312. }
  112313. declare module BABYLON {
  112314. /**
  112315. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112316. */
  112317. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112318. private static _AnyMouseID;
  112319. /**
  112320. * Abstract mesh the behavior is set on
  112321. */
  112322. attachedNode: AbstractMesh;
  112323. private _dragPlane;
  112324. private _scene;
  112325. private _pointerObserver;
  112326. private _beforeRenderObserver;
  112327. private static _planeScene;
  112328. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112329. /**
  112330. * 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)
  112331. */
  112332. maxDragAngle: number;
  112333. /**
  112334. * @hidden
  112335. */
  112336. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112337. /**
  112338. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112339. */
  112340. currentDraggingPointerID: number;
  112341. /**
  112342. * The last position where the pointer hit the drag plane in world space
  112343. */
  112344. lastDragPosition: Vector3;
  112345. /**
  112346. * If the behavior is currently in a dragging state
  112347. */
  112348. dragging: boolean;
  112349. /**
  112350. * 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)
  112351. */
  112352. dragDeltaRatio: number;
  112353. /**
  112354. * If the drag plane orientation should be updated during the dragging (Default: true)
  112355. */
  112356. updateDragPlane: boolean;
  112357. private _debugMode;
  112358. private _moving;
  112359. /**
  112360. * Fires each time the attached mesh is dragged with the pointer
  112361. * * delta between last drag position and current drag position in world space
  112362. * * dragDistance along the drag axis
  112363. * * dragPlaneNormal normal of the current drag plane used during the drag
  112364. * * dragPlanePoint in world space where the drag intersects the drag plane
  112365. */
  112366. onDragObservable: Observable<{
  112367. delta: Vector3;
  112368. dragPlanePoint: Vector3;
  112369. dragPlaneNormal: Vector3;
  112370. dragDistance: number;
  112371. pointerId: number;
  112372. }>;
  112373. /**
  112374. * Fires each time a drag begins (eg. mouse down on mesh)
  112375. */
  112376. onDragStartObservable: Observable<{
  112377. dragPlanePoint: Vector3;
  112378. pointerId: number;
  112379. }>;
  112380. /**
  112381. * Fires each time a drag ends (eg. mouse release after drag)
  112382. */
  112383. onDragEndObservable: Observable<{
  112384. dragPlanePoint: Vector3;
  112385. pointerId: number;
  112386. }>;
  112387. /**
  112388. * If the attached mesh should be moved when dragged
  112389. */
  112390. moveAttached: boolean;
  112391. /**
  112392. * If the drag behavior will react to drag events (Default: true)
  112393. */
  112394. enabled: boolean;
  112395. /**
  112396. * If pointer events should start and release the drag (Default: true)
  112397. */
  112398. startAndReleaseDragOnPointerEvents: boolean;
  112399. /**
  112400. * If camera controls should be detached during the drag
  112401. */
  112402. detachCameraControls: boolean;
  112403. /**
  112404. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112405. */
  112406. useObjectOrientationForDragging: boolean;
  112407. private _options;
  112408. /**
  112409. * Gets the options used by the behavior
  112410. */
  112411. get options(): {
  112412. dragAxis?: Vector3;
  112413. dragPlaneNormal?: Vector3;
  112414. };
  112415. /**
  112416. * Sets the options used by the behavior
  112417. */
  112418. set options(options: {
  112419. dragAxis?: Vector3;
  112420. dragPlaneNormal?: Vector3;
  112421. });
  112422. /**
  112423. * Creates a pointer drag behavior that can be attached to a mesh
  112424. * @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)
  112425. */
  112426. constructor(options?: {
  112427. dragAxis?: Vector3;
  112428. dragPlaneNormal?: Vector3;
  112429. });
  112430. /**
  112431. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112432. */
  112433. validateDrag: (targetPosition: Vector3) => boolean;
  112434. /**
  112435. * The name of the behavior
  112436. */
  112437. get name(): string;
  112438. /**
  112439. * Initializes the behavior
  112440. */
  112441. init(): void;
  112442. private _tmpVector;
  112443. private _alternatePickedPoint;
  112444. private _worldDragAxis;
  112445. private _targetPosition;
  112446. private _attachedElement;
  112447. /**
  112448. * Attaches the drag behavior the passed in mesh
  112449. * @param ownerNode The mesh that will be dragged around once attached
  112450. * @param predicate Predicate to use for pick filtering
  112451. */
  112452. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112453. /**
  112454. * Force relase the drag action by code.
  112455. */
  112456. releaseDrag(): void;
  112457. private _startDragRay;
  112458. private _lastPointerRay;
  112459. /**
  112460. * Simulates the start of a pointer drag event on the behavior
  112461. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112462. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112463. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112464. */
  112465. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112466. private _startDrag;
  112467. private _dragDelta;
  112468. private _moveDrag;
  112469. private _pickWithRayOnDragPlane;
  112470. private _pointA;
  112471. private _pointB;
  112472. private _pointC;
  112473. private _lineA;
  112474. private _lineB;
  112475. private _localAxis;
  112476. private _lookAt;
  112477. private _updateDragPlanePosition;
  112478. /**
  112479. * Detaches the behavior from the mesh
  112480. */
  112481. detach(): void;
  112482. }
  112483. }
  112484. declare module BABYLON {
  112485. /**
  112486. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112487. */
  112488. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112489. private _dragBehaviorA;
  112490. private _dragBehaviorB;
  112491. private _startDistance;
  112492. private _initialScale;
  112493. private _targetScale;
  112494. private _ownerNode;
  112495. private _sceneRenderObserver;
  112496. /**
  112497. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112498. */
  112499. constructor();
  112500. /**
  112501. * The name of the behavior
  112502. */
  112503. get name(): string;
  112504. /**
  112505. * Initializes the behavior
  112506. */
  112507. init(): void;
  112508. private _getCurrentDistance;
  112509. /**
  112510. * Attaches the scale behavior the passed in mesh
  112511. * @param ownerNode The mesh that will be scaled around once attached
  112512. */
  112513. attach(ownerNode: Mesh): void;
  112514. /**
  112515. * Detaches the behavior from the mesh
  112516. */
  112517. detach(): void;
  112518. }
  112519. }
  112520. declare module BABYLON {
  112521. /**
  112522. * 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
  112523. */
  112524. export class SixDofDragBehavior implements Behavior<Mesh> {
  112525. private static _virtualScene;
  112526. private _ownerNode;
  112527. private _sceneRenderObserver;
  112528. private _scene;
  112529. private _targetPosition;
  112530. private _virtualOriginMesh;
  112531. private _virtualDragMesh;
  112532. private _pointerObserver;
  112533. private _moving;
  112534. private _startingOrientation;
  112535. /**
  112536. * 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)
  112537. */
  112538. private zDragFactor;
  112539. /**
  112540. * If the object should rotate to face the drag origin
  112541. */
  112542. rotateDraggedObject: boolean;
  112543. /**
  112544. * If the behavior is currently in a dragging state
  112545. */
  112546. dragging: boolean;
  112547. /**
  112548. * 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)
  112549. */
  112550. dragDeltaRatio: number;
  112551. /**
  112552. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112553. */
  112554. currentDraggingPointerID: number;
  112555. /**
  112556. * If camera controls should be detached during the drag
  112557. */
  112558. detachCameraControls: boolean;
  112559. /**
  112560. * Fires each time a drag starts
  112561. */
  112562. onDragStartObservable: Observable<{}>;
  112563. /**
  112564. * Fires each time a drag ends (eg. mouse release after drag)
  112565. */
  112566. onDragEndObservable: Observable<{}>;
  112567. /**
  112568. * 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
  112569. */
  112570. constructor();
  112571. /**
  112572. * The name of the behavior
  112573. */
  112574. get name(): string;
  112575. /**
  112576. * Initializes the behavior
  112577. */
  112578. init(): void;
  112579. /**
  112580. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112581. */
  112582. private get _pointerCamera();
  112583. /**
  112584. * Attaches the scale behavior the passed in mesh
  112585. * @param ownerNode The mesh that will be scaled around once attached
  112586. */
  112587. attach(ownerNode: Mesh): void;
  112588. /**
  112589. * Detaches the behavior from the mesh
  112590. */
  112591. detach(): void;
  112592. }
  112593. }
  112594. declare module BABYLON {
  112595. /**
  112596. * Class used to apply inverse kinematics to bones
  112597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112598. */
  112599. export class BoneIKController {
  112600. private static _tmpVecs;
  112601. private static _tmpQuat;
  112602. private static _tmpMats;
  112603. /**
  112604. * Gets or sets the target mesh
  112605. */
  112606. targetMesh: AbstractMesh;
  112607. /** Gets or sets the mesh used as pole */
  112608. poleTargetMesh: AbstractMesh;
  112609. /**
  112610. * Gets or sets the bone used as pole
  112611. */
  112612. poleTargetBone: Nullable<Bone>;
  112613. /**
  112614. * Gets or sets the target position
  112615. */
  112616. targetPosition: Vector3;
  112617. /**
  112618. * Gets or sets the pole target position
  112619. */
  112620. poleTargetPosition: Vector3;
  112621. /**
  112622. * Gets or sets the pole target local offset
  112623. */
  112624. poleTargetLocalOffset: Vector3;
  112625. /**
  112626. * Gets or sets the pole angle
  112627. */
  112628. poleAngle: number;
  112629. /**
  112630. * Gets or sets the mesh associated with the controller
  112631. */
  112632. mesh: AbstractMesh;
  112633. /**
  112634. * 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)
  112635. */
  112636. slerpAmount: number;
  112637. private _bone1Quat;
  112638. private _bone1Mat;
  112639. private _bone2Ang;
  112640. private _bone1;
  112641. private _bone2;
  112642. private _bone1Length;
  112643. private _bone2Length;
  112644. private _maxAngle;
  112645. private _maxReach;
  112646. private _rightHandedSystem;
  112647. private _bendAxis;
  112648. private _slerping;
  112649. private _adjustRoll;
  112650. /**
  112651. * Gets or sets maximum allowed angle
  112652. */
  112653. get maxAngle(): number;
  112654. set maxAngle(value: number);
  112655. /**
  112656. * Creates a new BoneIKController
  112657. * @param mesh defines the mesh to control
  112658. * @param bone defines the bone to control
  112659. * @param options defines options to set up the controller
  112660. */
  112661. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112662. targetMesh?: AbstractMesh;
  112663. poleTargetMesh?: AbstractMesh;
  112664. poleTargetBone?: Bone;
  112665. poleTargetLocalOffset?: Vector3;
  112666. poleAngle?: number;
  112667. bendAxis?: Vector3;
  112668. maxAngle?: number;
  112669. slerpAmount?: number;
  112670. });
  112671. private _setMaxAngle;
  112672. /**
  112673. * Force the controller to update the bones
  112674. */
  112675. update(): void;
  112676. }
  112677. }
  112678. declare module BABYLON {
  112679. /**
  112680. * Class used to make a bone look toward a point in space
  112681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112682. */
  112683. export class BoneLookController {
  112684. private static _tmpVecs;
  112685. private static _tmpQuat;
  112686. private static _tmpMats;
  112687. /**
  112688. * The target Vector3 that the bone will look at
  112689. */
  112690. target: Vector3;
  112691. /**
  112692. * The mesh that the bone is attached to
  112693. */
  112694. mesh: AbstractMesh;
  112695. /**
  112696. * The bone that will be looking to the target
  112697. */
  112698. bone: Bone;
  112699. /**
  112700. * The up axis of the coordinate system that is used when the bone is rotated
  112701. */
  112702. upAxis: Vector3;
  112703. /**
  112704. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112705. */
  112706. upAxisSpace: Space;
  112707. /**
  112708. * Used to make an adjustment to the yaw of the bone
  112709. */
  112710. adjustYaw: number;
  112711. /**
  112712. * Used to make an adjustment to the pitch of the bone
  112713. */
  112714. adjustPitch: number;
  112715. /**
  112716. * Used to make an adjustment to the roll of the bone
  112717. */
  112718. adjustRoll: number;
  112719. /**
  112720. * 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)
  112721. */
  112722. slerpAmount: number;
  112723. private _minYaw;
  112724. private _maxYaw;
  112725. private _minPitch;
  112726. private _maxPitch;
  112727. private _minYawSin;
  112728. private _minYawCos;
  112729. private _maxYawSin;
  112730. private _maxYawCos;
  112731. private _midYawConstraint;
  112732. private _minPitchTan;
  112733. private _maxPitchTan;
  112734. private _boneQuat;
  112735. private _slerping;
  112736. private _transformYawPitch;
  112737. private _transformYawPitchInv;
  112738. private _firstFrameSkipped;
  112739. private _yawRange;
  112740. private _fowardAxis;
  112741. /**
  112742. * Gets or sets the minimum yaw angle that the bone can look to
  112743. */
  112744. get minYaw(): number;
  112745. set minYaw(value: number);
  112746. /**
  112747. * Gets or sets the maximum yaw angle that the bone can look to
  112748. */
  112749. get maxYaw(): number;
  112750. set maxYaw(value: number);
  112751. /**
  112752. * Gets or sets the minimum pitch angle that the bone can look to
  112753. */
  112754. get minPitch(): number;
  112755. set minPitch(value: number);
  112756. /**
  112757. * Gets or sets the maximum pitch angle that the bone can look to
  112758. */
  112759. get maxPitch(): number;
  112760. set maxPitch(value: number);
  112761. /**
  112762. * Create a BoneLookController
  112763. * @param mesh the mesh that the bone belongs to
  112764. * @param bone the bone that will be looking to the target
  112765. * @param target the target Vector3 to look at
  112766. * @param options optional settings:
  112767. * * maxYaw: the maximum angle the bone will yaw to
  112768. * * minYaw: the minimum angle the bone will yaw to
  112769. * * maxPitch: the maximum angle the bone will pitch to
  112770. * * minPitch: the minimum angle the bone will yaw to
  112771. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112772. * * upAxis: the up axis of the coordinate system
  112773. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112774. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112775. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112776. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112777. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112778. * * adjustRoll: used to make an adjustment to the roll of the bone
  112779. **/
  112780. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112781. maxYaw?: number;
  112782. minYaw?: number;
  112783. maxPitch?: number;
  112784. minPitch?: number;
  112785. slerpAmount?: number;
  112786. upAxis?: Vector3;
  112787. upAxisSpace?: Space;
  112788. yawAxis?: Vector3;
  112789. pitchAxis?: Vector3;
  112790. adjustYaw?: number;
  112791. adjustPitch?: number;
  112792. adjustRoll?: number;
  112793. });
  112794. /**
  112795. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112796. */
  112797. update(): void;
  112798. private _getAngleDiff;
  112799. private _getAngleBetween;
  112800. private _isAngleBetween;
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /**
  112805. * Manage the gamepad inputs to control an arc rotate camera.
  112806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112807. */
  112808. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112809. /**
  112810. * Defines the camera the input is attached to.
  112811. */
  112812. camera: ArcRotateCamera;
  112813. /**
  112814. * Defines the gamepad the input is gathering event from.
  112815. */
  112816. gamepad: Nullable<Gamepad>;
  112817. /**
  112818. * Defines the gamepad rotation sensiblity.
  112819. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112820. */
  112821. gamepadRotationSensibility: number;
  112822. /**
  112823. * Defines the gamepad move sensiblity.
  112824. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112825. */
  112826. gamepadMoveSensibility: number;
  112827. private _yAxisScale;
  112828. /**
  112829. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112830. */
  112831. get invertYAxis(): boolean;
  112832. set invertYAxis(value: boolean);
  112833. private _onGamepadConnectedObserver;
  112834. private _onGamepadDisconnectedObserver;
  112835. /**
  112836. * Attach the input controls to a specific dom element to get the input from.
  112837. * @param element Defines the element the controls should be listened from
  112838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112839. */
  112840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112841. /**
  112842. * Detach the current controls from the specified dom element.
  112843. * @param element Defines the element to stop listening the inputs from
  112844. */
  112845. detachControl(element: Nullable<HTMLElement>): void;
  112846. /**
  112847. * Update the current camera state depending on the inputs that have been used this frame.
  112848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112849. */
  112850. checkInputs(): void;
  112851. /**
  112852. * Gets the class name of the current intput.
  112853. * @returns the class name
  112854. */
  112855. getClassName(): string;
  112856. /**
  112857. * Get the friendly name associated with the input class.
  112858. * @returns the input friendly name
  112859. */
  112860. getSimpleName(): string;
  112861. }
  112862. }
  112863. declare module BABYLON {
  112864. interface ArcRotateCameraInputsManager {
  112865. /**
  112866. * Add orientation input support to the input manager.
  112867. * @returns the current input manager
  112868. */
  112869. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112870. }
  112871. /**
  112872. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112874. */
  112875. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112876. /**
  112877. * Defines the camera the input is attached to.
  112878. */
  112879. camera: ArcRotateCamera;
  112880. /**
  112881. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112882. */
  112883. alphaCorrection: number;
  112884. /**
  112885. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112886. */
  112887. gammaCorrection: number;
  112888. private _alpha;
  112889. private _gamma;
  112890. private _dirty;
  112891. private _deviceOrientationHandler;
  112892. /**
  112893. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112894. */
  112895. constructor();
  112896. /**
  112897. * Attach the input controls to a specific dom element to get the input from.
  112898. * @param element Defines the element the controls should be listened from
  112899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112900. */
  112901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112902. /** @hidden */
  112903. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112904. /**
  112905. * Update the current camera state depending on the inputs that have been used this frame.
  112906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112907. */
  112908. checkInputs(): void;
  112909. /**
  112910. * Detach the current controls from the specified dom element.
  112911. * @param element Defines the element to stop listening the inputs from
  112912. */
  112913. detachControl(element: Nullable<HTMLElement>): void;
  112914. /**
  112915. * Gets the class name of the current intput.
  112916. * @returns the class name
  112917. */
  112918. getClassName(): string;
  112919. /**
  112920. * Get the friendly name associated with the input class.
  112921. * @returns the input friendly name
  112922. */
  112923. getSimpleName(): string;
  112924. }
  112925. }
  112926. declare module BABYLON {
  112927. /**
  112928. * Listen to mouse events to control the camera.
  112929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112930. */
  112931. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112932. /**
  112933. * Defines the camera the input is attached to.
  112934. */
  112935. camera: FlyCamera;
  112936. /**
  112937. * Defines if touch is enabled. (Default is true.)
  112938. */
  112939. touchEnabled: boolean;
  112940. /**
  112941. * Defines the buttons associated with the input to handle camera rotation.
  112942. */
  112943. buttons: number[];
  112944. /**
  112945. * Assign buttons for Yaw control.
  112946. */
  112947. buttonsYaw: number[];
  112948. /**
  112949. * Assign buttons for Pitch control.
  112950. */
  112951. buttonsPitch: number[];
  112952. /**
  112953. * Assign buttons for Roll control.
  112954. */
  112955. buttonsRoll: number[];
  112956. /**
  112957. * Detect if any button is being pressed while mouse is moved.
  112958. * -1 = Mouse locked.
  112959. * 0 = Left button.
  112960. * 1 = Middle Button.
  112961. * 2 = Right Button.
  112962. */
  112963. activeButton: number;
  112964. /**
  112965. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112966. * Higher values reduce its sensitivity.
  112967. */
  112968. angularSensibility: number;
  112969. private _mousemoveCallback;
  112970. private _observer;
  112971. private _rollObserver;
  112972. private previousPosition;
  112973. private noPreventDefault;
  112974. private element;
  112975. /**
  112976. * Listen to mouse events to control the camera.
  112977. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112979. */
  112980. constructor(touchEnabled?: boolean);
  112981. /**
  112982. * Attach the mouse control to the HTML DOM element.
  112983. * @param element Defines the element that listens to the input events.
  112984. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112985. */
  112986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112987. /**
  112988. * Detach the current controls from the specified dom element.
  112989. * @param element Defines the element to stop listening the inputs from
  112990. */
  112991. detachControl(element: Nullable<HTMLElement>): void;
  112992. /**
  112993. * Gets the class name of the current input.
  112994. * @returns the class name.
  112995. */
  112996. getClassName(): string;
  112997. /**
  112998. * Get the friendly name associated with the input class.
  112999. * @returns the input's friendly name.
  113000. */
  113001. getSimpleName(): string;
  113002. private _pointerInput;
  113003. private _onMouseMove;
  113004. /**
  113005. * Rotate camera by mouse offset.
  113006. */
  113007. private rotateCamera;
  113008. }
  113009. }
  113010. declare module BABYLON {
  113011. /**
  113012. * Default Inputs manager for the FlyCamera.
  113013. * It groups all the default supported inputs for ease of use.
  113014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113015. */
  113016. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113017. /**
  113018. * Instantiates a new FlyCameraInputsManager.
  113019. * @param camera Defines the camera the inputs belong to.
  113020. */
  113021. constructor(camera: FlyCamera);
  113022. /**
  113023. * Add keyboard input support to the input manager.
  113024. * @returns the new FlyCameraKeyboardMoveInput().
  113025. */
  113026. addKeyboard(): FlyCameraInputsManager;
  113027. /**
  113028. * Add mouse input support to the input manager.
  113029. * @param touchEnabled Enable touch screen support.
  113030. * @returns the new FlyCameraMouseInput().
  113031. */
  113032. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113033. }
  113034. }
  113035. declare module BABYLON {
  113036. /**
  113037. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113038. * such as in a 3D Space Shooter or a Flight Simulator.
  113039. */
  113040. export class FlyCamera extends TargetCamera {
  113041. /**
  113042. * Define the collision ellipsoid of the camera.
  113043. * This is helpful for simulating a camera body, like a player's body.
  113044. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113045. */
  113046. ellipsoid: Vector3;
  113047. /**
  113048. * Define an offset for the position of the ellipsoid around the camera.
  113049. * This can be helpful if the camera is attached away from the player's body center,
  113050. * such as at its head.
  113051. */
  113052. ellipsoidOffset: Vector3;
  113053. /**
  113054. * Enable or disable collisions of the camera with the rest of the scene objects.
  113055. */
  113056. checkCollisions: boolean;
  113057. /**
  113058. * Enable or disable gravity on the camera.
  113059. */
  113060. applyGravity: boolean;
  113061. /**
  113062. * Define the current direction the camera is moving to.
  113063. */
  113064. cameraDirection: Vector3;
  113065. /**
  113066. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113067. * This overrides and empties cameraRotation.
  113068. */
  113069. rotationQuaternion: Quaternion;
  113070. /**
  113071. * Track Roll to maintain the wanted Rolling when looking around.
  113072. */
  113073. _trackRoll: number;
  113074. /**
  113075. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113076. */
  113077. rollCorrect: number;
  113078. /**
  113079. * Mimic a banked turn, Rolling the camera when Yawing.
  113080. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113081. */
  113082. bankedTurn: boolean;
  113083. /**
  113084. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113085. */
  113086. bankedTurnLimit: number;
  113087. /**
  113088. * Value of 0 disables the banked Roll.
  113089. * Value of 1 is equal to the Yaw angle in radians.
  113090. */
  113091. bankedTurnMultiplier: number;
  113092. /**
  113093. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113094. */
  113095. inputs: FlyCameraInputsManager;
  113096. /**
  113097. * Gets the input sensibility for mouse input.
  113098. * Higher values reduce sensitivity.
  113099. */
  113100. get angularSensibility(): number;
  113101. /**
  113102. * Sets the input sensibility for a mouse input.
  113103. * Higher values reduce sensitivity.
  113104. */
  113105. set angularSensibility(value: number);
  113106. /**
  113107. * Get the keys for camera movement forward.
  113108. */
  113109. get keysForward(): number[];
  113110. /**
  113111. * Set the keys for camera movement forward.
  113112. */
  113113. set keysForward(value: number[]);
  113114. /**
  113115. * Get the keys for camera movement backward.
  113116. */
  113117. get keysBackward(): number[];
  113118. set keysBackward(value: number[]);
  113119. /**
  113120. * Get the keys for camera movement up.
  113121. */
  113122. get keysUp(): number[];
  113123. /**
  113124. * Set the keys for camera movement up.
  113125. */
  113126. set keysUp(value: number[]);
  113127. /**
  113128. * Get the keys for camera movement down.
  113129. */
  113130. get keysDown(): number[];
  113131. /**
  113132. * Set the keys for camera movement down.
  113133. */
  113134. set keysDown(value: number[]);
  113135. /**
  113136. * Get the keys for camera movement left.
  113137. */
  113138. get keysLeft(): number[];
  113139. /**
  113140. * Set the keys for camera movement left.
  113141. */
  113142. set keysLeft(value: number[]);
  113143. /**
  113144. * Set the keys for camera movement right.
  113145. */
  113146. get keysRight(): number[];
  113147. /**
  113148. * Set the keys for camera movement right.
  113149. */
  113150. set keysRight(value: number[]);
  113151. /**
  113152. * Event raised when the camera collides with a mesh in the scene.
  113153. */
  113154. onCollide: (collidedMesh: AbstractMesh) => void;
  113155. private _collider;
  113156. private _needMoveForGravity;
  113157. private _oldPosition;
  113158. private _diffPosition;
  113159. private _newPosition;
  113160. /** @hidden */
  113161. _localDirection: Vector3;
  113162. /** @hidden */
  113163. _transformedDirection: Vector3;
  113164. /**
  113165. * Instantiates a FlyCamera.
  113166. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113167. * such as in a 3D Space Shooter or a Flight Simulator.
  113168. * @param name Define the name of the camera in the scene.
  113169. * @param position Define the starting position of the camera in the scene.
  113170. * @param scene Define the scene the camera belongs to.
  113171. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113172. */
  113173. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113174. /**
  113175. * Attach a control to the HTML DOM element.
  113176. * @param element Defines the element that listens to the input events.
  113177. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113178. */
  113179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113180. /**
  113181. * Detach a control from the HTML DOM element.
  113182. * The camera will stop reacting to that input.
  113183. * @param element Defines the element that listens to the input events.
  113184. */
  113185. detachControl(element: HTMLElement): void;
  113186. private _collisionMask;
  113187. /**
  113188. * Get the mask that the camera ignores in collision events.
  113189. */
  113190. get collisionMask(): number;
  113191. /**
  113192. * Set the mask that the camera ignores in collision events.
  113193. */
  113194. set collisionMask(mask: number);
  113195. /** @hidden */
  113196. _collideWithWorld(displacement: Vector3): void;
  113197. /** @hidden */
  113198. private _onCollisionPositionChange;
  113199. /** @hidden */
  113200. _checkInputs(): void;
  113201. /** @hidden */
  113202. _decideIfNeedsToMove(): boolean;
  113203. /** @hidden */
  113204. _updatePosition(): void;
  113205. /**
  113206. * Restore the Roll to its target value at the rate specified.
  113207. * @param rate - Higher means slower restoring.
  113208. * @hidden
  113209. */
  113210. restoreRoll(rate: number): void;
  113211. /**
  113212. * Destroy the camera and release the current resources held by it.
  113213. */
  113214. dispose(): void;
  113215. /**
  113216. * Get the current object class name.
  113217. * @returns the class name.
  113218. */
  113219. getClassName(): string;
  113220. }
  113221. }
  113222. declare module BABYLON {
  113223. /**
  113224. * Listen to keyboard events to control the camera.
  113225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113226. */
  113227. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113228. /**
  113229. * Defines the camera the input is attached to.
  113230. */
  113231. camera: FlyCamera;
  113232. /**
  113233. * The list of keyboard keys used to control the forward move of the camera.
  113234. */
  113235. keysForward: number[];
  113236. /**
  113237. * The list of keyboard keys used to control the backward move of the camera.
  113238. */
  113239. keysBackward: number[];
  113240. /**
  113241. * The list of keyboard keys used to control the forward move of the camera.
  113242. */
  113243. keysUp: number[];
  113244. /**
  113245. * The list of keyboard keys used to control the backward move of the camera.
  113246. */
  113247. keysDown: number[];
  113248. /**
  113249. * The list of keyboard keys used to control the right strafe move of the camera.
  113250. */
  113251. keysRight: number[];
  113252. /**
  113253. * The list of keyboard keys used to control the left strafe move of the camera.
  113254. */
  113255. keysLeft: number[];
  113256. private _keys;
  113257. private _onCanvasBlurObserver;
  113258. private _onKeyboardObserver;
  113259. private _engine;
  113260. private _scene;
  113261. /**
  113262. * Attach the input controls to a specific dom element to get the input from.
  113263. * @param element Defines the element the controls should be listened from
  113264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113265. */
  113266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113267. /**
  113268. * Detach the current controls from the specified dom element.
  113269. * @param element Defines the element to stop listening the inputs from
  113270. */
  113271. detachControl(element: Nullable<HTMLElement>): void;
  113272. /**
  113273. * Gets the class name of the current intput.
  113274. * @returns the class name
  113275. */
  113276. getClassName(): string;
  113277. /** @hidden */
  113278. _onLostFocus(e: FocusEvent): void;
  113279. /**
  113280. * Get the friendly name associated with the input class.
  113281. * @returns the input friendly name
  113282. */
  113283. getSimpleName(): string;
  113284. /**
  113285. * Update the current camera state depending on the inputs that have been used this frame.
  113286. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113287. */
  113288. checkInputs(): void;
  113289. }
  113290. }
  113291. declare module BABYLON {
  113292. /**
  113293. * Manage the mouse wheel inputs to control a follow camera.
  113294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113295. */
  113296. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113297. /**
  113298. * Defines the camera the input is attached to.
  113299. */
  113300. camera: FollowCamera;
  113301. /**
  113302. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113303. */
  113304. axisControlRadius: boolean;
  113305. /**
  113306. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113307. */
  113308. axisControlHeight: boolean;
  113309. /**
  113310. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113311. */
  113312. axisControlRotation: boolean;
  113313. /**
  113314. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113315. * relation to mouseWheel events.
  113316. */
  113317. wheelPrecision: number;
  113318. /**
  113319. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113320. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113321. */
  113322. wheelDeltaPercentage: number;
  113323. private _wheel;
  113324. private _observer;
  113325. /**
  113326. * Attach the input controls to a specific dom element to get the input from.
  113327. * @param element Defines the element the controls should be listened from
  113328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113329. */
  113330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113331. /**
  113332. * Detach the current controls from the specified dom element.
  113333. * @param element Defines the element to stop listening the inputs from
  113334. */
  113335. detachControl(element: Nullable<HTMLElement>): void;
  113336. /**
  113337. * Gets the class name of the current intput.
  113338. * @returns the class name
  113339. */
  113340. getClassName(): string;
  113341. /**
  113342. * Get the friendly name associated with the input class.
  113343. * @returns the input friendly name
  113344. */
  113345. getSimpleName(): string;
  113346. }
  113347. }
  113348. declare module BABYLON {
  113349. /**
  113350. * Manage the pointers inputs to control an follow camera.
  113351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113352. */
  113353. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113354. /**
  113355. * Defines the camera the input is attached to.
  113356. */
  113357. camera: FollowCamera;
  113358. /**
  113359. * Gets the class name of the current input.
  113360. * @returns the class name
  113361. */
  113362. getClassName(): string;
  113363. /**
  113364. * Defines the pointer angular sensibility along the X axis or how fast is
  113365. * the camera rotating.
  113366. * A negative number will reverse the axis direction.
  113367. */
  113368. angularSensibilityX: number;
  113369. /**
  113370. * Defines the pointer angular sensibility along the Y axis or how fast is
  113371. * the camera rotating.
  113372. * A negative number will reverse the axis direction.
  113373. */
  113374. angularSensibilityY: number;
  113375. /**
  113376. * Defines the pointer pinch precision or how fast is the camera zooming.
  113377. * A negative number will reverse the axis direction.
  113378. */
  113379. pinchPrecision: number;
  113380. /**
  113381. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113382. * from 0.
  113383. * It defines the percentage of current camera.radius to use as delta when
  113384. * pinch zoom is used.
  113385. */
  113386. pinchDeltaPercentage: number;
  113387. /**
  113388. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113389. */
  113390. axisXControlRadius: boolean;
  113391. /**
  113392. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113393. */
  113394. axisXControlHeight: boolean;
  113395. /**
  113396. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113397. */
  113398. axisXControlRotation: boolean;
  113399. /**
  113400. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113401. */
  113402. axisYControlRadius: boolean;
  113403. /**
  113404. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113405. */
  113406. axisYControlHeight: boolean;
  113407. /**
  113408. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113409. */
  113410. axisYControlRotation: boolean;
  113411. /**
  113412. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113413. */
  113414. axisPinchControlRadius: boolean;
  113415. /**
  113416. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113417. */
  113418. axisPinchControlHeight: boolean;
  113419. /**
  113420. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113421. */
  113422. axisPinchControlRotation: boolean;
  113423. /**
  113424. * Log error messages if basic misconfiguration has occurred.
  113425. */
  113426. warningEnable: boolean;
  113427. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113428. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113429. private _warningCounter;
  113430. private _warning;
  113431. }
  113432. }
  113433. declare module BABYLON {
  113434. /**
  113435. * Default Inputs manager for the FollowCamera.
  113436. * It groups all the default supported inputs for ease of use.
  113437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113438. */
  113439. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113440. /**
  113441. * Instantiates a new FollowCameraInputsManager.
  113442. * @param camera Defines the camera the inputs belong to
  113443. */
  113444. constructor(camera: FollowCamera);
  113445. /**
  113446. * Add keyboard input support to the input manager.
  113447. * @returns the current input manager
  113448. */
  113449. addKeyboard(): FollowCameraInputsManager;
  113450. /**
  113451. * Add mouse wheel input support to the input manager.
  113452. * @returns the current input manager
  113453. */
  113454. addMouseWheel(): FollowCameraInputsManager;
  113455. /**
  113456. * Add pointers input support to the input manager.
  113457. * @returns the current input manager
  113458. */
  113459. addPointers(): FollowCameraInputsManager;
  113460. /**
  113461. * Add orientation input support to the input manager.
  113462. * @returns the current input manager
  113463. */
  113464. addVRDeviceOrientation(): FollowCameraInputsManager;
  113465. }
  113466. }
  113467. declare module BABYLON {
  113468. /**
  113469. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113470. * an arc rotate version arcFollowCamera are available.
  113471. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113472. */
  113473. export class FollowCamera extends TargetCamera {
  113474. /**
  113475. * Distance the follow camera should follow an object at
  113476. */
  113477. radius: number;
  113478. /**
  113479. * Minimum allowed distance of the camera to the axis of rotation
  113480. * (The camera can not get closer).
  113481. * This can help limiting how the Camera is able to move in the scene.
  113482. */
  113483. lowerRadiusLimit: Nullable<number>;
  113484. /**
  113485. * Maximum allowed distance of the camera to the axis of rotation
  113486. * (The camera can not get further).
  113487. * This can help limiting how the Camera is able to move in the scene.
  113488. */
  113489. upperRadiusLimit: Nullable<number>;
  113490. /**
  113491. * Define a rotation offset between the camera and the object it follows
  113492. */
  113493. rotationOffset: number;
  113494. /**
  113495. * Minimum allowed angle to camera position relative to target object.
  113496. * This can help limiting how the Camera is able to move in the scene.
  113497. */
  113498. lowerRotationOffsetLimit: Nullable<number>;
  113499. /**
  113500. * Maximum allowed angle to camera position relative to target object.
  113501. * This can help limiting how the Camera is able to move in the scene.
  113502. */
  113503. upperRotationOffsetLimit: Nullable<number>;
  113504. /**
  113505. * Define a height offset between the camera and the object it follows.
  113506. * It can help following an object from the top (like a car chaing a plane)
  113507. */
  113508. heightOffset: number;
  113509. /**
  113510. * Minimum allowed height of camera position relative to target object.
  113511. * This can help limiting how the Camera is able to move in the scene.
  113512. */
  113513. lowerHeightOffsetLimit: Nullable<number>;
  113514. /**
  113515. * Maximum allowed height of camera position relative to target object.
  113516. * This can help limiting how the Camera is able to move in the scene.
  113517. */
  113518. upperHeightOffsetLimit: Nullable<number>;
  113519. /**
  113520. * Define how fast the camera can accelerate to follow it s target.
  113521. */
  113522. cameraAcceleration: number;
  113523. /**
  113524. * Define the speed limit of the camera following an object.
  113525. */
  113526. maxCameraSpeed: number;
  113527. /**
  113528. * Define the target of the camera.
  113529. */
  113530. lockedTarget: Nullable<AbstractMesh>;
  113531. /**
  113532. * Defines the input associated with the camera.
  113533. */
  113534. inputs: FollowCameraInputsManager;
  113535. /**
  113536. * Instantiates the follow camera.
  113537. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113538. * @param name Define the name of the camera in the scene
  113539. * @param position Define the position of the camera
  113540. * @param scene Define the scene the camera belong to
  113541. * @param lockedTarget Define the target of the camera
  113542. */
  113543. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113544. private _follow;
  113545. /**
  113546. * Attached controls to the current camera.
  113547. * @param element Defines the element the controls should be listened from
  113548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113549. */
  113550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113551. /**
  113552. * Detach the current controls from the camera.
  113553. * The camera will stop reacting to inputs.
  113554. * @param element Defines the element to stop listening the inputs from
  113555. */
  113556. detachControl(element: HTMLElement): void;
  113557. /** @hidden */
  113558. _checkInputs(): void;
  113559. private _checkLimits;
  113560. /**
  113561. * Gets the camera class name.
  113562. * @returns the class name
  113563. */
  113564. getClassName(): string;
  113565. }
  113566. /**
  113567. * Arc Rotate version of the follow camera.
  113568. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113569. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113570. */
  113571. export class ArcFollowCamera extends TargetCamera {
  113572. /** The longitudinal angle of the camera */
  113573. alpha: number;
  113574. /** The latitudinal angle of the camera */
  113575. beta: number;
  113576. /** The radius of the camera from its target */
  113577. radius: number;
  113578. /** Define the camera target (the messh it should follow) */
  113579. target: Nullable<AbstractMesh>;
  113580. private _cartesianCoordinates;
  113581. /**
  113582. * Instantiates a new ArcFollowCamera
  113583. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113584. * @param name Define the name of the camera
  113585. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113586. * @param beta Define the rotation angle of the camera around the elevation axis
  113587. * @param radius Define the radius of the camera from its target point
  113588. * @param target Define the target of the camera
  113589. * @param scene Define the scene the camera belongs to
  113590. */
  113591. constructor(name: string,
  113592. /** The longitudinal angle of the camera */
  113593. alpha: number,
  113594. /** The latitudinal angle of the camera */
  113595. beta: number,
  113596. /** The radius of the camera from its target */
  113597. radius: number,
  113598. /** Define the camera target (the messh it should follow) */
  113599. target: Nullable<AbstractMesh>, scene: Scene);
  113600. private _follow;
  113601. /** @hidden */
  113602. _checkInputs(): void;
  113603. /**
  113604. * Returns the class name of the object.
  113605. * It is mostly used internally for serialization purposes.
  113606. */
  113607. getClassName(): string;
  113608. }
  113609. }
  113610. declare module BABYLON {
  113611. /**
  113612. * Manage the keyboard inputs to control the movement of a follow camera.
  113613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113614. */
  113615. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113616. /**
  113617. * Defines the camera the input is attached to.
  113618. */
  113619. camera: FollowCamera;
  113620. /**
  113621. * Defines the list of key codes associated with the up action (increase heightOffset)
  113622. */
  113623. keysHeightOffsetIncr: number[];
  113624. /**
  113625. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113626. */
  113627. keysHeightOffsetDecr: number[];
  113628. /**
  113629. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113630. */
  113631. keysHeightOffsetModifierAlt: boolean;
  113632. /**
  113633. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113634. */
  113635. keysHeightOffsetModifierCtrl: boolean;
  113636. /**
  113637. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113638. */
  113639. keysHeightOffsetModifierShift: boolean;
  113640. /**
  113641. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113642. */
  113643. keysRotationOffsetIncr: number[];
  113644. /**
  113645. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113646. */
  113647. keysRotationOffsetDecr: number[];
  113648. /**
  113649. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113650. */
  113651. keysRotationOffsetModifierAlt: boolean;
  113652. /**
  113653. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113654. */
  113655. keysRotationOffsetModifierCtrl: boolean;
  113656. /**
  113657. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113658. */
  113659. keysRotationOffsetModifierShift: boolean;
  113660. /**
  113661. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113662. */
  113663. keysRadiusIncr: number[];
  113664. /**
  113665. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113666. */
  113667. keysRadiusDecr: number[];
  113668. /**
  113669. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113670. */
  113671. keysRadiusModifierAlt: boolean;
  113672. /**
  113673. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113674. */
  113675. keysRadiusModifierCtrl: boolean;
  113676. /**
  113677. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113678. */
  113679. keysRadiusModifierShift: boolean;
  113680. /**
  113681. * Defines the rate of change of heightOffset.
  113682. */
  113683. heightSensibility: number;
  113684. /**
  113685. * Defines the rate of change of rotationOffset.
  113686. */
  113687. rotationSensibility: number;
  113688. /**
  113689. * Defines the rate of change of radius.
  113690. */
  113691. radiusSensibility: number;
  113692. private _keys;
  113693. private _ctrlPressed;
  113694. private _altPressed;
  113695. private _shiftPressed;
  113696. private _onCanvasBlurObserver;
  113697. private _onKeyboardObserver;
  113698. private _engine;
  113699. private _scene;
  113700. /**
  113701. * Attach the input controls to a specific dom element to get the input from.
  113702. * @param element Defines the element the controls should be listened from
  113703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113704. */
  113705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113706. /**
  113707. * Detach the current controls from the specified dom element.
  113708. * @param element Defines the element to stop listening the inputs from
  113709. */
  113710. detachControl(element: Nullable<HTMLElement>): void;
  113711. /**
  113712. * Update the current camera state depending on the inputs that have been used this frame.
  113713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113714. */
  113715. checkInputs(): void;
  113716. /**
  113717. * Gets the class name of the current input.
  113718. * @returns the class name
  113719. */
  113720. getClassName(): string;
  113721. /**
  113722. * Get the friendly name associated with the input class.
  113723. * @returns the input friendly name
  113724. */
  113725. getSimpleName(): string;
  113726. /**
  113727. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113728. * allow modification of the heightOffset value.
  113729. */
  113730. private _modifierHeightOffset;
  113731. /**
  113732. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113733. * allow modification of the rotationOffset value.
  113734. */
  113735. private _modifierRotationOffset;
  113736. /**
  113737. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113738. * allow modification of the radius value.
  113739. */
  113740. private _modifierRadius;
  113741. }
  113742. }
  113743. declare module BABYLON {
  113744. interface FreeCameraInputsManager {
  113745. /**
  113746. * @hidden
  113747. */
  113748. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113749. /**
  113750. * Add orientation input support to the input manager.
  113751. * @returns the current input manager
  113752. */
  113753. addDeviceOrientation(): FreeCameraInputsManager;
  113754. }
  113755. /**
  113756. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113757. * Screen rotation is taken into account.
  113758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113759. */
  113760. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113761. private _camera;
  113762. private _screenOrientationAngle;
  113763. private _constantTranform;
  113764. private _screenQuaternion;
  113765. private _alpha;
  113766. private _beta;
  113767. private _gamma;
  113768. /**
  113769. * Can be used to detect if a device orientation sensor is available on a device
  113770. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113771. * @returns a promise that will resolve on orientation change
  113772. */
  113773. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113774. /**
  113775. * @hidden
  113776. */
  113777. _onDeviceOrientationChangedObservable: Observable<void>;
  113778. /**
  113779. * Instantiates a new input
  113780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113781. */
  113782. constructor();
  113783. /**
  113784. * Define the camera controlled by the input.
  113785. */
  113786. get camera(): FreeCamera;
  113787. set camera(camera: FreeCamera);
  113788. /**
  113789. * Attach the input controls to a specific dom element to get the input from.
  113790. * @param element Defines the element the controls should be listened from
  113791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113792. */
  113793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113794. private _orientationChanged;
  113795. private _deviceOrientation;
  113796. /**
  113797. * Detach the current controls from the specified dom element.
  113798. * @param element Defines the element to stop listening the inputs from
  113799. */
  113800. detachControl(element: Nullable<HTMLElement>): void;
  113801. /**
  113802. * Update the current camera state depending on the inputs that have been used this frame.
  113803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113804. */
  113805. checkInputs(): void;
  113806. /**
  113807. * Gets the class name of the current intput.
  113808. * @returns the class name
  113809. */
  113810. getClassName(): string;
  113811. /**
  113812. * Get the friendly name associated with the input class.
  113813. * @returns the input friendly name
  113814. */
  113815. getSimpleName(): string;
  113816. }
  113817. }
  113818. declare module BABYLON {
  113819. /**
  113820. * Manage the gamepad inputs to control a free camera.
  113821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113822. */
  113823. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113824. /**
  113825. * Define the camera the input is attached to.
  113826. */
  113827. camera: FreeCamera;
  113828. /**
  113829. * Define the Gamepad controlling the input
  113830. */
  113831. gamepad: Nullable<Gamepad>;
  113832. /**
  113833. * Defines the gamepad rotation sensiblity.
  113834. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113835. */
  113836. gamepadAngularSensibility: number;
  113837. /**
  113838. * Defines the gamepad move sensiblity.
  113839. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113840. */
  113841. gamepadMoveSensibility: number;
  113842. private _yAxisScale;
  113843. /**
  113844. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113845. */
  113846. get invertYAxis(): boolean;
  113847. set invertYAxis(value: boolean);
  113848. private _onGamepadConnectedObserver;
  113849. private _onGamepadDisconnectedObserver;
  113850. private _cameraTransform;
  113851. private _deltaTransform;
  113852. private _vector3;
  113853. private _vector2;
  113854. /**
  113855. * Attach the input controls to a specific dom element to get the input from.
  113856. * @param element Defines the element the controls should be listened from
  113857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113858. */
  113859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113860. /**
  113861. * Detach the current controls from the specified dom element.
  113862. * @param element Defines the element to stop listening the inputs from
  113863. */
  113864. detachControl(element: Nullable<HTMLElement>): void;
  113865. /**
  113866. * Update the current camera state depending on the inputs that have been used this frame.
  113867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113868. */
  113869. checkInputs(): void;
  113870. /**
  113871. * Gets the class name of the current intput.
  113872. * @returns the class name
  113873. */
  113874. getClassName(): string;
  113875. /**
  113876. * Get the friendly name associated with the input class.
  113877. * @returns the input friendly name
  113878. */
  113879. getSimpleName(): string;
  113880. }
  113881. }
  113882. declare module BABYLON {
  113883. /**
  113884. * Defines the potential axis of a Joystick
  113885. */
  113886. export enum JoystickAxis {
  113887. /** X axis */
  113888. X = 0,
  113889. /** Y axis */
  113890. Y = 1,
  113891. /** Z axis */
  113892. Z = 2
  113893. }
  113894. /**
  113895. * Class used to define virtual joystick (used in touch mode)
  113896. */
  113897. export class VirtualJoystick {
  113898. /**
  113899. * Gets or sets a boolean indicating that left and right values must be inverted
  113900. */
  113901. reverseLeftRight: boolean;
  113902. /**
  113903. * Gets or sets a boolean indicating that up and down values must be inverted
  113904. */
  113905. reverseUpDown: boolean;
  113906. /**
  113907. * Gets the offset value for the position (ie. the change of the position value)
  113908. */
  113909. deltaPosition: Vector3;
  113910. /**
  113911. * Gets a boolean indicating if the virtual joystick was pressed
  113912. */
  113913. pressed: boolean;
  113914. /**
  113915. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113916. */
  113917. static Canvas: Nullable<HTMLCanvasElement>;
  113918. private static _globalJoystickIndex;
  113919. private static vjCanvasContext;
  113920. private static vjCanvasWidth;
  113921. private static vjCanvasHeight;
  113922. private static halfWidth;
  113923. private _action;
  113924. private _axisTargetedByLeftAndRight;
  113925. private _axisTargetedByUpAndDown;
  113926. private _joystickSensibility;
  113927. private _inversedSensibility;
  113928. private _joystickPointerID;
  113929. private _joystickColor;
  113930. private _joystickPointerPos;
  113931. private _joystickPreviousPointerPos;
  113932. private _joystickPointerStartPos;
  113933. private _deltaJoystickVector;
  113934. private _leftJoystick;
  113935. private _touches;
  113936. private _onPointerDownHandlerRef;
  113937. private _onPointerMoveHandlerRef;
  113938. private _onPointerUpHandlerRef;
  113939. private _onResize;
  113940. /**
  113941. * Creates a new virtual joystick
  113942. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113943. */
  113944. constructor(leftJoystick?: boolean);
  113945. /**
  113946. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113947. * @param newJoystickSensibility defines the new sensibility
  113948. */
  113949. setJoystickSensibility(newJoystickSensibility: number): void;
  113950. private _onPointerDown;
  113951. private _onPointerMove;
  113952. private _onPointerUp;
  113953. /**
  113954. * Change the color of the virtual joystick
  113955. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113956. */
  113957. setJoystickColor(newColor: string): void;
  113958. /**
  113959. * Defines a callback to call when the joystick is touched
  113960. * @param action defines the callback
  113961. */
  113962. setActionOnTouch(action: () => any): void;
  113963. /**
  113964. * Defines which axis you'd like to control for left & right
  113965. * @param axis defines the axis to use
  113966. */
  113967. setAxisForLeftRight(axis: JoystickAxis): void;
  113968. /**
  113969. * Defines which axis you'd like to control for up & down
  113970. * @param axis defines the axis to use
  113971. */
  113972. setAxisForUpDown(axis: JoystickAxis): void;
  113973. private _drawVirtualJoystick;
  113974. /**
  113975. * Release internal HTML canvas
  113976. */
  113977. releaseCanvas(): void;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. interface FreeCameraInputsManager {
  113982. /**
  113983. * Add virtual joystick input support to the input manager.
  113984. * @returns the current input manager
  113985. */
  113986. addVirtualJoystick(): FreeCameraInputsManager;
  113987. }
  113988. /**
  113989. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113991. */
  113992. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113993. /**
  113994. * Defines the camera the input is attached to.
  113995. */
  113996. camera: FreeCamera;
  113997. private _leftjoystick;
  113998. private _rightjoystick;
  113999. /**
  114000. * Gets the left stick of the virtual joystick.
  114001. * @returns The virtual Joystick
  114002. */
  114003. getLeftJoystick(): VirtualJoystick;
  114004. /**
  114005. * Gets the right stick of the virtual joystick.
  114006. * @returns The virtual Joystick
  114007. */
  114008. getRightJoystick(): VirtualJoystick;
  114009. /**
  114010. * Update the current camera state depending on the inputs that have been used this frame.
  114011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114012. */
  114013. checkInputs(): void;
  114014. /**
  114015. * Attach the input controls to a specific dom element to get the input from.
  114016. * @param element Defines the element the controls should be listened from
  114017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114018. */
  114019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114020. /**
  114021. * Detach the current controls from the specified dom element.
  114022. * @param element Defines the element to stop listening the inputs from
  114023. */
  114024. detachControl(element: Nullable<HTMLElement>): void;
  114025. /**
  114026. * Gets the class name of the current intput.
  114027. * @returns the class name
  114028. */
  114029. getClassName(): string;
  114030. /**
  114031. * Get the friendly name associated with the input class.
  114032. * @returns the input friendly name
  114033. */
  114034. getSimpleName(): string;
  114035. }
  114036. }
  114037. declare module BABYLON {
  114038. /**
  114039. * This represents a FPS type of camera controlled by touch.
  114040. * This is like a universal camera minus the Gamepad controls.
  114041. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114042. */
  114043. export class TouchCamera extends FreeCamera {
  114044. /**
  114045. * Defines the touch sensibility for rotation.
  114046. * The higher the faster.
  114047. */
  114048. get touchAngularSensibility(): number;
  114049. set touchAngularSensibility(value: number);
  114050. /**
  114051. * Defines the touch sensibility for move.
  114052. * The higher the faster.
  114053. */
  114054. get touchMoveSensibility(): number;
  114055. set touchMoveSensibility(value: number);
  114056. /**
  114057. * Instantiates a new touch camera.
  114058. * This represents a FPS type of camera controlled by touch.
  114059. * This is like a universal camera minus the Gamepad controls.
  114060. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114061. * @param name Define the name of the camera in the scene
  114062. * @param position Define the start position of the camera in the scene
  114063. * @param scene Define the scene the camera belongs to
  114064. */
  114065. constructor(name: string, position: Vector3, scene: Scene);
  114066. /**
  114067. * Gets the current object class name.
  114068. * @return the class name
  114069. */
  114070. getClassName(): string;
  114071. /** @hidden */
  114072. _setupInputs(): void;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114078. * being tilted forward or back and left or right.
  114079. */
  114080. export class DeviceOrientationCamera extends FreeCamera {
  114081. private _initialQuaternion;
  114082. private _quaternionCache;
  114083. private _tmpDragQuaternion;
  114084. private _disablePointerInputWhenUsingDeviceOrientation;
  114085. /**
  114086. * Creates a new device orientation camera
  114087. * @param name The name of the camera
  114088. * @param position The start position camera
  114089. * @param scene The scene the camera belongs to
  114090. */
  114091. constructor(name: string, position: Vector3, scene: Scene);
  114092. /**
  114093. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114094. */
  114095. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114096. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114097. private _dragFactor;
  114098. /**
  114099. * Enabled turning on the y axis when the orientation sensor is active
  114100. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114101. */
  114102. enableHorizontalDragging(dragFactor?: number): void;
  114103. /**
  114104. * Gets the current instance class name ("DeviceOrientationCamera").
  114105. * This helps avoiding instanceof at run time.
  114106. * @returns the class name
  114107. */
  114108. getClassName(): string;
  114109. /**
  114110. * @hidden
  114111. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114112. */
  114113. _checkInputs(): void;
  114114. /**
  114115. * Reset the camera to its default orientation on the specified axis only.
  114116. * @param axis The axis to reset
  114117. */
  114118. resetToCurrentRotation(axis?: Axis): void;
  114119. }
  114120. }
  114121. declare module BABYLON {
  114122. /**
  114123. * Defines supported buttons for XBox360 compatible gamepads
  114124. */
  114125. export enum Xbox360Button {
  114126. /** A */
  114127. A = 0,
  114128. /** B */
  114129. B = 1,
  114130. /** X */
  114131. X = 2,
  114132. /** Y */
  114133. Y = 3,
  114134. /** Start */
  114135. Start = 4,
  114136. /** Back */
  114137. Back = 5,
  114138. /** Left button */
  114139. LB = 6,
  114140. /** Right button */
  114141. RB = 7,
  114142. /** Left stick */
  114143. LeftStick = 8,
  114144. /** Right stick */
  114145. RightStick = 9
  114146. }
  114147. /** Defines values for XBox360 DPad */
  114148. export enum Xbox360Dpad {
  114149. /** Up */
  114150. Up = 0,
  114151. /** Down */
  114152. Down = 1,
  114153. /** Left */
  114154. Left = 2,
  114155. /** Right */
  114156. Right = 3
  114157. }
  114158. /**
  114159. * Defines a XBox360 gamepad
  114160. */
  114161. export class Xbox360Pad extends Gamepad {
  114162. private _leftTrigger;
  114163. private _rightTrigger;
  114164. private _onlefttriggerchanged;
  114165. private _onrighttriggerchanged;
  114166. private _onbuttondown;
  114167. private _onbuttonup;
  114168. private _ondpaddown;
  114169. private _ondpadup;
  114170. /** Observable raised when a button is pressed */
  114171. onButtonDownObservable: Observable<Xbox360Button>;
  114172. /** Observable raised when a button is released */
  114173. onButtonUpObservable: Observable<Xbox360Button>;
  114174. /** Observable raised when a pad is pressed */
  114175. onPadDownObservable: Observable<Xbox360Dpad>;
  114176. /** Observable raised when a pad is released */
  114177. onPadUpObservable: Observable<Xbox360Dpad>;
  114178. private _buttonA;
  114179. private _buttonB;
  114180. private _buttonX;
  114181. private _buttonY;
  114182. private _buttonBack;
  114183. private _buttonStart;
  114184. private _buttonLB;
  114185. private _buttonRB;
  114186. private _buttonLeftStick;
  114187. private _buttonRightStick;
  114188. private _dPadUp;
  114189. private _dPadDown;
  114190. private _dPadLeft;
  114191. private _dPadRight;
  114192. private _isXboxOnePad;
  114193. /**
  114194. * Creates a new XBox360 gamepad object
  114195. * @param id defines the id of this gamepad
  114196. * @param index defines its index
  114197. * @param gamepad defines the internal HTML gamepad object
  114198. * @param xboxOne defines if it is a XBox One gamepad
  114199. */
  114200. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114201. /**
  114202. * Defines the callback to call when left trigger is pressed
  114203. * @param callback defines the callback to use
  114204. */
  114205. onlefttriggerchanged(callback: (value: number) => void): void;
  114206. /**
  114207. * Defines the callback to call when right trigger is pressed
  114208. * @param callback defines the callback to use
  114209. */
  114210. onrighttriggerchanged(callback: (value: number) => void): void;
  114211. /**
  114212. * Gets the left trigger value
  114213. */
  114214. get leftTrigger(): number;
  114215. /**
  114216. * Sets the left trigger value
  114217. */
  114218. set leftTrigger(newValue: number);
  114219. /**
  114220. * Gets the right trigger value
  114221. */
  114222. get rightTrigger(): number;
  114223. /**
  114224. * Sets the right trigger value
  114225. */
  114226. set rightTrigger(newValue: number);
  114227. /**
  114228. * Defines the callback to call when a button is pressed
  114229. * @param callback defines the callback to use
  114230. */
  114231. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114232. /**
  114233. * Defines the callback to call when a button is released
  114234. * @param callback defines the callback to use
  114235. */
  114236. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114237. /**
  114238. * Defines the callback to call when a pad is pressed
  114239. * @param callback defines the callback to use
  114240. */
  114241. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114242. /**
  114243. * Defines the callback to call when a pad is released
  114244. * @param callback defines the callback to use
  114245. */
  114246. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114247. private _setButtonValue;
  114248. private _setDPadValue;
  114249. /**
  114250. * Gets the value of the `A` button
  114251. */
  114252. get buttonA(): number;
  114253. /**
  114254. * Sets the value of the `A` button
  114255. */
  114256. set buttonA(value: number);
  114257. /**
  114258. * Gets the value of the `B` button
  114259. */
  114260. get buttonB(): number;
  114261. /**
  114262. * Sets the value of the `B` button
  114263. */
  114264. set buttonB(value: number);
  114265. /**
  114266. * Gets the value of the `X` button
  114267. */
  114268. get buttonX(): number;
  114269. /**
  114270. * Sets the value of the `X` button
  114271. */
  114272. set buttonX(value: number);
  114273. /**
  114274. * Gets the value of the `Y` button
  114275. */
  114276. get buttonY(): number;
  114277. /**
  114278. * Sets the value of the `Y` button
  114279. */
  114280. set buttonY(value: number);
  114281. /**
  114282. * Gets the value of the `Start` button
  114283. */
  114284. get buttonStart(): number;
  114285. /**
  114286. * Sets the value of the `Start` button
  114287. */
  114288. set buttonStart(value: number);
  114289. /**
  114290. * Gets the value of the `Back` button
  114291. */
  114292. get buttonBack(): number;
  114293. /**
  114294. * Sets the value of the `Back` button
  114295. */
  114296. set buttonBack(value: number);
  114297. /**
  114298. * Gets the value of the `Left` button
  114299. */
  114300. get buttonLB(): number;
  114301. /**
  114302. * Sets the value of the `Left` button
  114303. */
  114304. set buttonLB(value: number);
  114305. /**
  114306. * Gets the value of the `Right` button
  114307. */
  114308. get buttonRB(): number;
  114309. /**
  114310. * Sets the value of the `Right` button
  114311. */
  114312. set buttonRB(value: number);
  114313. /**
  114314. * Gets the value of the Left joystick
  114315. */
  114316. get buttonLeftStick(): number;
  114317. /**
  114318. * Sets the value of the Left joystick
  114319. */
  114320. set buttonLeftStick(value: number);
  114321. /**
  114322. * Gets the value of the Right joystick
  114323. */
  114324. get buttonRightStick(): number;
  114325. /**
  114326. * Sets the value of the Right joystick
  114327. */
  114328. set buttonRightStick(value: number);
  114329. /**
  114330. * Gets the value of D-pad up
  114331. */
  114332. get dPadUp(): number;
  114333. /**
  114334. * Sets the value of D-pad up
  114335. */
  114336. set dPadUp(value: number);
  114337. /**
  114338. * Gets the value of D-pad down
  114339. */
  114340. get dPadDown(): number;
  114341. /**
  114342. * Sets the value of D-pad down
  114343. */
  114344. set dPadDown(value: number);
  114345. /**
  114346. * Gets the value of D-pad left
  114347. */
  114348. get dPadLeft(): number;
  114349. /**
  114350. * Sets the value of D-pad left
  114351. */
  114352. set dPadLeft(value: number);
  114353. /**
  114354. * Gets the value of D-pad right
  114355. */
  114356. get dPadRight(): number;
  114357. /**
  114358. * Sets the value of D-pad right
  114359. */
  114360. set dPadRight(value: number);
  114361. /**
  114362. * Force the gamepad to synchronize with device values
  114363. */
  114364. update(): void;
  114365. /**
  114366. * Disposes the gamepad
  114367. */
  114368. dispose(): void;
  114369. }
  114370. }
  114371. declare module BABYLON {
  114372. /**
  114373. * Defines supported buttons for DualShock compatible gamepads
  114374. */
  114375. export enum DualShockButton {
  114376. /** Cross */
  114377. Cross = 0,
  114378. /** Circle */
  114379. Circle = 1,
  114380. /** Square */
  114381. Square = 2,
  114382. /** Triangle */
  114383. Triangle = 3,
  114384. /** Options */
  114385. Options = 4,
  114386. /** Share */
  114387. Share = 5,
  114388. /** L1 */
  114389. L1 = 6,
  114390. /** R1 */
  114391. R1 = 7,
  114392. /** Left stick */
  114393. LeftStick = 8,
  114394. /** Right stick */
  114395. RightStick = 9
  114396. }
  114397. /** Defines values for DualShock DPad */
  114398. export enum DualShockDpad {
  114399. /** Up */
  114400. Up = 0,
  114401. /** Down */
  114402. Down = 1,
  114403. /** Left */
  114404. Left = 2,
  114405. /** Right */
  114406. Right = 3
  114407. }
  114408. /**
  114409. * Defines a DualShock gamepad
  114410. */
  114411. export class DualShockPad extends Gamepad {
  114412. private _leftTrigger;
  114413. private _rightTrigger;
  114414. private _onlefttriggerchanged;
  114415. private _onrighttriggerchanged;
  114416. private _onbuttondown;
  114417. private _onbuttonup;
  114418. private _ondpaddown;
  114419. private _ondpadup;
  114420. /** Observable raised when a button is pressed */
  114421. onButtonDownObservable: Observable<DualShockButton>;
  114422. /** Observable raised when a button is released */
  114423. onButtonUpObservable: Observable<DualShockButton>;
  114424. /** Observable raised when a pad is pressed */
  114425. onPadDownObservable: Observable<DualShockDpad>;
  114426. /** Observable raised when a pad is released */
  114427. onPadUpObservable: Observable<DualShockDpad>;
  114428. private _buttonCross;
  114429. private _buttonCircle;
  114430. private _buttonSquare;
  114431. private _buttonTriangle;
  114432. private _buttonShare;
  114433. private _buttonOptions;
  114434. private _buttonL1;
  114435. private _buttonR1;
  114436. private _buttonLeftStick;
  114437. private _buttonRightStick;
  114438. private _dPadUp;
  114439. private _dPadDown;
  114440. private _dPadLeft;
  114441. private _dPadRight;
  114442. /**
  114443. * Creates a new DualShock gamepad object
  114444. * @param id defines the id of this gamepad
  114445. * @param index defines its index
  114446. * @param gamepad defines the internal HTML gamepad object
  114447. */
  114448. constructor(id: string, index: number, gamepad: any);
  114449. /**
  114450. * Defines the callback to call when left trigger is pressed
  114451. * @param callback defines the callback to use
  114452. */
  114453. onlefttriggerchanged(callback: (value: number) => void): void;
  114454. /**
  114455. * Defines the callback to call when right trigger is pressed
  114456. * @param callback defines the callback to use
  114457. */
  114458. onrighttriggerchanged(callback: (value: number) => void): void;
  114459. /**
  114460. * Gets the left trigger value
  114461. */
  114462. get leftTrigger(): number;
  114463. /**
  114464. * Sets the left trigger value
  114465. */
  114466. set leftTrigger(newValue: number);
  114467. /**
  114468. * Gets the right trigger value
  114469. */
  114470. get rightTrigger(): number;
  114471. /**
  114472. * Sets the right trigger value
  114473. */
  114474. set rightTrigger(newValue: number);
  114475. /**
  114476. * Defines the callback to call when a button is pressed
  114477. * @param callback defines the callback to use
  114478. */
  114479. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114480. /**
  114481. * Defines the callback to call when a button is released
  114482. * @param callback defines the callback to use
  114483. */
  114484. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114485. /**
  114486. * Defines the callback to call when a pad is pressed
  114487. * @param callback defines the callback to use
  114488. */
  114489. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114490. /**
  114491. * Defines the callback to call when a pad is released
  114492. * @param callback defines the callback to use
  114493. */
  114494. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114495. private _setButtonValue;
  114496. private _setDPadValue;
  114497. /**
  114498. * Gets the value of the `Cross` button
  114499. */
  114500. get buttonCross(): number;
  114501. /**
  114502. * Sets the value of the `Cross` button
  114503. */
  114504. set buttonCross(value: number);
  114505. /**
  114506. * Gets the value of the `Circle` button
  114507. */
  114508. get buttonCircle(): number;
  114509. /**
  114510. * Sets the value of the `Circle` button
  114511. */
  114512. set buttonCircle(value: number);
  114513. /**
  114514. * Gets the value of the `Square` button
  114515. */
  114516. get buttonSquare(): number;
  114517. /**
  114518. * Sets the value of the `Square` button
  114519. */
  114520. set buttonSquare(value: number);
  114521. /**
  114522. * Gets the value of the `Triangle` button
  114523. */
  114524. get buttonTriangle(): number;
  114525. /**
  114526. * Sets the value of the `Triangle` button
  114527. */
  114528. set buttonTriangle(value: number);
  114529. /**
  114530. * Gets the value of the `Options` button
  114531. */
  114532. get buttonOptions(): number;
  114533. /**
  114534. * Sets the value of the `Options` button
  114535. */
  114536. set buttonOptions(value: number);
  114537. /**
  114538. * Gets the value of the `Share` button
  114539. */
  114540. get buttonShare(): number;
  114541. /**
  114542. * Sets the value of the `Share` button
  114543. */
  114544. set buttonShare(value: number);
  114545. /**
  114546. * Gets the value of the `L1` button
  114547. */
  114548. get buttonL1(): number;
  114549. /**
  114550. * Sets the value of the `L1` button
  114551. */
  114552. set buttonL1(value: number);
  114553. /**
  114554. * Gets the value of the `R1` button
  114555. */
  114556. get buttonR1(): number;
  114557. /**
  114558. * Sets the value of the `R1` button
  114559. */
  114560. set buttonR1(value: number);
  114561. /**
  114562. * Gets the value of the Left joystick
  114563. */
  114564. get buttonLeftStick(): number;
  114565. /**
  114566. * Sets the value of the Left joystick
  114567. */
  114568. set buttonLeftStick(value: number);
  114569. /**
  114570. * Gets the value of the Right joystick
  114571. */
  114572. get buttonRightStick(): number;
  114573. /**
  114574. * Sets the value of the Right joystick
  114575. */
  114576. set buttonRightStick(value: number);
  114577. /**
  114578. * Gets the value of D-pad up
  114579. */
  114580. get dPadUp(): number;
  114581. /**
  114582. * Sets the value of D-pad up
  114583. */
  114584. set dPadUp(value: number);
  114585. /**
  114586. * Gets the value of D-pad down
  114587. */
  114588. get dPadDown(): number;
  114589. /**
  114590. * Sets the value of D-pad down
  114591. */
  114592. set dPadDown(value: number);
  114593. /**
  114594. * Gets the value of D-pad left
  114595. */
  114596. get dPadLeft(): number;
  114597. /**
  114598. * Sets the value of D-pad left
  114599. */
  114600. set dPadLeft(value: number);
  114601. /**
  114602. * Gets the value of D-pad right
  114603. */
  114604. get dPadRight(): number;
  114605. /**
  114606. * Sets the value of D-pad right
  114607. */
  114608. set dPadRight(value: number);
  114609. /**
  114610. * Force the gamepad to synchronize with device values
  114611. */
  114612. update(): void;
  114613. /**
  114614. * Disposes the gamepad
  114615. */
  114616. dispose(): void;
  114617. }
  114618. }
  114619. declare module BABYLON {
  114620. /**
  114621. * Manager for handling gamepads
  114622. */
  114623. export class GamepadManager {
  114624. private _scene?;
  114625. private _babylonGamepads;
  114626. private _oneGamepadConnected;
  114627. /** @hidden */
  114628. _isMonitoring: boolean;
  114629. private _gamepadEventSupported;
  114630. private _gamepadSupport?;
  114631. /**
  114632. * observable to be triggered when the gamepad controller has been connected
  114633. */
  114634. onGamepadConnectedObservable: Observable<Gamepad>;
  114635. /**
  114636. * observable to be triggered when the gamepad controller has been disconnected
  114637. */
  114638. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114639. private _onGamepadConnectedEvent;
  114640. private _onGamepadDisconnectedEvent;
  114641. /**
  114642. * Initializes the gamepad manager
  114643. * @param _scene BabylonJS scene
  114644. */
  114645. constructor(_scene?: Scene | undefined);
  114646. /**
  114647. * The gamepads in the game pad manager
  114648. */
  114649. get gamepads(): Gamepad[];
  114650. /**
  114651. * Get the gamepad controllers based on type
  114652. * @param type The type of gamepad controller
  114653. * @returns Nullable gamepad
  114654. */
  114655. getGamepadByType(type?: number): Nullable<Gamepad>;
  114656. /**
  114657. * Disposes the gamepad manager
  114658. */
  114659. dispose(): void;
  114660. private _addNewGamepad;
  114661. private _startMonitoringGamepads;
  114662. private _stopMonitoringGamepads;
  114663. /** @hidden */
  114664. _checkGamepadsStatus(): void;
  114665. private _updateGamepadObjects;
  114666. }
  114667. }
  114668. declare module BABYLON {
  114669. interface Scene {
  114670. /** @hidden */
  114671. _gamepadManager: Nullable<GamepadManager>;
  114672. /**
  114673. * Gets the gamepad manager associated with the scene
  114674. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114675. */
  114676. gamepadManager: GamepadManager;
  114677. }
  114678. /**
  114679. * Interface representing a free camera inputs manager
  114680. */
  114681. interface FreeCameraInputsManager {
  114682. /**
  114683. * Adds gamepad input support to the FreeCameraInputsManager.
  114684. * @returns the FreeCameraInputsManager
  114685. */
  114686. addGamepad(): FreeCameraInputsManager;
  114687. }
  114688. /**
  114689. * Interface representing an arc rotate camera inputs manager
  114690. */
  114691. interface ArcRotateCameraInputsManager {
  114692. /**
  114693. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114694. * @returns the camera inputs manager
  114695. */
  114696. addGamepad(): ArcRotateCameraInputsManager;
  114697. }
  114698. /**
  114699. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114700. */
  114701. export class GamepadSystemSceneComponent implements ISceneComponent {
  114702. /**
  114703. * The component name helpfull to identify the component in the list of scene components.
  114704. */
  114705. readonly name: string;
  114706. /**
  114707. * The scene the component belongs to.
  114708. */
  114709. scene: Scene;
  114710. /**
  114711. * Creates a new instance of the component for the given scene
  114712. * @param scene Defines the scene to register the component in
  114713. */
  114714. constructor(scene: Scene);
  114715. /**
  114716. * Registers the component in a given scene
  114717. */
  114718. register(): void;
  114719. /**
  114720. * Rebuilds the elements related to this component in case of
  114721. * context lost for instance.
  114722. */
  114723. rebuild(): void;
  114724. /**
  114725. * Disposes the component and the associated ressources
  114726. */
  114727. dispose(): void;
  114728. private _beforeCameraUpdate;
  114729. }
  114730. }
  114731. declare module BABYLON {
  114732. /**
  114733. * 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,
  114734. * which still works and will still be found in many Playgrounds.
  114735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114736. */
  114737. export class UniversalCamera extends TouchCamera {
  114738. /**
  114739. * Defines the gamepad rotation sensiblity.
  114740. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114741. */
  114742. get gamepadAngularSensibility(): number;
  114743. set gamepadAngularSensibility(value: number);
  114744. /**
  114745. * Defines the gamepad move sensiblity.
  114746. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114747. */
  114748. get gamepadMoveSensibility(): number;
  114749. set gamepadMoveSensibility(value: number);
  114750. /**
  114751. * 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,
  114752. * which still works and will still be found in many Playgrounds.
  114753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114754. * @param name Define the name of the camera in the scene
  114755. * @param position Define the start position of the camera in the scene
  114756. * @param scene Define the scene the camera belongs to
  114757. */
  114758. constructor(name: string, position: Vector3, scene: Scene);
  114759. /**
  114760. * Gets the current object class name.
  114761. * @return the class name
  114762. */
  114763. getClassName(): string;
  114764. }
  114765. }
  114766. declare module BABYLON {
  114767. /**
  114768. * This represents a FPS type of camera. This is only here for back compat purpose.
  114769. * Please use the UniversalCamera instead as both are identical.
  114770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114771. */
  114772. export class GamepadCamera extends UniversalCamera {
  114773. /**
  114774. * Instantiates a new Gamepad Camera
  114775. * This represents a FPS type of camera. This is only here for back compat purpose.
  114776. * Please use the UniversalCamera instead as both are identical.
  114777. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114778. * @param name Define the name of the camera in the scene
  114779. * @param position Define the start position of the camera in the scene
  114780. * @param scene Define the scene the camera belongs to
  114781. */
  114782. constructor(name: string, position: Vector3, scene: Scene);
  114783. /**
  114784. * Gets the current object class name.
  114785. * @return the class name
  114786. */
  114787. getClassName(): string;
  114788. }
  114789. }
  114790. declare module BABYLON {
  114791. /** @hidden */
  114792. export var passPixelShader: {
  114793. name: string;
  114794. shader: string;
  114795. };
  114796. }
  114797. declare module BABYLON {
  114798. /** @hidden */
  114799. export var passCubePixelShader: {
  114800. name: string;
  114801. shader: string;
  114802. };
  114803. }
  114804. declare module BABYLON {
  114805. /**
  114806. * PassPostProcess which produces an output the same as it's input
  114807. */
  114808. export class PassPostProcess extends PostProcess {
  114809. /**
  114810. * Creates the PassPostProcess
  114811. * @param name The name of the effect.
  114812. * @param options The required width/height ratio to downsize to before computing the render pass.
  114813. * @param camera The camera to apply the render pass to.
  114814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114815. * @param engine The engine which the post process will be applied. (default: current engine)
  114816. * @param reusable If the post process can be reused on the same frame. (default: false)
  114817. * @param textureType The type of texture to be used when performing the post processing.
  114818. * @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)
  114819. */
  114820. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114821. }
  114822. /**
  114823. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114824. */
  114825. export class PassCubePostProcess extends PostProcess {
  114826. private _face;
  114827. /**
  114828. * Gets or sets the cube face to display.
  114829. * * 0 is +X
  114830. * * 1 is -X
  114831. * * 2 is +Y
  114832. * * 3 is -Y
  114833. * * 4 is +Z
  114834. * * 5 is -Z
  114835. */
  114836. get face(): number;
  114837. set face(value: number);
  114838. /**
  114839. * Creates the PassCubePostProcess
  114840. * @param name The name of the effect.
  114841. * @param options The required width/height ratio to downsize to before computing the render pass.
  114842. * @param camera The camera to apply the render pass to.
  114843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114844. * @param engine The engine which the post process will be applied. (default: current engine)
  114845. * @param reusable If the post process can be reused on the same frame. (default: false)
  114846. * @param textureType The type of texture to be used when performing the post processing.
  114847. * @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)
  114848. */
  114849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114850. }
  114851. }
  114852. declare module BABYLON {
  114853. /** @hidden */
  114854. export var anaglyphPixelShader: {
  114855. name: string;
  114856. shader: string;
  114857. };
  114858. }
  114859. declare module BABYLON {
  114860. /**
  114861. * Postprocess used to generate anaglyphic rendering
  114862. */
  114863. export class AnaglyphPostProcess extends PostProcess {
  114864. private _passedProcess;
  114865. /**
  114866. * Creates a new AnaglyphPostProcess
  114867. * @param name defines postprocess name
  114868. * @param options defines creation options or target ratio scale
  114869. * @param rigCameras defines cameras using this postprocess
  114870. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114871. * @param engine defines hosting engine
  114872. * @param reusable defines if the postprocess will be reused multiple times per frame
  114873. */
  114874. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114875. }
  114876. }
  114877. declare module BABYLON {
  114878. /**
  114879. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114880. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114881. */
  114882. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114883. /**
  114884. * Creates a new AnaglyphArcRotateCamera
  114885. * @param name defines camera name
  114886. * @param alpha defines alpha angle (in radians)
  114887. * @param beta defines beta angle (in radians)
  114888. * @param radius defines radius
  114889. * @param target defines camera target
  114890. * @param interaxialDistance defines distance between each color axis
  114891. * @param scene defines the hosting scene
  114892. */
  114893. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114894. /**
  114895. * Gets camera class name
  114896. * @returns AnaglyphArcRotateCamera
  114897. */
  114898. getClassName(): string;
  114899. }
  114900. }
  114901. declare module BABYLON {
  114902. /**
  114903. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114904. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114905. */
  114906. export class AnaglyphFreeCamera extends FreeCamera {
  114907. /**
  114908. * Creates a new AnaglyphFreeCamera
  114909. * @param name defines camera name
  114910. * @param position defines initial position
  114911. * @param interaxialDistance defines distance between each color axis
  114912. * @param scene defines the hosting scene
  114913. */
  114914. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114915. /**
  114916. * Gets camera class name
  114917. * @returns AnaglyphFreeCamera
  114918. */
  114919. getClassName(): string;
  114920. }
  114921. }
  114922. declare module BABYLON {
  114923. /**
  114924. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114925. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114926. */
  114927. export class AnaglyphGamepadCamera extends GamepadCamera {
  114928. /**
  114929. * Creates a new AnaglyphGamepadCamera
  114930. * @param name defines camera name
  114931. * @param position defines initial position
  114932. * @param interaxialDistance defines distance between each color axis
  114933. * @param scene defines the hosting scene
  114934. */
  114935. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114936. /**
  114937. * Gets camera class name
  114938. * @returns AnaglyphGamepadCamera
  114939. */
  114940. getClassName(): string;
  114941. }
  114942. }
  114943. declare module BABYLON {
  114944. /**
  114945. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114946. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114947. */
  114948. export class AnaglyphUniversalCamera extends UniversalCamera {
  114949. /**
  114950. * Creates a new AnaglyphUniversalCamera
  114951. * @param name defines camera name
  114952. * @param position defines initial position
  114953. * @param interaxialDistance defines distance between each color axis
  114954. * @param scene defines the hosting scene
  114955. */
  114956. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114957. /**
  114958. * Gets camera class name
  114959. * @returns AnaglyphUniversalCamera
  114960. */
  114961. getClassName(): string;
  114962. }
  114963. }
  114964. declare module BABYLON {
  114965. /** @hidden */
  114966. export var stereoscopicInterlacePixelShader: {
  114967. name: string;
  114968. shader: string;
  114969. };
  114970. }
  114971. declare module BABYLON {
  114972. /**
  114973. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114974. */
  114975. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114976. private _stepSize;
  114977. private _passedProcess;
  114978. /**
  114979. * Initializes a StereoscopicInterlacePostProcessI
  114980. * @param name The name of the effect.
  114981. * @param rigCameras The rig cameras to be appled to the post process
  114982. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114983. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114985. * @param engine The engine which the post process will be applied. (default: current engine)
  114986. * @param reusable If the post process can be reused on the same frame. (default: false)
  114987. */
  114988. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114989. }
  114990. /**
  114991. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114992. */
  114993. export class StereoscopicInterlacePostProcess extends PostProcess {
  114994. private _stepSize;
  114995. private _passedProcess;
  114996. /**
  114997. * Initializes a StereoscopicInterlacePostProcess
  114998. * @param name The name of the effect.
  114999. * @param rigCameras The rig cameras to be appled to the post process
  115000. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115002. * @param engine The engine which the post process will be applied. (default: current engine)
  115003. * @param reusable If the post process can be reused on the same frame. (default: false)
  115004. */
  115005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115006. }
  115007. }
  115008. declare module BABYLON {
  115009. /**
  115010. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115011. * @see http://doc.babylonjs.com/features/cameras
  115012. */
  115013. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115014. /**
  115015. * Creates a new StereoscopicArcRotateCamera
  115016. * @param name defines camera name
  115017. * @param alpha defines alpha angle (in radians)
  115018. * @param beta defines beta angle (in radians)
  115019. * @param radius defines radius
  115020. * @param target defines camera target
  115021. * @param interaxialDistance defines distance between each color axis
  115022. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115023. * @param scene defines the hosting scene
  115024. */
  115025. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115026. /**
  115027. * Gets camera class name
  115028. * @returns StereoscopicArcRotateCamera
  115029. */
  115030. getClassName(): string;
  115031. }
  115032. }
  115033. declare module BABYLON {
  115034. /**
  115035. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115036. * @see http://doc.babylonjs.com/features/cameras
  115037. */
  115038. export class StereoscopicFreeCamera extends FreeCamera {
  115039. /**
  115040. * Creates a new StereoscopicFreeCamera
  115041. * @param name defines camera name
  115042. * @param position defines initial position
  115043. * @param interaxialDistance defines distance between each color axis
  115044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115045. * @param scene defines the hosting scene
  115046. */
  115047. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115048. /**
  115049. * Gets camera class name
  115050. * @returns StereoscopicFreeCamera
  115051. */
  115052. getClassName(): string;
  115053. }
  115054. }
  115055. declare module BABYLON {
  115056. /**
  115057. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115058. * @see http://doc.babylonjs.com/features/cameras
  115059. */
  115060. export class StereoscopicGamepadCamera extends GamepadCamera {
  115061. /**
  115062. * Creates a new StereoscopicGamepadCamera
  115063. * @param name defines camera name
  115064. * @param position defines initial position
  115065. * @param interaxialDistance defines distance between each color axis
  115066. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115067. * @param scene defines the hosting scene
  115068. */
  115069. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115070. /**
  115071. * Gets camera class name
  115072. * @returns StereoscopicGamepadCamera
  115073. */
  115074. getClassName(): string;
  115075. }
  115076. }
  115077. declare module BABYLON {
  115078. /**
  115079. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115080. * @see http://doc.babylonjs.com/features/cameras
  115081. */
  115082. export class StereoscopicUniversalCamera extends UniversalCamera {
  115083. /**
  115084. * Creates a new StereoscopicUniversalCamera
  115085. * @param name defines camera name
  115086. * @param position defines initial position
  115087. * @param interaxialDistance defines distance between each color axis
  115088. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115089. * @param scene defines the hosting scene
  115090. */
  115091. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115092. /**
  115093. * Gets camera class name
  115094. * @returns StereoscopicUniversalCamera
  115095. */
  115096. getClassName(): string;
  115097. }
  115098. }
  115099. declare module BABYLON {
  115100. /**
  115101. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115102. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115103. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115104. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115105. */
  115106. export class VirtualJoysticksCamera extends FreeCamera {
  115107. /**
  115108. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115109. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115110. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115111. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115112. * @param name Define the name of the camera in the scene
  115113. * @param position Define the start position of the camera in the scene
  115114. * @param scene Define the scene the camera belongs to
  115115. */
  115116. constructor(name: string, position: Vector3, scene: Scene);
  115117. /**
  115118. * Gets the current object class name.
  115119. * @return the class name
  115120. */
  115121. getClassName(): string;
  115122. }
  115123. }
  115124. declare module BABYLON {
  115125. /**
  115126. * This represents all the required metrics to create a VR camera.
  115127. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115128. */
  115129. export class VRCameraMetrics {
  115130. /**
  115131. * Define the horizontal resolution off the screen.
  115132. */
  115133. hResolution: number;
  115134. /**
  115135. * Define the vertical resolution off the screen.
  115136. */
  115137. vResolution: number;
  115138. /**
  115139. * Define the horizontal screen size.
  115140. */
  115141. hScreenSize: number;
  115142. /**
  115143. * Define the vertical screen size.
  115144. */
  115145. vScreenSize: number;
  115146. /**
  115147. * Define the vertical screen center position.
  115148. */
  115149. vScreenCenter: number;
  115150. /**
  115151. * Define the distance of the eyes to the screen.
  115152. */
  115153. eyeToScreenDistance: number;
  115154. /**
  115155. * Define the distance between both lenses
  115156. */
  115157. lensSeparationDistance: number;
  115158. /**
  115159. * Define the distance between both viewer's eyes.
  115160. */
  115161. interpupillaryDistance: number;
  115162. /**
  115163. * Define the distortion factor of the VR postprocess.
  115164. * Please, touch with care.
  115165. */
  115166. distortionK: number[];
  115167. /**
  115168. * Define the chromatic aberration correction factors for the VR post process.
  115169. */
  115170. chromaAbCorrection: number[];
  115171. /**
  115172. * Define the scale factor of the post process.
  115173. * The smaller the better but the slower.
  115174. */
  115175. postProcessScaleFactor: number;
  115176. /**
  115177. * Define an offset for the lens center.
  115178. */
  115179. lensCenterOffset: number;
  115180. /**
  115181. * Define if the current vr camera should compensate the distortion of the lense or not.
  115182. */
  115183. compensateDistortion: boolean;
  115184. /**
  115185. * Defines if multiview should be enabled when rendering (Default: false)
  115186. */
  115187. multiviewEnabled: boolean;
  115188. /**
  115189. * Gets the rendering aspect ratio based on the provided resolutions.
  115190. */
  115191. get aspectRatio(): number;
  115192. /**
  115193. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115194. */
  115195. get aspectRatioFov(): number;
  115196. /**
  115197. * @hidden
  115198. */
  115199. get leftHMatrix(): Matrix;
  115200. /**
  115201. * @hidden
  115202. */
  115203. get rightHMatrix(): Matrix;
  115204. /**
  115205. * @hidden
  115206. */
  115207. get leftPreViewMatrix(): Matrix;
  115208. /**
  115209. * @hidden
  115210. */
  115211. get rightPreViewMatrix(): Matrix;
  115212. /**
  115213. * Get the default VRMetrics based on the most generic setup.
  115214. * @returns the default vr metrics
  115215. */
  115216. static GetDefault(): VRCameraMetrics;
  115217. }
  115218. }
  115219. declare module BABYLON {
  115220. /** @hidden */
  115221. export var vrDistortionCorrectionPixelShader: {
  115222. name: string;
  115223. shader: string;
  115224. };
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * VRDistortionCorrectionPostProcess used for mobile VR
  115229. */
  115230. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115231. private _isRightEye;
  115232. private _distortionFactors;
  115233. private _postProcessScaleFactor;
  115234. private _lensCenterOffset;
  115235. private _scaleIn;
  115236. private _scaleFactor;
  115237. private _lensCenter;
  115238. /**
  115239. * Initializes the VRDistortionCorrectionPostProcess
  115240. * @param name The name of the effect.
  115241. * @param camera The camera to apply the render pass to.
  115242. * @param isRightEye If this is for the right eye distortion
  115243. * @param vrMetrics All the required metrics for the VR camera
  115244. */
  115245. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115246. }
  115247. }
  115248. declare module BABYLON {
  115249. /**
  115250. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115251. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115252. */
  115253. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115254. /**
  115255. * Creates a new VRDeviceOrientationArcRotateCamera
  115256. * @param name defines camera name
  115257. * @param alpha defines the camera rotation along the logitudinal axis
  115258. * @param beta defines the camera rotation along the latitudinal axis
  115259. * @param radius defines the camera distance from its target
  115260. * @param target defines the camera target
  115261. * @param scene defines the scene the camera belongs to
  115262. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115263. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115264. */
  115265. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115266. /**
  115267. * Gets camera class name
  115268. * @returns VRDeviceOrientationArcRotateCamera
  115269. */
  115270. getClassName(): string;
  115271. }
  115272. }
  115273. declare module BABYLON {
  115274. /**
  115275. * Camera used to simulate VR rendering (based on FreeCamera)
  115276. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115277. */
  115278. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115279. /**
  115280. * Creates a new VRDeviceOrientationFreeCamera
  115281. * @param name defines camera name
  115282. * @param position defines the start position of the camera
  115283. * @param scene defines the scene the camera belongs to
  115284. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115285. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115286. */
  115287. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115288. /**
  115289. * Gets camera class name
  115290. * @returns VRDeviceOrientationFreeCamera
  115291. */
  115292. getClassName(): string;
  115293. }
  115294. }
  115295. declare module BABYLON {
  115296. /**
  115297. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115298. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115299. */
  115300. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115301. /**
  115302. * Creates a new VRDeviceOrientationGamepadCamera
  115303. * @param name defines camera name
  115304. * @param position defines the start position of the camera
  115305. * @param scene defines the scene the camera belongs to
  115306. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115307. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115308. */
  115309. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115310. /**
  115311. * Gets camera class name
  115312. * @returns VRDeviceOrientationGamepadCamera
  115313. */
  115314. getClassName(): string;
  115315. }
  115316. }
  115317. declare module BABYLON {
  115318. /** @hidden */
  115319. export var imageProcessingPixelShader: {
  115320. name: string;
  115321. shader: string;
  115322. };
  115323. }
  115324. declare module BABYLON {
  115325. /**
  115326. * ImageProcessingPostProcess
  115327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115328. */
  115329. export class ImageProcessingPostProcess extends PostProcess {
  115330. /**
  115331. * Default configuration related to image processing available in the PBR Material.
  115332. */
  115333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115334. /**
  115335. * Gets the image processing configuration used either in this material.
  115336. */
  115337. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115338. /**
  115339. * Sets the Default image processing configuration used either in the this material.
  115340. *
  115341. * If sets to null, the scene one is in use.
  115342. */
  115343. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115344. /**
  115345. * Keep track of the image processing observer to allow dispose and replace.
  115346. */
  115347. private _imageProcessingObserver;
  115348. /**
  115349. * Attaches a new image processing configuration to the PBR Material.
  115350. * @param configuration
  115351. */
  115352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115353. /**
  115354. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115355. */
  115356. get colorCurves(): Nullable<ColorCurves>;
  115357. /**
  115358. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115359. */
  115360. set colorCurves(value: Nullable<ColorCurves>);
  115361. /**
  115362. * Gets wether the color curves effect is enabled.
  115363. */
  115364. get colorCurvesEnabled(): boolean;
  115365. /**
  115366. * Sets wether the color curves effect is enabled.
  115367. */
  115368. set colorCurvesEnabled(value: boolean);
  115369. /**
  115370. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115371. */
  115372. get colorGradingTexture(): Nullable<BaseTexture>;
  115373. /**
  115374. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115375. */
  115376. set colorGradingTexture(value: Nullable<BaseTexture>);
  115377. /**
  115378. * Gets wether the color grading effect is enabled.
  115379. */
  115380. get colorGradingEnabled(): boolean;
  115381. /**
  115382. * Gets wether the color grading effect is enabled.
  115383. */
  115384. set colorGradingEnabled(value: boolean);
  115385. /**
  115386. * Gets exposure used in the effect.
  115387. */
  115388. get exposure(): number;
  115389. /**
  115390. * Sets exposure used in the effect.
  115391. */
  115392. set exposure(value: number);
  115393. /**
  115394. * Gets wether tonemapping is enabled or not.
  115395. */
  115396. get toneMappingEnabled(): boolean;
  115397. /**
  115398. * Sets wether tonemapping is enabled or not
  115399. */
  115400. set toneMappingEnabled(value: boolean);
  115401. /**
  115402. * Gets the type of tone mapping effect.
  115403. */
  115404. get toneMappingType(): number;
  115405. /**
  115406. * Sets the type of tone mapping effect.
  115407. */
  115408. set toneMappingType(value: number);
  115409. /**
  115410. * Gets contrast used in the effect.
  115411. */
  115412. get contrast(): number;
  115413. /**
  115414. * Sets contrast used in the effect.
  115415. */
  115416. set contrast(value: number);
  115417. /**
  115418. * Gets Vignette stretch size.
  115419. */
  115420. get vignetteStretch(): number;
  115421. /**
  115422. * Sets Vignette stretch size.
  115423. */
  115424. set vignetteStretch(value: number);
  115425. /**
  115426. * Gets Vignette centre X Offset.
  115427. */
  115428. get vignetteCentreX(): number;
  115429. /**
  115430. * Sets Vignette centre X Offset.
  115431. */
  115432. set vignetteCentreX(value: number);
  115433. /**
  115434. * Gets Vignette centre Y Offset.
  115435. */
  115436. get vignetteCentreY(): number;
  115437. /**
  115438. * Sets Vignette centre Y Offset.
  115439. */
  115440. set vignetteCentreY(value: number);
  115441. /**
  115442. * Gets Vignette weight or intensity of the vignette effect.
  115443. */
  115444. get vignetteWeight(): number;
  115445. /**
  115446. * Sets Vignette weight or intensity of the vignette effect.
  115447. */
  115448. set vignetteWeight(value: number);
  115449. /**
  115450. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115451. * if vignetteEnabled is set to true.
  115452. */
  115453. get vignetteColor(): Color4;
  115454. /**
  115455. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115456. * if vignetteEnabled is set to true.
  115457. */
  115458. set vignetteColor(value: Color4);
  115459. /**
  115460. * Gets Camera field of view used by the Vignette effect.
  115461. */
  115462. get vignetteCameraFov(): number;
  115463. /**
  115464. * Sets Camera field of view used by the Vignette effect.
  115465. */
  115466. set vignetteCameraFov(value: number);
  115467. /**
  115468. * Gets the vignette blend mode allowing different kind of effect.
  115469. */
  115470. get vignetteBlendMode(): number;
  115471. /**
  115472. * Sets the vignette blend mode allowing different kind of effect.
  115473. */
  115474. set vignetteBlendMode(value: number);
  115475. /**
  115476. * Gets wether the vignette effect is enabled.
  115477. */
  115478. get vignetteEnabled(): boolean;
  115479. /**
  115480. * Sets wether the vignette effect is enabled.
  115481. */
  115482. set vignetteEnabled(value: boolean);
  115483. private _fromLinearSpace;
  115484. /**
  115485. * Gets wether the input of the processing is in Gamma or Linear Space.
  115486. */
  115487. get fromLinearSpace(): boolean;
  115488. /**
  115489. * Sets wether the input of the processing is in Gamma or Linear Space.
  115490. */
  115491. set fromLinearSpace(value: boolean);
  115492. /**
  115493. * Defines cache preventing GC.
  115494. */
  115495. private _defines;
  115496. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115497. /**
  115498. * "ImageProcessingPostProcess"
  115499. * @returns "ImageProcessingPostProcess"
  115500. */
  115501. getClassName(): string;
  115502. protected _updateParameters(): void;
  115503. dispose(camera?: Camera): void;
  115504. }
  115505. }
  115506. declare module BABYLON {
  115507. /**
  115508. * Class containing static functions to help procedurally build meshes
  115509. */
  115510. export class GroundBuilder {
  115511. /**
  115512. * Creates a ground mesh
  115513. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115514. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115516. * @param name defines the name of the mesh
  115517. * @param options defines the options used to create the mesh
  115518. * @param scene defines the hosting scene
  115519. * @returns the ground mesh
  115520. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115521. */
  115522. static CreateGround(name: string, options: {
  115523. width?: number;
  115524. height?: number;
  115525. subdivisions?: number;
  115526. subdivisionsX?: number;
  115527. subdivisionsY?: number;
  115528. updatable?: boolean;
  115529. }, scene: any): Mesh;
  115530. /**
  115531. * Creates a tiled ground mesh
  115532. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115533. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115534. * * 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
  115535. * * 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
  115536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115537. * @param name defines the name of the mesh
  115538. * @param options defines the options used to create the mesh
  115539. * @param scene defines the hosting scene
  115540. * @returns the tiled ground mesh
  115541. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115542. */
  115543. static CreateTiledGround(name: string, options: {
  115544. xmin: number;
  115545. zmin: number;
  115546. xmax: number;
  115547. zmax: number;
  115548. subdivisions?: {
  115549. w: number;
  115550. h: number;
  115551. };
  115552. precision?: {
  115553. w: number;
  115554. h: number;
  115555. };
  115556. updatable?: boolean;
  115557. }, scene?: Nullable<Scene>): Mesh;
  115558. /**
  115559. * Creates a ground mesh from a height map
  115560. * * The parameter `url` sets the URL of the height map image resource.
  115561. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115562. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115563. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115564. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115565. * * 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.
  115566. * * 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).
  115567. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115569. * @param name defines the name of the mesh
  115570. * @param url defines the url to the height map
  115571. * @param options defines the options used to create the mesh
  115572. * @param scene defines the hosting scene
  115573. * @returns the ground mesh
  115574. * @see https://doc.babylonjs.com/babylon101/height_map
  115575. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115576. */
  115577. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115578. width?: number;
  115579. height?: number;
  115580. subdivisions?: number;
  115581. minHeight?: number;
  115582. maxHeight?: number;
  115583. colorFilter?: Color3;
  115584. alphaFilter?: number;
  115585. updatable?: boolean;
  115586. onReady?: (mesh: GroundMesh) => void;
  115587. }, scene?: Nullable<Scene>): GroundMesh;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Class containing static functions to help procedurally build meshes
  115593. */
  115594. export class TorusBuilder {
  115595. /**
  115596. * Creates a torus mesh
  115597. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115598. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115599. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115603. * @param name defines the name of the mesh
  115604. * @param options defines the options used to create the mesh
  115605. * @param scene defines the hosting scene
  115606. * @returns the torus mesh
  115607. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115608. */
  115609. static CreateTorus(name: string, options: {
  115610. diameter?: number;
  115611. thickness?: number;
  115612. tessellation?: number;
  115613. updatable?: boolean;
  115614. sideOrientation?: number;
  115615. frontUVs?: Vector4;
  115616. backUVs?: Vector4;
  115617. }, scene: any): Mesh;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * Class containing static functions to help procedurally build meshes
  115623. */
  115624. export class CylinderBuilder {
  115625. /**
  115626. * Creates a cylinder or a cone mesh
  115627. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115628. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115629. * * 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.
  115630. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115631. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115632. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115633. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115634. * * 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).
  115635. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115636. * * 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).
  115637. * * 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
  115638. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115639. * * 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
  115640. * * 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.
  115641. * * If `enclose` is false, a ring surface is one element.
  115642. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115643. * * 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
  115644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115647. * @param name defines the name of the mesh
  115648. * @param options defines the options used to create the mesh
  115649. * @param scene defines the hosting scene
  115650. * @returns the cylinder mesh
  115651. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115652. */
  115653. static CreateCylinder(name: string, options: {
  115654. height?: number;
  115655. diameterTop?: number;
  115656. diameterBottom?: number;
  115657. diameter?: number;
  115658. tessellation?: number;
  115659. subdivisions?: number;
  115660. arc?: number;
  115661. faceColors?: Color4[];
  115662. faceUV?: Vector4[];
  115663. updatable?: boolean;
  115664. hasRings?: boolean;
  115665. enclose?: boolean;
  115666. cap?: number;
  115667. sideOrientation?: number;
  115668. frontUVs?: Vector4;
  115669. backUVs?: Vector4;
  115670. }, scene: any): Mesh;
  115671. }
  115672. }
  115673. declare module BABYLON {
  115674. /**
  115675. * States of the webXR experience
  115676. */
  115677. export enum WebXRState {
  115678. /**
  115679. * Transitioning to being in XR mode
  115680. */
  115681. ENTERING_XR = 0,
  115682. /**
  115683. * Transitioning to non XR mode
  115684. */
  115685. EXITING_XR = 1,
  115686. /**
  115687. * In XR mode and presenting
  115688. */
  115689. IN_XR = 2,
  115690. /**
  115691. * Not entered XR mode
  115692. */
  115693. NOT_IN_XR = 3
  115694. }
  115695. /**
  115696. * Abstraction of the XR render target
  115697. */
  115698. export interface WebXRRenderTarget extends IDisposable {
  115699. /**
  115700. * xrpresent context of the canvas which can be used to display/mirror xr content
  115701. */
  115702. canvasContext: WebGLRenderingContext;
  115703. /**
  115704. * xr layer for the canvas
  115705. */
  115706. xrLayer: Nullable<XRWebGLLayer>;
  115707. /**
  115708. * Initializes the xr layer for the session
  115709. * @param xrSession xr session
  115710. * @returns a promise that will resolve once the XR Layer has been created
  115711. */
  115712. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115713. }
  115714. }
  115715. declare module BABYLON {
  115716. /**
  115717. * COnfiguration object for WebXR output canvas
  115718. */
  115719. export class WebXRManagedOutputCanvasOptions {
  115720. /**
  115721. * An optional canvas in case you wish to create it yourself and provide it here.
  115722. * If not provided, a new canvas will be created
  115723. */
  115724. canvasElement?: HTMLCanvasElement;
  115725. /**
  115726. * Options for this XR Layer output
  115727. */
  115728. canvasOptions?: XRWebGLLayerOptions;
  115729. /**
  115730. * CSS styling for a newly created canvas (if not provided)
  115731. */
  115732. newCanvasCssStyle?: string;
  115733. /**
  115734. * Get the default values of the configuration object
  115735. * @returns default values of this configuration object
  115736. */
  115737. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115738. }
  115739. /**
  115740. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115741. */
  115742. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115743. private _options;
  115744. private _canvas;
  115745. private _engine;
  115746. /**
  115747. * Rendering context of the canvas which can be used to display/mirror xr content
  115748. */
  115749. canvasContext: WebGLRenderingContext;
  115750. /**
  115751. * xr layer for the canvas
  115752. */
  115753. xrLayer: Nullable<XRWebGLLayer>;
  115754. /**
  115755. * Initializes the canvas to be added/removed upon entering/exiting xr
  115756. * @param _xrSessionManager The XR Session manager
  115757. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115758. */
  115759. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115760. /**
  115761. * Disposes of the object
  115762. */
  115763. dispose(): void;
  115764. /**
  115765. * Initializes the xr layer for the session
  115766. * @param xrSession xr session
  115767. * @returns a promise that will resolve once the XR Layer has been created
  115768. */
  115769. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115770. private _addCanvas;
  115771. private _removeCanvas;
  115772. private _setManagedOutputCanvas;
  115773. }
  115774. }
  115775. declare module BABYLON {
  115776. /**
  115777. * Manages an XRSession to work with Babylon's engine
  115778. * @see https://doc.babylonjs.com/how_to/webxr
  115779. */
  115780. export class WebXRSessionManager implements IDisposable {
  115781. /** The scene which the session should be created for */
  115782. scene: Scene;
  115783. private _referenceSpace;
  115784. private _rttProvider;
  115785. private _sessionEnded;
  115786. private _xrNavigator;
  115787. private baseLayer;
  115788. /**
  115789. * The base reference space from which the session started. good if you want to reset your
  115790. * reference space
  115791. */
  115792. baseReferenceSpace: XRReferenceSpace;
  115793. /**
  115794. * Current XR frame
  115795. */
  115796. currentFrame: Nullable<XRFrame>;
  115797. /** WebXR timestamp updated every frame */
  115798. currentTimestamp: number;
  115799. /**
  115800. * Used just in case of a failure to initialize an immersive session.
  115801. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115802. */
  115803. defaultHeightCompensation: number;
  115804. /**
  115805. * Fires every time a new xrFrame arrives which can be used to update the camera
  115806. */
  115807. onXRFrameObservable: Observable<XRFrame>;
  115808. /**
  115809. * Fires when the reference space changed
  115810. */
  115811. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115812. /**
  115813. * Fires when the xr session is ended either by the device or manually done
  115814. */
  115815. onXRSessionEnded: Observable<any>;
  115816. /**
  115817. * Fires when the xr session is ended either by the device or manually done
  115818. */
  115819. onXRSessionInit: Observable<XRSession>;
  115820. /**
  115821. * Underlying xr session
  115822. */
  115823. session: XRSession;
  115824. /**
  115825. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115826. * or get the offset the player is currently at.
  115827. */
  115828. viewerReferenceSpace: XRReferenceSpace;
  115829. /**
  115830. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115831. * @param scene The scene which the session should be created for
  115832. */
  115833. constructor(
  115834. /** The scene which the session should be created for */
  115835. scene: Scene);
  115836. /**
  115837. * The current reference space used in this session. This reference space can constantly change!
  115838. * It is mainly used to offset the camera's position.
  115839. */
  115840. get referenceSpace(): XRReferenceSpace;
  115841. /**
  115842. * Set a new reference space and triggers the observable
  115843. */
  115844. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115845. /**
  115846. * Disposes of the session manager
  115847. */
  115848. dispose(): void;
  115849. /**
  115850. * Stops the xrSession and restores the render loop
  115851. * @returns Promise which resolves after it exits XR
  115852. */
  115853. exitXRAsync(): Promise<void>;
  115854. /**
  115855. * Gets the correct render target texture to be rendered this frame for this eye
  115856. * @param eye the eye for which to get the render target
  115857. * @returns the render target for the specified eye
  115858. */
  115859. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115860. /**
  115861. * Creates a WebXRRenderTarget object for the XR session
  115862. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115863. * @param options optional options to provide when creating a new render target
  115864. * @returns a WebXR render target to which the session can render
  115865. */
  115866. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115867. /**
  115868. * Initializes the manager
  115869. * After initialization enterXR can be called to start an XR session
  115870. * @returns Promise which resolves after it is initialized
  115871. */
  115872. initializeAsync(): Promise<void>;
  115873. /**
  115874. * Initializes an xr session
  115875. * @param xrSessionMode mode to initialize
  115876. * @param xrSessionInit defines optional and required values to pass to the session builder
  115877. * @returns a promise which will resolve once the session has been initialized
  115878. */
  115879. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115880. /**
  115881. * Checks if a session would be supported for the creation options specified
  115882. * @param sessionMode session mode to check if supported eg. immersive-vr
  115883. * @returns A Promise that resolves to true if supported and false if not
  115884. */
  115885. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115886. /**
  115887. * Resets the reference space to the one started the session
  115888. */
  115889. resetReferenceSpace(): void;
  115890. /**
  115891. * Starts rendering to the xr layer
  115892. */
  115893. runXRRenderLoop(): void;
  115894. /**
  115895. * Sets the reference space on the xr session
  115896. * @param referenceSpaceType space to set
  115897. * @returns a promise that will resolve once the reference space has been set
  115898. */
  115899. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115900. /**
  115901. * Updates the render state of the session
  115902. * @param state state to set
  115903. * @returns a promise that resolves once the render state has been updated
  115904. */
  115905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115906. /**
  115907. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115908. * @param sessionMode defines the session to test
  115909. * @returns a promise with boolean as final value
  115910. */
  115911. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115912. /**
  115913. * @hidden
  115914. * Converts the render layer of xrSession to a render target
  115915. * @param session session to create render target for
  115916. * @param scene scene the new render target should be created for
  115917. * @param baseLayer the webgl layer to create the render target for
  115918. */
  115919. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115920. }
  115921. }
  115922. declare module BABYLON {
  115923. /**
  115924. * WebXR Camera which holds the views for the xrSession
  115925. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115926. */
  115927. export class WebXRCamera extends FreeCamera {
  115928. private _xrSessionManager;
  115929. private _firstFrame;
  115930. private _referenceQuaternion;
  115931. private _referencedPosition;
  115932. private _xrInvPositionCache;
  115933. private _xrInvQuaternionCache;
  115934. /**
  115935. * Should position compensation execute on first frame.
  115936. * This is used when copying the position from a native (non XR) camera
  115937. */
  115938. compensateOnFirstFrame: boolean;
  115939. /**
  115940. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115941. * @param name the name of the camera
  115942. * @param scene the scene to add the camera to
  115943. * @param _xrSessionManager a constructed xr session manager
  115944. */
  115945. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115946. /**
  115947. * Return the user's height, unrelated to the current ground.
  115948. * This will be the y position of this camera, when ground level is 0.
  115949. */
  115950. get realWorldHeight(): number;
  115951. /** @hidden */
  115952. _updateForDualEyeDebugging(): void;
  115953. /**
  115954. * Sets this camera's transformation based on a non-vr camera
  115955. * @param otherCamera the non-vr camera to copy the transformation from
  115956. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115957. */
  115958. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115959. private _updateFromXRSession;
  115960. private _updateNumberOfRigCameras;
  115961. private _updateReferenceSpace;
  115962. private _updateReferenceSpaceOffset;
  115963. }
  115964. }
  115965. declare module BABYLON {
  115966. /**
  115967. * Defining the interface required for a (webxr) feature
  115968. */
  115969. export interface IWebXRFeature extends IDisposable {
  115970. /**
  115971. * Is this feature attached
  115972. */
  115973. attached: boolean;
  115974. /**
  115975. * Should auto-attach be disabled?
  115976. */
  115977. disableAutoAttach: boolean;
  115978. /**
  115979. * Attach the feature to the session
  115980. * Will usually be called by the features manager
  115981. *
  115982. * @param force should attachment be forced (even when already attached)
  115983. * @returns true if successful.
  115984. */
  115985. attach(force?: boolean): boolean;
  115986. /**
  115987. * Detach the feature from the session
  115988. * Will usually be called by the features manager
  115989. *
  115990. * @returns true if successful.
  115991. */
  115992. detach(): boolean;
  115993. }
  115994. /**
  115995. * A list of the currently available features without referencing them
  115996. */
  115997. export class WebXRFeatureName {
  115998. /**
  115999. * The name of the anchor system feature
  116000. */
  116001. static ANCHOR_SYSTEM: string;
  116002. /**
  116003. * The name of the background remover feature
  116004. */
  116005. static BACKGROUND_REMOVER: string;
  116006. /**
  116007. * The name of the hit test feature
  116008. */
  116009. static HIT_TEST: string;
  116010. /**
  116011. * physics impostors for xr controllers feature
  116012. */
  116013. static PHYSICS_CONTROLLERS: string;
  116014. /**
  116015. * The name of the plane detection feature
  116016. */
  116017. static PLANE_DETECTION: string;
  116018. /**
  116019. * The name of the pointer selection feature
  116020. */
  116021. static POINTER_SELECTION: string;
  116022. /**
  116023. * The name of the teleportation feature
  116024. */
  116025. static TELEPORTATION: string;
  116026. }
  116027. /**
  116028. * Defining the constructor of a feature. Used to register the modules.
  116029. */
  116030. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116031. /**
  116032. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116033. * It is mainly used in AR sessions.
  116034. *
  116035. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116036. */
  116037. export class WebXRFeaturesManager implements IDisposable {
  116038. private _xrSessionManager;
  116039. private static readonly _AvailableFeatures;
  116040. private _features;
  116041. /**
  116042. * constructs a new features manages.
  116043. *
  116044. * @param _xrSessionManager an instance of WebXRSessionManager
  116045. */
  116046. constructor(_xrSessionManager: WebXRSessionManager);
  116047. /**
  116048. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116049. * Mainly used internally.
  116050. *
  116051. * @param featureName the name of the feature to register
  116052. * @param constructorFunction the function used to construct the module
  116053. * @param version the (babylon) version of the module
  116054. * @param stable is that a stable version of this module
  116055. */
  116056. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116057. /**
  116058. * Returns a constructor of a specific feature.
  116059. *
  116060. * @param featureName the name of the feature to construct
  116061. * @param version the version of the feature to load
  116062. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116063. * @param options optional options provided to the module.
  116064. * @returns a function that, when called, will return a new instance of this feature
  116065. */
  116066. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116067. /**
  116068. * Can be used to return the list of features currently registered
  116069. *
  116070. * @returns an Array of available features
  116071. */
  116072. static GetAvailableFeatures(): string[];
  116073. /**
  116074. * Gets the versions available for a specific feature
  116075. * @param featureName the name of the feature
  116076. * @returns an array with the available versions
  116077. */
  116078. static GetAvailableVersions(featureName: string): string[];
  116079. /**
  116080. * Return the latest unstable version of this feature
  116081. * @param featureName the name of the feature to search
  116082. * @returns the version number. if not found will return -1
  116083. */
  116084. static GetLatestVersionOfFeature(featureName: string): number;
  116085. /**
  116086. * Return the latest stable version of this feature
  116087. * @param featureName the name of the feature to search
  116088. * @returns the version number. if not found will return -1
  116089. */
  116090. static GetStableVersionOfFeature(featureName: string): number;
  116091. /**
  116092. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116093. * Can be used during a session to start a feature
  116094. * @param featureName the name of feature to attach
  116095. */
  116096. attachFeature(featureName: string): void;
  116097. /**
  116098. * Can be used inside a session or when the session ends to detach a specific feature
  116099. * @param featureName the name of the feature to detach
  116100. */
  116101. detachFeature(featureName: string): void;
  116102. /**
  116103. * Used to disable an already-enabled feature
  116104. * The feature will be disposed and will be recreated once enabled.
  116105. * @param featureName the feature to disable
  116106. * @returns true if disable was successful
  116107. */
  116108. disableFeature(featureName: string | {
  116109. Name: string;
  116110. }): boolean;
  116111. /**
  116112. * dispose this features manager
  116113. */
  116114. dispose(): void;
  116115. /**
  116116. * 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.
  116117. * 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.
  116118. *
  116119. * @param featureName the name of the feature to load or the class of the feature
  116120. * @param version optional version to load. if not provided the latest version will be enabled
  116121. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116122. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116123. * @returns a new constructed feature or throws an error if feature not found.
  116124. */
  116125. enableFeature(featureName: string | {
  116126. Name: string;
  116127. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116128. /**
  116129. * get the implementation of an enabled feature.
  116130. * @param featureName the name of the feature to load
  116131. * @returns the feature class, if found
  116132. */
  116133. getEnabledFeature(featureName: string): IWebXRFeature;
  116134. /**
  116135. * Get the list of enabled features
  116136. * @returns an array of enabled features
  116137. */
  116138. getEnabledFeatures(): string[];
  116139. }
  116140. }
  116141. declare module BABYLON {
  116142. /**
  116143. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116144. * @see https://doc.babylonjs.com/how_to/webxr
  116145. */
  116146. export class WebXRExperienceHelper implements IDisposable {
  116147. private scene;
  116148. private _nonVRCamera;
  116149. private _originalSceneAutoClear;
  116150. private _supported;
  116151. /**
  116152. * Camera used to render xr content
  116153. */
  116154. camera: WebXRCamera;
  116155. /** A features manager for this xr session */
  116156. featuresManager: WebXRFeaturesManager;
  116157. /**
  116158. * Observers registered here will be triggered after the camera's initial transformation is set
  116159. * This can be used to set a different ground level or an extra rotation.
  116160. *
  116161. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116162. * to the position set after this observable is done executing.
  116163. */
  116164. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116165. /**
  116166. * Fires when the state of the experience helper has changed
  116167. */
  116168. onStateChangedObservable: Observable<WebXRState>;
  116169. /** Session manager used to keep track of xr session */
  116170. sessionManager: WebXRSessionManager;
  116171. /**
  116172. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116173. */
  116174. state: WebXRState;
  116175. /**
  116176. * Creates a WebXRExperienceHelper
  116177. * @param scene The scene the helper should be created in
  116178. */
  116179. private constructor();
  116180. /**
  116181. * Creates the experience helper
  116182. * @param scene the scene to attach the experience helper to
  116183. * @returns a promise for the experience helper
  116184. */
  116185. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116186. /**
  116187. * Disposes of the experience helper
  116188. */
  116189. dispose(): void;
  116190. /**
  116191. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116192. * @param sessionMode options for the XR session
  116193. * @param referenceSpaceType frame of reference of the XR session
  116194. * @param renderTarget the output canvas that will be used to enter XR mode
  116195. * @returns promise that resolves after xr mode has entered
  116196. */
  116197. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116198. /**
  116199. * Exits XR mode and returns the scene to its original state
  116200. * @returns promise that resolves after xr mode has exited
  116201. */
  116202. exitXRAsync(): Promise<void>;
  116203. private _nonXRToXRCamera;
  116204. private _setState;
  116205. }
  116206. }
  116207. declare module BABYLON {
  116208. /**
  116209. * X-Y values for axes in WebXR
  116210. */
  116211. export interface IWebXRMotionControllerAxesValue {
  116212. /**
  116213. * The value of the x axis
  116214. */
  116215. x: number;
  116216. /**
  116217. * The value of the y-axis
  116218. */
  116219. y: number;
  116220. }
  116221. /**
  116222. * changed / previous values for the values of this component
  116223. */
  116224. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116225. /**
  116226. * current (this frame) value
  116227. */
  116228. current: T;
  116229. /**
  116230. * previous (last change) value
  116231. */
  116232. previous: T;
  116233. }
  116234. /**
  116235. * Represents changes in the component between current frame and last values recorded
  116236. */
  116237. export interface IWebXRMotionControllerComponentChanges {
  116238. /**
  116239. * will be populated with previous and current values if axes changed
  116240. */
  116241. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116242. /**
  116243. * will be populated with previous and current values if pressed changed
  116244. */
  116245. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116246. /**
  116247. * will be populated with previous and current values if touched changed
  116248. */
  116249. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116250. /**
  116251. * will be populated with previous and current values if value changed
  116252. */
  116253. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116254. }
  116255. /**
  116256. * This class represents a single component (for example button or thumbstick) of a motion controller
  116257. */
  116258. export class WebXRControllerComponent implements IDisposable {
  116259. /**
  116260. * the id of this component
  116261. */
  116262. id: string;
  116263. /**
  116264. * the type of the component
  116265. */
  116266. type: MotionControllerComponentType;
  116267. private _buttonIndex;
  116268. private _axesIndices;
  116269. private _axes;
  116270. private _changes;
  116271. private _currentValue;
  116272. private _hasChanges;
  116273. private _pressed;
  116274. private _touched;
  116275. /**
  116276. * button component type
  116277. */
  116278. static BUTTON_TYPE: MotionControllerComponentType;
  116279. /**
  116280. * squeeze component type
  116281. */
  116282. static SQUEEZE_TYPE: MotionControllerComponentType;
  116283. /**
  116284. * Thumbstick component type
  116285. */
  116286. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116287. /**
  116288. * Touchpad component type
  116289. */
  116290. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116291. /**
  116292. * trigger component type
  116293. */
  116294. static TRIGGER_TYPE: MotionControllerComponentType;
  116295. /**
  116296. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116297. * the axes data changes
  116298. */
  116299. onAxisValueChangedObservable: Observable<{
  116300. x: number;
  116301. y: number;
  116302. }>;
  116303. /**
  116304. * Observers registered here will be triggered when the state of a button changes
  116305. * State change is either pressed / touched / value
  116306. */
  116307. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116308. /**
  116309. * Creates a new component for a motion controller.
  116310. * It is created by the motion controller itself
  116311. *
  116312. * @param id the id of this component
  116313. * @param type the type of the component
  116314. * @param _buttonIndex index in the buttons array of the gamepad
  116315. * @param _axesIndices indices of the values in the axes array of the gamepad
  116316. */
  116317. constructor(
  116318. /**
  116319. * the id of this component
  116320. */
  116321. id: string,
  116322. /**
  116323. * the type of the component
  116324. */
  116325. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116326. /**
  116327. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116328. */
  116329. get axes(): IWebXRMotionControllerAxesValue;
  116330. /**
  116331. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116332. */
  116333. get changes(): IWebXRMotionControllerComponentChanges;
  116334. /**
  116335. * Return whether or not the component changed the last frame
  116336. */
  116337. get hasChanges(): boolean;
  116338. /**
  116339. * is the button currently pressed
  116340. */
  116341. get pressed(): boolean;
  116342. /**
  116343. * is the button currently touched
  116344. */
  116345. get touched(): boolean;
  116346. /**
  116347. * Get the current value of this component
  116348. */
  116349. get value(): number;
  116350. /**
  116351. * Dispose this component
  116352. */
  116353. dispose(): void;
  116354. /**
  116355. * Are there axes correlating to this component
  116356. * @return true is axes data is available
  116357. */
  116358. isAxes(): boolean;
  116359. /**
  116360. * Is this component a button (hence - pressable)
  116361. * @returns true if can be pressed
  116362. */
  116363. isButton(): boolean;
  116364. /**
  116365. * update this component using the gamepad object it is in. Called on every frame
  116366. * @param nativeController the native gamepad controller object
  116367. */
  116368. update(nativeController: IMinimalMotionControllerObject): void;
  116369. }
  116370. }
  116371. declare module BABYLON {
  116372. /**
  116373. * Class used to represent data loading progression
  116374. */
  116375. export class SceneLoaderProgressEvent {
  116376. /** defines if data length to load can be evaluated */
  116377. readonly lengthComputable: boolean;
  116378. /** defines the loaded data length */
  116379. readonly loaded: number;
  116380. /** defines the data length to load */
  116381. readonly total: number;
  116382. /**
  116383. * Create a new progress event
  116384. * @param lengthComputable defines if data length to load can be evaluated
  116385. * @param loaded defines the loaded data length
  116386. * @param total defines the data length to load
  116387. */
  116388. constructor(
  116389. /** defines if data length to load can be evaluated */
  116390. lengthComputable: boolean,
  116391. /** defines the loaded data length */
  116392. loaded: number,
  116393. /** defines the data length to load */
  116394. total: number);
  116395. /**
  116396. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116397. * @param event defines the source event
  116398. * @returns a new SceneLoaderProgressEvent
  116399. */
  116400. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116401. }
  116402. /**
  116403. * Interface used by SceneLoader plugins to define supported file extensions
  116404. */
  116405. export interface ISceneLoaderPluginExtensions {
  116406. /**
  116407. * Defines the list of supported extensions
  116408. */
  116409. [extension: string]: {
  116410. isBinary: boolean;
  116411. };
  116412. }
  116413. /**
  116414. * Interface used by SceneLoader plugin factory
  116415. */
  116416. export interface ISceneLoaderPluginFactory {
  116417. /**
  116418. * Defines the name of the factory
  116419. */
  116420. name: string;
  116421. /**
  116422. * Function called to create a new plugin
  116423. * @return the new plugin
  116424. */
  116425. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116426. /**
  116427. * The callback that returns true if the data can be directly loaded.
  116428. * @param data string containing the file data
  116429. * @returns if the data can be loaded directly
  116430. */
  116431. canDirectLoad?(data: string): boolean;
  116432. }
  116433. /**
  116434. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116435. */
  116436. export interface ISceneLoaderPluginBase {
  116437. /**
  116438. * The friendly name of this plugin.
  116439. */
  116440. name: string;
  116441. /**
  116442. * The file extensions supported by this plugin.
  116443. */
  116444. extensions: string | ISceneLoaderPluginExtensions;
  116445. /**
  116446. * The callback called when loading from a url.
  116447. * @param scene scene loading this url
  116448. * @param url url to load
  116449. * @param onSuccess callback called when the file successfully loads
  116450. * @param onProgress callback called while file is loading (if the server supports this mode)
  116451. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116452. * @param onError callback called when the file fails to load
  116453. * @returns a file request object
  116454. */
  116455. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116456. /**
  116457. * The callback called when loading from a file object.
  116458. * @param scene scene loading this file
  116459. * @param file defines the file to load
  116460. * @param onSuccess defines the callback to call when data is loaded
  116461. * @param onProgress defines the callback to call during loading process
  116462. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116463. * @param onError defines the callback to call when an error occurs
  116464. * @returns a file request object
  116465. */
  116466. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116467. /**
  116468. * The callback that returns true if the data can be directly loaded.
  116469. * @param data string containing the file data
  116470. * @returns if the data can be loaded directly
  116471. */
  116472. canDirectLoad?(data: string): boolean;
  116473. /**
  116474. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116475. * @param scene scene loading this data
  116476. * @param data string containing the data
  116477. * @returns data to pass to the plugin
  116478. */
  116479. directLoad?(scene: Scene, data: string): any;
  116480. /**
  116481. * The callback that allows custom handling of the root url based on the response url.
  116482. * @param rootUrl the original root url
  116483. * @param responseURL the response url if available
  116484. * @returns the new root url
  116485. */
  116486. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116487. }
  116488. /**
  116489. * Interface used to define a SceneLoader plugin
  116490. */
  116491. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116492. /**
  116493. * Import meshes into a scene.
  116494. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116495. * @param scene The scene to import into
  116496. * @param data The data to import
  116497. * @param rootUrl The root url for scene and resources
  116498. * @param meshes The meshes array to import into
  116499. * @param particleSystems The particle systems array to import into
  116500. * @param skeletons The skeletons array to import into
  116501. * @param onError The callback when import fails
  116502. * @returns True if successful or false otherwise
  116503. */
  116504. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116505. /**
  116506. * Load into a scene.
  116507. * @param scene The scene to load into
  116508. * @param data The data to import
  116509. * @param rootUrl The root url for scene and resources
  116510. * @param onError The callback when import fails
  116511. * @returns True if successful or false otherwise
  116512. */
  116513. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116514. /**
  116515. * Load into an asset container.
  116516. * @param scene The scene to load into
  116517. * @param data The data to import
  116518. * @param rootUrl The root url for scene and resources
  116519. * @param onError The callback when import fails
  116520. * @returns The loaded asset container
  116521. */
  116522. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116523. }
  116524. /**
  116525. * Interface used to define an async SceneLoader plugin
  116526. */
  116527. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116528. /**
  116529. * Import meshes into a scene.
  116530. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116531. * @param scene The scene to import into
  116532. * @param data The data to import
  116533. * @param rootUrl The root url for scene and resources
  116534. * @param onProgress The callback when the load progresses
  116535. * @param fileName Defines the name of the file to load
  116536. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116537. */
  116538. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116539. meshes: AbstractMesh[];
  116540. particleSystems: IParticleSystem[];
  116541. skeletons: Skeleton[];
  116542. animationGroups: AnimationGroup[];
  116543. }>;
  116544. /**
  116545. * Load into a scene.
  116546. * @param scene The scene to load into
  116547. * @param data The data to import
  116548. * @param rootUrl The root url for scene and resources
  116549. * @param onProgress The callback when the load progresses
  116550. * @param fileName Defines the name of the file to load
  116551. * @returns Nothing
  116552. */
  116553. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116554. /**
  116555. * Load into an asset container.
  116556. * @param scene The scene to load into
  116557. * @param data The data to import
  116558. * @param rootUrl The root url for scene and resources
  116559. * @param onProgress The callback when the load progresses
  116560. * @param fileName Defines the name of the file to load
  116561. * @returns The loaded asset container
  116562. */
  116563. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116564. }
  116565. /**
  116566. * Mode that determines how to handle old animation groups before loading new ones.
  116567. */
  116568. export enum SceneLoaderAnimationGroupLoadingMode {
  116569. /**
  116570. * Reset all old animations to initial state then dispose them.
  116571. */
  116572. Clean = 0,
  116573. /**
  116574. * Stop all old animations.
  116575. */
  116576. Stop = 1,
  116577. /**
  116578. * Restart old animations from first frame.
  116579. */
  116580. Sync = 2,
  116581. /**
  116582. * Old animations remains untouched.
  116583. */
  116584. NoSync = 3
  116585. }
  116586. /**
  116587. * Class used to load scene from various file formats using registered plugins
  116588. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116589. */
  116590. export class SceneLoader {
  116591. /**
  116592. * No logging while loading
  116593. */
  116594. static readonly NO_LOGGING: number;
  116595. /**
  116596. * Minimal logging while loading
  116597. */
  116598. static readonly MINIMAL_LOGGING: number;
  116599. /**
  116600. * Summary logging while loading
  116601. */
  116602. static readonly SUMMARY_LOGGING: number;
  116603. /**
  116604. * Detailled logging while loading
  116605. */
  116606. static readonly DETAILED_LOGGING: number;
  116607. /**
  116608. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116609. */
  116610. static get ForceFullSceneLoadingForIncremental(): boolean;
  116611. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116612. /**
  116613. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116614. */
  116615. static get ShowLoadingScreen(): boolean;
  116616. static set ShowLoadingScreen(value: boolean);
  116617. /**
  116618. * Defines the current logging level (while loading the scene)
  116619. * @ignorenaming
  116620. */
  116621. static get loggingLevel(): number;
  116622. static set loggingLevel(value: number);
  116623. /**
  116624. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116625. */
  116626. static get CleanBoneMatrixWeights(): boolean;
  116627. static set CleanBoneMatrixWeights(value: boolean);
  116628. /**
  116629. * Event raised when a plugin is used to load a scene
  116630. */
  116631. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116632. private static _registeredPlugins;
  116633. private static _getDefaultPlugin;
  116634. private static _getPluginForExtension;
  116635. private static _getPluginForDirectLoad;
  116636. private static _getPluginForFilename;
  116637. private static _getDirectLoad;
  116638. private static _loadData;
  116639. private static _getFileInfo;
  116640. /**
  116641. * Gets a plugin that can load the given extension
  116642. * @param extension defines the extension to load
  116643. * @returns a plugin or null if none works
  116644. */
  116645. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116646. /**
  116647. * Gets a boolean indicating that the given extension can be loaded
  116648. * @param extension defines the extension to load
  116649. * @returns true if the extension is supported
  116650. */
  116651. static IsPluginForExtensionAvailable(extension: string): boolean;
  116652. /**
  116653. * Adds a new plugin to the list of registered plugins
  116654. * @param plugin defines the plugin to add
  116655. */
  116656. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116657. /**
  116658. * Import meshes into a scene
  116659. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116660. * @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)
  116661. * @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)
  116662. * @param scene the instance of BABYLON.Scene to append to
  116663. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116664. * @param onProgress a callback with a progress event for each file being loaded
  116665. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116666. * @param pluginExtension the extension used to determine the plugin
  116667. * @returns The loaded plugin
  116668. */
  116669. 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>;
  116670. /**
  116671. * Import meshes into a scene
  116672. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116673. * @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)
  116674. * @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)
  116675. * @param scene the instance of BABYLON.Scene to append to
  116676. * @param onProgress a callback with a progress event for each file being loaded
  116677. * @param pluginExtension the extension used to determine the plugin
  116678. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116679. */
  116680. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116681. meshes: AbstractMesh[];
  116682. particleSystems: IParticleSystem[];
  116683. skeletons: Skeleton[];
  116684. animationGroups: AnimationGroup[];
  116685. }>;
  116686. /**
  116687. * Load a scene
  116688. * @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)
  116689. * @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)
  116690. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116691. * @param onSuccess a callback with the scene when import succeeds
  116692. * @param onProgress a callback with a progress event for each file being loaded
  116693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116694. * @param pluginExtension the extension used to determine the plugin
  116695. * @returns The loaded plugin
  116696. */
  116697. 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>;
  116698. /**
  116699. * Load a scene
  116700. * @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)
  116701. * @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)
  116702. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116703. * @param onProgress a callback with a progress event for each file being loaded
  116704. * @param pluginExtension the extension used to determine the plugin
  116705. * @returns The loaded scene
  116706. */
  116707. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116708. /**
  116709. * Append a scene
  116710. * @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)
  116711. * @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)
  116712. * @param scene is the instance of BABYLON.Scene to append to
  116713. * @param onSuccess a callback with the scene when import succeeds
  116714. * @param onProgress a callback with a progress event for each file being loaded
  116715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116716. * @param pluginExtension the extension used to determine the plugin
  116717. * @returns The loaded plugin
  116718. */
  116719. 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>;
  116720. /**
  116721. * Append a scene
  116722. * @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)
  116723. * @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)
  116724. * @param scene is the instance of BABYLON.Scene to append to
  116725. * @param onProgress a callback with a progress event for each file being loaded
  116726. * @param pluginExtension the extension used to determine the plugin
  116727. * @returns The given scene
  116728. */
  116729. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116730. /**
  116731. * Load a scene into an asset container
  116732. * @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)
  116733. * @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)
  116734. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116735. * @param onSuccess a callback with the scene when import succeeds
  116736. * @param onProgress a callback with a progress event for each file being loaded
  116737. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116738. * @param pluginExtension the extension used to determine the plugin
  116739. * @returns The loaded plugin
  116740. */
  116741. 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>;
  116742. /**
  116743. * Load a scene into an asset container
  116744. * @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)
  116745. * @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)
  116746. * @param scene is the instance of Scene to append to
  116747. * @param onProgress a callback with a progress event for each file being loaded
  116748. * @param pluginExtension the extension used to determine the plugin
  116749. * @returns The loaded asset container
  116750. */
  116751. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116752. /**
  116753. * Import animations from a file into a scene
  116754. * @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)
  116755. * @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)
  116756. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116757. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116758. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116759. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116760. * @param onSuccess a callback with the scene when import succeeds
  116761. * @param onProgress a callback with a progress event for each file being loaded
  116762. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116763. */
  116764. 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;
  116765. /**
  116766. * Import animations from a file into a scene
  116767. * @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)
  116768. * @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)
  116769. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116770. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116771. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116772. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116773. * @param onSuccess a callback with the scene when import succeeds
  116774. * @param onProgress a callback with a progress event for each file being loaded
  116775. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116776. * @returns the updated scene with imported animations
  116777. */
  116778. 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>;
  116779. }
  116780. }
  116781. declare module BABYLON {
  116782. /**
  116783. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116784. */
  116785. export type MotionControllerHandness = "none" | "left" | "right";
  116786. /**
  116787. * The type of components available in motion controllers.
  116788. * This is not the name of the component.
  116789. */
  116790. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116791. /**
  116792. * The state of a controller component
  116793. */
  116794. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116795. /**
  116796. * The schema of motion controller layout.
  116797. * No object will be initialized using this interface
  116798. * This is used just to define the profile.
  116799. */
  116800. export interface IMotionControllerLayout {
  116801. /**
  116802. * Path to load the assets. Usually relative to the base path
  116803. */
  116804. assetPath: string;
  116805. /**
  116806. * Available components (unsorted)
  116807. */
  116808. components: {
  116809. /**
  116810. * A map of component Ids
  116811. */
  116812. [componentId: string]: {
  116813. /**
  116814. * The type of input the component outputs
  116815. */
  116816. type: MotionControllerComponentType;
  116817. /**
  116818. * The indices of this component in the gamepad object
  116819. */
  116820. gamepadIndices: {
  116821. /**
  116822. * Index of button
  116823. */
  116824. button?: number;
  116825. /**
  116826. * If available, index of x-axis
  116827. */
  116828. xAxis?: number;
  116829. /**
  116830. * If available, index of y-axis
  116831. */
  116832. yAxis?: number;
  116833. };
  116834. /**
  116835. * The mesh's root node name
  116836. */
  116837. rootNodeName: string;
  116838. /**
  116839. * Animation definitions for this model
  116840. */
  116841. visualResponses: {
  116842. [stateKey: string]: {
  116843. /**
  116844. * What property will be animated
  116845. */
  116846. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116847. /**
  116848. * What states influence this visual response
  116849. */
  116850. states: MotionControllerComponentStateType[];
  116851. /**
  116852. * Type of animation - movement or visibility
  116853. */
  116854. valueNodeProperty: "transform" | "visibility";
  116855. /**
  116856. * Base node name to move. Its position will be calculated according to the min and max nodes
  116857. */
  116858. valueNodeName?: string;
  116859. /**
  116860. * Minimum movement node
  116861. */
  116862. minNodeName?: string;
  116863. /**
  116864. * Max movement node
  116865. */
  116866. maxNodeName?: string;
  116867. };
  116868. };
  116869. /**
  116870. * If touch enabled, what is the name of node to display user feedback
  116871. */
  116872. touchPointNodeName?: string;
  116873. };
  116874. };
  116875. /**
  116876. * Is it xr standard mapping or not
  116877. */
  116878. gamepadMapping: "" | "xr-standard";
  116879. /**
  116880. * Base root node of this entire model
  116881. */
  116882. rootNodeName: string;
  116883. /**
  116884. * Defines the main button component id
  116885. */
  116886. selectComponentId: string;
  116887. }
  116888. /**
  116889. * A definition for the layout map in the input profile
  116890. */
  116891. export interface IMotionControllerLayoutMap {
  116892. /**
  116893. * Layouts with handness type as a key
  116894. */
  116895. [handness: string]: IMotionControllerLayout;
  116896. }
  116897. /**
  116898. * The XR Input profile schema
  116899. * Profiles can be found here:
  116900. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116901. */
  116902. export interface IMotionControllerProfile {
  116903. /**
  116904. * fallback profiles for this profileId
  116905. */
  116906. fallbackProfileIds: string[];
  116907. /**
  116908. * The layout map, with handness as key
  116909. */
  116910. layouts: IMotionControllerLayoutMap;
  116911. /**
  116912. * The id of this profile
  116913. * correlates to the profile(s) in the xrInput.profiles array
  116914. */
  116915. profileId: string;
  116916. }
  116917. /**
  116918. * A helper-interface for the 3 meshes needed for controller button animation
  116919. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116920. */
  116921. export interface IMotionControllerButtonMeshMap {
  116922. /**
  116923. * the mesh that defines the pressed value mesh position.
  116924. * This is used to find the max-position of this button
  116925. */
  116926. pressedMesh: AbstractMesh;
  116927. /**
  116928. * the mesh that defines the unpressed value mesh position.
  116929. * This is used to find the min (or initial) position of this button
  116930. */
  116931. unpressedMesh: AbstractMesh;
  116932. /**
  116933. * The mesh that will be changed when value changes
  116934. */
  116935. valueMesh: AbstractMesh;
  116936. }
  116937. /**
  116938. * A helper-interface for the 3 meshes needed for controller axis animation.
  116939. * This will be expanded when touchpad animations are fully supported
  116940. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116941. */
  116942. export interface IMotionControllerMeshMap {
  116943. /**
  116944. * the mesh that defines the maximum value mesh position.
  116945. */
  116946. maxMesh?: AbstractMesh;
  116947. /**
  116948. * the mesh that defines the minimum value mesh position.
  116949. */
  116950. minMesh?: AbstractMesh;
  116951. /**
  116952. * The mesh that will be changed when axis value changes
  116953. */
  116954. valueMesh: AbstractMesh;
  116955. }
  116956. /**
  116957. * The elements needed for change-detection of the gamepad objects in motion controllers
  116958. */
  116959. export interface IMinimalMotionControllerObject {
  116960. /**
  116961. * Available axes of this controller
  116962. */
  116963. axes: number[];
  116964. /**
  116965. * An array of available buttons
  116966. */
  116967. buttons: Array<{
  116968. /**
  116969. * Value of the button/trigger
  116970. */
  116971. value: number;
  116972. /**
  116973. * If the button/trigger is currently touched
  116974. */
  116975. touched: boolean;
  116976. /**
  116977. * If the button/trigger is currently pressed
  116978. */
  116979. pressed: boolean;
  116980. }>;
  116981. }
  116982. /**
  116983. * An Abstract Motion controller
  116984. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116985. * Each component has an observable to check for changes in value and state
  116986. */
  116987. export abstract class WebXRAbstractMotionController implements IDisposable {
  116988. protected scene: Scene;
  116989. protected layout: IMotionControllerLayout;
  116990. /**
  116991. * The gamepad object correlating to this controller
  116992. */
  116993. gamepadObject: IMinimalMotionControllerObject;
  116994. /**
  116995. * handness (left/right/none) of this controller
  116996. */
  116997. handness: MotionControllerHandness;
  116998. private _initComponent;
  116999. private _modelReady;
  117000. /**
  117001. * A map of components (WebXRControllerComponent) in this motion controller
  117002. * Components have a ComponentType and can also have both button and axis definitions
  117003. */
  117004. readonly components: {
  117005. [id: string]: WebXRControllerComponent;
  117006. };
  117007. /**
  117008. * Disable the model's animation. Can be set at any time.
  117009. */
  117010. disableAnimation: boolean;
  117011. /**
  117012. * Observers registered here will be triggered when the model of this controller is done loading
  117013. */
  117014. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117015. /**
  117016. * The profile id of this motion controller
  117017. */
  117018. abstract profileId: string;
  117019. /**
  117020. * The root mesh of the model. It is null if the model was not yet initialized
  117021. */
  117022. rootMesh: Nullable<AbstractMesh>;
  117023. /**
  117024. * constructs a new abstract motion controller
  117025. * @param scene the scene to which the model of the controller will be added
  117026. * @param layout The profile layout to load
  117027. * @param gamepadObject The gamepad object correlating to this controller
  117028. * @param handness handness (left/right/none) of this controller
  117029. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117030. */
  117031. constructor(scene: Scene, layout: IMotionControllerLayout,
  117032. /**
  117033. * The gamepad object correlating to this controller
  117034. */
  117035. gamepadObject: IMinimalMotionControllerObject,
  117036. /**
  117037. * handness (left/right/none) of this controller
  117038. */
  117039. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117040. /**
  117041. * Dispose this controller, the model mesh and all its components
  117042. */
  117043. dispose(): void;
  117044. /**
  117045. * Returns all components of specific type
  117046. * @param type the type to search for
  117047. * @return an array of components with this type
  117048. */
  117049. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117050. /**
  117051. * get a component based an its component id as defined in layout.components
  117052. * @param id the id of the component
  117053. * @returns the component correlates to the id or undefined if not found
  117054. */
  117055. getComponent(id: string): WebXRControllerComponent;
  117056. /**
  117057. * Get the list of components available in this motion controller
  117058. * @returns an array of strings correlating to available components
  117059. */
  117060. getComponentIds(): string[];
  117061. /**
  117062. * Get the first component of specific type
  117063. * @param type type of component to find
  117064. * @return a controller component or null if not found
  117065. */
  117066. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117067. /**
  117068. * Get the main (Select) component of this controller as defined in the layout
  117069. * @returns the main component of this controller
  117070. */
  117071. getMainComponent(): WebXRControllerComponent;
  117072. /**
  117073. * Loads the model correlating to this controller
  117074. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117075. * @returns A promise fulfilled with the result of the model loading
  117076. */
  117077. loadModel(): Promise<boolean>;
  117078. /**
  117079. * Update this model using the current XRFrame
  117080. * @param xrFrame the current xr frame to use and update the model
  117081. */
  117082. updateFromXRFrame(xrFrame: XRFrame): void;
  117083. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117084. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117085. /**
  117086. * Moves the axis on the controller mesh based on its current state
  117087. * @param axis the index of the axis
  117088. * @param axisValue the value of the axis which determines the meshes new position
  117089. * @hidden
  117090. */
  117091. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117092. /**
  117093. * Update the model itself with the current frame data
  117094. * @param xrFrame the frame to use for updating the model mesh
  117095. */
  117096. protected updateModel(xrFrame: XRFrame): void;
  117097. /**
  117098. * Get the filename and path for this controller's model
  117099. * @returns a map of filename and path
  117100. */
  117101. protected abstract _getFilenameAndPath(): {
  117102. filename: string;
  117103. path: string;
  117104. };
  117105. /**
  117106. * This function is called before the mesh is loaded. It checks for loading constraints.
  117107. * For example, this function can check if the GLB loader is available
  117108. * If this function returns false, the generic controller will be loaded instead
  117109. * @returns Is the client ready to load the mesh
  117110. */
  117111. protected abstract _getModelLoadingConstraints(): boolean;
  117112. /**
  117113. * This function will be called after the model was successfully loaded and can be used
  117114. * for mesh transformations before it is available for the user
  117115. * @param meshes the loaded meshes
  117116. */
  117117. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117118. /**
  117119. * Set the root mesh for this controller. Important for the WebXR controller class
  117120. * @param meshes the loaded meshes
  117121. */
  117122. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117123. /**
  117124. * A function executed each frame that updates the mesh (if needed)
  117125. * @param xrFrame the current xrFrame
  117126. */
  117127. protected abstract _updateModel(xrFrame: XRFrame): void;
  117128. private _getGenericFilenameAndPath;
  117129. private _getGenericParentMesh;
  117130. }
  117131. }
  117132. declare module BABYLON {
  117133. /**
  117134. * A generic trigger-only motion controller for WebXR
  117135. */
  117136. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117137. /**
  117138. * Static version of the profile id of this controller
  117139. */
  117140. static ProfileId: string;
  117141. profileId: string;
  117142. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117143. protected _getFilenameAndPath(): {
  117144. filename: string;
  117145. path: string;
  117146. };
  117147. protected _getModelLoadingConstraints(): boolean;
  117148. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117149. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117150. protected _updateModel(): void;
  117151. }
  117152. }
  117153. declare module BABYLON {
  117154. /**
  117155. * Class containing static functions to help procedurally build meshes
  117156. */
  117157. export class SphereBuilder {
  117158. /**
  117159. * Creates a sphere mesh
  117160. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117161. * * 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`)
  117162. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117163. * * 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
  117164. * * 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)
  117165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117168. * @param name defines the name of the mesh
  117169. * @param options defines the options used to create the mesh
  117170. * @param scene defines the hosting scene
  117171. * @returns the sphere mesh
  117172. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117173. */
  117174. static CreateSphere(name: string, options: {
  117175. segments?: number;
  117176. diameter?: number;
  117177. diameterX?: number;
  117178. diameterY?: number;
  117179. diameterZ?: number;
  117180. arc?: number;
  117181. slice?: number;
  117182. sideOrientation?: number;
  117183. frontUVs?: Vector4;
  117184. backUVs?: Vector4;
  117185. updatable?: boolean;
  117186. }, scene?: Nullable<Scene>): Mesh;
  117187. }
  117188. }
  117189. declare module BABYLON {
  117190. /**
  117191. * A profiled motion controller has its profile loaded from an online repository.
  117192. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117193. */
  117194. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117195. private _repositoryUrl;
  117196. private _buttonMeshMapping;
  117197. private _touchDots;
  117198. /**
  117199. * The profile ID of this controller. Will be populated when the controller initializes.
  117200. */
  117201. profileId: string;
  117202. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117203. dispose(): void;
  117204. protected _getFilenameAndPath(): {
  117205. filename: string;
  117206. path: string;
  117207. };
  117208. protected _getModelLoadingConstraints(): boolean;
  117209. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117210. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117211. protected _updateModel(_xrFrame: XRFrame): void;
  117212. }
  117213. }
  117214. declare module BABYLON {
  117215. /**
  117216. * A construction function type to create a new controller based on an xrInput object
  117217. */
  117218. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117219. /**
  117220. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117221. *
  117222. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117223. * it should be replaced with auto-loaded controllers.
  117224. *
  117225. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117226. */
  117227. export class WebXRMotionControllerManager {
  117228. private static _AvailableControllers;
  117229. private static _Fallbacks;
  117230. private static _ProfileLoadingPromises;
  117231. private static _ProfilesList;
  117232. /**
  117233. * The base URL of the online controller repository. Can be changed at any time.
  117234. */
  117235. static BaseRepositoryUrl: string;
  117236. /**
  117237. * Which repository gets priority - local or online
  117238. */
  117239. static PrioritizeOnlineRepository: boolean;
  117240. /**
  117241. * Use the online repository, or use only locally-defined controllers
  117242. */
  117243. static UseOnlineRepository: boolean;
  117244. /**
  117245. * Clear the cache used for profile loading and reload when requested again
  117246. */
  117247. static ClearProfilesCache(): void;
  117248. /**
  117249. * Register the default fallbacks.
  117250. * This function is called automatically when this file is imported.
  117251. */
  117252. static DefaultFallbacks(): void;
  117253. /**
  117254. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117255. * @param profileId the profile to which a fallback needs to be found
  117256. * @return an array with corresponding fallback profiles
  117257. */
  117258. static FindFallbackWithProfileId(profileId: string): string[];
  117259. /**
  117260. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117261. * The order of search:
  117262. *
  117263. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117264. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117265. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117266. * 4) return the generic trigger controller if none were found
  117267. *
  117268. * @param xrInput the xrInput to which a new controller is initialized
  117269. * @param scene the scene to which the model will be added
  117270. * @param forceProfile force a certain profile for this controller
  117271. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117272. */
  117273. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117274. /**
  117275. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117276. *
  117277. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117278. *
  117279. * @param type the profile type to register
  117280. * @param constructFunction the function to be called when loading this profile
  117281. */
  117282. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117283. /**
  117284. * Register a fallback to a specific profile.
  117285. * @param profileId the profileId that will receive the fallbacks
  117286. * @param fallbacks A list of fallback profiles
  117287. */
  117288. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117289. /**
  117290. * Will update the list of profiles available in the repository
  117291. * @return a promise that resolves to a map of profiles available online
  117292. */
  117293. static UpdateProfilesList(): Promise<{
  117294. [profile: string]: string;
  117295. }>;
  117296. private static _LoadProfileFromRepository;
  117297. private static _LoadProfilesFromAvailableControllers;
  117298. }
  117299. }
  117300. declare module BABYLON {
  117301. /**
  117302. * Configuration options for the WebXR controller creation
  117303. */
  117304. export interface IWebXRControllerOptions {
  117305. /**
  117306. * Should the controller mesh be animated when a user interacts with it
  117307. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117308. */
  117309. disableMotionControllerAnimation?: boolean;
  117310. /**
  117311. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117312. */
  117313. doNotLoadControllerMesh?: boolean;
  117314. /**
  117315. * Force a specific controller type for this controller.
  117316. * This can be used when creating your own profile or when testing different controllers
  117317. */
  117318. forceControllerProfile?: string;
  117319. }
  117320. /**
  117321. * Represents an XR controller
  117322. */
  117323. export class WebXRInputSource {
  117324. private _scene;
  117325. /** The underlying input source for the controller */
  117326. inputSource: XRInputSource;
  117327. private _options;
  117328. private _tmpQuaternion;
  117329. private _tmpVector;
  117330. private _uniqueId;
  117331. /**
  117332. * 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
  117333. */
  117334. grip?: AbstractMesh;
  117335. /**
  117336. * If available, this is the gamepad object related to this controller.
  117337. * Using this object it is possible to get click events and trackpad changes of the
  117338. * webxr controller that is currently being used.
  117339. */
  117340. motionController?: WebXRAbstractMotionController;
  117341. /**
  117342. * Event that fires when the controller is removed/disposed.
  117343. * The object provided as event data is this controller, after associated assets were disposed.
  117344. * uniqueId is still available.
  117345. */
  117346. onDisposeObservable: Observable<WebXRInputSource>;
  117347. /**
  117348. * Will be triggered when the mesh associated with the motion controller is done loading.
  117349. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117350. * A shortened version of controller -> motion controller -> on mesh loaded.
  117351. */
  117352. onMeshLoadedObservable: Observable<AbstractMesh>;
  117353. /**
  117354. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117355. */
  117356. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117357. /**
  117358. * Pointer which can be used to select objects or attach a visible laser to
  117359. */
  117360. pointer: AbstractMesh;
  117361. /**
  117362. * Creates the controller
  117363. * @see https://doc.babylonjs.com/how_to/webxr
  117364. * @param _scene the scene which the controller should be associated to
  117365. * @param inputSource the underlying input source for the controller
  117366. * @param _options options for this controller creation
  117367. */
  117368. constructor(_scene: Scene,
  117369. /** The underlying input source for the controller */
  117370. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117371. /**
  117372. * Get this controllers unique id
  117373. */
  117374. get uniqueId(): string;
  117375. /**
  117376. * Disposes of the object
  117377. */
  117378. dispose(): void;
  117379. /**
  117380. * Gets a world space ray coming from the pointer or grip
  117381. * @param result the resulting ray
  117382. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117383. */
  117384. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117385. /**
  117386. * Updates the controller pose based on the given XRFrame
  117387. * @param xrFrame xr frame to update the pose with
  117388. * @param referenceSpace reference space to use
  117389. */
  117390. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117391. }
  117392. }
  117393. declare module BABYLON {
  117394. /**
  117395. * The schema for initialization options of the XR Input class
  117396. */
  117397. export interface IWebXRInputOptions {
  117398. /**
  117399. * If set to true no model will be automatically loaded
  117400. */
  117401. doNotLoadControllerMeshes?: boolean;
  117402. /**
  117403. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117404. * If not found, the xr input profile data will be used.
  117405. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117406. */
  117407. forceInputProfile?: string;
  117408. /**
  117409. * Do not send a request to the controller repository to load the profile.
  117410. *
  117411. * Instead, use the controllers available in babylon itself.
  117412. */
  117413. disableOnlineControllerRepository?: boolean;
  117414. /**
  117415. * A custom URL for the controllers repository
  117416. */
  117417. customControllersRepositoryURL?: string;
  117418. /**
  117419. * Should the controller model's components not move according to the user input
  117420. */
  117421. disableControllerAnimation?: boolean;
  117422. }
  117423. /**
  117424. * XR input used to track XR inputs such as controllers/rays
  117425. */
  117426. export class WebXRInput implements IDisposable {
  117427. /**
  117428. * the xr session manager for this session
  117429. */
  117430. xrSessionManager: WebXRSessionManager;
  117431. /**
  117432. * the WebXR camera for this session. Mainly used for teleportation
  117433. */
  117434. xrCamera: WebXRCamera;
  117435. private readonly options;
  117436. /**
  117437. * XR controllers being tracked
  117438. */
  117439. controllers: Array<WebXRInputSource>;
  117440. private _frameObserver;
  117441. private _sessionEndedObserver;
  117442. private _sessionInitObserver;
  117443. /**
  117444. * Event when a controller has been connected/added
  117445. */
  117446. onControllerAddedObservable: Observable<WebXRInputSource>;
  117447. /**
  117448. * Event when a controller has been removed/disconnected
  117449. */
  117450. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117451. /**
  117452. * Initializes the WebXRInput
  117453. * @param xrSessionManager the xr session manager for this session
  117454. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117455. * @param options = initialization options for this xr input
  117456. */
  117457. constructor(
  117458. /**
  117459. * the xr session manager for this session
  117460. */
  117461. xrSessionManager: WebXRSessionManager,
  117462. /**
  117463. * the WebXR camera for this session. Mainly used for teleportation
  117464. */
  117465. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117466. private _onInputSourcesChange;
  117467. private _addAndRemoveControllers;
  117468. /**
  117469. * Disposes of the object
  117470. */
  117471. dispose(): void;
  117472. }
  117473. }
  117474. declare module BABYLON {
  117475. /**
  117476. * This is the base class for all WebXR features.
  117477. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117478. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117479. */
  117480. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117481. protected _xrSessionManager: WebXRSessionManager;
  117482. private _attached;
  117483. private _removeOnDetach;
  117484. /**
  117485. * Should auto-attach be disabled?
  117486. */
  117487. disableAutoAttach: boolean;
  117488. /**
  117489. * Construct a new (abstract) WebXR feature
  117490. * @param _xrSessionManager the xr session manager for this feature
  117491. */
  117492. constructor(_xrSessionManager: WebXRSessionManager);
  117493. /**
  117494. * Is this feature attached
  117495. */
  117496. get attached(): boolean;
  117497. /**
  117498. * attach this feature
  117499. *
  117500. * @param force should attachment be forced (even when already attached)
  117501. * @returns true if successful, false is failed or already attached
  117502. */
  117503. attach(force?: boolean): boolean;
  117504. /**
  117505. * detach this feature.
  117506. *
  117507. * @returns true if successful, false if failed or already detached
  117508. */
  117509. detach(): boolean;
  117510. /**
  117511. * Dispose this feature and all of the resources attached
  117512. */
  117513. dispose(): void;
  117514. /**
  117515. * This is used to register callbacks that will automatically be removed when detach is called.
  117516. * @param observable the observable to which the observer will be attached
  117517. * @param callback the callback to register
  117518. */
  117519. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117520. /**
  117521. * Code in this function will be executed on each xrFrame received from the browser.
  117522. * This function will not execute after the feature is detached.
  117523. * @param _xrFrame the current frame
  117524. */
  117525. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117526. }
  117527. }
  117528. declare module BABYLON {
  117529. /**
  117530. * Renders a layer on top of an existing scene
  117531. */
  117532. export class UtilityLayerRenderer implements IDisposable {
  117533. /** the original scene that will be rendered on top of */
  117534. originalScene: Scene;
  117535. private _pointerCaptures;
  117536. private _lastPointerEvents;
  117537. private static _DefaultUtilityLayer;
  117538. private static _DefaultKeepDepthUtilityLayer;
  117539. private _sharedGizmoLight;
  117540. private _renderCamera;
  117541. /**
  117542. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117543. * @returns the camera that is used when rendering the utility layer
  117544. */
  117545. getRenderCamera(): Camera;
  117546. /**
  117547. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117548. * @param cam the camera that should be used when rendering the utility layer
  117549. */
  117550. setRenderCamera(cam: Nullable<Camera>): void;
  117551. /**
  117552. * @hidden
  117553. * Light which used by gizmos to get light shading
  117554. */
  117555. _getSharedGizmoLight(): HemisphericLight;
  117556. /**
  117557. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117558. */
  117559. pickUtilitySceneFirst: boolean;
  117560. /**
  117561. * 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)
  117562. */
  117563. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117564. /**
  117565. * 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)
  117566. */
  117567. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117568. /**
  117569. * The scene that is rendered on top of the original scene
  117570. */
  117571. utilityLayerScene: Scene;
  117572. /**
  117573. * If the utility layer should automatically be rendered on top of existing scene
  117574. */
  117575. shouldRender: boolean;
  117576. /**
  117577. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117578. */
  117579. onlyCheckPointerDownEvents: boolean;
  117580. /**
  117581. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117582. */
  117583. processAllEvents: boolean;
  117584. /**
  117585. * Observable raised when the pointer move from the utility layer scene to the main scene
  117586. */
  117587. onPointerOutObservable: Observable<number>;
  117588. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117589. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117590. private _afterRenderObserver;
  117591. private _sceneDisposeObserver;
  117592. private _originalPointerObserver;
  117593. /**
  117594. * Instantiates a UtilityLayerRenderer
  117595. * @param originalScene the original scene that will be rendered on top of
  117596. * @param handleEvents boolean indicating if the utility layer should handle events
  117597. */
  117598. constructor(
  117599. /** the original scene that will be rendered on top of */
  117600. originalScene: Scene, handleEvents?: boolean);
  117601. private _notifyObservers;
  117602. /**
  117603. * Renders the utility layers scene on top of the original scene
  117604. */
  117605. render(): void;
  117606. /**
  117607. * Disposes of the renderer
  117608. */
  117609. dispose(): void;
  117610. private _updateCamera;
  117611. }
  117612. }
  117613. declare module BABYLON {
  117614. /**
  117615. * Options interface for the pointer selection module
  117616. */
  117617. export interface IWebXRControllerPointerSelectionOptions {
  117618. /**
  117619. * if provided, this scene will be used to render meshes.
  117620. */
  117621. customUtilityLayerScene?: Scene;
  117622. /**
  117623. * 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)
  117624. * If not disabled, the last picked point will be used to execute a pointer up event
  117625. * If disabled, pointer up event will be triggered right after the pointer down event.
  117626. * Used in screen and gaze target ray mode only
  117627. */
  117628. disablePointerUpOnTouchOut: boolean;
  117629. /**
  117630. * For gaze mode (time to select instead of press)
  117631. */
  117632. forceGazeMode: boolean;
  117633. /**
  117634. * 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
  117635. * to start a new countdown to the pointer down event.
  117636. * Defaults to 1.
  117637. */
  117638. gazeModePointerMovedFactor?: number;
  117639. /**
  117640. * Different button type to use instead of the main component
  117641. */
  117642. overrideButtonId?: string;
  117643. /**
  117644. * use this rendering group id for the meshes (optional)
  117645. */
  117646. renderingGroupId?: number;
  117647. /**
  117648. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117649. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117650. * 3000 means 3 seconds between pointing at something and selecting it
  117651. */
  117652. timeToSelect?: number;
  117653. /**
  117654. * Should meshes created here be added to a utility layer or the main scene
  117655. */
  117656. useUtilityLayer?: boolean;
  117657. /**
  117658. * the xr input to use with this pointer selection
  117659. */
  117660. xrInput: WebXRInput;
  117661. }
  117662. /**
  117663. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117664. */
  117665. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117666. private readonly _options;
  117667. private static _idCounter;
  117668. private _attachController;
  117669. private _controllers;
  117670. private _scene;
  117671. private _tmpVectorForPickCompare;
  117672. /**
  117673. * The module's name
  117674. */
  117675. static readonly Name: string;
  117676. /**
  117677. * The (Babylon) version of this module.
  117678. * This is an integer representing the implementation version.
  117679. * This number does not correspond to the WebXR specs version
  117680. */
  117681. static readonly Version: number;
  117682. /**
  117683. * Disable lighting on the laser pointer (so it will always be visible)
  117684. */
  117685. disablePointerLighting: boolean;
  117686. /**
  117687. * Disable lighting on the selection mesh (so it will always be visible)
  117688. */
  117689. disableSelectionMeshLighting: boolean;
  117690. /**
  117691. * Should the laser pointer be displayed
  117692. */
  117693. displayLaserPointer: boolean;
  117694. /**
  117695. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117696. */
  117697. displaySelectionMesh: boolean;
  117698. /**
  117699. * This color will be set to the laser pointer when selection is triggered
  117700. */
  117701. laserPointerPickedColor: Color3;
  117702. /**
  117703. * Default color of the laser pointer
  117704. */
  117705. lasterPointerDefaultColor: Color3;
  117706. /**
  117707. * default color of the selection ring
  117708. */
  117709. selectionMeshDefaultColor: Color3;
  117710. /**
  117711. * This color will be applied to the selection ring when selection is triggered
  117712. */
  117713. selectionMeshPickedColor: Color3;
  117714. /**
  117715. * constructs a new background remover module
  117716. * @param _xrSessionManager the session manager for this module
  117717. * @param _options read-only options to be used in this module
  117718. */
  117719. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117720. /**
  117721. * attach this feature
  117722. * Will usually be called by the features manager
  117723. *
  117724. * @returns true if successful.
  117725. */
  117726. attach(): boolean;
  117727. /**
  117728. * detach this feature.
  117729. * Will usually be called by the features manager
  117730. *
  117731. * @returns true if successful.
  117732. */
  117733. detach(): boolean;
  117734. /**
  117735. * Will get the mesh under a specific pointer.
  117736. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117737. * @param controllerId the controllerId to check
  117738. * @returns The mesh under pointer or null if no mesh is under the pointer
  117739. */
  117740. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117741. /**
  117742. * Get the xr controller that correlates to the pointer id in the pointer event
  117743. *
  117744. * @param id the pointer id to search for
  117745. * @returns the controller that correlates to this id or null if not found
  117746. */
  117747. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117748. protected _onXRFrame(_xrFrame: XRFrame): void;
  117749. private _attachGazeMode;
  117750. private _attachScreenRayMode;
  117751. private _attachTrackedPointerRayMode;
  117752. private _convertNormalToDirectionOfRay;
  117753. private _detachController;
  117754. private _generateNewMeshPair;
  117755. private _pickingMoved;
  117756. private _updatePointerDistance;
  117757. }
  117758. }
  117759. declare module BABYLON {
  117760. /**
  117761. * Button which can be used to enter a different mode of XR
  117762. */
  117763. export class WebXREnterExitUIButton {
  117764. /** button element */
  117765. element: HTMLElement;
  117766. /** XR initialization options for the button */
  117767. sessionMode: XRSessionMode;
  117768. /** Reference space type */
  117769. referenceSpaceType: XRReferenceSpaceType;
  117770. /**
  117771. * Creates a WebXREnterExitUIButton
  117772. * @param element button element
  117773. * @param sessionMode XR initialization session mode
  117774. * @param referenceSpaceType the type of reference space to be used
  117775. */
  117776. constructor(
  117777. /** button element */
  117778. element: HTMLElement,
  117779. /** XR initialization options for the button */
  117780. sessionMode: XRSessionMode,
  117781. /** Reference space type */
  117782. referenceSpaceType: XRReferenceSpaceType);
  117783. /**
  117784. * Extendable function which can be used to update the button's visuals when the state changes
  117785. * @param activeButton the current active button in the UI
  117786. */
  117787. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117788. }
  117789. /**
  117790. * Options to create the webXR UI
  117791. */
  117792. export class WebXREnterExitUIOptions {
  117793. /**
  117794. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117795. */
  117796. customButtons?: Array<WebXREnterExitUIButton>;
  117797. /**
  117798. * A reference space type to use when creating the default button.
  117799. * Default is local-floor
  117800. */
  117801. referenceSpaceType?: XRReferenceSpaceType;
  117802. /**
  117803. * Context to enter xr with
  117804. */
  117805. renderTarget?: Nullable<WebXRRenderTarget>;
  117806. /**
  117807. * A session mode to use when creating the default button.
  117808. * Default is immersive-vr
  117809. */
  117810. sessionMode?: XRSessionMode;
  117811. }
  117812. /**
  117813. * UI to allow the user to enter/exit XR mode
  117814. */
  117815. export class WebXREnterExitUI implements IDisposable {
  117816. private scene;
  117817. /** version of the options passed to this UI */
  117818. options: WebXREnterExitUIOptions;
  117819. private _activeButton;
  117820. private _buttons;
  117821. private _overlay;
  117822. /**
  117823. * Fired every time the active button is changed.
  117824. *
  117825. * When xr is entered via a button that launches xr that button will be the callback parameter
  117826. *
  117827. * When exiting xr the callback parameter will be null)
  117828. */
  117829. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117830. /**
  117831. *
  117832. * @param scene babylon scene object to use
  117833. * @param options (read-only) version of the options passed to this UI
  117834. */
  117835. private constructor();
  117836. /**
  117837. * Creates UI to allow the user to enter/exit XR mode
  117838. * @param scene the scene to add the ui to
  117839. * @param helper the xr experience helper to enter/exit xr with
  117840. * @param options options to configure the UI
  117841. * @returns the created ui
  117842. */
  117843. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117844. /**
  117845. * Disposes of the XR UI component
  117846. */
  117847. dispose(): void;
  117848. private _updateButtons;
  117849. }
  117850. }
  117851. declare module BABYLON {
  117852. /**
  117853. * Class containing static functions to help procedurally build meshes
  117854. */
  117855. export class LinesBuilder {
  117856. /**
  117857. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117858. * * 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
  117859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117860. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117861. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117862. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117863. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117864. * * 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
  117865. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117868. * @param name defines the name of the new line system
  117869. * @param options defines the options used to create the line system
  117870. * @param scene defines the hosting scene
  117871. * @returns a new line system mesh
  117872. */
  117873. static CreateLineSystem(name: string, options: {
  117874. lines: Vector3[][];
  117875. updatable?: boolean;
  117876. instance?: Nullable<LinesMesh>;
  117877. colors?: Nullable<Color4[][]>;
  117878. useVertexAlpha?: boolean;
  117879. }, scene: Nullable<Scene>): LinesMesh;
  117880. /**
  117881. * Creates a line mesh
  117882. * 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
  117883. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117884. * * The parameter `points` is an array successive Vector3
  117885. * * 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
  117886. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117887. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117888. * * When updating an instance, remember that only point positions can change, not the number of points
  117889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117891. * @param name defines the name of the new line system
  117892. * @param options defines the options used to create the line system
  117893. * @param scene defines the hosting scene
  117894. * @returns a new line mesh
  117895. */
  117896. static CreateLines(name: string, options: {
  117897. points: Vector3[];
  117898. updatable?: boolean;
  117899. instance?: Nullable<LinesMesh>;
  117900. colors?: Color4[];
  117901. useVertexAlpha?: boolean;
  117902. }, scene?: Nullable<Scene>): LinesMesh;
  117903. /**
  117904. * Creates a dashed line mesh
  117905. * * 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
  117906. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117907. * * The parameter `points` is an array successive Vector3
  117908. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117909. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117910. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117911. * * 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
  117912. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117913. * * When updating an instance, remember that only point positions can change, not the number of points
  117914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117915. * @param name defines the name of the mesh
  117916. * @param options defines the options used to create the mesh
  117917. * @param scene defines the hosting scene
  117918. * @returns the dashed line mesh
  117919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117920. */
  117921. static CreateDashedLines(name: string, options: {
  117922. points: Vector3[];
  117923. dashSize?: number;
  117924. gapSize?: number;
  117925. dashNb?: number;
  117926. updatable?: boolean;
  117927. instance?: LinesMesh;
  117928. useVertexAlpha?: boolean;
  117929. }, scene?: Nullable<Scene>): LinesMesh;
  117930. }
  117931. }
  117932. declare module BABYLON {
  117933. /**
  117934. * The options container for the teleportation module
  117935. */
  117936. export interface IWebXRTeleportationOptions {
  117937. /**
  117938. * if provided, this scene will be used to render meshes.
  117939. */
  117940. customUtilityLayerScene?: Scene;
  117941. /**
  117942. * Values to configure the default target mesh
  117943. */
  117944. defaultTargetMeshOptions?: {
  117945. /**
  117946. * Fill color of the teleportation area
  117947. */
  117948. teleportationFillColor?: string;
  117949. /**
  117950. * Border color for the teleportation area
  117951. */
  117952. teleportationBorderColor?: string;
  117953. /**
  117954. * Disable the mesh's animation sequence
  117955. */
  117956. disableAnimation?: boolean;
  117957. /**
  117958. * Disable lighting on the material or the ring and arrow
  117959. */
  117960. disableLighting?: boolean;
  117961. /**
  117962. * Override the default material of the torus and arrow
  117963. */
  117964. torusArrowMaterial?: Material;
  117965. };
  117966. /**
  117967. * A list of meshes to use as floor meshes.
  117968. * Meshes can be added and removed after initializing the feature using the
  117969. * addFloorMesh and removeFloorMesh functions
  117970. * If empty, rotation will still work
  117971. */
  117972. floorMeshes?: AbstractMesh[];
  117973. /**
  117974. * use this rendering group id for the meshes (optional)
  117975. */
  117976. renderingGroupId?: number;
  117977. /**
  117978. * Should teleportation move only to snap points
  117979. */
  117980. snapPointsOnly?: boolean;
  117981. /**
  117982. * An array of points to which the teleportation will snap to.
  117983. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  117984. */
  117985. snapPositions?: Vector3[];
  117986. /**
  117987. * How close should the teleportation ray be in order to snap to position.
  117988. * Default to 0.8 units (meters)
  117989. */
  117990. snapToPositionRadius?: number;
  117991. /**
  117992. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117993. * If you want to support rotation, make sure your mesh has a direction indicator.
  117994. *
  117995. * When left untouched, the default mesh will be initialized.
  117996. */
  117997. teleportationTargetMesh?: AbstractMesh;
  117998. /**
  117999. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118000. */
  118001. timeToTeleport?: number;
  118002. /**
  118003. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118004. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118005. */
  118006. useMainComponentOnly?: boolean;
  118007. /**
  118008. * Should meshes created here be added to a utility layer or the main scene
  118009. */
  118010. useUtilityLayer?: boolean;
  118011. /**
  118012. * Babylon XR Input class for controller
  118013. */
  118014. xrInput: WebXRInput;
  118015. }
  118016. /**
  118017. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118018. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118019. * the input of the attached controllers.
  118020. */
  118021. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118022. private _options;
  118023. private _controllers;
  118024. private _currentTeleportationControllerId;
  118025. private _floorMeshes;
  118026. private _quadraticBezierCurve;
  118027. private _selectionFeature;
  118028. private _snapToPositions;
  118029. private _snappedToPoint;
  118030. private _teleportationRingMaterial?;
  118031. private _tmpRay;
  118032. private _tmpVector;
  118033. /**
  118034. * The module's name
  118035. */
  118036. static readonly Name: string;
  118037. /**
  118038. * The (Babylon) version of this module.
  118039. * This is an integer representing the implementation version.
  118040. * This number does not correspond to the webxr specs version
  118041. */
  118042. static readonly Version: number;
  118043. /**
  118044. * Is movement backwards enabled
  118045. */
  118046. backwardsMovementEnabled: boolean;
  118047. /**
  118048. * Distance to travel when moving backwards
  118049. */
  118050. backwardsTeleportationDistance: number;
  118051. /**
  118052. * The distance from the user to the inspection point in the direction of the controller
  118053. * A higher number will allow the user to move further
  118054. * defaults to 5 (meters, in xr units)
  118055. */
  118056. parabolicCheckRadius: number;
  118057. /**
  118058. * Should the module support parabolic ray on top of direct ray
  118059. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118060. * Very helpful when moving between floors / different heights
  118061. */
  118062. parabolicRayEnabled: boolean;
  118063. /**
  118064. * How much rotation should be applied when rotating right and left
  118065. */
  118066. rotationAngle: number;
  118067. /**
  118068. * Is rotation enabled when moving forward?
  118069. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118070. */
  118071. rotationEnabled: boolean;
  118072. /**
  118073. * constructs a new anchor system
  118074. * @param _xrSessionManager an instance of WebXRSessionManager
  118075. * @param _options configuration object for this feature
  118076. */
  118077. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118078. /**
  118079. * Get the snapPointsOnly flag
  118080. */
  118081. get snapPointsOnly(): boolean;
  118082. /**
  118083. * Sets the snapPointsOnly flag
  118084. * @param snapToPoints should teleportation be exclusively to snap points
  118085. */
  118086. set snapPointsOnly(snapToPoints: boolean);
  118087. /**
  118088. * Add a new mesh to the floor meshes array
  118089. * @param mesh the mesh to use as floor mesh
  118090. */
  118091. addFloorMesh(mesh: AbstractMesh): void;
  118092. /**
  118093. * Add a new snap-to point to fix teleportation to this position
  118094. * @param newSnapPoint The new Snap-To point
  118095. */
  118096. addSnapPoint(newSnapPoint: Vector3): void;
  118097. attach(): boolean;
  118098. detach(): boolean;
  118099. dispose(): void;
  118100. /**
  118101. * Remove a mesh from the floor meshes array
  118102. * @param mesh the mesh to remove
  118103. */
  118104. removeFloorMesh(mesh: AbstractMesh): void;
  118105. /**
  118106. * Remove a mesh from the floor meshes array using its name
  118107. * @param name the mesh name to remove
  118108. */
  118109. removeFloorMeshByName(name: string): void;
  118110. /**
  118111. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  118112. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118113. * @returns was the point found and removed or not
  118114. */
  118115. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118116. /**
  118117. * This function sets a selection feature that will be disabled when
  118118. * the forward ray is shown and will be reattached when hidden.
  118119. * This is used to remove the selection rays when moving.
  118120. * @param selectionFeature the feature to disable when forward movement is enabled
  118121. */
  118122. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118123. protected _onXRFrame(_xrFrame: XRFrame): void;
  118124. private _attachController;
  118125. private _createDefaultTargetMesh;
  118126. private _detachController;
  118127. private _findClosestSnapPointWithRadius;
  118128. private _setTargetMeshPosition;
  118129. private _setTargetMeshVisibility;
  118130. private _showParabolicPath;
  118131. private _teleportForward;
  118132. }
  118133. }
  118134. declare module BABYLON {
  118135. /**
  118136. * Options for the default xr helper
  118137. */
  118138. export class WebXRDefaultExperienceOptions {
  118139. /**
  118140. * Enable or disable default UI to enter XR
  118141. */
  118142. disableDefaultUI?: boolean;
  118143. /**
  118144. * Should teleportation not initialize. defaults to false.
  118145. */
  118146. disableTeleportation?: boolean;
  118147. /**
  118148. * Floor meshes that will be used for teleport
  118149. */
  118150. floorMeshes?: Array<AbstractMesh>;
  118151. /**
  118152. * If set to true, the first frame will not be used to reset position
  118153. * The first frame is mainly used when copying transformation from the old camera
  118154. * Mainly used in AR
  118155. */
  118156. ignoreNativeCameraTransformation?: boolean;
  118157. /**
  118158. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118159. */
  118160. inputOptions?: IWebXRInputOptions;
  118161. /**
  118162. * optional configuration for the output canvas
  118163. */
  118164. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118165. /**
  118166. * optional UI options. This can be used among other to change session mode and reference space type
  118167. */
  118168. uiOptions?: WebXREnterExitUIOptions;
  118169. /**
  118170. * When loading teleportation and pointer select, use stable versions instead of latest.
  118171. */
  118172. useStablePlugins?: boolean;
  118173. }
  118174. /**
  118175. * Default experience which provides a similar setup to the previous webVRExperience
  118176. */
  118177. export class WebXRDefaultExperience {
  118178. /**
  118179. * Base experience
  118180. */
  118181. baseExperience: WebXRExperienceHelper;
  118182. /**
  118183. * Enables ui for entering/exiting xr
  118184. */
  118185. enterExitUI: WebXREnterExitUI;
  118186. /**
  118187. * Input experience extension
  118188. */
  118189. input: WebXRInput;
  118190. /**
  118191. * Enables laser pointer and selection
  118192. */
  118193. pointerSelection: WebXRControllerPointerSelection;
  118194. /**
  118195. * Default target xr should render to
  118196. */
  118197. renderTarget: WebXRRenderTarget;
  118198. /**
  118199. * Enables teleportation
  118200. */
  118201. teleportation: WebXRMotionControllerTeleportation;
  118202. private constructor();
  118203. /**
  118204. * Creates the default xr experience
  118205. * @param scene scene
  118206. * @param options options for basic configuration
  118207. * @returns resulting WebXRDefaultExperience
  118208. */
  118209. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118210. /**
  118211. * DIsposes of the experience helper
  118212. */
  118213. dispose(): void;
  118214. }
  118215. }
  118216. declare module BABYLON {
  118217. /**
  118218. * Options to modify the vr teleportation behavior.
  118219. */
  118220. export interface VRTeleportationOptions {
  118221. /**
  118222. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118223. */
  118224. floorMeshName?: string;
  118225. /**
  118226. * A list of meshes to be used as the teleportation floor. (default: empty)
  118227. */
  118228. floorMeshes?: Mesh[];
  118229. /**
  118230. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118231. */
  118232. teleportationMode?: number;
  118233. /**
  118234. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118235. */
  118236. teleportationTime?: number;
  118237. /**
  118238. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118239. */
  118240. teleportationSpeed?: number;
  118241. /**
  118242. * The easing function used in the animation or null for Linear. (default CircleEase)
  118243. */
  118244. easingFunction?: EasingFunction;
  118245. }
  118246. /**
  118247. * Options to modify the vr experience helper's behavior.
  118248. */
  118249. export interface VRExperienceHelperOptions extends WebVROptions {
  118250. /**
  118251. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118252. */
  118253. createDeviceOrientationCamera?: boolean;
  118254. /**
  118255. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118256. */
  118257. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118258. /**
  118259. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118260. */
  118261. laserToggle?: boolean;
  118262. /**
  118263. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118264. */
  118265. floorMeshes?: Mesh[];
  118266. /**
  118267. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118268. */
  118269. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118270. /**
  118271. * Defines if WebXR should be used instead of WebVR (if available)
  118272. */
  118273. useXR?: boolean;
  118274. }
  118275. /**
  118276. * Event containing information after VR has been entered
  118277. */
  118278. export class OnAfterEnteringVRObservableEvent {
  118279. /**
  118280. * If entering vr was successful
  118281. */
  118282. success: boolean;
  118283. }
  118284. /**
  118285. * Helps to quickly add VR support to an existing scene.
  118286. * See http://doc.babylonjs.com/how_to/webvr_helper
  118287. */
  118288. export class VRExperienceHelper {
  118289. /** Options to modify the vr experience helper's behavior. */
  118290. webVROptions: VRExperienceHelperOptions;
  118291. private _scene;
  118292. private _position;
  118293. private _btnVR;
  118294. private _btnVRDisplayed;
  118295. private _webVRsupported;
  118296. private _webVRready;
  118297. private _webVRrequesting;
  118298. private _webVRpresenting;
  118299. private _hasEnteredVR;
  118300. private _fullscreenVRpresenting;
  118301. private _inputElement;
  118302. private _webVRCamera;
  118303. private _vrDeviceOrientationCamera;
  118304. private _deviceOrientationCamera;
  118305. private _existingCamera;
  118306. private _onKeyDown;
  118307. private _onVrDisplayPresentChange;
  118308. private _onVRDisplayChanged;
  118309. private _onVRRequestPresentStart;
  118310. private _onVRRequestPresentComplete;
  118311. /**
  118312. * 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)
  118313. */
  118314. enableGazeEvenWhenNoPointerLock: boolean;
  118315. /**
  118316. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118317. */
  118318. exitVROnDoubleTap: boolean;
  118319. /**
  118320. * Observable raised right before entering VR.
  118321. */
  118322. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118323. /**
  118324. * Observable raised when entering VR has completed.
  118325. */
  118326. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118327. /**
  118328. * Observable raised when exiting VR.
  118329. */
  118330. onExitingVRObservable: Observable<VRExperienceHelper>;
  118331. /**
  118332. * Observable raised when controller mesh is loaded.
  118333. */
  118334. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118335. /** Return this.onEnteringVRObservable
  118336. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118337. */
  118338. get onEnteringVR(): Observable<VRExperienceHelper>;
  118339. /** Return this.onExitingVRObservable
  118340. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118341. */
  118342. get onExitingVR(): Observable<VRExperienceHelper>;
  118343. /** Return this.onControllerMeshLoadedObservable
  118344. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118345. */
  118346. get onControllerMeshLoaded(): Observable<WebVRController>;
  118347. private _rayLength;
  118348. private _useCustomVRButton;
  118349. private _teleportationRequested;
  118350. private _teleportActive;
  118351. private _floorMeshName;
  118352. private _floorMeshesCollection;
  118353. private _teleportationMode;
  118354. private _teleportationTime;
  118355. private _teleportationSpeed;
  118356. private _teleportationEasing;
  118357. private _rotationAllowed;
  118358. private _teleportBackwardsVector;
  118359. private _teleportationTarget;
  118360. private _isDefaultTeleportationTarget;
  118361. private _postProcessMove;
  118362. private _teleportationFillColor;
  118363. private _teleportationBorderColor;
  118364. private _rotationAngle;
  118365. private _haloCenter;
  118366. private _cameraGazer;
  118367. private _padSensibilityUp;
  118368. private _padSensibilityDown;
  118369. private _leftController;
  118370. private _rightController;
  118371. private _gazeColor;
  118372. private _laserColor;
  118373. private _pickedLaserColor;
  118374. private _pickedGazeColor;
  118375. /**
  118376. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118377. */
  118378. onNewMeshSelected: Observable<AbstractMesh>;
  118379. /**
  118380. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118381. * This observable will provide the mesh and the controller used to select the mesh
  118382. */
  118383. onMeshSelectedWithController: Observable<{
  118384. mesh: AbstractMesh;
  118385. controller: WebVRController;
  118386. }>;
  118387. /**
  118388. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118389. */
  118390. onNewMeshPicked: Observable<PickingInfo>;
  118391. private _circleEase;
  118392. /**
  118393. * Observable raised before camera teleportation
  118394. */
  118395. onBeforeCameraTeleport: Observable<Vector3>;
  118396. /**
  118397. * Observable raised after camera teleportation
  118398. */
  118399. onAfterCameraTeleport: Observable<Vector3>;
  118400. /**
  118401. * Observable raised when current selected mesh gets unselected
  118402. */
  118403. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118404. private _raySelectionPredicate;
  118405. /**
  118406. * To be optionaly changed by user to define custom ray selection
  118407. */
  118408. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118409. /**
  118410. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118411. */
  118412. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118413. /**
  118414. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118415. */
  118416. teleportationEnabled: boolean;
  118417. private _defaultHeight;
  118418. private _teleportationInitialized;
  118419. private _interactionsEnabled;
  118420. private _interactionsRequested;
  118421. private _displayGaze;
  118422. private _displayLaserPointer;
  118423. /**
  118424. * The mesh used to display where the user is going to teleport.
  118425. */
  118426. get teleportationTarget(): Mesh;
  118427. /**
  118428. * Sets the mesh to be used to display where the user is going to teleport.
  118429. */
  118430. set teleportationTarget(value: Mesh);
  118431. /**
  118432. * 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
  118433. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118434. * See http://doc.babylonjs.com/resources/baking_transformations
  118435. */
  118436. get gazeTrackerMesh(): Mesh;
  118437. set gazeTrackerMesh(value: Mesh);
  118438. /**
  118439. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118440. */
  118441. updateGazeTrackerScale: boolean;
  118442. /**
  118443. * If the gaze trackers color should be updated when selecting meshes
  118444. */
  118445. updateGazeTrackerColor: boolean;
  118446. /**
  118447. * If the controller laser color should be updated when selecting meshes
  118448. */
  118449. updateControllerLaserColor: boolean;
  118450. /**
  118451. * The gaze tracking mesh corresponding to the left controller
  118452. */
  118453. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118454. /**
  118455. * The gaze tracking mesh corresponding to the right controller
  118456. */
  118457. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118458. /**
  118459. * If the ray of the gaze should be displayed.
  118460. */
  118461. get displayGaze(): boolean;
  118462. /**
  118463. * Sets if the ray of the gaze should be displayed.
  118464. */
  118465. set displayGaze(value: boolean);
  118466. /**
  118467. * If the ray of the LaserPointer should be displayed.
  118468. */
  118469. get displayLaserPointer(): boolean;
  118470. /**
  118471. * Sets if the ray of the LaserPointer should be displayed.
  118472. */
  118473. set displayLaserPointer(value: boolean);
  118474. /**
  118475. * The deviceOrientationCamera used as the camera when not in VR.
  118476. */
  118477. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118478. /**
  118479. * Based on the current WebVR support, returns the current VR camera used.
  118480. */
  118481. get currentVRCamera(): Nullable<Camera>;
  118482. /**
  118483. * The webVRCamera which is used when in VR.
  118484. */
  118485. get webVRCamera(): WebVRFreeCamera;
  118486. /**
  118487. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118488. */
  118489. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118490. /**
  118491. * The html button that is used to trigger entering into VR.
  118492. */
  118493. get vrButton(): Nullable<HTMLButtonElement>;
  118494. private get _teleportationRequestInitiated();
  118495. /**
  118496. * Defines whether or not Pointer lock should be requested when switching to
  118497. * full screen.
  118498. */
  118499. requestPointerLockOnFullScreen: boolean;
  118500. /**
  118501. * If asking to force XR, this will be populated with the default xr experience
  118502. */
  118503. xr: WebXRDefaultExperience;
  118504. /**
  118505. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118506. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118507. */
  118508. xrTestDone: boolean;
  118509. /**
  118510. * Instantiates a VRExperienceHelper.
  118511. * Helps to quickly add VR support to an existing scene.
  118512. * @param scene The scene the VRExperienceHelper belongs to.
  118513. * @param webVROptions Options to modify the vr experience helper's behavior.
  118514. */
  118515. constructor(scene: Scene,
  118516. /** Options to modify the vr experience helper's behavior. */
  118517. webVROptions?: VRExperienceHelperOptions);
  118518. private completeVRInit;
  118519. private _onDefaultMeshLoaded;
  118520. private _onResize;
  118521. private _onFullscreenChange;
  118522. /**
  118523. * Gets a value indicating if we are currently in VR mode.
  118524. */
  118525. get isInVRMode(): boolean;
  118526. private onVrDisplayPresentChange;
  118527. private onVRDisplayChanged;
  118528. private moveButtonToBottomRight;
  118529. private displayVRButton;
  118530. private updateButtonVisibility;
  118531. private _cachedAngularSensibility;
  118532. /**
  118533. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118534. * Otherwise, will use the fullscreen API.
  118535. */
  118536. enterVR(): void;
  118537. /**
  118538. * Attempt to exit VR, or fullscreen.
  118539. */
  118540. exitVR(): void;
  118541. /**
  118542. * The position of the vr experience helper.
  118543. */
  118544. get position(): Vector3;
  118545. /**
  118546. * Sets the position of the vr experience helper.
  118547. */
  118548. set position(value: Vector3);
  118549. /**
  118550. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118551. */
  118552. enableInteractions(): void;
  118553. private get _noControllerIsActive();
  118554. private beforeRender;
  118555. private _isTeleportationFloor;
  118556. /**
  118557. * Adds a floor mesh to be used for teleportation.
  118558. * @param floorMesh the mesh to be used for teleportation.
  118559. */
  118560. addFloorMesh(floorMesh: Mesh): void;
  118561. /**
  118562. * Removes a floor mesh from being used for teleportation.
  118563. * @param floorMesh the mesh to be removed.
  118564. */
  118565. removeFloorMesh(floorMesh: Mesh): void;
  118566. /**
  118567. * Enables interactions and teleportation using the VR controllers and gaze.
  118568. * @param vrTeleportationOptions options to modify teleportation behavior.
  118569. */
  118570. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118571. private _onNewGamepadConnected;
  118572. private _tryEnableInteractionOnController;
  118573. private _onNewGamepadDisconnected;
  118574. private _enableInteractionOnController;
  118575. private _checkTeleportWithRay;
  118576. private _checkRotate;
  118577. private _checkTeleportBackwards;
  118578. private _enableTeleportationOnController;
  118579. private _createTeleportationCircles;
  118580. private _displayTeleportationTarget;
  118581. private _hideTeleportationTarget;
  118582. private _rotateCamera;
  118583. private _moveTeleportationSelectorTo;
  118584. private _workingVector;
  118585. private _workingQuaternion;
  118586. private _workingMatrix;
  118587. /**
  118588. * Time Constant Teleportation Mode
  118589. */
  118590. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118591. /**
  118592. * Speed Constant Teleportation Mode
  118593. */
  118594. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118595. /**
  118596. * Teleports the users feet to the desired location
  118597. * @param location The location where the user's feet should be placed
  118598. */
  118599. teleportCamera(location: Vector3): void;
  118600. private _convertNormalToDirectionOfRay;
  118601. private _castRayAndSelectObject;
  118602. private _notifySelectedMeshUnselected;
  118603. /**
  118604. * Permanently set new colors for the laser pointer
  118605. * @param color the new laser color
  118606. * @param pickedColor the new laser color when picked mesh detected
  118607. */
  118608. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118609. /**
  118610. * Set lighting enabled / disabled on the laser pointer of both controllers
  118611. * @param enabled should the lighting be enabled on the laser pointer
  118612. */
  118613. setLaserLightingState(enabled?: boolean): void;
  118614. /**
  118615. * Permanently set new colors for the gaze pointer
  118616. * @param color the new gaze color
  118617. * @param pickedColor the new gaze color when picked mesh detected
  118618. */
  118619. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118620. /**
  118621. * Sets the color of the laser ray from the vr controllers.
  118622. * @param color new color for the ray.
  118623. */
  118624. changeLaserColor(color: Color3): void;
  118625. /**
  118626. * Sets the color of the ray from the vr headsets gaze.
  118627. * @param color new color for the ray.
  118628. */
  118629. changeGazeColor(color: Color3): void;
  118630. /**
  118631. * Exits VR and disposes of the vr experience helper
  118632. */
  118633. dispose(): void;
  118634. /**
  118635. * Gets the name of the VRExperienceHelper class
  118636. * @returns "VRExperienceHelper"
  118637. */
  118638. getClassName(): string;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * Contains an array of blocks representing the octree
  118644. */
  118645. export interface IOctreeContainer<T> {
  118646. /**
  118647. * Blocks within the octree
  118648. */
  118649. blocks: Array<OctreeBlock<T>>;
  118650. }
  118651. /**
  118652. * Class used to store a cell in an octree
  118653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118654. */
  118655. export class OctreeBlock<T> {
  118656. /**
  118657. * Gets the content of the current block
  118658. */
  118659. entries: T[];
  118660. /**
  118661. * Gets the list of block children
  118662. */
  118663. blocks: Array<OctreeBlock<T>>;
  118664. private _depth;
  118665. private _maxDepth;
  118666. private _capacity;
  118667. private _minPoint;
  118668. private _maxPoint;
  118669. private _boundingVectors;
  118670. private _creationFunc;
  118671. /**
  118672. * Creates a new block
  118673. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118674. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118675. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118676. * @param depth defines the current depth of this block in the octree
  118677. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118678. * @param creationFunc defines a callback to call when an element is added to the block
  118679. */
  118680. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118681. /**
  118682. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118683. */
  118684. get capacity(): number;
  118685. /**
  118686. * Gets the minimum vector (in world space) of the block's bounding box
  118687. */
  118688. get minPoint(): Vector3;
  118689. /**
  118690. * Gets the maximum vector (in world space) of the block's bounding box
  118691. */
  118692. get maxPoint(): Vector3;
  118693. /**
  118694. * Add a new element to this block
  118695. * @param entry defines the element to add
  118696. */
  118697. addEntry(entry: T): void;
  118698. /**
  118699. * Remove an element from this block
  118700. * @param entry defines the element to remove
  118701. */
  118702. removeEntry(entry: T): void;
  118703. /**
  118704. * Add an array of elements to this block
  118705. * @param entries defines the array of elements to add
  118706. */
  118707. addEntries(entries: T[]): void;
  118708. /**
  118709. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118710. * @param frustumPlanes defines the frustum planes to test
  118711. * @param selection defines the array to store current content if selection is positive
  118712. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118713. */
  118714. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118715. /**
  118716. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118717. * @param sphereCenter defines the bounding sphere center
  118718. * @param sphereRadius defines the bounding sphere radius
  118719. * @param selection defines the array to store current content if selection is positive
  118720. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118721. */
  118722. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118723. /**
  118724. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118725. * @param ray defines the ray to test with
  118726. * @param selection defines the array to store current content if selection is positive
  118727. */
  118728. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118729. /**
  118730. * Subdivide the content into child blocks (this block will then be empty)
  118731. */
  118732. createInnerBlocks(): void;
  118733. /**
  118734. * @hidden
  118735. */
  118736. 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;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118742. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118743. */
  118744. export class Octree<T> {
  118745. /** 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.) */
  118746. maxDepth: number;
  118747. /**
  118748. * Blocks within the octree containing objects
  118749. */
  118750. blocks: Array<OctreeBlock<T>>;
  118751. /**
  118752. * Content stored in the octree
  118753. */
  118754. dynamicContent: T[];
  118755. private _maxBlockCapacity;
  118756. private _selectionContent;
  118757. private _creationFunc;
  118758. /**
  118759. * Creates a octree
  118760. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118761. * @param creationFunc function to be used to instatiate the octree
  118762. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118763. * @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.)
  118764. */
  118765. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118766. /** 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.) */
  118767. maxDepth?: number);
  118768. /**
  118769. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118770. * @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);
  118771. * @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);
  118772. * @param entries meshes to be added to the octree blocks
  118773. */
  118774. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118775. /**
  118776. * Adds a mesh to the octree
  118777. * @param entry Mesh to add to the octree
  118778. */
  118779. addMesh(entry: T): void;
  118780. /**
  118781. * Remove an element from the octree
  118782. * @param entry defines the element to remove
  118783. */
  118784. removeMesh(entry: T): void;
  118785. /**
  118786. * Selects an array of meshes within the frustum
  118787. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118788. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118789. * @returns array of meshes within the frustum
  118790. */
  118791. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118792. /**
  118793. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118794. * @param sphereCenter defines the bounding sphere center
  118795. * @param sphereRadius defines the bounding sphere radius
  118796. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118797. * @returns an array of objects that intersect the sphere
  118798. */
  118799. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118800. /**
  118801. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118802. * @param ray defines the ray to test with
  118803. * @returns array of intersected objects
  118804. */
  118805. intersectsRay(ray: Ray): SmartArray<T>;
  118806. /**
  118807. * Adds a mesh into the octree block if it intersects the block
  118808. */
  118809. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118810. /**
  118811. * Adds a submesh into the octree block if it intersects the block
  118812. */
  118813. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118814. }
  118815. }
  118816. declare module BABYLON {
  118817. interface Scene {
  118818. /**
  118819. * @hidden
  118820. * Backing Filed
  118821. */
  118822. _selectionOctree: Octree<AbstractMesh>;
  118823. /**
  118824. * Gets the octree used to boost mesh selection (picking)
  118825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118826. */
  118827. selectionOctree: Octree<AbstractMesh>;
  118828. /**
  118829. * Creates or updates the octree used to boost selection (picking)
  118830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118831. * @param maxCapacity defines the maximum capacity per leaf
  118832. * @param maxDepth defines the maximum depth of the octree
  118833. * @returns an octree of AbstractMesh
  118834. */
  118835. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118836. }
  118837. interface AbstractMesh {
  118838. /**
  118839. * @hidden
  118840. * Backing Field
  118841. */
  118842. _submeshesOctree: Octree<SubMesh>;
  118843. /**
  118844. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118845. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118846. * @param maxCapacity defines the maximum size of each block (64 by default)
  118847. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118848. * @returns the new octree
  118849. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118851. */
  118852. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118853. }
  118854. /**
  118855. * Defines the octree scene component responsible to manage any octrees
  118856. * in a given scene.
  118857. */
  118858. export class OctreeSceneComponent {
  118859. /**
  118860. * The component name help to identify the component in the list of scene components.
  118861. */
  118862. readonly name: string;
  118863. /**
  118864. * The scene the component belongs to.
  118865. */
  118866. scene: Scene;
  118867. /**
  118868. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118869. */
  118870. readonly checksIsEnabled: boolean;
  118871. /**
  118872. * Creates a new instance of the component for the given scene
  118873. * @param scene Defines the scene to register the component in
  118874. */
  118875. constructor(scene: Scene);
  118876. /**
  118877. * Registers the component in a given scene
  118878. */
  118879. register(): void;
  118880. /**
  118881. * Return the list of active meshes
  118882. * @returns the list of active meshes
  118883. */
  118884. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118885. /**
  118886. * Return the list of active sub meshes
  118887. * @param mesh The mesh to get the candidates sub meshes from
  118888. * @returns the list of active sub meshes
  118889. */
  118890. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118891. private _tempRay;
  118892. /**
  118893. * Return the list of sub meshes intersecting with a given local ray
  118894. * @param mesh defines the mesh to find the submesh for
  118895. * @param localRay defines the ray in local space
  118896. * @returns the list of intersecting sub meshes
  118897. */
  118898. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118899. /**
  118900. * Return the list of sub meshes colliding with a collider
  118901. * @param mesh defines the mesh to find the submesh for
  118902. * @param collider defines the collider to evaluate the collision against
  118903. * @returns the list of colliding sub meshes
  118904. */
  118905. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118906. /**
  118907. * Rebuilds the elements related to this component in case of
  118908. * context lost for instance.
  118909. */
  118910. rebuild(): void;
  118911. /**
  118912. * Disposes the component and the associated ressources.
  118913. */
  118914. dispose(): void;
  118915. }
  118916. }
  118917. declare module BABYLON {
  118918. /**
  118919. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118920. */
  118921. export class Gizmo implements IDisposable {
  118922. /** The utility layer the gizmo will be added to */
  118923. gizmoLayer: UtilityLayerRenderer;
  118924. /**
  118925. * The root mesh of the gizmo
  118926. */
  118927. _rootMesh: Mesh;
  118928. private _attachedMesh;
  118929. /**
  118930. * Ratio for the scale of the gizmo (Default: 1)
  118931. */
  118932. scaleRatio: number;
  118933. /**
  118934. * If a custom mesh has been set (Default: false)
  118935. */
  118936. protected _customMeshSet: boolean;
  118937. /**
  118938. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118939. * * When set, interactions will be enabled
  118940. */
  118941. get attachedMesh(): Nullable<AbstractMesh>;
  118942. set attachedMesh(value: Nullable<AbstractMesh>);
  118943. /**
  118944. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118945. * @param mesh The mesh to replace the default mesh of the gizmo
  118946. */
  118947. setCustomMesh(mesh: Mesh): void;
  118948. /**
  118949. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118950. */
  118951. updateGizmoRotationToMatchAttachedMesh: boolean;
  118952. /**
  118953. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118954. */
  118955. updateGizmoPositionToMatchAttachedMesh: boolean;
  118956. /**
  118957. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118958. */
  118959. updateScale: boolean;
  118960. protected _interactionsEnabled: boolean;
  118961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118962. private _beforeRenderObserver;
  118963. private _tempVector;
  118964. /**
  118965. * Creates a gizmo
  118966. * @param gizmoLayer The utility layer the gizmo will be added to
  118967. */
  118968. constructor(
  118969. /** The utility layer the gizmo will be added to */
  118970. gizmoLayer?: UtilityLayerRenderer);
  118971. /**
  118972. * Updates the gizmo to match the attached mesh's position/rotation
  118973. */
  118974. protected _update(): void;
  118975. /**
  118976. * Disposes of the gizmo
  118977. */
  118978. dispose(): void;
  118979. }
  118980. }
  118981. declare module BABYLON {
  118982. /**
  118983. * Single plane drag gizmo
  118984. */
  118985. export class PlaneDragGizmo extends Gizmo {
  118986. /**
  118987. * Drag behavior responsible for the gizmos dragging interactions
  118988. */
  118989. dragBehavior: PointerDragBehavior;
  118990. private _pointerObserver;
  118991. /**
  118992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118993. */
  118994. snapDistance: number;
  118995. /**
  118996. * Event that fires each time the gizmo snaps to a new location.
  118997. * * snapDistance is the the change in distance
  118998. */
  118999. onSnapObservable: Observable<{
  119000. snapDistance: number;
  119001. }>;
  119002. private _plane;
  119003. private _coloredMaterial;
  119004. private _hoverMaterial;
  119005. private _isEnabled;
  119006. private _parent;
  119007. /** @hidden */
  119008. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119009. /** @hidden */
  119010. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119011. /**
  119012. * Creates a PlaneDragGizmo
  119013. * @param gizmoLayer The utility layer the gizmo will be added to
  119014. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119015. * @param color The color of the gizmo
  119016. */
  119017. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119019. /**
  119020. * If the gizmo is enabled
  119021. */
  119022. set isEnabled(value: boolean);
  119023. get isEnabled(): boolean;
  119024. /**
  119025. * Disposes of the gizmo
  119026. */
  119027. dispose(): void;
  119028. }
  119029. }
  119030. declare module BABYLON {
  119031. /**
  119032. * Gizmo that enables dragging a mesh along 3 axis
  119033. */
  119034. export class PositionGizmo extends Gizmo {
  119035. /**
  119036. * Internal gizmo used for interactions on the x axis
  119037. */
  119038. xGizmo: AxisDragGizmo;
  119039. /**
  119040. * Internal gizmo used for interactions on the y axis
  119041. */
  119042. yGizmo: AxisDragGizmo;
  119043. /**
  119044. * Internal gizmo used for interactions on the z axis
  119045. */
  119046. zGizmo: AxisDragGizmo;
  119047. /**
  119048. * Internal gizmo used for interactions on the yz plane
  119049. */
  119050. xPlaneGizmo: PlaneDragGizmo;
  119051. /**
  119052. * Internal gizmo used for interactions on the xz plane
  119053. */
  119054. yPlaneGizmo: PlaneDragGizmo;
  119055. /**
  119056. * Internal gizmo used for interactions on the xy plane
  119057. */
  119058. zPlaneGizmo: PlaneDragGizmo;
  119059. /**
  119060. * private variables
  119061. */
  119062. private _meshAttached;
  119063. private _updateGizmoRotationToMatchAttachedMesh;
  119064. private _snapDistance;
  119065. private _scaleRatio;
  119066. /** Fires an event when any of it's sub gizmos are dragged */
  119067. onDragStartObservable: Observable<unknown>;
  119068. /** Fires an event when any of it's sub gizmos are released from dragging */
  119069. onDragEndObservable: Observable<unknown>;
  119070. /**
  119071. * If set to true, planar drag is enabled
  119072. */
  119073. private _planarGizmoEnabled;
  119074. get attachedMesh(): Nullable<AbstractMesh>;
  119075. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119076. /**
  119077. * Creates a PositionGizmo
  119078. * @param gizmoLayer The utility layer the gizmo will be added to
  119079. */
  119080. constructor(gizmoLayer?: UtilityLayerRenderer);
  119081. /**
  119082. * If the planar drag gizmo is enabled
  119083. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119084. */
  119085. set planarGizmoEnabled(value: boolean);
  119086. get planarGizmoEnabled(): boolean;
  119087. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119088. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119089. /**
  119090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119091. */
  119092. set snapDistance(value: number);
  119093. get snapDistance(): number;
  119094. /**
  119095. * Ratio for the scale of the gizmo (Default: 1)
  119096. */
  119097. set scaleRatio(value: number);
  119098. get scaleRatio(): number;
  119099. /**
  119100. * Disposes of the gizmo
  119101. */
  119102. dispose(): void;
  119103. /**
  119104. * CustomMeshes are not supported by this gizmo
  119105. * @param mesh The mesh to replace the default mesh of the gizmo
  119106. */
  119107. setCustomMesh(mesh: Mesh): void;
  119108. }
  119109. }
  119110. declare module BABYLON {
  119111. /**
  119112. * Single axis drag gizmo
  119113. */
  119114. export class AxisDragGizmo extends Gizmo {
  119115. /**
  119116. * Drag behavior responsible for the gizmos dragging interactions
  119117. */
  119118. dragBehavior: PointerDragBehavior;
  119119. private _pointerObserver;
  119120. /**
  119121. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119122. */
  119123. snapDistance: number;
  119124. /**
  119125. * Event that fires each time the gizmo snaps to a new location.
  119126. * * snapDistance is the the change in distance
  119127. */
  119128. onSnapObservable: Observable<{
  119129. snapDistance: number;
  119130. }>;
  119131. private _isEnabled;
  119132. private _parent;
  119133. private _arrow;
  119134. private _coloredMaterial;
  119135. private _hoverMaterial;
  119136. /** @hidden */
  119137. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119138. /** @hidden */
  119139. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119140. /**
  119141. * Creates an AxisDragGizmo
  119142. * @param gizmoLayer The utility layer the gizmo will be added to
  119143. * @param dragAxis The axis which the gizmo will be able to drag on
  119144. * @param color The color of the gizmo
  119145. */
  119146. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119147. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119148. /**
  119149. * If the gizmo is enabled
  119150. */
  119151. set isEnabled(value: boolean);
  119152. get isEnabled(): boolean;
  119153. /**
  119154. * Disposes of the gizmo
  119155. */
  119156. dispose(): void;
  119157. }
  119158. }
  119159. declare module BABYLON.Debug {
  119160. /**
  119161. * The Axes viewer will show 3 axes in a specific point in space
  119162. */
  119163. export class AxesViewer {
  119164. private _xAxis;
  119165. private _yAxis;
  119166. private _zAxis;
  119167. private _scaleLinesFactor;
  119168. private _instanced;
  119169. /**
  119170. * Gets the hosting scene
  119171. */
  119172. scene: Scene;
  119173. /**
  119174. * Gets or sets a number used to scale line length
  119175. */
  119176. scaleLines: number;
  119177. /** Gets the node hierarchy used to render x-axis */
  119178. get xAxis(): TransformNode;
  119179. /** Gets the node hierarchy used to render y-axis */
  119180. get yAxis(): TransformNode;
  119181. /** Gets the node hierarchy used to render z-axis */
  119182. get zAxis(): TransformNode;
  119183. /**
  119184. * Creates a new AxesViewer
  119185. * @param scene defines the hosting scene
  119186. * @param scaleLines defines a number used to scale line length (1 by default)
  119187. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119188. * @param xAxis defines the node hierarchy used to render the x-axis
  119189. * @param yAxis defines the node hierarchy used to render the y-axis
  119190. * @param zAxis defines the node hierarchy used to render the z-axis
  119191. */
  119192. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119193. /**
  119194. * Force the viewer to update
  119195. * @param position defines the position of the viewer
  119196. * @param xaxis defines the x axis of the viewer
  119197. * @param yaxis defines the y axis of the viewer
  119198. * @param zaxis defines the z axis of the viewer
  119199. */
  119200. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119201. /**
  119202. * Creates an instance of this axes viewer.
  119203. * @returns a new axes viewer with instanced meshes
  119204. */
  119205. createInstance(): AxesViewer;
  119206. /** Releases resources */
  119207. dispose(): void;
  119208. private static _SetRenderingGroupId;
  119209. }
  119210. }
  119211. declare module BABYLON.Debug {
  119212. /**
  119213. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119214. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119215. */
  119216. export class BoneAxesViewer extends AxesViewer {
  119217. /**
  119218. * Gets or sets the target mesh where to display the axes viewer
  119219. */
  119220. mesh: Nullable<Mesh>;
  119221. /**
  119222. * Gets or sets the target bone where to display the axes viewer
  119223. */
  119224. bone: Nullable<Bone>;
  119225. /** Gets current position */
  119226. pos: Vector3;
  119227. /** Gets direction of X axis */
  119228. xaxis: Vector3;
  119229. /** Gets direction of Y axis */
  119230. yaxis: Vector3;
  119231. /** Gets direction of Z axis */
  119232. zaxis: Vector3;
  119233. /**
  119234. * Creates a new BoneAxesViewer
  119235. * @param scene defines the hosting scene
  119236. * @param bone defines the target bone
  119237. * @param mesh defines the target mesh
  119238. * @param scaleLines defines a scaling factor for line length (1 by default)
  119239. */
  119240. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119241. /**
  119242. * Force the viewer to update
  119243. */
  119244. update(): void;
  119245. /** Releases resources */
  119246. dispose(): void;
  119247. }
  119248. }
  119249. declare module BABYLON {
  119250. /**
  119251. * Interface used to define scene explorer extensibility option
  119252. */
  119253. export interface IExplorerExtensibilityOption {
  119254. /**
  119255. * Define the option label
  119256. */
  119257. label: string;
  119258. /**
  119259. * Defines the action to execute on click
  119260. */
  119261. action: (entity: any) => void;
  119262. }
  119263. /**
  119264. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119265. */
  119266. export interface IExplorerExtensibilityGroup {
  119267. /**
  119268. * Defines a predicate to test if a given type mut be extended
  119269. */
  119270. predicate: (entity: any) => boolean;
  119271. /**
  119272. * Gets the list of options added to a type
  119273. */
  119274. entries: IExplorerExtensibilityOption[];
  119275. }
  119276. /**
  119277. * Interface used to define the options to use to create the Inspector
  119278. */
  119279. export interface IInspectorOptions {
  119280. /**
  119281. * Display in overlay mode (default: false)
  119282. */
  119283. overlay?: boolean;
  119284. /**
  119285. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119286. */
  119287. globalRoot?: HTMLElement;
  119288. /**
  119289. * Display the Scene explorer
  119290. */
  119291. showExplorer?: boolean;
  119292. /**
  119293. * Display the property inspector
  119294. */
  119295. showInspector?: boolean;
  119296. /**
  119297. * Display in embed mode (both panes on the right)
  119298. */
  119299. embedMode?: boolean;
  119300. /**
  119301. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119302. */
  119303. handleResize?: boolean;
  119304. /**
  119305. * Allow the panes to popup (default: true)
  119306. */
  119307. enablePopup?: boolean;
  119308. /**
  119309. * Allow the panes to be closed by users (default: true)
  119310. */
  119311. enableClose?: boolean;
  119312. /**
  119313. * Optional list of extensibility entries
  119314. */
  119315. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119316. /**
  119317. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119318. */
  119319. inspectorURL?: string;
  119320. /**
  119321. * Optional initial tab (default to DebugLayerTab.Properties)
  119322. */
  119323. initialTab?: DebugLayerTab;
  119324. }
  119325. interface Scene {
  119326. /**
  119327. * @hidden
  119328. * Backing field
  119329. */
  119330. _debugLayer: DebugLayer;
  119331. /**
  119332. * Gets the debug layer (aka Inspector) associated with the scene
  119333. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119334. */
  119335. debugLayer: DebugLayer;
  119336. }
  119337. /**
  119338. * Enum of inspector action tab
  119339. */
  119340. export enum DebugLayerTab {
  119341. /**
  119342. * Properties tag (default)
  119343. */
  119344. Properties = 0,
  119345. /**
  119346. * Debug tab
  119347. */
  119348. Debug = 1,
  119349. /**
  119350. * Statistics tab
  119351. */
  119352. Statistics = 2,
  119353. /**
  119354. * Tools tab
  119355. */
  119356. Tools = 3,
  119357. /**
  119358. * Settings tab
  119359. */
  119360. Settings = 4
  119361. }
  119362. /**
  119363. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119364. * what is happening in your scene
  119365. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119366. */
  119367. export class DebugLayer {
  119368. /**
  119369. * Define the url to get the inspector script from.
  119370. * By default it uses the babylonjs CDN.
  119371. * @ignoreNaming
  119372. */
  119373. static InspectorURL: string;
  119374. private _scene;
  119375. private BJSINSPECTOR;
  119376. private _onPropertyChangedObservable?;
  119377. /**
  119378. * Observable triggered when a property is changed through the inspector.
  119379. */
  119380. get onPropertyChangedObservable(): any;
  119381. /**
  119382. * Instantiates a new debug layer.
  119383. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119384. * what is happening in your scene
  119385. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119386. * @param scene Defines the scene to inspect
  119387. */
  119388. constructor(scene: Scene);
  119389. /** Creates the inspector window. */
  119390. private _createInspector;
  119391. /**
  119392. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119393. * @param entity defines the entity to select
  119394. * @param lineContainerTitle defines the specific block to highlight
  119395. */
  119396. select(entity: any, lineContainerTitle?: string): void;
  119397. /** Get the inspector from bundle or global */
  119398. private _getGlobalInspector;
  119399. /**
  119400. * Get if the inspector is visible or not.
  119401. * @returns true if visible otherwise, false
  119402. */
  119403. isVisible(): boolean;
  119404. /**
  119405. * Hide the inspector and close its window.
  119406. */
  119407. hide(): void;
  119408. /**
  119409. * Launch the debugLayer.
  119410. * @param config Define the configuration of the inspector
  119411. * @return a promise fulfilled when the debug layer is visible
  119412. */
  119413. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119414. }
  119415. }
  119416. declare module BABYLON {
  119417. /**
  119418. * Class containing static functions to help procedurally build meshes
  119419. */
  119420. export class BoxBuilder {
  119421. /**
  119422. * Creates a box mesh
  119423. * * The parameter `size` sets the size (float) of each box side (default 1)
  119424. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119425. * * 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)
  119426. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119430. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119431. * @param name defines the name of the mesh
  119432. * @param options defines the options used to create the mesh
  119433. * @param scene defines the hosting scene
  119434. * @returns the box mesh
  119435. */
  119436. static CreateBox(name: string, options: {
  119437. size?: number;
  119438. width?: number;
  119439. height?: number;
  119440. depth?: number;
  119441. faceUV?: Vector4[];
  119442. faceColors?: Color4[];
  119443. sideOrientation?: number;
  119444. frontUVs?: Vector4;
  119445. backUVs?: Vector4;
  119446. wrap?: boolean;
  119447. topBaseAt?: number;
  119448. bottomBaseAt?: number;
  119449. updatable?: boolean;
  119450. }, scene?: Nullable<Scene>): Mesh;
  119451. }
  119452. }
  119453. declare module BABYLON.Debug {
  119454. /**
  119455. * Used to show the physics impostor around the specific mesh
  119456. */
  119457. export class PhysicsViewer {
  119458. /** @hidden */
  119459. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119460. /** @hidden */
  119461. protected _meshes: Array<Nullable<AbstractMesh>>;
  119462. /** @hidden */
  119463. protected _scene: Nullable<Scene>;
  119464. /** @hidden */
  119465. protected _numMeshes: number;
  119466. /** @hidden */
  119467. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119468. private _renderFunction;
  119469. private _utilityLayer;
  119470. private _debugBoxMesh;
  119471. private _debugSphereMesh;
  119472. private _debugCylinderMesh;
  119473. private _debugMaterial;
  119474. private _debugMeshMeshes;
  119475. /**
  119476. * Creates a new PhysicsViewer
  119477. * @param scene defines the hosting scene
  119478. */
  119479. constructor(scene: Scene);
  119480. /** @hidden */
  119481. protected _updateDebugMeshes(): void;
  119482. /**
  119483. * Renders a specified physic impostor
  119484. * @param impostor defines the impostor to render
  119485. * @param targetMesh defines the mesh represented by the impostor
  119486. * @returns the new debug mesh used to render the impostor
  119487. */
  119488. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119489. /**
  119490. * Hides a specified physic impostor
  119491. * @param impostor defines the impostor to hide
  119492. */
  119493. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119494. private _getDebugMaterial;
  119495. private _getDebugBoxMesh;
  119496. private _getDebugSphereMesh;
  119497. private _getDebugCylinderMesh;
  119498. private _getDebugMeshMesh;
  119499. private _getDebugMesh;
  119500. /** Releases all resources */
  119501. dispose(): void;
  119502. }
  119503. }
  119504. declare module BABYLON {
  119505. /**
  119506. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119507. * in order to better appreciate the issue one might have.
  119508. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119509. */
  119510. export class RayHelper {
  119511. /**
  119512. * Defines the ray we are currently tryin to visualize.
  119513. */
  119514. ray: Nullable<Ray>;
  119515. private _renderPoints;
  119516. private _renderLine;
  119517. private _renderFunction;
  119518. private _scene;
  119519. private _updateToMeshFunction;
  119520. private _attachedToMesh;
  119521. private _meshSpaceDirection;
  119522. private _meshSpaceOrigin;
  119523. /**
  119524. * Helper function to create a colored helper in a scene in one line.
  119525. * @param ray Defines the ray we are currently tryin to visualize
  119526. * @param scene Defines the scene the ray is used in
  119527. * @param color Defines the color we want to see the ray in
  119528. * @returns The newly created ray helper.
  119529. */
  119530. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119531. /**
  119532. * Instantiate a new ray helper.
  119533. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119534. * in order to better appreciate the issue one might have.
  119535. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119536. * @param ray Defines the ray we are currently tryin to visualize
  119537. */
  119538. constructor(ray: Ray);
  119539. /**
  119540. * Shows the ray we are willing to debug.
  119541. * @param scene Defines the scene the ray needs to be rendered in
  119542. * @param color Defines the color the ray needs to be rendered in
  119543. */
  119544. show(scene: Scene, color?: Color3): void;
  119545. /**
  119546. * Hides the ray we are debugging.
  119547. */
  119548. hide(): void;
  119549. private _render;
  119550. /**
  119551. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119552. * @param mesh Defines the mesh we want the helper attached to
  119553. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119554. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119555. * @param length Defines the length of the ray
  119556. */
  119557. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119558. /**
  119559. * Detach the ray helper from the mesh it has previously been attached to.
  119560. */
  119561. detachFromMesh(): void;
  119562. private _updateToMesh;
  119563. /**
  119564. * Dispose the helper and release its associated resources.
  119565. */
  119566. dispose(): void;
  119567. }
  119568. }
  119569. declare module BABYLON.Debug {
  119570. /**
  119571. * Class used to render a debug view of a given skeleton
  119572. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119573. */
  119574. export class SkeletonViewer {
  119575. /** defines the skeleton to render */
  119576. skeleton: Skeleton;
  119577. /** defines the mesh attached to the skeleton */
  119578. mesh: AbstractMesh;
  119579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119580. autoUpdateBonesMatrices: boolean;
  119581. /** defines the rendering group id to use with the viewer */
  119582. renderingGroupId: number;
  119583. /** Gets or sets the color used to render the skeleton */
  119584. color: Color3;
  119585. private _scene;
  119586. private _debugLines;
  119587. private _debugMesh;
  119588. private _isEnabled;
  119589. private _renderFunction;
  119590. private _utilityLayer;
  119591. /**
  119592. * Returns the mesh used to render the bones
  119593. */
  119594. get debugMesh(): Nullable<LinesMesh>;
  119595. /**
  119596. * Creates a new SkeletonViewer
  119597. * @param skeleton defines the skeleton to render
  119598. * @param mesh defines the mesh attached to the skeleton
  119599. * @param scene defines the hosting scene
  119600. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119601. * @param renderingGroupId defines the rendering group id to use with the viewer
  119602. */
  119603. constructor(
  119604. /** defines the skeleton to render */
  119605. skeleton: Skeleton,
  119606. /** defines the mesh attached to the skeleton */
  119607. mesh: AbstractMesh, scene: Scene,
  119608. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119609. autoUpdateBonesMatrices?: boolean,
  119610. /** defines the rendering group id to use with the viewer */
  119611. renderingGroupId?: number);
  119612. /** Gets or sets a boolean indicating if the viewer is enabled */
  119613. set isEnabled(value: boolean);
  119614. get isEnabled(): boolean;
  119615. private _getBonePosition;
  119616. private _getLinesForBonesWithLength;
  119617. private _getLinesForBonesNoLength;
  119618. /** Update the viewer to sync with current skeleton state */
  119619. update(): void;
  119620. /** Release associated resources */
  119621. dispose(): void;
  119622. }
  119623. }
  119624. declare module BABYLON {
  119625. /**
  119626. * Options to create the null engine
  119627. */
  119628. export class NullEngineOptions {
  119629. /**
  119630. * Render width (Default: 512)
  119631. */
  119632. renderWidth: number;
  119633. /**
  119634. * Render height (Default: 256)
  119635. */
  119636. renderHeight: number;
  119637. /**
  119638. * Texture size (Default: 512)
  119639. */
  119640. textureSize: number;
  119641. /**
  119642. * If delta time between frames should be constant
  119643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119644. */
  119645. deterministicLockstep: boolean;
  119646. /**
  119647. * Maximum about of steps between frames (Default: 4)
  119648. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119649. */
  119650. lockstepMaxSteps: number;
  119651. }
  119652. /**
  119653. * The null engine class provides support for headless version of babylon.js.
  119654. * This can be used in server side scenario or for testing purposes
  119655. */
  119656. export class NullEngine extends Engine {
  119657. private _options;
  119658. /**
  119659. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119661. * @returns true if engine is in deterministic lock step mode
  119662. */
  119663. isDeterministicLockStep(): boolean;
  119664. /**
  119665. * Gets the max steps when engine is running in deterministic lock step
  119666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119667. * @returns the max steps
  119668. */
  119669. getLockstepMaxSteps(): number;
  119670. /**
  119671. * Gets the current hardware scaling level.
  119672. * By default the hardware scaling level is computed from the window device ratio.
  119673. * 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.
  119674. * @returns a number indicating the current hardware scaling level
  119675. */
  119676. getHardwareScalingLevel(): number;
  119677. constructor(options?: NullEngineOptions);
  119678. /**
  119679. * Creates a vertex buffer
  119680. * @param vertices the data for the vertex buffer
  119681. * @returns the new WebGL static buffer
  119682. */
  119683. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119684. /**
  119685. * Creates a new index buffer
  119686. * @param indices defines the content of the index buffer
  119687. * @param updatable defines if the index buffer must be updatable
  119688. * @returns a new webGL buffer
  119689. */
  119690. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119691. /**
  119692. * Clear the current render buffer or the current render target (if any is set up)
  119693. * @param color defines the color to use
  119694. * @param backBuffer defines if the back buffer must be cleared
  119695. * @param depth defines if the depth buffer must be cleared
  119696. * @param stencil defines if the stencil buffer must be cleared
  119697. */
  119698. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119699. /**
  119700. * Gets the current render width
  119701. * @param useScreen defines if screen size must be used (or the current render target if any)
  119702. * @returns a number defining the current render width
  119703. */
  119704. getRenderWidth(useScreen?: boolean): number;
  119705. /**
  119706. * Gets the current render height
  119707. * @param useScreen defines if screen size must be used (or the current render target if any)
  119708. * @returns a number defining the current render height
  119709. */
  119710. getRenderHeight(useScreen?: boolean): number;
  119711. /**
  119712. * Set the WebGL's viewport
  119713. * @param viewport defines the viewport element to be used
  119714. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119715. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119716. */
  119717. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119718. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119719. /**
  119720. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119721. * @param pipelineContext defines the pipeline context to use
  119722. * @param uniformsNames defines the list of uniform names
  119723. * @returns an array of webGL uniform locations
  119724. */
  119725. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119726. /**
  119727. * Gets the lsit of active attributes for a given webGL program
  119728. * @param pipelineContext defines the pipeline context to use
  119729. * @param attributesNames defines the list of attribute names to get
  119730. * @returns an array of indices indicating the offset of each attribute
  119731. */
  119732. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119733. /**
  119734. * Binds an effect to the webGL context
  119735. * @param effect defines the effect to bind
  119736. */
  119737. bindSamplers(effect: Effect): void;
  119738. /**
  119739. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119740. * @param effect defines the effect to activate
  119741. */
  119742. enableEffect(effect: Effect): void;
  119743. /**
  119744. * Set various states to the webGL context
  119745. * @param culling defines backface culling state
  119746. * @param zOffset defines the value to apply to zOffset (0 by default)
  119747. * @param force defines if states must be applied even if cache is up to date
  119748. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119749. */
  119750. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119751. /**
  119752. * Set the value of an uniform to an array of int32
  119753. * @param uniform defines the webGL uniform location where to store the value
  119754. * @param array defines the array of int32 to store
  119755. */
  119756. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119757. /**
  119758. * Set the value of an uniform to an array of int32 (stored as vec2)
  119759. * @param uniform defines the webGL uniform location where to store the value
  119760. * @param array defines the array of int32 to store
  119761. */
  119762. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119763. /**
  119764. * Set the value of an uniform to an array of int32 (stored as vec3)
  119765. * @param uniform defines the webGL uniform location where to store the value
  119766. * @param array defines the array of int32 to store
  119767. */
  119768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119769. /**
  119770. * Set the value of an uniform to an array of int32 (stored as vec4)
  119771. * @param uniform defines the webGL uniform location where to store the value
  119772. * @param array defines the array of int32 to store
  119773. */
  119774. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119775. /**
  119776. * Set the value of an uniform to an array of float32
  119777. * @param uniform defines the webGL uniform location where to store the value
  119778. * @param array defines the array of float32 to store
  119779. */
  119780. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119781. /**
  119782. * Set the value of an uniform to an array of float32 (stored as vec2)
  119783. * @param uniform defines the webGL uniform location where to store the value
  119784. * @param array defines the array of float32 to store
  119785. */
  119786. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119787. /**
  119788. * Set the value of an uniform to an array of float32 (stored as vec3)
  119789. * @param uniform defines the webGL uniform location where to store the value
  119790. * @param array defines the array of float32 to store
  119791. */
  119792. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119793. /**
  119794. * Set the value of an uniform to an array of float32 (stored as vec4)
  119795. * @param uniform defines the webGL uniform location where to store the value
  119796. * @param array defines the array of float32 to store
  119797. */
  119798. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119799. /**
  119800. * Set the value of an uniform to an array of number
  119801. * @param uniform defines the webGL uniform location where to store the value
  119802. * @param array defines the array of number to store
  119803. */
  119804. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119805. /**
  119806. * Set the value of an uniform to an array of number (stored as vec2)
  119807. * @param uniform defines the webGL uniform location where to store the value
  119808. * @param array defines the array of number to store
  119809. */
  119810. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119811. /**
  119812. * Set the value of an uniform to an array of number (stored as vec3)
  119813. * @param uniform defines the webGL uniform location where to store the value
  119814. * @param array defines the array of number to store
  119815. */
  119816. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119817. /**
  119818. * Set the value of an uniform to an array of number (stored as vec4)
  119819. * @param uniform defines the webGL uniform location where to store the value
  119820. * @param array defines the array of number to store
  119821. */
  119822. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119823. /**
  119824. * Set the value of an uniform to an array of float32 (stored as matrices)
  119825. * @param uniform defines the webGL uniform location where to store the value
  119826. * @param matrices defines the array of float32 to store
  119827. */
  119828. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119829. /**
  119830. * Set the value of an uniform to a matrix (3x3)
  119831. * @param uniform defines the webGL uniform location where to store the value
  119832. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119833. */
  119834. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119835. /**
  119836. * Set the value of an uniform to a matrix (2x2)
  119837. * @param uniform defines the webGL uniform location where to store the value
  119838. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119839. */
  119840. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119841. /**
  119842. * Set the value of an uniform to a number (float)
  119843. * @param uniform defines the webGL uniform location where to store the value
  119844. * @param value defines the float number to store
  119845. */
  119846. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119847. /**
  119848. * Set the value of an uniform to a vec2
  119849. * @param uniform defines the webGL uniform location where to store the value
  119850. * @param x defines the 1st component of the value
  119851. * @param y defines the 2nd component of the value
  119852. */
  119853. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119854. /**
  119855. * Set the value of an uniform to a vec3
  119856. * @param uniform defines the webGL uniform location where to store the value
  119857. * @param x defines the 1st component of the value
  119858. * @param y defines the 2nd component of the value
  119859. * @param z defines the 3rd component of the value
  119860. */
  119861. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119862. /**
  119863. * Set the value of an uniform to a boolean
  119864. * @param uniform defines the webGL uniform location where to store the value
  119865. * @param bool defines the boolean to store
  119866. */
  119867. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119868. /**
  119869. * Set the value of an uniform to a vec4
  119870. * @param uniform defines the webGL uniform location where to store the value
  119871. * @param x defines the 1st component of the value
  119872. * @param y defines the 2nd component of the value
  119873. * @param z defines the 3rd component of the value
  119874. * @param w defines the 4th component of the value
  119875. */
  119876. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119877. /**
  119878. * Sets the current alpha mode
  119879. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119880. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119882. */
  119883. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119884. /**
  119885. * Bind webGl buffers directly to the webGL context
  119886. * @param vertexBuffers defines the vertex buffer to bind
  119887. * @param indexBuffer defines the index buffer to bind
  119888. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119889. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119890. * @param effect defines the effect associated with the vertex buffer
  119891. */
  119892. bindBuffers(vertexBuffers: {
  119893. [key: string]: VertexBuffer;
  119894. }, indexBuffer: DataBuffer, effect: Effect): void;
  119895. /**
  119896. * Force the entire cache to be cleared
  119897. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119898. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119899. */
  119900. wipeCaches(bruteForce?: boolean): void;
  119901. /**
  119902. * Send a draw order
  119903. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119904. * @param indexStart defines the starting index
  119905. * @param indexCount defines the number of index to draw
  119906. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119907. */
  119908. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119909. /**
  119910. * Draw a list of indexed primitives
  119911. * @param fillMode defines the primitive to use
  119912. * @param indexStart defines the starting index
  119913. * @param indexCount defines the number of index to draw
  119914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119915. */
  119916. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119917. /**
  119918. * Draw a list of unindexed primitives
  119919. * @param fillMode defines the primitive to use
  119920. * @param verticesStart defines the index of first vertex to draw
  119921. * @param verticesCount defines the count of vertices to draw
  119922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119923. */
  119924. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119925. /** @hidden */
  119926. _createTexture(): WebGLTexture;
  119927. /** @hidden */
  119928. _releaseTexture(texture: InternalTexture): void;
  119929. /**
  119930. * Usually called from Texture.ts.
  119931. * Passed information to create a WebGLTexture
  119932. * @param urlArg defines a value which contains one of the following:
  119933. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119934. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119935. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119937. * @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)
  119938. * @param scene needed for loading to the correct scene
  119939. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119940. * @param onLoad optional callback to be called upon successful completion
  119941. * @param onError optional callback to be called upon failure
  119942. * @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
  119943. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119944. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119945. * @param forcedExtension defines the extension to use to pick the right loader
  119946. * @param mimeType defines an optional mime type
  119947. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119948. */
  119949. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  119950. /**
  119951. * Creates a new render target texture
  119952. * @param size defines the size of the texture
  119953. * @param options defines the options used to create the texture
  119954. * @returns a new render target texture stored in an InternalTexture
  119955. */
  119956. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119957. /**
  119958. * Update the sampling mode of a given texture
  119959. * @param samplingMode defines the required sampling mode
  119960. * @param texture defines the texture to update
  119961. */
  119962. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119963. /**
  119964. * Binds the frame buffer to the specified texture.
  119965. * @param texture The texture to render to or null for the default canvas
  119966. * @param faceIndex The face of the texture to render to in case of cube texture
  119967. * @param requiredWidth The width of the target to render to
  119968. * @param requiredHeight The height of the target to render to
  119969. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119970. * @param lodLevel defines le lod level to bind to the frame buffer
  119971. */
  119972. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119973. /**
  119974. * Unbind the current render target texture from the webGL context
  119975. * @param texture defines the render target texture to unbind
  119976. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119977. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119978. */
  119979. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119980. /**
  119981. * Creates a dynamic vertex buffer
  119982. * @param vertices the data for the dynamic vertex buffer
  119983. * @returns the new WebGL dynamic buffer
  119984. */
  119985. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119986. /**
  119987. * Update the content of a dynamic texture
  119988. * @param texture defines the texture to update
  119989. * @param canvas defines the canvas containing the source
  119990. * @param invertY defines if data must be stored with Y axis inverted
  119991. * @param premulAlpha defines if alpha is stored as premultiplied
  119992. * @param format defines the format of the data
  119993. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119994. */
  119995. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119996. /**
  119997. * Gets a boolean indicating if all created effects are ready
  119998. * @returns true if all effects are ready
  119999. */
  120000. areAllEffectsReady(): boolean;
  120001. /**
  120002. * @hidden
  120003. * Get the current error code of the webGL context
  120004. * @returns the error code
  120005. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120006. */
  120007. getError(): number;
  120008. /** @hidden */
  120009. _getUnpackAlignement(): number;
  120010. /** @hidden */
  120011. _unpackFlipY(value: boolean): void;
  120012. /**
  120013. * Update a dynamic index buffer
  120014. * @param indexBuffer defines the target index buffer
  120015. * @param indices defines the data to update
  120016. * @param offset defines the offset in the target index buffer where update should start
  120017. */
  120018. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120019. /**
  120020. * Updates a dynamic vertex buffer.
  120021. * @param vertexBuffer the vertex buffer to update
  120022. * @param vertices the data used to update the vertex buffer
  120023. * @param byteOffset the byte offset of the data (optional)
  120024. * @param byteLength the byte length of the data (optional)
  120025. */
  120026. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120027. /** @hidden */
  120028. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120029. /** @hidden */
  120030. _bindTexture(channel: number, texture: InternalTexture): void;
  120031. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120032. /**
  120033. * 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
  120034. */
  120035. releaseEffects(): void;
  120036. displayLoadingUI(): void;
  120037. hideLoadingUI(): void;
  120038. /** @hidden */
  120039. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120040. /** @hidden */
  120041. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120042. /** @hidden */
  120043. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120044. /** @hidden */
  120045. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120046. }
  120047. }
  120048. declare module BABYLON {
  120049. /**
  120050. * @hidden
  120051. **/
  120052. export class _TimeToken {
  120053. _startTimeQuery: Nullable<WebGLQuery>;
  120054. _endTimeQuery: Nullable<WebGLQuery>;
  120055. _timeElapsedQuery: Nullable<WebGLQuery>;
  120056. _timeElapsedQueryEnded: boolean;
  120057. }
  120058. }
  120059. declare module BABYLON {
  120060. /** @hidden */
  120061. export class _OcclusionDataStorage {
  120062. /** @hidden */
  120063. occlusionInternalRetryCounter: number;
  120064. /** @hidden */
  120065. isOcclusionQueryInProgress: boolean;
  120066. /** @hidden */
  120067. isOccluded: boolean;
  120068. /** @hidden */
  120069. occlusionRetryCount: number;
  120070. /** @hidden */
  120071. occlusionType: number;
  120072. /** @hidden */
  120073. occlusionQueryAlgorithmType: number;
  120074. }
  120075. interface Engine {
  120076. /**
  120077. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120078. * @return the new query
  120079. */
  120080. createQuery(): WebGLQuery;
  120081. /**
  120082. * Delete and release a webGL query
  120083. * @param query defines the query to delete
  120084. * @return the current engine
  120085. */
  120086. deleteQuery(query: WebGLQuery): Engine;
  120087. /**
  120088. * Check if a given query has resolved and got its value
  120089. * @param query defines the query to check
  120090. * @returns true if the query got its value
  120091. */
  120092. isQueryResultAvailable(query: WebGLQuery): boolean;
  120093. /**
  120094. * Gets the value of a given query
  120095. * @param query defines the query to check
  120096. * @returns the value of the query
  120097. */
  120098. getQueryResult(query: WebGLQuery): number;
  120099. /**
  120100. * Initiates an occlusion query
  120101. * @param algorithmType defines the algorithm to use
  120102. * @param query defines the query to use
  120103. * @returns the current engine
  120104. * @see http://doc.babylonjs.com/features/occlusionquery
  120105. */
  120106. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120107. /**
  120108. * Ends an occlusion query
  120109. * @see http://doc.babylonjs.com/features/occlusionquery
  120110. * @param algorithmType defines the algorithm to use
  120111. * @returns the current engine
  120112. */
  120113. endOcclusionQuery(algorithmType: number): Engine;
  120114. /**
  120115. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120116. * Please note that only one query can be issued at a time
  120117. * @returns a time token used to track the time span
  120118. */
  120119. startTimeQuery(): Nullable<_TimeToken>;
  120120. /**
  120121. * Ends a time query
  120122. * @param token defines the token used to measure the time span
  120123. * @returns the time spent (in ns)
  120124. */
  120125. endTimeQuery(token: _TimeToken): int;
  120126. /** @hidden */
  120127. _currentNonTimestampToken: Nullable<_TimeToken>;
  120128. /** @hidden */
  120129. _createTimeQuery(): WebGLQuery;
  120130. /** @hidden */
  120131. _deleteTimeQuery(query: WebGLQuery): void;
  120132. /** @hidden */
  120133. _getGlAlgorithmType(algorithmType: number): number;
  120134. /** @hidden */
  120135. _getTimeQueryResult(query: WebGLQuery): any;
  120136. /** @hidden */
  120137. _getTimeQueryAvailability(query: WebGLQuery): any;
  120138. }
  120139. interface AbstractMesh {
  120140. /**
  120141. * Backing filed
  120142. * @hidden
  120143. */
  120144. __occlusionDataStorage: _OcclusionDataStorage;
  120145. /**
  120146. * Access property
  120147. * @hidden
  120148. */
  120149. _occlusionDataStorage: _OcclusionDataStorage;
  120150. /**
  120151. * 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.
  120152. * The default value is -1 which means don't break the query and wait till the result
  120153. * @see http://doc.babylonjs.com/features/occlusionquery
  120154. */
  120155. occlusionRetryCount: number;
  120156. /**
  120157. * 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:
  120158. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120159. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120160. * * 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.
  120161. * @see http://doc.babylonjs.com/features/occlusionquery
  120162. */
  120163. occlusionType: number;
  120164. /**
  120165. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120166. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120167. * * 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.
  120168. * @see http://doc.babylonjs.com/features/occlusionquery
  120169. */
  120170. occlusionQueryAlgorithmType: number;
  120171. /**
  120172. * 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
  120173. * @see http://doc.babylonjs.com/features/occlusionquery
  120174. */
  120175. isOccluded: boolean;
  120176. /**
  120177. * Flag to check the progress status of the query
  120178. * @see http://doc.babylonjs.com/features/occlusionquery
  120179. */
  120180. isOcclusionQueryInProgress: boolean;
  120181. }
  120182. }
  120183. declare module BABYLON {
  120184. /** @hidden */
  120185. export var _forceTransformFeedbackToBundle: boolean;
  120186. interface Engine {
  120187. /**
  120188. * Creates a webGL transform feedback object
  120189. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120190. * @returns the webGL transform feedback object
  120191. */
  120192. createTransformFeedback(): WebGLTransformFeedback;
  120193. /**
  120194. * Delete a webGL transform feedback object
  120195. * @param value defines the webGL transform feedback object to delete
  120196. */
  120197. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120198. /**
  120199. * Bind a webGL transform feedback object to the webgl context
  120200. * @param value defines the webGL transform feedback object to bind
  120201. */
  120202. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120203. /**
  120204. * Begins a transform feedback operation
  120205. * @param usePoints defines if points or triangles must be used
  120206. */
  120207. beginTransformFeedback(usePoints: boolean): void;
  120208. /**
  120209. * Ends a transform feedback operation
  120210. */
  120211. endTransformFeedback(): void;
  120212. /**
  120213. * Specify the varyings to use with transform feedback
  120214. * @param program defines the associated webGL program
  120215. * @param value defines the list of strings representing the varying names
  120216. */
  120217. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120218. /**
  120219. * Bind a webGL buffer for a transform feedback operation
  120220. * @param value defines the webGL buffer to bind
  120221. */
  120222. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120223. }
  120224. }
  120225. declare module BABYLON {
  120226. /**
  120227. * Creation options of the multi render target texture.
  120228. */
  120229. export interface IMultiRenderTargetOptions {
  120230. /**
  120231. * Define if the texture needs to create mip maps after render.
  120232. */
  120233. generateMipMaps?: boolean;
  120234. /**
  120235. * Define the types of all the draw buffers we want to create
  120236. */
  120237. types?: number[];
  120238. /**
  120239. * Define the sampling modes of all the draw buffers we want to create
  120240. */
  120241. samplingModes?: number[];
  120242. /**
  120243. * Define if a depth buffer is required
  120244. */
  120245. generateDepthBuffer?: boolean;
  120246. /**
  120247. * Define if a stencil buffer is required
  120248. */
  120249. generateStencilBuffer?: boolean;
  120250. /**
  120251. * Define if a depth texture is required instead of a depth buffer
  120252. */
  120253. generateDepthTexture?: boolean;
  120254. /**
  120255. * Define the number of desired draw buffers
  120256. */
  120257. textureCount?: number;
  120258. /**
  120259. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120260. */
  120261. doNotChangeAspectRatio?: boolean;
  120262. /**
  120263. * Define the default type of the buffers we are creating
  120264. */
  120265. defaultType?: number;
  120266. }
  120267. /**
  120268. * A multi render target, like a render target provides the ability to render to a texture.
  120269. * Unlike the render target, it can render to several draw buffers in one draw.
  120270. * This is specially interesting in deferred rendering or for any effects requiring more than
  120271. * just one color from a single pass.
  120272. */
  120273. export class MultiRenderTarget extends RenderTargetTexture {
  120274. private _internalTextures;
  120275. private _textures;
  120276. private _multiRenderTargetOptions;
  120277. /**
  120278. * Get if draw buffers are currently supported by the used hardware and browser.
  120279. */
  120280. get isSupported(): boolean;
  120281. /**
  120282. * Get the list of textures generated by the multi render target.
  120283. */
  120284. get textures(): Texture[];
  120285. /**
  120286. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120287. */
  120288. get depthTexture(): Texture;
  120289. /**
  120290. * Set the wrapping mode on U of all the textures we are rendering to.
  120291. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120292. */
  120293. set wrapU(wrap: number);
  120294. /**
  120295. * Set the wrapping mode on V of all the textures we are rendering to.
  120296. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120297. */
  120298. set wrapV(wrap: number);
  120299. /**
  120300. * Instantiate a new multi render target texture.
  120301. * A multi render target, like a render target provides the ability to render to a texture.
  120302. * Unlike the render target, it can render to several draw buffers in one draw.
  120303. * This is specially interesting in deferred rendering or for any effects requiring more than
  120304. * just one color from a single pass.
  120305. * @param name Define the name of the texture
  120306. * @param size Define the size of the buffers to render to
  120307. * @param count Define the number of target we are rendering into
  120308. * @param scene Define the scene the texture belongs to
  120309. * @param options Define the options used to create the multi render target
  120310. */
  120311. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120312. /** @hidden */
  120313. _rebuild(): void;
  120314. private _createInternalTextures;
  120315. private _createTextures;
  120316. /**
  120317. * Define the number of samples used if MSAA is enabled.
  120318. */
  120319. get samples(): number;
  120320. set samples(value: number);
  120321. /**
  120322. * Resize all the textures in the multi render target.
  120323. * Be carrefull as it will recreate all the data in the new texture.
  120324. * @param size Define the new size
  120325. */
  120326. resize(size: any): void;
  120327. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120328. /**
  120329. * Dispose the render targets and their associated resources
  120330. */
  120331. dispose(): void;
  120332. /**
  120333. * Release all the underlying texture used as draw buffers.
  120334. */
  120335. releaseInternalTextures(): void;
  120336. }
  120337. }
  120338. declare module BABYLON {
  120339. interface ThinEngine {
  120340. /**
  120341. * Unbind a list of render target textures from the webGL context
  120342. * This is used only when drawBuffer extension or webGL2 are active
  120343. * @param textures defines the render target textures to unbind
  120344. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120345. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120346. */
  120347. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120348. /**
  120349. * Create a multi render target texture
  120350. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120351. * @param size defines the size of the texture
  120352. * @param options defines the creation options
  120353. * @returns the cube texture as an InternalTexture
  120354. */
  120355. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120356. /**
  120357. * Update the sample count for a given multiple render target texture
  120358. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120359. * @param textures defines the textures to update
  120360. * @param samples defines the sample count to set
  120361. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120362. */
  120363. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120364. }
  120365. }
  120366. declare module BABYLON {
  120367. /**
  120368. * Class used to define an additional view for the engine
  120369. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120370. */
  120371. export class EngineView {
  120372. /** Defines the canvas where to render the view */
  120373. target: HTMLCanvasElement;
  120374. /** Defines an optional camera used to render the view (will use active camera else) */
  120375. camera?: Camera;
  120376. }
  120377. interface Engine {
  120378. /**
  120379. * Gets or sets the HTML element to use for attaching events
  120380. */
  120381. inputElement: Nullable<HTMLElement>;
  120382. /**
  120383. * Gets the current engine view
  120384. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120385. */
  120386. activeView: Nullable<EngineView>;
  120387. /** Gets or sets the list of views */
  120388. views: EngineView[];
  120389. /**
  120390. * Register a new child canvas
  120391. * @param canvas defines the canvas to register
  120392. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120393. * @returns the associated view
  120394. */
  120395. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120396. /**
  120397. * Remove a registered child canvas
  120398. * @param canvas defines the canvas to remove
  120399. * @returns the current engine
  120400. */
  120401. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120402. }
  120403. }
  120404. declare module BABYLON {
  120405. /**
  120406. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120407. */
  120408. export interface CubeMapInfo {
  120409. /**
  120410. * The pixel array for the front face.
  120411. * This is stored in format, left to right, up to down format.
  120412. */
  120413. front: Nullable<ArrayBufferView>;
  120414. /**
  120415. * The pixel array for the back face.
  120416. * This is stored in format, left to right, up to down format.
  120417. */
  120418. back: Nullable<ArrayBufferView>;
  120419. /**
  120420. * The pixel array for the left face.
  120421. * This is stored in format, left to right, up to down format.
  120422. */
  120423. left: Nullable<ArrayBufferView>;
  120424. /**
  120425. * The pixel array for the right face.
  120426. * This is stored in format, left to right, up to down format.
  120427. */
  120428. right: Nullable<ArrayBufferView>;
  120429. /**
  120430. * The pixel array for the up face.
  120431. * This is stored in format, left to right, up to down format.
  120432. */
  120433. up: Nullable<ArrayBufferView>;
  120434. /**
  120435. * The pixel array for the down face.
  120436. * This is stored in format, left to right, up to down format.
  120437. */
  120438. down: Nullable<ArrayBufferView>;
  120439. /**
  120440. * The size of the cubemap stored.
  120441. *
  120442. * Each faces will be size * size pixels.
  120443. */
  120444. size: number;
  120445. /**
  120446. * The format of the texture.
  120447. *
  120448. * RGBA, RGB.
  120449. */
  120450. format: number;
  120451. /**
  120452. * The type of the texture data.
  120453. *
  120454. * UNSIGNED_INT, FLOAT.
  120455. */
  120456. type: number;
  120457. /**
  120458. * Specifies whether the texture is in gamma space.
  120459. */
  120460. gammaSpace: boolean;
  120461. }
  120462. /**
  120463. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120464. */
  120465. export class PanoramaToCubeMapTools {
  120466. private static FACE_FRONT;
  120467. private static FACE_BACK;
  120468. private static FACE_RIGHT;
  120469. private static FACE_LEFT;
  120470. private static FACE_DOWN;
  120471. private static FACE_UP;
  120472. /**
  120473. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120474. *
  120475. * @param float32Array The source data.
  120476. * @param inputWidth The width of the input panorama.
  120477. * @param inputHeight The height of the input panorama.
  120478. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120479. * @return The cubemap data
  120480. */
  120481. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120482. private static CreateCubemapTexture;
  120483. private static CalcProjectionSpherical;
  120484. }
  120485. }
  120486. declare module BABYLON {
  120487. /**
  120488. * Helper class dealing with the extraction of spherical polynomial dataArray
  120489. * from a cube map.
  120490. */
  120491. export class CubeMapToSphericalPolynomialTools {
  120492. private static FileFaces;
  120493. /**
  120494. * Converts a texture to the according Spherical Polynomial data.
  120495. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120496. *
  120497. * @param texture The texture to extract the information from.
  120498. * @return The Spherical Polynomial data.
  120499. */
  120500. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120501. /**
  120502. * Converts a cubemap to the according Spherical Polynomial data.
  120503. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120504. *
  120505. * @param cubeInfo The Cube map to extract the information from.
  120506. * @return The Spherical Polynomial data.
  120507. */
  120508. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120509. }
  120510. }
  120511. declare module BABYLON {
  120512. interface BaseTexture {
  120513. /**
  120514. * Get the polynomial representation of the texture data.
  120515. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120516. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120517. */
  120518. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120519. }
  120520. }
  120521. declare module BABYLON {
  120522. /** @hidden */
  120523. export var rgbdEncodePixelShader: {
  120524. name: string;
  120525. shader: string;
  120526. };
  120527. }
  120528. declare module BABYLON {
  120529. /** @hidden */
  120530. export var rgbdDecodePixelShader: {
  120531. name: string;
  120532. shader: string;
  120533. };
  120534. }
  120535. declare module BABYLON {
  120536. /**
  120537. * Raw texture data and descriptor sufficient for WebGL texture upload
  120538. */
  120539. export interface EnvironmentTextureInfo {
  120540. /**
  120541. * Version of the environment map
  120542. */
  120543. version: number;
  120544. /**
  120545. * Width of image
  120546. */
  120547. width: number;
  120548. /**
  120549. * Irradiance information stored in the file.
  120550. */
  120551. irradiance: any;
  120552. /**
  120553. * Specular information stored in the file.
  120554. */
  120555. specular: any;
  120556. }
  120557. /**
  120558. * Defines One Image in the file. It requires only the position in the file
  120559. * as well as the length.
  120560. */
  120561. interface BufferImageData {
  120562. /**
  120563. * Length of the image data.
  120564. */
  120565. length: number;
  120566. /**
  120567. * Position of the data from the null terminator delimiting the end of the JSON.
  120568. */
  120569. position: number;
  120570. }
  120571. /**
  120572. * Defines the specular data enclosed in the file.
  120573. * This corresponds to the version 1 of the data.
  120574. */
  120575. export interface EnvironmentTextureSpecularInfoV1 {
  120576. /**
  120577. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120578. */
  120579. specularDataPosition?: number;
  120580. /**
  120581. * This contains all the images data needed to reconstruct the cubemap.
  120582. */
  120583. mipmaps: Array<BufferImageData>;
  120584. /**
  120585. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120586. */
  120587. lodGenerationScale: number;
  120588. }
  120589. /**
  120590. * Sets of helpers addressing the serialization and deserialization of environment texture
  120591. * stored in a BabylonJS env file.
  120592. * Those files are usually stored as .env files.
  120593. */
  120594. export class EnvironmentTextureTools {
  120595. /**
  120596. * Magic number identifying the env file.
  120597. */
  120598. private static _MagicBytes;
  120599. /**
  120600. * Gets the environment info from an env file.
  120601. * @param data The array buffer containing the .env bytes.
  120602. * @returns the environment file info (the json header) if successfully parsed.
  120603. */
  120604. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120605. /**
  120606. * Creates an environment texture from a loaded cube texture.
  120607. * @param texture defines the cube texture to convert in env file
  120608. * @return a promise containing the environment data if succesfull.
  120609. */
  120610. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120611. /**
  120612. * Creates a JSON representation of the spherical data.
  120613. * @param texture defines the texture containing the polynomials
  120614. * @return the JSON representation of the spherical info
  120615. */
  120616. private static _CreateEnvTextureIrradiance;
  120617. /**
  120618. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120619. * @param data the image data
  120620. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120621. * @return the views described by info providing access to the underlying buffer
  120622. */
  120623. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120624. /**
  120625. * Uploads the texture info contained in the env file to the GPU.
  120626. * @param texture defines the internal texture to upload to
  120627. * @param data defines the data to load
  120628. * @param info defines the texture info retrieved through the GetEnvInfo method
  120629. * @returns a promise
  120630. */
  120631. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120632. private static _OnImageReadyAsync;
  120633. /**
  120634. * Uploads the levels of image data to the GPU.
  120635. * @param texture defines the internal texture to upload to
  120636. * @param imageData defines the array buffer views of image data [mipmap][face]
  120637. * @returns a promise
  120638. */
  120639. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120640. /**
  120641. * Uploads spherical polynomials information to the texture.
  120642. * @param texture defines the texture we are trying to upload the information to
  120643. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120644. */
  120645. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120646. /** @hidden */
  120647. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120648. }
  120649. }
  120650. declare module BABYLON {
  120651. /**
  120652. * Contains position and normal vectors for a vertex
  120653. */
  120654. export class PositionNormalVertex {
  120655. /** the position of the vertex (defaut: 0,0,0) */
  120656. position: Vector3;
  120657. /** the normal of the vertex (defaut: 0,1,0) */
  120658. normal: Vector3;
  120659. /**
  120660. * Creates a PositionNormalVertex
  120661. * @param position the position of the vertex (defaut: 0,0,0)
  120662. * @param normal the normal of the vertex (defaut: 0,1,0)
  120663. */
  120664. constructor(
  120665. /** the position of the vertex (defaut: 0,0,0) */
  120666. position?: Vector3,
  120667. /** the normal of the vertex (defaut: 0,1,0) */
  120668. normal?: Vector3);
  120669. /**
  120670. * Clones the PositionNormalVertex
  120671. * @returns the cloned PositionNormalVertex
  120672. */
  120673. clone(): PositionNormalVertex;
  120674. }
  120675. /**
  120676. * Contains position, normal and uv vectors for a vertex
  120677. */
  120678. export class PositionNormalTextureVertex {
  120679. /** the position of the vertex (defaut: 0,0,0) */
  120680. position: Vector3;
  120681. /** the normal of the vertex (defaut: 0,1,0) */
  120682. normal: Vector3;
  120683. /** the uv of the vertex (default: 0,0) */
  120684. uv: Vector2;
  120685. /**
  120686. * Creates a PositionNormalTextureVertex
  120687. * @param position the position of the vertex (defaut: 0,0,0)
  120688. * @param normal the normal of the vertex (defaut: 0,1,0)
  120689. * @param uv the uv of the vertex (default: 0,0)
  120690. */
  120691. constructor(
  120692. /** the position of the vertex (defaut: 0,0,0) */
  120693. position?: Vector3,
  120694. /** the normal of the vertex (defaut: 0,1,0) */
  120695. normal?: Vector3,
  120696. /** the uv of the vertex (default: 0,0) */
  120697. uv?: Vector2);
  120698. /**
  120699. * Clones the PositionNormalTextureVertex
  120700. * @returns the cloned PositionNormalTextureVertex
  120701. */
  120702. clone(): PositionNormalTextureVertex;
  120703. }
  120704. }
  120705. declare module BABYLON {
  120706. /** @hidden */
  120707. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120708. private _genericAttributeLocation;
  120709. private _varyingLocationCount;
  120710. private _varyingLocationMap;
  120711. private _replacements;
  120712. private _textureCount;
  120713. private _uniforms;
  120714. lineProcessor(line: string): string;
  120715. attributeProcessor(attribute: string): string;
  120716. varyingProcessor(varying: string, isFragment: boolean): string;
  120717. uniformProcessor(uniform: string): string;
  120718. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120719. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120720. }
  120721. }
  120722. declare module BABYLON {
  120723. /**
  120724. * Container for accessors for natively-stored mesh data buffers.
  120725. */
  120726. class NativeDataBuffer extends DataBuffer {
  120727. /**
  120728. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120729. */
  120730. nativeIndexBuffer?: any;
  120731. /**
  120732. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120733. */
  120734. nativeVertexBuffer?: any;
  120735. }
  120736. /** @hidden */
  120737. class NativeTexture extends InternalTexture {
  120738. getInternalTexture(): InternalTexture;
  120739. getViewCount(): number;
  120740. }
  120741. /** @hidden */
  120742. export class NativeEngine extends Engine {
  120743. private readonly _native;
  120744. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120745. private readonly INVALID_HANDLE;
  120746. getHardwareScalingLevel(): number;
  120747. constructor();
  120748. /**
  120749. * Can be used to override the current requestAnimationFrame requester.
  120750. * @hidden
  120751. */
  120752. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120753. /**
  120754. * Override default engine behavior.
  120755. * @param color
  120756. * @param backBuffer
  120757. * @param depth
  120758. * @param stencil
  120759. */
  120760. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120761. /**
  120762. * Gets host document
  120763. * @returns the host document object
  120764. */
  120765. getHostDocument(): Nullable<Document>;
  120766. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120767. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120768. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120769. recordVertexArrayObject(vertexBuffers: {
  120770. [key: string]: VertexBuffer;
  120771. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120772. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120773. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120774. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120775. /**
  120776. * Draw a list of indexed primitives
  120777. * @param fillMode defines the primitive to use
  120778. * @param indexStart defines the starting index
  120779. * @param indexCount defines the number of index to draw
  120780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120781. */
  120782. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120783. /**
  120784. * Draw a list of unindexed primitives
  120785. * @param fillMode defines the primitive to use
  120786. * @param verticesStart defines the index of first vertex to draw
  120787. * @param verticesCount defines the count of vertices to draw
  120788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120789. */
  120790. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120791. createPipelineContext(): IPipelineContext;
  120792. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120793. /** @hidden */
  120794. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120795. /** @hidden */
  120796. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120797. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120798. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120799. protected _setProgram(program: WebGLProgram): void;
  120800. _releaseEffect(effect: Effect): void;
  120801. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120802. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120803. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120804. bindSamplers(effect: Effect): void;
  120805. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120806. getRenderWidth(useScreen?: boolean): number;
  120807. getRenderHeight(useScreen?: boolean): number;
  120808. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120809. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120810. /**
  120811. * Set the z offset to apply to current rendering
  120812. * @param value defines the offset to apply
  120813. */
  120814. setZOffset(value: number): void;
  120815. /**
  120816. * Gets the current value of the zOffset
  120817. * @returns the current zOffset state
  120818. */
  120819. getZOffset(): number;
  120820. /**
  120821. * Enable or disable depth buffering
  120822. * @param enable defines the state to set
  120823. */
  120824. setDepthBuffer(enable: boolean): void;
  120825. /**
  120826. * Gets a boolean indicating if depth writing is enabled
  120827. * @returns the current depth writing state
  120828. */
  120829. getDepthWrite(): boolean;
  120830. /**
  120831. * Enable or disable depth writing
  120832. * @param enable defines the state to set
  120833. */
  120834. setDepthWrite(enable: boolean): void;
  120835. /**
  120836. * Enable or disable color writing
  120837. * @param enable defines the state to set
  120838. */
  120839. setColorWrite(enable: boolean): void;
  120840. /**
  120841. * Gets a boolean indicating if color writing is enabled
  120842. * @returns the current color writing state
  120843. */
  120844. getColorWrite(): boolean;
  120845. /**
  120846. * Sets alpha constants used by some alpha blending modes
  120847. * @param r defines the red component
  120848. * @param g defines the green component
  120849. * @param b defines the blue component
  120850. * @param a defines the alpha component
  120851. */
  120852. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120853. /**
  120854. * Sets the current alpha mode
  120855. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120856. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120857. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120858. */
  120859. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120860. /**
  120861. * Gets the current alpha mode
  120862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120863. * @returns the current alpha mode
  120864. */
  120865. getAlphaMode(): number;
  120866. setInt(uniform: WebGLUniformLocation, int: number): void;
  120867. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120868. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120869. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120870. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120871. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120872. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120873. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120874. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120875. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120876. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120877. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120878. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120879. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120880. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120881. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120882. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120883. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120884. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120885. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120886. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120887. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120888. wipeCaches(bruteForce?: boolean): void;
  120889. _createTexture(): WebGLTexture;
  120890. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120891. /**
  120892. * Usually called from Texture.ts.
  120893. * Passed information to create a WebGLTexture
  120894. * @param urlArg defines a value which contains one of the following:
  120895. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120896. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120897. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120898. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120899. * @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)
  120900. * @param scene needed for loading to the correct scene
  120901. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120902. * @param onLoad optional callback to be called upon successful completion
  120903. * @param onError optional callback to be called upon failure
  120904. * @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
  120905. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120906. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120907. * @param forcedExtension defines the extension to use to pick the right loader
  120908. * @param mimeType defines an optional mime type
  120909. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120910. */
  120911. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  120912. /**
  120913. * Creates a cube texture
  120914. * @param rootUrl defines the url where the files to load is located
  120915. * @param scene defines the current scene
  120916. * @param files defines the list of files to load (1 per face)
  120917. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120918. * @param onLoad defines an optional callback raised when the texture is loaded
  120919. * @param onError defines an optional callback raised if there is an issue to load the texture
  120920. * @param format defines the format of the data
  120921. * @param forcedExtension defines the extension to use to pick the right loader
  120922. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120923. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120924. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120925. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120926. * @returns the cube texture as an InternalTexture
  120927. */
  120928. 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;
  120929. private _getSamplingFilter;
  120930. private static _GetNativeTextureFormat;
  120931. createRenderTargetTexture(size: number | {
  120932. width: number;
  120933. height: number;
  120934. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120935. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120936. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120937. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120938. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120939. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120940. /**
  120941. * Updates a dynamic vertex buffer.
  120942. * @param vertexBuffer the vertex buffer to update
  120943. * @param data the data used to update the vertex buffer
  120944. * @param byteOffset the byte offset of the data (optional)
  120945. * @param byteLength the byte length of the data (optional)
  120946. */
  120947. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120948. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120949. private _updateAnisotropicLevel;
  120950. private _getAddressMode;
  120951. /** @hidden */
  120952. _bindTexture(channel: number, texture: InternalTexture): void;
  120953. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120954. releaseEffects(): void;
  120955. /** @hidden */
  120956. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120957. /** @hidden */
  120958. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120959. /** @hidden */
  120960. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120961. /** @hidden */
  120962. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120963. }
  120964. }
  120965. declare module BABYLON {
  120966. /**
  120967. * Gather the list of clipboard event types as constants.
  120968. */
  120969. export class ClipboardEventTypes {
  120970. /**
  120971. * The clipboard event is fired when a copy command is active (pressed).
  120972. */
  120973. static readonly COPY: number;
  120974. /**
  120975. * The clipboard event is fired when a cut command is active (pressed).
  120976. */
  120977. static readonly CUT: number;
  120978. /**
  120979. * The clipboard event is fired when a paste command is active (pressed).
  120980. */
  120981. static readonly PASTE: number;
  120982. }
  120983. /**
  120984. * This class is used to store clipboard related info for the onClipboardObservable event.
  120985. */
  120986. export class ClipboardInfo {
  120987. /**
  120988. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120989. */
  120990. type: number;
  120991. /**
  120992. * Defines the related dom event
  120993. */
  120994. event: ClipboardEvent;
  120995. /**
  120996. *Creates an instance of ClipboardInfo.
  120997. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120998. * @param event Defines the related dom event
  120999. */
  121000. constructor(
  121001. /**
  121002. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121003. */
  121004. type: number,
  121005. /**
  121006. * Defines the related dom event
  121007. */
  121008. event: ClipboardEvent);
  121009. /**
  121010. * Get the clipboard event's type from the keycode.
  121011. * @param keyCode Defines the keyCode for the current keyboard event.
  121012. * @return {number}
  121013. */
  121014. static GetTypeFromCharacter(keyCode: number): number;
  121015. }
  121016. }
  121017. declare module BABYLON {
  121018. /**
  121019. * Google Daydream controller
  121020. */
  121021. export class DaydreamController extends WebVRController {
  121022. /**
  121023. * Base Url for the controller model.
  121024. */
  121025. static MODEL_BASE_URL: string;
  121026. /**
  121027. * File name for the controller model.
  121028. */
  121029. static MODEL_FILENAME: string;
  121030. /**
  121031. * Gamepad Id prefix used to identify Daydream Controller.
  121032. */
  121033. static readonly GAMEPAD_ID_PREFIX: string;
  121034. /**
  121035. * Creates a new DaydreamController from a gamepad
  121036. * @param vrGamepad the gamepad that the controller should be created from
  121037. */
  121038. constructor(vrGamepad: any);
  121039. /**
  121040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121041. * @param scene scene in which to add meshes
  121042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121043. */
  121044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121045. /**
  121046. * Called once for each button that changed state since the last frame
  121047. * @param buttonIdx Which button index changed
  121048. * @param state New state of the button
  121049. * @param changes Which properties on the state changed since last frame
  121050. */
  121051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121052. }
  121053. }
  121054. declare module BABYLON {
  121055. /**
  121056. * Gear VR Controller
  121057. */
  121058. export class GearVRController extends WebVRController {
  121059. /**
  121060. * Base Url for the controller model.
  121061. */
  121062. static MODEL_BASE_URL: string;
  121063. /**
  121064. * File name for the controller model.
  121065. */
  121066. static MODEL_FILENAME: string;
  121067. /**
  121068. * Gamepad Id prefix used to identify this controller.
  121069. */
  121070. static readonly GAMEPAD_ID_PREFIX: string;
  121071. private readonly _buttonIndexToObservableNameMap;
  121072. /**
  121073. * Creates a new GearVRController from a gamepad
  121074. * @param vrGamepad the gamepad that the controller should be created from
  121075. */
  121076. constructor(vrGamepad: any);
  121077. /**
  121078. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121079. * @param scene scene in which to add meshes
  121080. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121081. */
  121082. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121083. /**
  121084. * Called once for each button that changed state since the last frame
  121085. * @param buttonIdx Which button index changed
  121086. * @param state New state of the button
  121087. * @param changes Which properties on the state changed since last frame
  121088. */
  121089. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121090. }
  121091. }
  121092. declare module BABYLON {
  121093. /**
  121094. * Generic Controller
  121095. */
  121096. export class GenericController extends WebVRController {
  121097. /**
  121098. * Base Url for the controller model.
  121099. */
  121100. static readonly MODEL_BASE_URL: string;
  121101. /**
  121102. * File name for the controller model.
  121103. */
  121104. static readonly MODEL_FILENAME: string;
  121105. /**
  121106. * Creates a new GenericController from a gamepad
  121107. * @param vrGamepad the gamepad that the controller should be created from
  121108. */
  121109. constructor(vrGamepad: any);
  121110. /**
  121111. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121112. * @param scene scene in which to add meshes
  121113. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121114. */
  121115. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121116. /**
  121117. * Called once for each button that changed state since the last frame
  121118. * @param buttonIdx Which button index changed
  121119. * @param state New state of the button
  121120. * @param changes Which properties on the state changed since last frame
  121121. */
  121122. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121123. }
  121124. }
  121125. declare module BABYLON {
  121126. /**
  121127. * Oculus Touch Controller
  121128. */
  121129. export class OculusTouchController extends WebVRController {
  121130. /**
  121131. * Base Url for the controller model.
  121132. */
  121133. static MODEL_BASE_URL: string;
  121134. /**
  121135. * File name for the left controller model.
  121136. */
  121137. static MODEL_LEFT_FILENAME: string;
  121138. /**
  121139. * File name for the right controller model.
  121140. */
  121141. static MODEL_RIGHT_FILENAME: string;
  121142. /**
  121143. * Base Url for the Quest controller model.
  121144. */
  121145. static QUEST_MODEL_BASE_URL: string;
  121146. /**
  121147. * @hidden
  121148. * If the controllers are running on a device that needs the updated Quest controller models
  121149. */
  121150. static _IsQuest: boolean;
  121151. /**
  121152. * Fired when the secondary trigger on this controller is modified
  121153. */
  121154. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121155. /**
  121156. * Fired when the thumb rest on this controller is modified
  121157. */
  121158. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121159. /**
  121160. * Creates a new OculusTouchController from a gamepad
  121161. * @param vrGamepad the gamepad that the controller should be created from
  121162. */
  121163. constructor(vrGamepad: any);
  121164. /**
  121165. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121166. * @param scene scene in which to add meshes
  121167. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121168. */
  121169. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121170. /**
  121171. * Fired when the A button on this controller is modified
  121172. */
  121173. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121174. /**
  121175. * Fired when the B button on this controller is modified
  121176. */
  121177. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121178. /**
  121179. * Fired when the X button on this controller is modified
  121180. */
  121181. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121182. /**
  121183. * Fired when the Y button on this controller is modified
  121184. */
  121185. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121186. /**
  121187. * Called once for each button that changed state since the last frame
  121188. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121189. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121190. * 2) secondary trigger (same)
  121191. * 3) A (right) X (left), touch, pressed = value
  121192. * 4) B / Y
  121193. * 5) thumb rest
  121194. * @param buttonIdx Which button index changed
  121195. * @param state New state of the button
  121196. * @param changes Which properties on the state changed since last frame
  121197. */
  121198. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121199. }
  121200. }
  121201. declare module BABYLON {
  121202. /**
  121203. * Vive Controller
  121204. */
  121205. export class ViveController extends WebVRController {
  121206. /**
  121207. * Base Url for the controller model.
  121208. */
  121209. static MODEL_BASE_URL: string;
  121210. /**
  121211. * File name for the controller model.
  121212. */
  121213. static MODEL_FILENAME: string;
  121214. /**
  121215. * Creates a new ViveController from a gamepad
  121216. * @param vrGamepad the gamepad that the controller should be created from
  121217. */
  121218. constructor(vrGamepad: any);
  121219. /**
  121220. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121221. * @param scene scene in which to add meshes
  121222. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121223. */
  121224. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121225. /**
  121226. * Fired when the left button on this controller is modified
  121227. */
  121228. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121229. /**
  121230. * Fired when the right button on this controller is modified
  121231. */
  121232. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121233. /**
  121234. * Fired when the menu button on this controller is modified
  121235. */
  121236. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121237. /**
  121238. * Called once for each button that changed state since the last frame
  121239. * Vive mapping:
  121240. * 0: touchpad
  121241. * 1: trigger
  121242. * 2: left AND right buttons
  121243. * 3: menu button
  121244. * @param buttonIdx Which button index changed
  121245. * @param state New state of the button
  121246. * @param changes Which properties on the state changed since last frame
  121247. */
  121248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121249. }
  121250. }
  121251. declare module BABYLON {
  121252. /**
  121253. * Defines the WindowsMotionController object that the state of the windows motion controller
  121254. */
  121255. export class WindowsMotionController extends WebVRController {
  121256. /**
  121257. * The base url used to load the left and right controller models
  121258. */
  121259. static MODEL_BASE_URL: string;
  121260. /**
  121261. * The name of the left controller model file
  121262. */
  121263. static MODEL_LEFT_FILENAME: string;
  121264. /**
  121265. * The name of the right controller model file
  121266. */
  121267. static MODEL_RIGHT_FILENAME: string;
  121268. /**
  121269. * The controller name prefix for this controller type
  121270. */
  121271. static readonly GAMEPAD_ID_PREFIX: string;
  121272. /**
  121273. * The controller id pattern for this controller type
  121274. */
  121275. private static readonly GAMEPAD_ID_PATTERN;
  121276. private _loadedMeshInfo;
  121277. protected readonly _mapping: {
  121278. buttons: string[];
  121279. buttonMeshNames: {
  121280. 'trigger': string;
  121281. 'menu': string;
  121282. 'grip': string;
  121283. 'thumbstick': string;
  121284. 'trackpad': string;
  121285. };
  121286. buttonObservableNames: {
  121287. 'trigger': string;
  121288. 'menu': string;
  121289. 'grip': string;
  121290. 'thumbstick': string;
  121291. 'trackpad': string;
  121292. };
  121293. axisMeshNames: string[];
  121294. pointingPoseMeshName: string;
  121295. };
  121296. /**
  121297. * Fired when the trackpad on this controller is clicked
  121298. */
  121299. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121300. /**
  121301. * Fired when the trackpad on this controller is modified
  121302. */
  121303. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121304. /**
  121305. * The current x and y values of this controller's trackpad
  121306. */
  121307. trackpad: StickValues;
  121308. /**
  121309. * Creates a new WindowsMotionController from a gamepad
  121310. * @param vrGamepad the gamepad that the controller should be created from
  121311. */
  121312. constructor(vrGamepad: any);
  121313. /**
  121314. * Fired when the trigger on this controller is modified
  121315. */
  121316. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121317. /**
  121318. * Fired when the menu button on this controller is modified
  121319. */
  121320. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121321. /**
  121322. * Fired when the grip button on this controller is modified
  121323. */
  121324. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121325. /**
  121326. * Fired when the thumbstick button on this controller is modified
  121327. */
  121328. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121329. /**
  121330. * Fired when the touchpad button on this controller is modified
  121331. */
  121332. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121333. /**
  121334. * Fired when the touchpad values on this controller are modified
  121335. */
  121336. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121337. protected _updateTrackpad(): void;
  121338. /**
  121339. * Called once per frame by the engine.
  121340. */
  121341. update(): void;
  121342. /**
  121343. * Called once for each button that changed state since the last frame
  121344. * @param buttonIdx Which button index changed
  121345. * @param state New state of the button
  121346. * @param changes Which properties on the state changed since last frame
  121347. */
  121348. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121349. /**
  121350. * Moves the buttons on the controller mesh based on their current state
  121351. * @param buttonName the name of the button to move
  121352. * @param buttonValue the value of the button which determines the buttons new position
  121353. */
  121354. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121355. /**
  121356. * Moves the axis on the controller mesh based on its current state
  121357. * @param axis the index of the axis
  121358. * @param axisValue the value of the axis which determines the meshes new position
  121359. * @hidden
  121360. */
  121361. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121362. /**
  121363. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121364. * @param scene scene in which to add meshes
  121365. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121366. */
  121367. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121368. /**
  121369. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121370. * can be transformed by button presses and axes values, based on this._mapping.
  121371. *
  121372. * @param scene scene in which the meshes exist
  121373. * @param meshes list of meshes that make up the controller model to process
  121374. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121375. */
  121376. private processModel;
  121377. private createMeshInfo;
  121378. /**
  121379. * Gets the ray of the controller in the direction the controller is pointing
  121380. * @param length the length the resulting ray should be
  121381. * @returns a ray in the direction the controller is pointing
  121382. */
  121383. getForwardRay(length?: number): Ray;
  121384. /**
  121385. * Disposes of the controller
  121386. */
  121387. dispose(): void;
  121388. }
  121389. /**
  121390. * This class represents a new windows motion controller in XR.
  121391. */
  121392. export class XRWindowsMotionController extends WindowsMotionController {
  121393. /**
  121394. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121395. */
  121396. protected readonly _mapping: {
  121397. buttons: string[];
  121398. buttonMeshNames: {
  121399. 'trigger': string;
  121400. 'menu': string;
  121401. 'grip': string;
  121402. 'thumbstick': string;
  121403. 'trackpad': string;
  121404. };
  121405. buttonObservableNames: {
  121406. 'trigger': string;
  121407. 'menu': string;
  121408. 'grip': string;
  121409. 'thumbstick': string;
  121410. 'trackpad': string;
  121411. };
  121412. axisMeshNames: string[];
  121413. pointingPoseMeshName: string;
  121414. };
  121415. /**
  121416. * Construct a new XR-Based windows motion controller
  121417. *
  121418. * @param gamepadInfo the gamepad object from the browser
  121419. */
  121420. constructor(gamepadInfo: any);
  121421. /**
  121422. * holds the thumbstick values (X,Y)
  121423. */
  121424. thumbstickValues: StickValues;
  121425. /**
  121426. * Fired when the thumbstick on this controller is clicked
  121427. */
  121428. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121429. /**
  121430. * Fired when the thumbstick on this controller is modified
  121431. */
  121432. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121433. /**
  121434. * Fired when the touchpad button on this controller is modified
  121435. */
  121436. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121437. /**
  121438. * Fired when the touchpad values on this controller are modified
  121439. */
  121440. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121441. /**
  121442. * Fired when the thumbstick button on this controller is modified
  121443. * here to prevent breaking changes
  121444. */
  121445. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121446. /**
  121447. * updating the thumbstick(!) and not the trackpad.
  121448. * This is named this way due to the difference between WebVR and XR and to avoid
  121449. * changing the parent class.
  121450. */
  121451. protected _updateTrackpad(): void;
  121452. /**
  121453. * Disposes the class with joy
  121454. */
  121455. dispose(): void;
  121456. }
  121457. }
  121458. declare module BABYLON {
  121459. /**
  121460. * Class containing static functions to help procedurally build meshes
  121461. */
  121462. export class PolyhedronBuilder {
  121463. /**
  121464. * Creates a polyhedron mesh
  121465. * * 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
  121466. * * The parameter `size` (positive float, default 1) sets the polygon size
  121467. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121468. * * 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`
  121469. * * 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
  121470. * * 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)`)
  121471. * * 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
  121472. * * 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
  121473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121476. * @param name defines the name of the mesh
  121477. * @param options defines the options used to create the mesh
  121478. * @param scene defines the hosting scene
  121479. * @returns the polyhedron mesh
  121480. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121481. */
  121482. static CreatePolyhedron(name: string, options: {
  121483. type?: number;
  121484. size?: number;
  121485. sizeX?: number;
  121486. sizeY?: number;
  121487. sizeZ?: number;
  121488. custom?: any;
  121489. faceUV?: Vector4[];
  121490. faceColors?: Color4[];
  121491. flat?: boolean;
  121492. updatable?: boolean;
  121493. sideOrientation?: number;
  121494. frontUVs?: Vector4;
  121495. backUVs?: Vector4;
  121496. }, scene?: Nullable<Scene>): Mesh;
  121497. }
  121498. }
  121499. declare module BABYLON {
  121500. /**
  121501. * Gizmo that enables scaling a mesh along 3 axis
  121502. */
  121503. export class ScaleGizmo extends Gizmo {
  121504. /**
  121505. * Internal gizmo used for interactions on the x axis
  121506. */
  121507. xGizmo: AxisScaleGizmo;
  121508. /**
  121509. * Internal gizmo used for interactions on the y axis
  121510. */
  121511. yGizmo: AxisScaleGizmo;
  121512. /**
  121513. * Internal gizmo used for interactions on the z axis
  121514. */
  121515. zGizmo: AxisScaleGizmo;
  121516. /**
  121517. * Internal gizmo used to scale all axis equally
  121518. */
  121519. uniformScaleGizmo: AxisScaleGizmo;
  121520. private _meshAttached;
  121521. private _updateGizmoRotationToMatchAttachedMesh;
  121522. private _snapDistance;
  121523. private _scaleRatio;
  121524. private _uniformScalingMesh;
  121525. private _octahedron;
  121526. private _sensitivity;
  121527. /** Fires an event when any of it's sub gizmos are dragged */
  121528. onDragStartObservable: Observable<unknown>;
  121529. /** Fires an event when any of it's sub gizmos are released from dragging */
  121530. onDragEndObservable: Observable<unknown>;
  121531. get attachedMesh(): Nullable<AbstractMesh>;
  121532. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121533. /**
  121534. * Creates a ScaleGizmo
  121535. * @param gizmoLayer The utility layer the gizmo will be added to
  121536. */
  121537. constructor(gizmoLayer?: UtilityLayerRenderer);
  121538. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121539. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121540. /**
  121541. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121542. */
  121543. set snapDistance(value: number);
  121544. get snapDistance(): number;
  121545. /**
  121546. * Ratio for the scale of the gizmo (Default: 1)
  121547. */
  121548. set scaleRatio(value: number);
  121549. get scaleRatio(): number;
  121550. /**
  121551. * Sensitivity factor for dragging (Default: 1)
  121552. */
  121553. set sensitivity(value: number);
  121554. get sensitivity(): number;
  121555. /**
  121556. * Disposes of the gizmo
  121557. */
  121558. dispose(): void;
  121559. }
  121560. }
  121561. declare module BABYLON {
  121562. /**
  121563. * Single axis scale gizmo
  121564. */
  121565. export class AxisScaleGizmo extends Gizmo {
  121566. /**
  121567. * Drag behavior responsible for the gizmos dragging interactions
  121568. */
  121569. dragBehavior: PointerDragBehavior;
  121570. private _pointerObserver;
  121571. /**
  121572. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121573. */
  121574. snapDistance: number;
  121575. /**
  121576. * Event that fires each time the gizmo snaps to a new location.
  121577. * * snapDistance is the the change in distance
  121578. */
  121579. onSnapObservable: Observable<{
  121580. snapDistance: number;
  121581. }>;
  121582. /**
  121583. * If the scaling operation should be done on all axis (default: false)
  121584. */
  121585. uniformScaling: boolean;
  121586. /**
  121587. * Custom sensitivity value for the drag strength
  121588. */
  121589. sensitivity: number;
  121590. private _isEnabled;
  121591. private _parent;
  121592. private _arrow;
  121593. private _coloredMaterial;
  121594. private _hoverMaterial;
  121595. /**
  121596. * Creates an AxisScaleGizmo
  121597. * @param gizmoLayer The utility layer the gizmo will be added to
  121598. * @param dragAxis The axis which the gizmo will be able to scale on
  121599. * @param color The color of the gizmo
  121600. */
  121601. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121602. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121603. /**
  121604. * If the gizmo is enabled
  121605. */
  121606. set isEnabled(value: boolean);
  121607. get isEnabled(): boolean;
  121608. /**
  121609. * Disposes of the gizmo
  121610. */
  121611. dispose(): void;
  121612. /**
  121613. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121614. * @param mesh The mesh to replace the default mesh of the gizmo
  121615. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121616. */
  121617. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121618. }
  121619. }
  121620. declare module BABYLON {
  121621. /**
  121622. * Bounding box gizmo
  121623. */
  121624. export class BoundingBoxGizmo extends Gizmo {
  121625. private _lineBoundingBox;
  121626. private _rotateSpheresParent;
  121627. private _scaleBoxesParent;
  121628. private _boundingDimensions;
  121629. private _renderObserver;
  121630. private _pointerObserver;
  121631. private _scaleDragSpeed;
  121632. private _tmpQuaternion;
  121633. private _tmpVector;
  121634. private _tmpRotationMatrix;
  121635. /**
  121636. * 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)
  121637. */
  121638. ignoreChildren: boolean;
  121639. /**
  121640. * 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)
  121641. */
  121642. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121643. /**
  121644. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121645. */
  121646. rotationSphereSize: number;
  121647. /**
  121648. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121649. */
  121650. scaleBoxSize: number;
  121651. /**
  121652. * 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)
  121653. */
  121654. fixedDragMeshScreenSize: boolean;
  121655. /**
  121656. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121657. */
  121658. fixedDragMeshScreenSizeDistanceFactor: number;
  121659. /**
  121660. * Fired when a rotation sphere or scale box is dragged
  121661. */
  121662. onDragStartObservable: Observable<{}>;
  121663. /**
  121664. * Fired when a scale box is dragged
  121665. */
  121666. onScaleBoxDragObservable: Observable<{}>;
  121667. /**
  121668. * Fired when a scale box drag is ended
  121669. */
  121670. onScaleBoxDragEndObservable: Observable<{}>;
  121671. /**
  121672. * Fired when a rotation sphere is dragged
  121673. */
  121674. onRotationSphereDragObservable: Observable<{}>;
  121675. /**
  121676. * Fired when a rotation sphere drag is ended
  121677. */
  121678. onRotationSphereDragEndObservable: Observable<{}>;
  121679. /**
  121680. * 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)
  121681. */
  121682. scalePivot: Nullable<Vector3>;
  121683. /**
  121684. * Mesh used as a pivot to rotate the attached mesh
  121685. */
  121686. private _anchorMesh;
  121687. private _existingMeshScale;
  121688. private _dragMesh;
  121689. private pointerDragBehavior;
  121690. private coloredMaterial;
  121691. private hoverColoredMaterial;
  121692. /**
  121693. * Sets the color of the bounding box gizmo
  121694. * @param color the color to set
  121695. */
  121696. setColor(color: Color3): void;
  121697. /**
  121698. * Creates an BoundingBoxGizmo
  121699. * @param gizmoLayer The utility layer the gizmo will be added to
  121700. * @param color The color of the gizmo
  121701. */
  121702. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121704. private _selectNode;
  121705. /**
  121706. * Updates the bounding box information for the Gizmo
  121707. */
  121708. updateBoundingBox(): void;
  121709. private _updateRotationSpheres;
  121710. private _updateScaleBoxes;
  121711. /**
  121712. * Enables rotation on the specified axis and disables rotation on the others
  121713. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121714. */
  121715. setEnabledRotationAxis(axis: string): void;
  121716. /**
  121717. * Enables/disables scaling
  121718. * @param enable if scaling should be enabled
  121719. */
  121720. setEnabledScaling(enable: boolean): void;
  121721. private _updateDummy;
  121722. /**
  121723. * Enables a pointer drag behavior on the bounding box of the gizmo
  121724. */
  121725. enableDragBehavior(): void;
  121726. /**
  121727. * Disposes of the gizmo
  121728. */
  121729. dispose(): void;
  121730. /**
  121731. * 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)
  121732. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121733. * @returns the bounding box mesh with the passed in mesh as a child
  121734. */
  121735. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121736. /**
  121737. * CustomMeshes are not supported by this gizmo
  121738. * @param mesh The mesh to replace the default mesh of the gizmo
  121739. */
  121740. setCustomMesh(mesh: Mesh): void;
  121741. }
  121742. }
  121743. declare module BABYLON {
  121744. /**
  121745. * Single plane rotation gizmo
  121746. */
  121747. export class PlaneRotationGizmo extends Gizmo {
  121748. /**
  121749. * Drag behavior responsible for the gizmos dragging interactions
  121750. */
  121751. dragBehavior: PointerDragBehavior;
  121752. private _pointerObserver;
  121753. /**
  121754. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121755. */
  121756. snapDistance: number;
  121757. /**
  121758. * Event that fires each time the gizmo snaps to a new location.
  121759. * * snapDistance is the the change in distance
  121760. */
  121761. onSnapObservable: Observable<{
  121762. snapDistance: number;
  121763. }>;
  121764. private _isEnabled;
  121765. private _parent;
  121766. /**
  121767. * Creates a PlaneRotationGizmo
  121768. * @param gizmoLayer The utility layer the gizmo will be added to
  121769. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121770. * @param color The color of the gizmo
  121771. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121772. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121773. */
  121774. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121776. /**
  121777. * If the gizmo is enabled
  121778. */
  121779. set isEnabled(value: boolean);
  121780. get isEnabled(): boolean;
  121781. /**
  121782. * Disposes of the gizmo
  121783. */
  121784. dispose(): void;
  121785. }
  121786. }
  121787. declare module BABYLON {
  121788. /**
  121789. * Gizmo that enables rotating a mesh along 3 axis
  121790. */
  121791. export class RotationGizmo extends Gizmo {
  121792. /**
  121793. * Internal gizmo used for interactions on the x axis
  121794. */
  121795. xGizmo: PlaneRotationGizmo;
  121796. /**
  121797. * Internal gizmo used for interactions on the y axis
  121798. */
  121799. yGizmo: PlaneRotationGizmo;
  121800. /**
  121801. * Internal gizmo used for interactions on the z axis
  121802. */
  121803. zGizmo: PlaneRotationGizmo;
  121804. /** Fires an event when any of it's sub gizmos are dragged */
  121805. onDragStartObservable: Observable<unknown>;
  121806. /** Fires an event when any of it's sub gizmos are released from dragging */
  121807. onDragEndObservable: Observable<unknown>;
  121808. private _meshAttached;
  121809. get attachedMesh(): Nullable<AbstractMesh>;
  121810. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121811. /**
  121812. * Creates a RotationGizmo
  121813. * @param gizmoLayer The utility layer the gizmo will be added to
  121814. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121815. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121816. */
  121817. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121818. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121819. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121820. /**
  121821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121822. */
  121823. set snapDistance(value: number);
  121824. get snapDistance(): number;
  121825. /**
  121826. * Ratio for the scale of the gizmo (Default: 1)
  121827. */
  121828. set scaleRatio(value: number);
  121829. get scaleRatio(): number;
  121830. /**
  121831. * Disposes of the gizmo
  121832. */
  121833. dispose(): void;
  121834. /**
  121835. * CustomMeshes are not supported by this gizmo
  121836. * @param mesh The mesh to replace the default mesh of the gizmo
  121837. */
  121838. setCustomMesh(mesh: Mesh): void;
  121839. }
  121840. }
  121841. declare module BABYLON {
  121842. /**
  121843. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121844. */
  121845. export class GizmoManager implements IDisposable {
  121846. private scene;
  121847. /**
  121848. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121849. */
  121850. gizmos: {
  121851. positionGizmo: Nullable<PositionGizmo>;
  121852. rotationGizmo: Nullable<RotationGizmo>;
  121853. scaleGizmo: Nullable<ScaleGizmo>;
  121854. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121855. };
  121856. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121857. clearGizmoOnEmptyPointerEvent: boolean;
  121858. /** Fires an event when the manager is attached to a mesh */
  121859. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121860. private _gizmosEnabled;
  121861. private _pointerObserver;
  121862. private _attachedMesh;
  121863. private _boundingBoxColor;
  121864. private _defaultUtilityLayer;
  121865. private _defaultKeepDepthUtilityLayer;
  121866. /**
  121867. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121868. */
  121869. boundingBoxDragBehavior: SixDofDragBehavior;
  121870. /**
  121871. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121872. */
  121873. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121874. /**
  121875. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121876. */
  121877. usePointerToAttachGizmos: boolean;
  121878. /**
  121879. * Utility layer that the bounding box gizmo belongs to
  121880. */
  121881. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121882. /**
  121883. * Utility layer that all gizmos besides bounding box belong to
  121884. */
  121885. get utilityLayer(): UtilityLayerRenderer;
  121886. /**
  121887. * Instatiates a gizmo manager
  121888. * @param scene the scene to overlay the gizmos on top of
  121889. */
  121890. constructor(scene: Scene);
  121891. /**
  121892. * Attaches a set of gizmos to the specified mesh
  121893. * @param mesh The mesh the gizmo's should be attached to
  121894. */
  121895. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121896. /**
  121897. * If the position gizmo is enabled
  121898. */
  121899. set positionGizmoEnabled(value: boolean);
  121900. get positionGizmoEnabled(): boolean;
  121901. /**
  121902. * If the rotation gizmo is enabled
  121903. */
  121904. set rotationGizmoEnabled(value: boolean);
  121905. get rotationGizmoEnabled(): boolean;
  121906. /**
  121907. * If the scale gizmo is enabled
  121908. */
  121909. set scaleGizmoEnabled(value: boolean);
  121910. get scaleGizmoEnabled(): boolean;
  121911. /**
  121912. * If the boundingBox gizmo is enabled
  121913. */
  121914. set boundingBoxGizmoEnabled(value: boolean);
  121915. get boundingBoxGizmoEnabled(): boolean;
  121916. /**
  121917. * Disposes of the gizmo manager
  121918. */
  121919. dispose(): void;
  121920. }
  121921. }
  121922. declare module BABYLON {
  121923. /**
  121924. * A directional light is defined by a direction (what a surprise!).
  121925. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121926. * 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.
  121927. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121928. */
  121929. export class DirectionalLight extends ShadowLight {
  121930. private _shadowFrustumSize;
  121931. /**
  121932. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121933. */
  121934. get shadowFrustumSize(): number;
  121935. /**
  121936. * Specifies a fix frustum size for the shadow generation.
  121937. */
  121938. set shadowFrustumSize(value: number);
  121939. private _shadowOrthoScale;
  121940. /**
  121941. * Gets the shadow projection scale against the optimal computed one.
  121942. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121943. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121944. */
  121945. get shadowOrthoScale(): number;
  121946. /**
  121947. * Sets the shadow projection scale against the optimal computed one.
  121948. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121949. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121950. */
  121951. set shadowOrthoScale(value: number);
  121952. /**
  121953. * Automatically compute the projection matrix to best fit (including all the casters)
  121954. * on each frame.
  121955. */
  121956. autoUpdateExtends: boolean;
  121957. /**
  121958. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121959. * on each frame. autoUpdateExtends must be set to true for this to work
  121960. */
  121961. autoCalcShadowZBounds: boolean;
  121962. private _orthoLeft;
  121963. private _orthoRight;
  121964. private _orthoTop;
  121965. private _orthoBottom;
  121966. /**
  121967. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121968. * The directional light is emitted from everywhere in the given direction.
  121969. * It can cast shadows.
  121970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121971. * @param name The friendly name of the light
  121972. * @param direction The direction of the light
  121973. * @param scene The scene the light belongs to
  121974. */
  121975. constructor(name: string, direction: Vector3, scene: Scene);
  121976. /**
  121977. * Returns the string "DirectionalLight".
  121978. * @return The class name
  121979. */
  121980. getClassName(): string;
  121981. /**
  121982. * Returns the integer 1.
  121983. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121984. */
  121985. getTypeID(): number;
  121986. /**
  121987. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121988. * Returns the DirectionalLight Shadow projection matrix.
  121989. */
  121990. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121991. /**
  121992. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121993. * Returns the DirectionalLight Shadow projection matrix.
  121994. */
  121995. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121996. /**
  121997. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121998. * Returns the DirectionalLight Shadow projection matrix.
  121999. */
  122000. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122001. protected _buildUniformLayout(): void;
  122002. /**
  122003. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122004. * @param effect The effect to update
  122005. * @param lightIndex The index of the light in the effect to update
  122006. * @returns The directional light
  122007. */
  122008. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122009. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122010. /**
  122011. * Gets the minZ used for shadow according to both the scene and the light.
  122012. *
  122013. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122014. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122015. * @param activeCamera The camera we are returning the min for
  122016. * @returns the depth min z
  122017. */
  122018. getDepthMinZ(activeCamera: Camera): number;
  122019. /**
  122020. * Gets the maxZ used for shadow according to both the scene and the light.
  122021. *
  122022. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122023. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122024. * @param activeCamera The camera we are returning the max for
  122025. * @returns the depth max z
  122026. */
  122027. getDepthMaxZ(activeCamera: Camera): number;
  122028. /**
  122029. * Prepares the list of defines specific to the light type.
  122030. * @param defines the list of defines
  122031. * @param lightIndex defines the index of the light for the effect
  122032. */
  122033. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122034. }
  122035. }
  122036. declare module BABYLON {
  122037. /**
  122038. * Class containing static functions to help procedurally build meshes
  122039. */
  122040. export class HemisphereBuilder {
  122041. /**
  122042. * Creates a hemisphere mesh
  122043. * @param name defines the name of the mesh
  122044. * @param options defines the options used to create the mesh
  122045. * @param scene defines the hosting scene
  122046. * @returns the hemisphere mesh
  122047. */
  122048. static CreateHemisphere(name: string, options: {
  122049. segments?: number;
  122050. diameter?: number;
  122051. sideOrientation?: number;
  122052. }, scene: any): Mesh;
  122053. }
  122054. }
  122055. declare module BABYLON {
  122056. /**
  122057. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122058. * These values define a cone of light starting from the position, emitting toward the direction.
  122059. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122060. * and the exponent defines the speed of the decay of the light with distance (reach).
  122061. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122062. */
  122063. export class SpotLight extends ShadowLight {
  122064. private _angle;
  122065. private _innerAngle;
  122066. private _cosHalfAngle;
  122067. private _lightAngleScale;
  122068. private _lightAngleOffset;
  122069. /**
  122070. * Gets the cone angle of the spot light in Radians.
  122071. */
  122072. get angle(): number;
  122073. /**
  122074. * Sets the cone angle of the spot light in Radians.
  122075. */
  122076. set angle(value: number);
  122077. /**
  122078. * Only used in gltf falloff mode, this defines the angle where
  122079. * the directional falloff will start before cutting at angle which could be seen
  122080. * as outer angle.
  122081. */
  122082. get innerAngle(): number;
  122083. /**
  122084. * Only used in gltf falloff mode, this defines the angle where
  122085. * the directional falloff will start before cutting at angle which could be seen
  122086. * as outer angle.
  122087. */
  122088. set innerAngle(value: number);
  122089. private _shadowAngleScale;
  122090. /**
  122091. * Allows scaling the angle of the light for shadow generation only.
  122092. */
  122093. get shadowAngleScale(): number;
  122094. /**
  122095. * Allows scaling the angle of the light for shadow generation only.
  122096. */
  122097. set shadowAngleScale(value: number);
  122098. /**
  122099. * The light decay speed with the distance from the emission spot.
  122100. */
  122101. exponent: number;
  122102. private _projectionTextureMatrix;
  122103. /**
  122104. * Allows reading the projecton texture
  122105. */
  122106. get projectionTextureMatrix(): Matrix;
  122107. protected _projectionTextureLightNear: number;
  122108. /**
  122109. * Gets the near clip of the Spotlight for texture projection.
  122110. */
  122111. get projectionTextureLightNear(): number;
  122112. /**
  122113. * Sets the near clip of the Spotlight for texture projection.
  122114. */
  122115. set projectionTextureLightNear(value: number);
  122116. protected _projectionTextureLightFar: number;
  122117. /**
  122118. * Gets the far clip of the Spotlight for texture projection.
  122119. */
  122120. get projectionTextureLightFar(): number;
  122121. /**
  122122. * Sets the far clip of the Spotlight for texture projection.
  122123. */
  122124. set projectionTextureLightFar(value: number);
  122125. protected _projectionTextureUpDirection: Vector3;
  122126. /**
  122127. * Gets the Up vector of the Spotlight for texture projection.
  122128. */
  122129. get projectionTextureUpDirection(): Vector3;
  122130. /**
  122131. * Sets the Up vector of the Spotlight for texture projection.
  122132. */
  122133. set projectionTextureUpDirection(value: Vector3);
  122134. private _projectionTexture;
  122135. /**
  122136. * Gets the projection texture of the light.
  122137. */
  122138. get projectionTexture(): Nullable<BaseTexture>;
  122139. /**
  122140. * Sets the projection texture of the light.
  122141. */
  122142. set projectionTexture(value: Nullable<BaseTexture>);
  122143. private _projectionTextureViewLightDirty;
  122144. private _projectionTextureProjectionLightDirty;
  122145. private _projectionTextureDirty;
  122146. private _projectionTextureViewTargetVector;
  122147. private _projectionTextureViewLightMatrix;
  122148. private _projectionTextureProjectionLightMatrix;
  122149. private _projectionTextureScalingMatrix;
  122150. /**
  122151. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122152. * It can cast shadows.
  122153. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122154. * @param name The light friendly name
  122155. * @param position The position of the spot light in the scene
  122156. * @param direction The direction of the light in the scene
  122157. * @param angle The cone angle of the light in Radians
  122158. * @param exponent The light decay speed with the distance from the emission spot
  122159. * @param scene The scene the lights belongs to
  122160. */
  122161. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122162. /**
  122163. * Returns the string "SpotLight".
  122164. * @returns the class name
  122165. */
  122166. getClassName(): string;
  122167. /**
  122168. * Returns the integer 2.
  122169. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122170. */
  122171. getTypeID(): number;
  122172. /**
  122173. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122174. */
  122175. protected _setDirection(value: Vector3): void;
  122176. /**
  122177. * Overrides the position setter to recompute the projection texture view light Matrix.
  122178. */
  122179. protected _setPosition(value: Vector3): void;
  122180. /**
  122181. * 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.
  122182. * Returns the SpotLight.
  122183. */
  122184. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122185. protected _computeProjectionTextureViewLightMatrix(): void;
  122186. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122187. /**
  122188. * Main function for light texture projection matrix computing.
  122189. */
  122190. protected _computeProjectionTextureMatrix(): void;
  122191. protected _buildUniformLayout(): void;
  122192. private _computeAngleValues;
  122193. /**
  122194. * Sets the passed Effect "effect" with the Light textures.
  122195. * @param effect The effect to update
  122196. * @param lightIndex The index of the light in the effect to update
  122197. * @returns The light
  122198. */
  122199. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122200. /**
  122201. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122202. * @param effect The effect to update
  122203. * @param lightIndex The index of the light in the effect to update
  122204. * @returns The spot light
  122205. */
  122206. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122207. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122208. /**
  122209. * Disposes the light and the associated resources.
  122210. */
  122211. dispose(): void;
  122212. /**
  122213. * Prepares the list of defines specific to the light type.
  122214. * @param defines the list of defines
  122215. * @param lightIndex defines the index of the light for the effect
  122216. */
  122217. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122218. }
  122219. }
  122220. declare module BABYLON {
  122221. /**
  122222. * Gizmo that enables viewing a light
  122223. */
  122224. export class LightGizmo extends Gizmo {
  122225. private _lightMesh;
  122226. private _material;
  122227. private _cachedPosition;
  122228. private _cachedForward;
  122229. private _attachedMeshParent;
  122230. /**
  122231. * Creates a LightGizmo
  122232. * @param gizmoLayer The utility layer the gizmo will be added to
  122233. */
  122234. constructor(gizmoLayer?: UtilityLayerRenderer);
  122235. private _light;
  122236. /**
  122237. * The light that the gizmo is attached to
  122238. */
  122239. set light(light: Nullable<Light>);
  122240. get light(): Nullable<Light>;
  122241. /**
  122242. * Gets the material used to render the light gizmo
  122243. */
  122244. get material(): StandardMaterial;
  122245. /**
  122246. * @hidden
  122247. * Updates the gizmo to match the attached mesh's position/rotation
  122248. */
  122249. protected _update(): void;
  122250. private static _Scale;
  122251. /**
  122252. * Creates the lines for a light mesh
  122253. */
  122254. private static _CreateLightLines;
  122255. /**
  122256. * Disposes of the light gizmo
  122257. */
  122258. dispose(): void;
  122259. private static _CreateHemisphericLightMesh;
  122260. private static _CreatePointLightMesh;
  122261. private static _CreateSpotLightMesh;
  122262. private static _CreateDirectionalLightMesh;
  122263. }
  122264. }
  122265. declare module BABYLON {
  122266. /** @hidden */
  122267. export var backgroundFragmentDeclaration: {
  122268. name: string;
  122269. shader: string;
  122270. };
  122271. }
  122272. declare module BABYLON {
  122273. /** @hidden */
  122274. export var backgroundUboDeclaration: {
  122275. name: string;
  122276. shader: string;
  122277. };
  122278. }
  122279. declare module BABYLON {
  122280. /** @hidden */
  122281. export var backgroundPixelShader: {
  122282. name: string;
  122283. shader: string;
  122284. };
  122285. }
  122286. declare module BABYLON {
  122287. /** @hidden */
  122288. export var backgroundVertexDeclaration: {
  122289. name: string;
  122290. shader: string;
  122291. };
  122292. }
  122293. declare module BABYLON {
  122294. /** @hidden */
  122295. export var backgroundVertexShader: {
  122296. name: string;
  122297. shader: string;
  122298. };
  122299. }
  122300. declare module BABYLON {
  122301. /**
  122302. * Background material used to create an efficient environement around your scene.
  122303. */
  122304. export class BackgroundMaterial extends PushMaterial {
  122305. /**
  122306. * Standard reflectance value at parallel view angle.
  122307. */
  122308. static StandardReflectance0: number;
  122309. /**
  122310. * Standard reflectance value at grazing angle.
  122311. */
  122312. static StandardReflectance90: number;
  122313. protected _primaryColor: Color3;
  122314. /**
  122315. * Key light Color (multiply against the environement texture)
  122316. */
  122317. primaryColor: Color3;
  122318. protected __perceptualColor: Nullable<Color3>;
  122319. /**
  122320. * Experimental Internal Use Only.
  122321. *
  122322. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122323. * This acts as a helper to set the primary color to a more "human friendly" value.
  122324. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122325. * output color as close as possible from the chosen value.
  122326. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122327. * part of lighting setup.)
  122328. */
  122329. get _perceptualColor(): Nullable<Color3>;
  122330. set _perceptualColor(value: Nullable<Color3>);
  122331. protected _primaryColorShadowLevel: float;
  122332. /**
  122333. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122334. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122335. */
  122336. get primaryColorShadowLevel(): float;
  122337. set primaryColorShadowLevel(value: float);
  122338. protected _primaryColorHighlightLevel: float;
  122339. /**
  122340. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122341. * The primary color is used at the level chosen to define what the white area would look.
  122342. */
  122343. get primaryColorHighlightLevel(): float;
  122344. set primaryColorHighlightLevel(value: float);
  122345. protected _reflectionTexture: Nullable<BaseTexture>;
  122346. /**
  122347. * Reflection Texture used in the material.
  122348. * Should be author in a specific way for the best result (refer to the documentation).
  122349. */
  122350. reflectionTexture: Nullable<BaseTexture>;
  122351. protected _reflectionBlur: float;
  122352. /**
  122353. * Reflection Texture level of blur.
  122354. *
  122355. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122356. * texture twice.
  122357. */
  122358. reflectionBlur: float;
  122359. protected _diffuseTexture: Nullable<BaseTexture>;
  122360. /**
  122361. * Diffuse Texture used in the material.
  122362. * Should be author in a specific way for the best result (refer to the documentation).
  122363. */
  122364. diffuseTexture: Nullable<BaseTexture>;
  122365. protected _shadowLights: Nullable<IShadowLight[]>;
  122366. /**
  122367. * Specify the list of lights casting shadow on the material.
  122368. * All scene shadow lights will be included if null.
  122369. */
  122370. shadowLights: Nullable<IShadowLight[]>;
  122371. protected _shadowLevel: float;
  122372. /**
  122373. * Helps adjusting the shadow to a softer level if required.
  122374. * 0 means black shadows and 1 means no shadows.
  122375. */
  122376. shadowLevel: float;
  122377. protected _sceneCenter: Vector3;
  122378. /**
  122379. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122380. * It is usually zero but might be interesting to modify according to your setup.
  122381. */
  122382. sceneCenter: Vector3;
  122383. protected _opacityFresnel: boolean;
  122384. /**
  122385. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122386. * This helps ensuring a nice transition when the camera goes under the ground.
  122387. */
  122388. opacityFresnel: boolean;
  122389. protected _reflectionFresnel: boolean;
  122390. /**
  122391. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122392. * This helps adding a mirror texture on the ground.
  122393. */
  122394. reflectionFresnel: boolean;
  122395. protected _reflectionFalloffDistance: number;
  122396. /**
  122397. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122398. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122399. */
  122400. reflectionFalloffDistance: number;
  122401. protected _reflectionAmount: number;
  122402. /**
  122403. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122404. */
  122405. reflectionAmount: number;
  122406. protected _reflectionReflectance0: number;
  122407. /**
  122408. * This specifies the weight of the reflection at grazing angle.
  122409. */
  122410. reflectionReflectance0: number;
  122411. protected _reflectionReflectance90: number;
  122412. /**
  122413. * This specifies the weight of the reflection at a perpendicular point of view.
  122414. */
  122415. reflectionReflectance90: number;
  122416. /**
  122417. * Sets the reflection reflectance fresnel values according to the default standard
  122418. * empirically know to work well :-)
  122419. */
  122420. set reflectionStandardFresnelWeight(value: number);
  122421. protected _useRGBColor: boolean;
  122422. /**
  122423. * Helps to directly use the maps channels instead of their level.
  122424. */
  122425. useRGBColor: boolean;
  122426. protected _enableNoise: boolean;
  122427. /**
  122428. * This helps reducing the banding effect that could occur on the background.
  122429. */
  122430. enableNoise: boolean;
  122431. /**
  122432. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122433. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122434. * Recommended to be keep at 1.0 except for special cases.
  122435. */
  122436. get fovMultiplier(): number;
  122437. set fovMultiplier(value: number);
  122438. private _fovMultiplier;
  122439. /**
  122440. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122441. */
  122442. useEquirectangularFOV: boolean;
  122443. private _maxSimultaneousLights;
  122444. /**
  122445. * Number of Simultaneous lights allowed on the material.
  122446. */
  122447. maxSimultaneousLights: int;
  122448. /**
  122449. * Default configuration related to image processing available in the Background Material.
  122450. */
  122451. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122452. /**
  122453. * Keep track of the image processing observer to allow dispose and replace.
  122454. */
  122455. private _imageProcessingObserver;
  122456. /**
  122457. * Attaches a new image processing configuration to the PBR Material.
  122458. * @param configuration (if null the scene configuration will be use)
  122459. */
  122460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122461. /**
  122462. * Gets the image processing configuration used either in this material.
  122463. */
  122464. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122465. /**
  122466. * Sets the Default image processing configuration used either in the this material.
  122467. *
  122468. * If sets to null, the scene one is in use.
  122469. */
  122470. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122471. /**
  122472. * Gets wether the color curves effect is enabled.
  122473. */
  122474. get cameraColorCurvesEnabled(): boolean;
  122475. /**
  122476. * Sets wether the color curves effect is enabled.
  122477. */
  122478. set cameraColorCurvesEnabled(value: boolean);
  122479. /**
  122480. * Gets wether the color grading effect is enabled.
  122481. */
  122482. get cameraColorGradingEnabled(): boolean;
  122483. /**
  122484. * Gets wether the color grading effect is enabled.
  122485. */
  122486. set cameraColorGradingEnabled(value: boolean);
  122487. /**
  122488. * Gets wether tonemapping is enabled or not.
  122489. */
  122490. get cameraToneMappingEnabled(): boolean;
  122491. /**
  122492. * Sets wether tonemapping is enabled or not
  122493. */
  122494. set cameraToneMappingEnabled(value: boolean);
  122495. /**
  122496. * The camera exposure used on this material.
  122497. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122498. * This corresponds to a photographic exposure.
  122499. */
  122500. get cameraExposure(): float;
  122501. /**
  122502. * The camera exposure used on this material.
  122503. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122504. * This corresponds to a photographic exposure.
  122505. */
  122506. set cameraExposure(value: float);
  122507. /**
  122508. * Gets The camera contrast used on this material.
  122509. */
  122510. get cameraContrast(): float;
  122511. /**
  122512. * Sets The camera contrast used on this material.
  122513. */
  122514. set cameraContrast(value: float);
  122515. /**
  122516. * Gets the Color Grading 2D Lookup Texture.
  122517. */
  122518. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122519. /**
  122520. * Sets the Color Grading 2D Lookup Texture.
  122521. */
  122522. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122523. /**
  122524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122526. * 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;
  122527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122528. */
  122529. get cameraColorCurves(): Nullable<ColorCurves>;
  122530. /**
  122531. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122532. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122533. * 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;
  122534. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122535. */
  122536. set cameraColorCurves(value: Nullable<ColorCurves>);
  122537. /**
  122538. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122539. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122540. */
  122541. switchToBGR: boolean;
  122542. private _renderTargets;
  122543. private _reflectionControls;
  122544. private _white;
  122545. private _primaryShadowColor;
  122546. private _primaryHighlightColor;
  122547. /**
  122548. * Instantiates a Background Material in the given scene
  122549. * @param name The friendly name of the material
  122550. * @param scene The scene to add the material to
  122551. */
  122552. constructor(name: string, scene: Scene);
  122553. /**
  122554. * Gets a boolean indicating that current material needs to register RTT
  122555. */
  122556. get hasRenderTargetTextures(): boolean;
  122557. /**
  122558. * The entire material has been created in order to prevent overdraw.
  122559. * @returns false
  122560. */
  122561. needAlphaTesting(): boolean;
  122562. /**
  122563. * The entire material has been created in order to prevent overdraw.
  122564. * @returns true if blending is enable
  122565. */
  122566. needAlphaBlending(): boolean;
  122567. /**
  122568. * Checks wether the material is ready to be rendered for a given mesh.
  122569. * @param mesh The mesh to render
  122570. * @param subMesh The submesh to check against
  122571. * @param useInstances Specify wether or not the material is used with instances
  122572. * @returns true if all the dependencies are ready (Textures, Effects...)
  122573. */
  122574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122575. /**
  122576. * Compute the primary color according to the chosen perceptual color.
  122577. */
  122578. private _computePrimaryColorFromPerceptualColor;
  122579. /**
  122580. * Compute the highlights and shadow colors according to their chosen levels.
  122581. */
  122582. private _computePrimaryColors;
  122583. /**
  122584. * Build the uniform buffer used in the material.
  122585. */
  122586. buildUniformLayout(): void;
  122587. /**
  122588. * Unbind the material.
  122589. */
  122590. unbind(): void;
  122591. /**
  122592. * Bind only the world matrix to the material.
  122593. * @param world The world matrix to bind.
  122594. */
  122595. bindOnlyWorldMatrix(world: Matrix): void;
  122596. /**
  122597. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122598. * @param world The world matrix to bind.
  122599. * @param subMesh The submesh to bind for.
  122600. */
  122601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122602. /**
  122603. * Checks to see if a texture is used in the material.
  122604. * @param texture - Base texture to use.
  122605. * @returns - Boolean specifying if a texture is used in the material.
  122606. */
  122607. hasTexture(texture: BaseTexture): boolean;
  122608. /**
  122609. * Dispose the material.
  122610. * @param forceDisposeEffect Force disposal of the associated effect.
  122611. * @param forceDisposeTextures Force disposal of the associated textures.
  122612. */
  122613. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122614. /**
  122615. * Clones the material.
  122616. * @param name The cloned name.
  122617. * @returns The cloned material.
  122618. */
  122619. clone(name: string): BackgroundMaterial;
  122620. /**
  122621. * Serializes the current material to its JSON representation.
  122622. * @returns The JSON representation.
  122623. */
  122624. serialize(): any;
  122625. /**
  122626. * Gets the class name of the material
  122627. * @returns "BackgroundMaterial"
  122628. */
  122629. getClassName(): string;
  122630. /**
  122631. * Parse a JSON input to create back a background material.
  122632. * @param source The JSON data to parse
  122633. * @param scene The scene to create the parsed material in
  122634. * @param rootUrl The root url of the assets the material depends upon
  122635. * @returns the instantiated BackgroundMaterial.
  122636. */
  122637. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122638. }
  122639. }
  122640. declare module BABYLON {
  122641. /**
  122642. * Represents the different options available during the creation of
  122643. * a Environment helper.
  122644. *
  122645. * This can control the default ground, skybox and image processing setup of your scene.
  122646. */
  122647. export interface IEnvironmentHelperOptions {
  122648. /**
  122649. * Specifies whether or not to create a ground.
  122650. * True by default.
  122651. */
  122652. createGround: boolean;
  122653. /**
  122654. * Specifies the ground size.
  122655. * 15 by default.
  122656. */
  122657. groundSize: number;
  122658. /**
  122659. * The texture used on the ground for the main color.
  122660. * Comes from the BabylonJS CDN by default.
  122661. *
  122662. * Remarks: Can be either a texture or a url.
  122663. */
  122664. groundTexture: string | BaseTexture;
  122665. /**
  122666. * The color mixed in the ground texture by default.
  122667. * BabylonJS clearColor by default.
  122668. */
  122669. groundColor: Color3;
  122670. /**
  122671. * Specifies the ground opacity.
  122672. * 1 by default.
  122673. */
  122674. groundOpacity: number;
  122675. /**
  122676. * Enables the ground to receive shadows.
  122677. * True by default.
  122678. */
  122679. enableGroundShadow: boolean;
  122680. /**
  122681. * Helps preventing the shadow to be fully black on the ground.
  122682. * 0.5 by default.
  122683. */
  122684. groundShadowLevel: number;
  122685. /**
  122686. * Creates a mirror texture attach to the ground.
  122687. * false by default.
  122688. */
  122689. enableGroundMirror: boolean;
  122690. /**
  122691. * Specifies the ground mirror size ratio.
  122692. * 0.3 by default as the default kernel is 64.
  122693. */
  122694. groundMirrorSizeRatio: number;
  122695. /**
  122696. * Specifies the ground mirror blur kernel size.
  122697. * 64 by default.
  122698. */
  122699. groundMirrorBlurKernel: number;
  122700. /**
  122701. * Specifies the ground mirror visibility amount.
  122702. * 1 by default
  122703. */
  122704. groundMirrorAmount: number;
  122705. /**
  122706. * Specifies the ground mirror reflectance weight.
  122707. * This uses the standard weight of the background material to setup the fresnel effect
  122708. * of the mirror.
  122709. * 1 by default.
  122710. */
  122711. groundMirrorFresnelWeight: number;
  122712. /**
  122713. * Specifies the ground mirror Falloff distance.
  122714. * This can helps reducing the size of the reflection.
  122715. * 0 by Default.
  122716. */
  122717. groundMirrorFallOffDistance: number;
  122718. /**
  122719. * Specifies the ground mirror texture type.
  122720. * Unsigned Int by Default.
  122721. */
  122722. groundMirrorTextureType: number;
  122723. /**
  122724. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122725. * the shown objects.
  122726. */
  122727. groundYBias: number;
  122728. /**
  122729. * Specifies whether or not to create a skybox.
  122730. * True by default.
  122731. */
  122732. createSkybox: boolean;
  122733. /**
  122734. * Specifies the skybox size.
  122735. * 20 by default.
  122736. */
  122737. skyboxSize: number;
  122738. /**
  122739. * The texture used on the skybox for the main color.
  122740. * Comes from the BabylonJS CDN by default.
  122741. *
  122742. * Remarks: Can be either a texture or a url.
  122743. */
  122744. skyboxTexture: string | BaseTexture;
  122745. /**
  122746. * The color mixed in the skybox texture by default.
  122747. * BabylonJS clearColor by default.
  122748. */
  122749. skyboxColor: Color3;
  122750. /**
  122751. * The background rotation around the Y axis of the scene.
  122752. * This helps aligning the key lights of your scene with the background.
  122753. * 0 by default.
  122754. */
  122755. backgroundYRotation: number;
  122756. /**
  122757. * Compute automatically the size of the elements to best fit with the scene.
  122758. */
  122759. sizeAuto: boolean;
  122760. /**
  122761. * Default position of the rootMesh if autoSize is not true.
  122762. */
  122763. rootPosition: Vector3;
  122764. /**
  122765. * Sets up the image processing in the scene.
  122766. * true by default.
  122767. */
  122768. setupImageProcessing: boolean;
  122769. /**
  122770. * The texture used as your environment texture in the scene.
  122771. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122772. *
  122773. * Remarks: Can be either a texture or a url.
  122774. */
  122775. environmentTexture: string | BaseTexture;
  122776. /**
  122777. * The value of the exposure to apply to the scene.
  122778. * 0.6 by default if setupImageProcessing is true.
  122779. */
  122780. cameraExposure: number;
  122781. /**
  122782. * The value of the contrast to apply to the scene.
  122783. * 1.6 by default if setupImageProcessing is true.
  122784. */
  122785. cameraContrast: number;
  122786. /**
  122787. * Specifies whether or not tonemapping should be enabled in the scene.
  122788. * true by default if setupImageProcessing is true.
  122789. */
  122790. toneMappingEnabled: boolean;
  122791. }
  122792. /**
  122793. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122794. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122795. * It also helps with the default setup of your imageProcessing configuration.
  122796. */
  122797. export class EnvironmentHelper {
  122798. /**
  122799. * Default ground texture URL.
  122800. */
  122801. private static _groundTextureCDNUrl;
  122802. /**
  122803. * Default skybox texture URL.
  122804. */
  122805. private static _skyboxTextureCDNUrl;
  122806. /**
  122807. * Default environment texture URL.
  122808. */
  122809. private static _environmentTextureCDNUrl;
  122810. /**
  122811. * Creates the default options for the helper.
  122812. */
  122813. private static _getDefaultOptions;
  122814. private _rootMesh;
  122815. /**
  122816. * Gets the root mesh created by the helper.
  122817. */
  122818. get rootMesh(): Mesh;
  122819. private _skybox;
  122820. /**
  122821. * Gets the skybox created by the helper.
  122822. */
  122823. get skybox(): Nullable<Mesh>;
  122824. private _skyboxTexture;
  122825. /**
  122826. * Gets the skybox texture created by the helper.
  122827. */
  122828. get skyboxTexture(): Nullable<BaseTexture>;
  122829. private _skyboxMaterial;
  122830. /**
  122831. * Gets the skybox material created by the helper.
  122832. */
  122833. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122834. private _ground;
  122835. /**
  122836. * Gets the ground mesh created by the helper.
  122837. */
  122838. get ground(): Nullable<Mesh>;
  122839. private _groundTexture;
  122840. /**
  122841. * Gets the ground texture created by the helper.
  122842. */
  122843. get groundTexture(): Nullable<BaseTexture>;
  122844. private _groundMirror;
  122845. /**
  122846. * Gets the ground mirror created by the helper.
  122847. */
  122848. get groundMirror(): Nullable<MirrorTexture>;
  122849. /**
  122850. * Gets the ground mirror render list to helps pushing the meshes
  122851. * you wish in the ground reflection.
  122852. */
  122853. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122854. private _groundMaterial;
  122855. /**
  122856. * Gets the ground material created by the helper.
  122857. */
  122858. get groundMaterial(): Nullable<BackgroundMaterial>;
  122859. /**
  122860. * Stores the creation options.
  122861. */
  122862. private readonly _scene;
  122863. private _options;
  122864. /**
  122865. * This observable will be notified with any error during the creation of the environment,
  122866. * mainly texture creation errors.
  122867. */
  122868. onErrorObservable: Observable<{
  122869. message?: string;
  122870. exception?: any;
  122871. }>;
  122872. /**
  122873. * constructor
  122874. * @param options Defines the options we want to customize the helper
  122875. * @param scene The scene to add the material to
  122876. */
  122877. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122878. /**
  122879. * Updates the background according to the new options
  122880. * @param options
  122881. */
  122882. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122883. /**
  122884. * Sets the primary color of all the available elements.
  122885. * @param color the main color to affect to the ground and the background
  122886. */
  122887. setMainColor(color: Color3): void;
  122888. /**
  122889. * Setup the image processing according to the specified options.
  122890. */
  122891. private _setupImageProcessing;
  122892. /**
  122893. * Setup the environment texture according to the specified options.
  122894. */
  122895. private _setupEnvironmentTexture;
  122896. /**
  122897. * Setup the background according to the specified options.
  122898. */
  122899. private _setupBackground;
  122900. /**
  122901. * Get the scene sizes according to the setup.
  122902. */
  122903. private _getSceneSize;
  122904. /**
  122905. * Setup the ground according to the specified options.
  122906. */
  122907. private _setupGround;
  122908. /**
  122909. * Setup the ground material according to the specified options.
  122910. */
  122911. private _setupGroundMaterial;
  122912. /**
  122913. * Setup the ground diffuse texture according to the specified options.
  122914. */
  122915. private _setupGroundDiffuseTexture;
  122916. /**
  122917. * Setup the ground mirror texture according to the specified options.
  122918. */
  122919. private _setupGroundMirrorTexture;
  122920. /**
  122921. * Setup the ground to receive the mirror texture.
  122922. */
  122923. private _setupMirrorInGroundMaterial;
  122924. /**
  122925. * Setup the skybox according to the specified options.
  122926. */
  122927. private _setupSkybox;
  122928. /**
  122929. * Setup the skybox material according to the specified options.
  122930. */
  122931. private _setupSkyboxMaterial;
  122932. /**
  122933. * Setup the skybox reflection texture according to the specified options.
  122934. */
  122935. private _setupSkyboxReflectionTexture;
  122936. private _errorHandler;
  122937. /**
  122938. * Dispose all the elements created by the Helper.
  122939. */
  122940. dispose(): void;
  122941. }
  122942. }
  122943. declare module BABYLON {
  122944. /**
  122945. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122946. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122947. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122948. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122949. */
  122950. export class PhotoDome extends TransformNode {
  122951. /**
  122952. * Define the image as a Monoscopic panoramic 360 image.
  122953. */
  122954. static readonly MODE_MONOSCOPIC: number;
  122955. /**
  122956. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122957. */
  122958. static readonly MODE_TOPBOTTOM: number;
  122959. /**
  122960. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122961. */
  122962. static readonly MODE_SIDEBYSIDE: number;
  122963. private _useDirectMapping;
  122964. /**
  122965. * The texture being displayed on the sphere
  122966. */
  122967. protected _photoTexture: Texture;
  122968. /**
  122969. * Gets or sets the texture being displayed on the sphere
  122970. */
  122971. get photoTexture(): Texture;
  122972. set photoTexture(value: Texture);
  122973. /**
  122974. * Observable raised when an error occured while loading the 360 image
  122975. */
  122976. onLoadErrorObservable: Observable<string>;
  122977. /**
  122978. * The skybox material
  122979. */
  122980. protected _material: BackgroundMaterial;
  122981. /**
  122982. * The surface used for the skybox
  122983. */
  122984. protected _mesh: Mesh;
  122985. /**
  122986. * Gets the mesh used for the skybox.
  122987. */
  122988. get mesh(): Mesh;
  122989. /**
  122990. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122991. * Also see the options.resolution property.
  122992. */
  122993. get fovMultiplier(): number;
  122994. set fovMultiplier(value: number);
  122995. private _imageMode;
  122996. /**
  122997. * Gets or set the current video mode for the video. It can be:
  122998. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122999. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123000. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123001. */
  123002. get imageMode(): number;
  123003. set imageMode(value: number);
  123004. /**
  123005. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123006. * @param name Element's name, child elements will append suffixes for their own names.
  123007. * @param urlsOfPhoto defines the url of the photo to display
  123008. * @param options defines an object containing optional or exposed sub element properties
  123009. * @param onError defines a callback called when an error occured while loading the texture
  123010. */
  123011. constructor(name: string, urlOfPhoto: string, options: {
  123012. resolution?: number;
  123013. size?: number;
  123014. useDirectMapping?: boolean;
  123015. faceForward?: boolean;
  123016. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123017. private _onBeforeCameraRenderObserver;
  123018. private _changeImageMode;
  123019. /**
  123020. * Releases resources associated with this node.
  123021. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123022. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123023. */
  123024. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123025. }
  123026. }
  123027. declare module BABYLON {
  123028. /**
  123029. * Class used to host RGBD texture specific utilities
  123030. */
  123031. export class RGBDTextureTools {
  123032. /**
  123033. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123034. * @param texture the texture to expand.
  123035. */
  123036. static ExpandRGBDTexture(texture: Texture): void;
  123037. }
  123038. }
  123039. declare module BABYLON {
  123040. /**
  123041. * Class used to host texture specific utilities
  123042. */
  123043. export class BRDFTextureTools {
  123044. /**
  123045. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123046. * @param scene defines the hosting scene
  123047. * @returns the environment BRDF texture
  123048. */
  123049. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123050. private static _environmentBRDFBase64Texture;
  123051. }
  123052. }
  123053. declare module BABYLON {
  123054. /**
  123055. * @hidden
  123056. */
  123057. export interface IMaterialClearCoatDefines {
  123058. CLEARCOAT: boolean;
  123059. CLEARCOAT_DEFAULTIOR: boolean;
  123060. CLEARCOAT_TEXTURE: boolean;
  123061. CLEARCOAT_TEXTUREDIRECTUV: number;
  123062. CLEARCOAT_BUMP: boolean;
  123063. CLEARCOAT_BUMPDIRECTUV: number;
  123064. CLEARCOAT_TINT: boolean;
  123065. CLEARCOAT_TINT_TEXTURE: boolean;
  123066. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123067. /** @hidden */
  123068. _areTexturesDirty: boolean;
  123069. }
  123070. /**
  123071. * Define the code related to the clear coat parameters of the pbr material.
  123072. */
  123073. export class PBRClearCoatConfiguration {
  123074. /**
  123075. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123076. * The default fits with a polyurethane material.
  123077. */
  123078. private static readonly _DefaultIndexOfRefraction;
  123079. private _isEnabled;
  123080. /**
  123081. * Defines if the clear coat is enabled in the material.
  123082. */
  123083. isEnabled: boolean;
  123084. /**
  123085. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123086. */
  123087. intensity: number;
  123088. /**
  123089. * Defines the clear coat layer roughness.
  123090. */
  123091. roughness: number;
  123092. private _indexOfRefraction;
  123093. /**
  123094. * Defines the index of refraction of the clear coat.
  123095. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123096. * The default fits with a polyurethane material.
  123097. * Changing the default value is more performance intensive.
  123098. */
  123099. indexOfRefraction: number;
  123100. private _texture;
  123101. /**
  123102. * Stores the clear coat values in a texture.
  123103. */
  123104. texture: Nullable<BaseTexture>;
  123105. private _bumpTexture;
  123106. /**
  123107. * Define the clear coat specific bump texture.
  123108. */
  123109. bumpTexture: Nullable<BaseTexture>;
  123110. private _isTintEnabled;
  123111. /**
  123112. * Defines if the clear coat tint is enabled in the material.
  123113. */
  123114. isTintEnabled: boolean;
  123115. /**
  123116. * Defines the clear coat tint of the material.
  123117. * This is only use if tint is enabled
  123118. */
  123119. tintColor: Color3;
  123120. /**
  123121. * Defines the distance at which the tint color should be found in the
  123122. * clear coat media.
  123123. * This is only use if tint is enabled
  123124. */
  123125. tintColorAtDistance: number;
  123126. /**
  123127. * Defines the clear coat layer thickness.
  123128. * This is only use if tint is enabled
  123129. */
  123130. tintThickness: number;
  123131. private _tintTexture;
  123132. /**
  123133. * Stores the clear tint values in a texture.
  123134. * rgb is tint
  123135. * a is a thickness factor
  123136. */
  123137. tintTexture: Nullable<BaseTexture>;
  123138. /** @hidden */
  123139. private _internalMarkAllSubMeshesAsTexturesDirty;
  123140. /** @hidden */
  123141. _markAllSubMeshesAsTexturesDirty(): void;
  123142. /**
  123143. * Instantiate a new istance of clear coat configuration.
  123144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123145. */
  123146. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123147. /**
  123148. * Gets wehter the submesh is ready to be used or not.
  123149. * @param defines the list of "defines" to update.
  123150. * @param scene defines the scene the material belongs to.
  123151. * @param engine defines the engine the material belongs to.
  123152. * @param disableBumpMap defines wether the material disables bump or not.
  123153. * @returns - boolean indicating that the submesh is ready or not.
  123154. */
  123155. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123156. /**
  123157. * Checks to see if a texture is used in the material.
  123158. * @param defines the list of "defines" to update.
  123159. * @param scene defines the scene to the material belongs to.
  123160. */
  123161. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123162. /**
  123163. * Binds the material data.
  123164. * @param uniformBuffer defines the Uniform buffer to fill in.
  123165. * @param scene defines the scene the material belongs to.
  123166. * @param engine defines the engine the material belongs to.
  123167. * @param disableBumpMap defines wether the material disables bump or not.
  123168. * @param isFrozen defines wether the material is frozen or not.
  123169. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123170. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123171. */
  123172. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123173. /**
  123174. * Checks to see if a texture is used in the material.
  123175. * @param texture - Base texture to use.
  123176. * @returns - Boolean specifying if a texture is used in the material.
  123177. */
  123178. hasTexture(texture: BaseTexture): boolean;
  123179. /**
  123180. * Returns an array of the actively used textures.
  123181. * @param activeTextures Array of BaseTextures
  123182. */
  123183. getActiveTextures(activeTextures: BaseTexture[]): void;
  123184. /**
  123185. * Returns the animatable textures.
  123186. * @param animatables Array of animatable textures.
  123187. */
  123188. getAnimatables(animatables: IAnimatable[]): void;
  123189. /**
  123190. * Disposes the resources of the material.
  123191. * @param forceDisposeTextures - Forces the disposal of all textures.
  123192. */
  123193. dispose(forceDisposeTextures?: boolean): void;
  123194. /**
  123195. * Get the current class name of the texture useful for serialization or dynamic coding.
  123196. * @returns "PBRClearCoatConfiguration"
  123197. */
  123198. getClassName(): string;
  123199. /**
  123200. * Add fallbacks to the effect fallbacks list.
  123201. * @param defines defines the Base texture to use.
  123202. * @param fallbacks defines the current fallback list.
  123203. * @param currentRank defines the current fallback rank.
  123204. * @returns the new fallback rank.
  123205. */
  123206. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123207. /**
  123208. * Add the required uniforms to the current list.
  123209. * @param uniforms defines the current uniform list.
  123210. */
  123211. static AddUniforms(uniforms: string[]): void;
  123212. /**
  123213. * Add the required samplers to the current list.
  123214. * @param samplers defines the current sampler list.
  123215. */
  123216. static AddSamplers(samplers: string[]): void;
  123217. /**
  123218. * Add the required uniforms to the current buffer.
  123219. * @param uniformBuffer defines the current uniform buffer.
  123220. */
  123221. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123222. /**
  123223. * Makes a duplicate of the current configuration into another one.
  123224. * @param clearCoatConfiguration define the config where to copy the info
  123225. */
  123226. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123227. /**
  123228. * Serializes this clear coat configuration.
  123229. * @returns - An object with the serialized config.
  123230. */
  123231. serialize(): any;
  123232. /**
  123233. * Parses a anisotropy Configuration from a serialized object.
  123234. * @param source - Serialized object.
  123235. * @param scene Defines the scene we are parsing for
  123236. * @param rootUrl Defines the rootUrl to load from
  123237. */
  123238. parse(source: any, scene: Scene, rootUrl: string): void;
  123239. }
  123240. }
  123241. declare module BABYLON {
  123242. /**
  123243. * @hidden
  123244. */
  123245. export interface IMaterialAnisotropicDefines {
  123246. ANISOTROPIC: boolean;
  123247. ANISOTROPIC_TEXTURE: boolean;
  123248. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123249. MAINUV1: boolean;
  123250. _areTexturesDirty: boolean;
  123251. _needUVs: boolean;
  123252. }
  123253. /**
  123254. * Define the code related to the anisotropic parameters of the pbr material.
  123255. */
  123256. export class PBRAnisotropicConfiguration {
  123257. private _isEnabled;
  123258. /**
  123259. * Defines if the anisotropy is enabled in the material.
  123260. */
  123261. isEnabled: boolean;
  123262. /**
  123263. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123264. */
  123265. intensity: number;
  123266. /**
  123267. * Defines if the effect is along the tangents, bitangents or in between.
  123268. * By default, the effect is "strectching" the highlights along the tangents.
  123269. */
  123270. direction: Vector2;
  123271. private _texture;
  123272. /**
  123273. * Stores the anisotropy values in a texture.
  123274. * rg is direction (like normal from -1 to 1)
  123275. * b is a intensity
  123276. */
  123277. texture: Nullable<BaseTexture>;
  123278. /** @hidden */
  123279. private _internalMarkAllSubMeshesAsTexturesDirty;
  123280. /** @hidden */
  123281. _markAllSubMeshesAsTexturesDirty(): void;
  123282. /**
  123283. * Instantiate a new istance of anisotropy configuration.
  123284. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123285. */
  123286. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123287. /**
  123288. * Specifies that the submesh is ready to be used.
  123289. * @param defines the list of "defines" to update.
  123290. * @param scene defines the scene the material belongs to.
  123291. * @returns - boolean indicating that the submesh is ready or not.
  123292. */
  123293. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123294. /**
  123295. * Checks to see if a texture is used in the material.
  123296. * @param defines the list of "defines" to update.
  123297. * @param mesh the mesh we are preparing the defines for.
  123298. * @param scene defines the scene the material belongs to.
  123299. */
  123300. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123301. /**
  123302. * Binds the material data.
  123303. * @param uniformBuffer defines the Uniform buffer to fill in.
  123304. * @param scene defines the scene the material belongs to.
  123305. * @param isFrozen defines wether the material is frozen or not.
  123306. */
  123307. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123308. /**
  123309. * Checks to see if a texture is used in the material.
  123310. * @param texture - Base texture to use.
  123311. * @returns - Boolean specifying if a texture is used in the material.
  123312. */
  123313. hasTexture(texture: BaseTexture): boolean;
  123314. /**
  123315. * Returns an array of the actively used textures.
  123316. * @param activeTextures Array of BaseTextures
  123317. */
  123318. getActiveTextures(activeTextures: BaseTexture[]): void;
  123319. /**
  123320. * Returns the animatable textures.
  123321. * @param animatables Array of animatable textures.
  123322. */
  123323. getAnimatables(animatables: IAnimatable[]): void;
  123324. /**
  123325. * Disposes the resources of the material.
  123326. * @param forceDisposeTextures - Forces the disposal of all textures.
  123327. */
  123328. dispose(forceDisposeTextures?: boolean): void;
  123329. /**
  123330. * Get the current class name of the texture useful for serialization or dynamic coding.
  123331. * @returns "PBRAnisotropicConfiguration"
  123332. */
  123333. getClassName(): string;
  123334. /**
  123335. * Add fallbacks to the effect fallbacks list.
  123336. * @param defines defines the Base texture to use.
  123337. * @param fallbacks defines the current fallback list.
  123338. * @param currentRank defines the current fallback rank.
  123339. * @returns the new fallback rank.
  123340. */
  123341. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123342. /**
  123343. * Add the required uniforms to the current list.
  123344. * @param uniforms defines the current uniform list.
  123345. */
  123346. static AddUniforms(uniforms: string[]): void;
  123347. /**
  123348. * Add the required uniforms to the current buffer.
  123349. * @param uniformBuffer defines the current uniform buffer.
  123350. */
  123351. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123352. /**
  123353. * Add the required samplers to the current list.
  123354. * @param samplers defines the current sampler list.
  123355. */
  123356. static AddSamplers(samplers: string[]): void;
  123357. /**
  123358. * Makes a duplicate of the current configuration into another one.
  123359. * @param anisotropicConfiguration define the config where to copy the info
  123360. */
  123361. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123362. /**
  123363. * Serializes this anisotropy configuration.
  123364. * @returns - An object with the serialized config.
  123365. */
  123366. serialize(): any;
  123367. /**
  123368. * Parses a anisotropy Configuration from a serialized object.
  123369. * @param source - Serialized object.
  123370. * @param scene Defines the scene we are parsing for
  123371. * @param rootUrl Defines the rootUrl to load from
  123372. */
  123373. parse(source: any, scene: Scene, rootUrl: string): void;
  123374. }
  123375. }
  123376. declare module BABYLON {
  123377. /**
  123378. * @hidden
  123379. */
  123380. export interface IMaterialBRDFDefines {
  123381. BRDF_V_HEIGHT_CORRELATED: boolean;
  123382. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123383. SPHERICAL_HARMONICS: boolean;
  123384. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123385. /** @hidden */
  123386. _areMiscDirty: boolean;
  123387. }
  123388. /**
  123389. * Define the code related to the BRDF parameters of the pbr material.
  123390. */
  123391. export class PBRBRDFConfiguration {
  123392. /**
  123393. * Default value used for the energy conservation.
  123394. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123395. */
  123396. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123397. /**
  123398. * Default value used for the Smith Visibility Height Correlated mode.
  123399. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123400. */
  123401. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123402. /**
  123403. * Default value used for the IBL diffuse part.
  123404. * This can help switching back to the polynomials mode globally which is a tiny bit
  123405. * less GPU intensive at the drawback of a lower quality.
  123406. */
  123407. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123408. /**
  123409. * Default value used for activating energy conservation for the specular workflow.
  123410. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123411. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123412. */
  123413. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123414. private _useEnergyConservation;
  123415. /**
  123416. * Defines if the material uses energy conservation.
  123417. */
  123418. useEnergyConservation: boolean;
  123419. private _useSmithVisibilityHeightCorrelated;
  123420. /**
  123421. * LEGACY Mode set to false
  123422. * Defines if the material uses height smith correlated visibility term.
  123423. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123424. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123425. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123426. * Not relying on height correlated will also disable energy conservation.
  123427. */
  123428. useSmithVisibilityHeightCorrelated: boolean;
  123429. private _useSphericalHarmonics;
  123430. /**
  123431. * LEGACY Mode set to false
  123432. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123433. * diffuse part of the IBL.
  123434. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123435. * to the ground truth.
  123436. */
  123437. useSphericalHarmonics: boolean;
  123438. private _useSpecularGlossinessInputEnergyConservation;
  123439. /**
  123440. * Defines if the material uses energy conservation, when the specular workflow is active.
  123441. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123442. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123443. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123444. */
  123445. useSpecularGlossinessInputEnergyConservation: boolean;
  123446. /** @hidden */
  123447. private _internalMarkAllSubMeshesAsMiscDirty;
  123448. /** @hidden */
  123449. _markAllSubMeshesAsMiscDirty(): void;
  123450. /**
  123451. * Instantiate a new istance of clear coat configuration.
  123452. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123453. */
  123454. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123455. /**
  123456. * Checks to see if a texture is used in the material.
  123457. * @param defines the list of "defines" to update.
  123458. */
  123459. prepareDefines(defines: IMaterialBRDFDefines): void;
  123460. /**
  123461. * Get the current class name of the texture useful for serialization or dynamic coding.
  123462. * @returns "PBRClearCoatConfiguration"
  123463. */
  123464. getClassName(): string;
  123465. /**
  123466. * Makes a duplicate of the current configuration into another one.
  123467. * @param brdfConfiguration define the config where to copy the info
  123468. */
  123469. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123470. /**
  123471. * Serializes this BRDF configuration.
  123472. * @returns - An object with the serialized config.
  123473. */
  123474. serialize(): any;
  123475. /**
  123476. * Parses a anisotropy Configuration from a serialized object.
  123477. * @param source - Serialized object.
  123478. * @param scene Defines the scene we are parsing for
  123479. * @param rootUrl Defines the rootUrl to load from
  123480. */
  123481. parse(source: any, scene: Scene, rootUrl: string): void;
  123482. }
  123483. }
  123484. declare module BABYLON {
  123485. /**
  123486. * @hidden
  123487. */
  123488. export interface IMaterialSheenDefines {
  123489. SHEEN: boolean;
  123490. SHEEN_TEXTURE: boolean;
  123491. SHEEN_TEXTUREDIRECTUV: number;
  123492. SHEEN_LINKWITHALBEDO: boolean;
  123493. /** @hidden */
  123494. _areTexturesDirty: boolean;
  123495. }
  123496. /**
  123497. * Define the code related to the Sheen parameters of the pbr material.
  123498. */
  123499. export class PBRSheenConfiguration {
  123500. private _isEnabled;
  123501. /**
  123502. * Defines if the material uses sheen.
  123503. */
  123504. isEnabled: boolean;
  123505. private _linkSheenWithAlbedo;
  123506. /**
  123507. * Defines if the sheen is linked to the sheen color.
  123508. */
  123509. linkSheenWithAlbedo: boolean;
  123510. /**
  123511. * Defines the sheen intensity.
  123512. */
  123513. intensity: number;
  123514. /**
  123515. * Defines the sheen color.
  123516. */
  123517. color: Color3;
  123518. private _texture;
  123519. /**
  123520. * Stores the sheen tint values in a texture.
  123521. * rgb is tint
  123522. * a is a intensity
  123523. */
  123524. texture: Nullable<BaseTexture>;
  123525. /** @hidden */
  123526. private _internalMarkAllSubMeshesAsTexturesDirty;
  123527. /** @hidden */
  123528. _markAllSubMeshesAsTexturesDirty(): void;
  123529. /**
  123530. * Instantiate a new istance of clear coat configuration.
  123531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123532. */
  123533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123534. /**
  123535. * Specifies that the submesh is ready to be used.
  123536. * @param defines the list of "defines" to update.
  123537. * @param scene defines the scene the material belongs to.
  123538. * @returns - boolean indicating that the submesh is ready or not.
  123539. */
  123540. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123541. /**
  123542. * Checks to see if a texture is used in the material.
  123543. * @param defines the list of "defines" to update.
  123544. * @param scene defines the scene the material belongs to.
  123545. */
  123546. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123547. /**
  123548. * Binds the material data.
  123549. * @param uniformBuffer defines the Uniform buffer to fill in.
  123550. * @param scene defines the scene the material belongs to.
  123551. * @param isFrozen defines wether the material is frozen or not.
  123552. */
  123553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123554. /**
  123555. * Checks to see if a texture is used in the material.
  123556. * @param texture - Base texture to use.
  123557. * @returns - Boolean specifying if a texture is used in the material.
  123558. */
  123559. hasTexture(texture: BaseTexture): boolean;
  123560. /**
  123561. * Returns an array of the actively used textures.
  123562. * @param activeTextures Array of BaseTextures
  123563. */
  123564. getActiveTextures(activeTextures: BaseTexture[]): void;
  123565. /**
  123566. * Returns the animatable textures.
  123567. * @param animatables Array of animatable textures.
  123568. */
  123569. getAnimatables(animatables: IAnimatable[]): void;
  123570. /**
  123571. * Disposes the resources of the material.
  123572. * @param forceDisposeTextures - Forces the disposal of all textures.
  123573. */
  123574. dispose(forceDisposeTextures?: boolean): void;
  123575. /**
  123576. * Get the current class name of the texture useful for serialization or dynamic coding.
  123577. * @returns "PBRSheenConfiguration"
  123578. */
  123579. getClassName(): string;
  123580. /**
  123581. * Add fallbacks to the effect fallbacks list.
  123582. * @param defines defines the Base texture to use.
  123583. * @param fallbacks defines the current fallback list.
  123584. * @param currentRank defines the current fallback rank.
  123585. * @returns the new fallback rank.
  123586. */
  123587. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123588. /**
  123589. * Add the required uniforms to the current list.
  123590. * @param uniforms defines the current uniform list.
  123591. */
  123592. static AddUniforms(uniforms: string[]): void;
  123593. /**
  123594. * Add the required uniforms to the current buffer.
  123595. * @param uniformBuffer defines the current uniform buffer.
  123596. */
  123597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123598. /**
  123599. * Add the required samplers to the current list.
  123600. * @param samplers defines the current sampler list.
  123601. */
  123602. static AddSamplers(samplers: string[]): void;
  123603. /**
  123604. * Makes a duplicate of the current configuration into another one.
  123605. * @param sheenConfiguration define the config where to copy the info
  123606. */
  123607. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123608. /**
  123609. * Serializes this BRDF configuration.
  123610. * @returns - An object with the serialized config.
  123611. */
  123612. serialize(): any;
  123613. /**
  123614. * Parses a anisotropy Configuration from a serialized object.
  123615. * @param source - Serialized object.
  123616. * @param scene Defines the scene we are parsing for
  123617. * @param rootUrl Defines the rootUrl to load from
  123618. */
  123619. parse(source: any, scene: Scene, rootUrl: string): void;
  123620. }
  123621. }
  123622. declare module BABYLON {
  123623. /**
  123624. * @hidden
  123625. */
  123626. export interface IMaterialSubSurfaceDefines {
  123627. SUBSURFACE: boolean;
  123628. SS_REFRACTION: boolean;
  123629. SS_TRANSLUCENCY: boolean;
  123630. SS_SCATERRING: boolean;
  123631. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123632. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123633. SS_REFRACTIONMAP_3D: boolean;
  123634. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123635. SS_LODINREFRACTIONALPHA: boolean;
  123636. SS_GAMMAREFRACTION: boolean;
  123637. SS_RGBDREFRACTION: boolean;
  123638. SS_LINEARSPECULARREFRACTION: boolean;
  123639. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123640. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123641. /** @hidden */
  123642. _areTexturesDirty: boolean;
  123643. }
  123644. /**
  123645. * Define the code related to the sub surface parameters of the pbr material.
  123646. */
  123647. export class PBRSubSurfaceConfiguration {
  123648. private _isRefractionEnabled;
  123649. /**
  123650. * Defines if the refraction is enabled in the material.
  123651. */
  123652. isRefractionEnabled: boolean;
  123653. private _isTranslucencyEnabled;
  123654. /**
  123655. * Defines if the translucency is enabled in the material.
  123656. */
  123657. isTranslucencyEnabled: boolean;
  123658. private _isScatteringEnabled;
  123659. /**
  123660. * Defines the refraction intensity of the material.
  123661. * The refraction when enabled replaces the Diffuse part of the material.
  123662. * The intensity helps transitionning between diffuse and refraction.
  123663. */
  123664. refractionIntensity: number;
  123665. /**
  123666. * Defines the translucency intensity of the material.
  123667. * When translucency has been enabled, this defines how much of the "translucency"
  123668. * is addded to the diffuse part of the material.
  123669. */
  123670. translucencyIntensity: number;
  123671. /**
  123672. * Defines the scattering intensity of the material.
  123673. * When scattering has been enabled, this defines how much of the "scattered light"
  123674. * is addded to the diffuse part of the material.
  123675. */
  123676. scatteringIntensity: number;
  123677. private _thicknessTexture;
  123678. /**
  123679. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123680. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123681. * 0 would mean minimumThickness
  123682. * 1 would mean maximumThickness
  123683. * The other channels might be use as a mask to vary the different effects intensity.
  123684. */
  123685. thicknessTexture: Nullable<BaseTexture>;
  123686. private _refractionTexture;
  123687. /**
  123688. * Defines the texture to use for refraction.
  123689. */
  123690. refractionTexture: Nullable<BaseTexture>;
  123691. private _indexOfRefraction;
  123692. /**
  123693. * Defines the index of refraction used in the material.
  123694. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123695. */
  123696. indexOfRefraction: number;
  123697. private _invertRefractionY;
  123698. /**
  123699. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123700. */
  123701. invertRefractionY: boolean;
  123702. private _linkRefractionWithTransparency;
  123703. /**
  123704. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123705. * Materials half opaque for instance using refraction could benefit from this control.
  123706. */
  123707. linkRefractionWithTransparency: boolean;
  123708. /**
  123709. * Defines the minimum thickness stored in the thickness map.
  123710. * If no thickness map is defined, this value will be used to simulate thickness.
  123711. */
  123712. minimumThickness: number;
  123713. /**
  123714. * Defines the maximum thickness stored in the thickness map.
  123715. */
  123716. maximumThickness: number;
  123717. /**
  123718. * Defines the volume tint of the material.
  123719. * This is used for both translucency and scattering.
  123720. */
  123721. tintColor: Color3;
  123722. /**
  123723. * Defines the distance at which the tint color should be found in the media.
  123724. * This is used for refraction only.
  123725. */
  123726. tintColorAtDistance: number;
  123727. /**
  123728. * Defines how far each channel transmit through the media.
  123729. * It is defined as a color to simplify it selection.
  123730. */
  123731. diffusionDistance: Color3;
  123732. private _useMaskFromThicknessTexture;
  123733. /**
  123734. * Stores the intensity of the different subsurface effects in the thickness texture.
  123735. * * the green channel is the translucency intensity.
  123736. * * the blue channel is the scattering intensity.
  123737. * * the alpha channel is the refraction intensity.
  123738. */
  123739. useMaskFromThicknessTexture: boolean;
  123740. /** @hidden */
  123741. private _internalMarkAllSubMeshesAsTexturesDirty;
  123742. /** @hidden */
  123743. _markAllSubMeshesAsTexturesDirty(): void;
  123744. /**
  123745. * Instantiate a new istance of sub surface configuration.
  123746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123747. */
  123748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123749. /**
  123750. * Gets wehter the submesh is ready to be used or not.
  123751. * @param defines the list of "defines" to update.
  123752. * @param scene defines the scene the material belongs to.
  123753. * @returns - boolean indicating that the submesh is ready or not.
  123754. */
  123755. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123756. /**
  123757. * Checks to see if a texture is used in the material.
  123758. * @param defines the list of "defines" to update.
  123759. * @param scene defines the scene to the material belongs to.
  123760. */
  123761. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123762. /**
  123763. * Binds the material data.
  123764. * @param uniformBuffer defines the Uniform buffer to fill in.
  123765. * @param scene defines the scene the material belongs to.
  123766. * @param engine defines the engine the material belongs to.
  123767. * @param isFrozen defines wether the material is frozen or not.
  123768. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123769. */
  123770. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123771. /**
  123772. * Unbinds the material from the mesh.
  123773. * @param activeEffect defines the effect that should be unbound from.
  123774. * @returns true if unbound, otherwise false
  123775. */
  123776. unbind(activeEffect: Effect): boolean;
  123777. /**
  123778. * Returns the texture used for refraction or null if none is used.
  123779. * @param scene defines the scene the material belongs to.
  123780. * @returns - Refraction texture if present. If no refraction texture and refraction
  123781. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123782. */
  123783. private _getRefractionTexture;
  123784. /**
  123785. * Returns true if alpha blending should be disabled.
  123786. */
  123787. get disableAlphaBlending(): boolean;
  123788. /**
  123789. * Fills the list of render target textures.
  123790. * @param renderTargets the list of render targets to update
  123791. */
  123792. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123793. /**
  123794. * Checks to see if a texture is used in the material.
  123795. * @param texture - Base texture to use.
  123796. * @returns - Boolean specifying if a texture is used in the material.
  123797. */
  123798. hasTexture(texture: BaseTexture): boolean;
  123799. /**
  123800. * Gets a boolean indicating that current material needs to register RTT
  123801. * @returns true if this uses a render target otherwise false.
  123802. */
  123803. hasRenderTargetTextures(): boolean;
  123804. /**
  123805. * Returns an array of the actively used textures.
  123806. * @param activeTextures Array of BaseTextures
  123807. */
  123808. getActiveTextures(activeTextures: BaseTexture[]): void;
  123809. /**
  123810. * Returns the animatable textures.
  123811. * @param animatables Array of animatable textures.
  123812. */
  123813. getAnimatables(animatables: IAnimatable[]): void;
  123814. /**
  123815. * Disposes the resources of the material.
  123816. * @param forceDisposeTextures - Forces the disposal of all textures.
  123817. */
  123818. dispose(forceDisposeTextures?: boolean): void;
  123819. /**
  123820. * Get the current class name of the texture useful for serialization or dynamic coding.
  123821. * @returns "PBRSubSurfaceConfiguration"
  123822. */
  123823. getClassName(): string;
  123824. /**
  123825. * Add fallbacks to the effect fallbacks list.
  123826. * @param defines defines the Base texture to use.
  123827. * @param fallbacks defines the current fallback list.
  123828. * @param currentRank defines the current fallback rank.
  123829. * @returns the new fallback rank.
  123830. */
  123831. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123832. /**
  123833. * Add the required uniforms to the current list.
  123834. * @param uniforms defines the current uniform list.
  123835. */
  123836. static AddUniforms(uniforms: string[]): void;
  123837. /**
  123838. * Add the required samplers to the current list.
  123839. * @param samplers defines the current sampler list.
  123840. */
  123841. static AddSamplers(samplers: string[]): void;
  123842. /**
  123843. * Add the required uniforms to the current buffer.
  123844. * @param uniformBuffer defines the current uniform buffer.
  123845. */
  123846. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123847. /**
  123848. * Makes a duplicate of the current configuration into another one.
  123849. * @param configuration define the config where to copy the info
  123850. */
  123851. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123852. /**
  123853. * Serializes this Sub Surface configuration.
  123854. * @returns - An object with the serialized config.
  123855. */
  123856. serialize(): any;
  123857. /**
  123858. * Parses a anisotropy Configuration from a serialized object.
  123859. * @param source - Serialized object.
  123860. * @param scene Defines the scene we are parsing for
  123861. * @param rootUrl Defines the rootUrl to load from
  123862. */
  123863. parse(source: any, scene: Scene, rootUrl: string): void;
  123864. }
  123865. }
  123866. declare module BABYLON {
  123867. /** @hidden */
  123868. export var pbrFragmentDeclaration: {
  123869. name: string;
  123870. shader: string;
  123871. };
  123872. }
  123873. declare module BABYLON {
  123874. /** @hidden */
  123875. export var pbrUboDeclaration: {
  123876. name: string;
  123877. shader: string;
  123878. };
  123879. }
  123880. declare module BABYLON {
  123881. /** @hidden */
  123882. export var pbrFragmentExtraDeclaration: {
  123883. name: string;
  123884. shader: string;
  123885. };
  123886. }
  123887. declare module BABYLON {
  123888. /** @hidden */
  123889. export var pbrFragmentSamplersDeclaration: {
  123890. name: string;
  123891. shader: string;
  123892. };
  123893. }
  123894. declare module BABYLON {
  123895. /** @hidden */
  123896. export var pbrHelperFunctions: {
  123897. name: string;
  123898. shader: string;
  123899. };
  123900. }
  123901. declare module BABYLON {
  123902. /** @hidden */
  123903. export var harmonicsFunctions: {
  123904. name: string;
  123905. shader: string;
  123906. };
  123907. }
  123908. declare module BABYLON {
  123909. /** @hidden */
  123910. export var pbrDirectLightingSetupFunctions: {
  123911. name: string;
  123912. shader: string;
  123913. };
  123914. }
  123915. declare module BABYLON {
  123916. /** @hidden */
  123917. export var pbrDirectLightingFalloffFunctions: {
  123918. name: string;
  123919. shader: string;
  123920. };
  123921. }
  123922. declare module BABYLON {
  123923. /** @hidden */
  123924. export var pbrBRDFFunctions: {
  123925. name: string;
  123926. shader: string;
  123927. };
  123928. }
  123929. declare module BABYLON {
  123930. /** @hidden */
  123931. export var pbrDirectLightingFunctions: {
  123932. name: string;
  123933. shader: string;
  123934. };
  123935. }
  123936. declare module BABYLON {
  123937. /** @hidden */
  123938. export var pbrIBLFunctions: {
  123939. name: string;
  123940. shader: string;
  123941. };
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export var pbrDebug: {
  123946. name: string;
  123947. shader: string;
  123948. };
  123949. }
  123950. declare module BABYLON {
  123951. /** @hidden */
  123952. export var pbrPixelShader: {
  123953. name: string;
  123954. shader: string;
  123955. };
  123956. }
  123957. declare module BABYLON {
  123958. /** @hidden */
  123959. export var pbrVertexDeclaration: {
  123960. name: string;
  123961. shader: string;
  123962. };
  123963. }
  123964. declare module BABYLON {
  123965. /** @hidden */
  123966. export var pbrVertexShader: {
  123967. name: string;
  123968. shader: string;
  123969. };
  123970. }
  123971. declare module BABYLON {
  123972. /**
  123973. * Manages the defines for the PBR Material.
  123974. * @hidden
  123975. */
  123976. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123977. PBR: boolean;
  123978. MAINUV1: boolean;
  123979. MAINUV2: boolean;
  123980. UV1: boolean;
  123981. UV2: boolean;
  123982. ALBEDO: boolean;
  123983. GAMMAALBEDO: boolean;
  123984. ALBEDODIRECTUV: number;
  123985. VERTEXCOLOR: boolean;
  123986. AMBIENT: boolean;
  123987. AMBIENTDIRECTUV: number;
  123988. AMBIENTINGRAYSCALE: boolean;
  123989. OPACITY: boolean;
  123990. VERTEXALPHA: boolean;
  123991. OPACITYDIRECTUV: number;
  123992. OPACITYRGB: boolean;
  123993. ALPHATEST: boolean;
  123994. DEPTHPREPASS: boolean;
  123995. ALPHABLEND: boolean;
  123996. ALPHAFROMALBEDO: boolean;
  123997. ALPHATESTVALUE: string;
  123998. SPECULAROVERALPHA: boolean;
  123999. RADIANCEOVERALPHA: boolean;
  124000. ALPHAFRESNEL: boolean;
  124001. LINEARALPHAFRESNEL: boolean;
  124002. PREMULTIPLYALPHA: boolean;
  124003. EMISSIVE: boolean;
  124004. EMISSIVEDIRECTUV: number;
  124005. REFLECTIVITY: boolean;
  124006. REFLECTIVITYDIRECTUV: number;
  124007. SPECULARTERM: boolean;
  124008. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124009. MICROSURFACEAUTOMATIC: boolean;
  124010. LODBASEDMICROSFURACE: boolean;
  124011. MICROSURFACEMAP: boolean;
  124012. MICROSURFACEMAPDIRECTUV: number;
  124013. METALLICWORKFLOW: boolean;
  124014. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124015. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124016. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124017. AOSTOREINMETALMAPRED: boolean;
  124018. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124019. ENVIRONMENTBRDF: boolean;
  124020. ENVIRONMENTBRDF_RGBD: boolean;
  124021. NORMAL: boolean;
  124022. TANGENT: boolean;
  124023. BUMP: boolean;
  124024. BUMPDIRECTUV: number;
  124025. OBJECTSPACE_NORMALMAP: boolean;
  124026. PARALLAX: boolean;
  124027. PARALLAXOCCLUSION: boolean;
  124028. NORMALXYSCALE: boolean;
  124029. LIGHTMAP: boolean;
  124030. LIGHTMAPDIRECTUV: number;
  124031. USELIGHTMAPASSHADOWMAP: boolean;
  124032. GAMMALIGHTMAP: boolean;
  124033. RGBDLIGHTMAP: boolean;
  124034. REFLECTION: boolean;
  124035. REFLECTIONMAP_3D: boolean;
  124036. REFLECTIONMAP_SPHERICAL: boolean;
  124037. REFLECTIONMAP_PLANAR: boolean;
  124038. REFLECTIONMAP_CUBIC: boolean;
  124039. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124040. REFLECTIONMAP_PROJECTION: boolean;
  124041. REFLECTIONMAP_SKYBOX: boolean;
  124042. REFLECTIONMAP_EXPLICIT: boolean;
  124043. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124044. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124045. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124046. INVERTCUBICMAP: boolean;
  124047. USESPHERICALFROMREFLECTIONMAP: boolean;
  124048. USEIRRADIANCEMAP: boolean;
  124049. SPHERICAL_HARMONICS: boolean;
  124050. USESPHERICALINVERTEX: boolean;
  124051. REFLECTIONMAP_OPPOSITEZ: boolean;
  124052. LODINREFLECTIONALPHA: boolean;
  124053. GAMMAREFLECTION: boolean;
  124054. RGBDREFLECTION: boolean;
  124055. LINEARSPECULARREFLECTION: boolean;
  124056. RADIANCEOCCLUSION: boolean;
  124057. HORIZONOCCLUSION: boolean;
  124058. INSTANCES: boolean;
  124059. NUM_BONE_INFLUENCERS: number;
  124060. BonesPerMesh: number;
  124061. BONETEXTURE: boolean;
  124062. NONUNIFORMSCALING: boolean;
  124063. MORPHTARGETS: boolean;
  124064. MORPHTARGETS_NORMAL: boolean;
  124065. MORPHTARGETS_TANGENT: boolean;
  124066. MORPHTARGETS_UV: boolean;
  124067. NUM_MORPH_INFLUENCERS: number;
  124068. IMAGEPROCESSING: boolean;
  124069. VIGNETTE: boolean;
  124070. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124071. VIGNETTEBLENDMODEOPAQUE: boolean;
  124072. TONEMAPPING: boolean;
  124073. TONEMAPPING_ACES: boolean;
  124074. CONTRAST: boolean;
  124075. COLORCURVES: boolean;
  124076. COLORGRADING: boolean;
  124077. COLORGRADING3D: boolean;
  124078. SAMPLER3DGREENDEPTH: boolean;
  124079. SAMPLER3DBGRMAP: boolean;
  124080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124081. EXPOSURE: boolean;
  124082. MULTIVIEW: boolean;
  124083. USEPHYSICALLIGHTFALLOFF: boolean;
  124084. USEGLTFLIGHTFALLOFF: boolean;
  124085. TWOSIDEDLIGHTING: boolean;
  124086. SHADOWFLOAT: boolean;
  124087. CLIPPLANE: boolean;
  124088. CLIPPLANE2: boolean;
  124089. CLIPPLANE3: boolean;
  124090. CLIPPLANE4: boolean;
  124091. CLIPPLANE5: boolean;
  124092. CLIPPLANE6: boolean;
  124093. POINTSIZE: boolean;
  124094. FOG: boolean;
  124095. LOGARITHMICDEPTH: boolean;
  124096. FORCENORMALFORWARD: boolean;
  124097. SPECULARAA: boolean;
  124098. CLEARCOAT: boolean;
  124099. CLEARCOAT_DEFAULTIOR: boolean;
  124100. CLEARCOAT_TEXTURE: boolean;
  124101. CLEARCOAT_TEXTUREDIRECTUV: number;
  124102. CLEARCOAT_BUMP: boolean;
  124103. CLEARCOAT_BUMPDIRECTUV: number;
  124104. CLEARCOAT_TINT: boolean;
  124105. CLEARCOAT_TINT_TEXTURE: boolean;
  124106. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124107. ANISOTROPIC: boolean;
  124108. ANISOTROPIC_TEXTURE: boolean;
  124109. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124110. BRDF_V_HEIGHT_CORRELATED: boolean;
  124111. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124112. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124113. SHEEN: boolean;
  124114. SHEEN_TEXTURE: boolean;
  124115. SHEEN_TEXTUREDIRECTUV: number;
  124116. SHEEN_LINKWITHALBEDO: boolean;
  124117. SUBSURFACE: boolean;
  124118. SS_REFRACTION: boolean;
  124119. SS_TRANSLUCENCY: boolean;
  124120. SS_SCATERRING: boolean;
  124121. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124122. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124123. SS_REFRACTIONMAP_3D: boolean;
  124124. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124125. SS_LODINREFRACTIONALPHA: boolean;
  124126. SS_GAMMAREFRACTION: boolean;
  124127. SS_RGBDREFRACTION: boolean;
  124128. SS_LINEARSPECULARREFRACTION: boolean;
  124129. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124130. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124131. UNLIT: boolean;
  124132. DEBUGMODE: number;
  124133. /**
  124134. * Initializes the PBR Material defines.
  124135. */
  124136. constructor();
  124137. /**
  124138. * Resets the PBR Material defines.
  124139. */
  124140. reset(): void;
  124141. }
  124142. /**
  124143. * The Physically based material base class of BJS.
  124144. *
  124145. * This offers the main features of a standard PBR material.
  124146. * For more information, please refer to the documentation :
  124147. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124148. */
  124149. export abstract class PBRBaseMaterial extends PushMaterial {
  124150. /**
  124151. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124152. */
  124153. static readonly PBRMATERIAL_OPAQUE: number;
  124154. /**
  124155. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124156. */
  124157. static readonly PBRMATERIAL_ALPHATEST: number;
  124158. /**
  124159. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124160. */
  124161. static readonly PBRMATERIAL_ALPHABLEND: number;
  124162. /**
  124163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124164. * They are also discarded below the alpha cutoff threshold to improve performances.
  124165. */
  124166. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124167. /**
  124168. * Defines the default value of how much AO map is occluding the analytical lights
  124169. * (point spot...).
  124170. */
  124171. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124172. /**
  124173. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124174. */
  124175. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124176. /**
  124177. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124178. * to enhance interoperability with other engines.
  124179. */
  124180. static readonly LIGHTFALLOFF_GLTF: number;
  124181. /**
  124182. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124183. * to enhance interoperability with other materials.
  124184. */
  124185. static readonly LIGHTFALLOFF_STANDARD: number;
  124186. /**
  124187. * Intensity of the direct lights e.g. the four lights available in your scene.
  124188. * This impacts both the direct diffuse and specular highlights.
  124189. */
  124190. protected _directIntensity: number;
  124191. /**
  124192. * Intensity of the emissive part of the material.
  124193. * This helps controlling the emissive effect without modifying the emissive color.
  124194. */
  124195. protected _emissiveIntensity: number;
  124196. /**
  124197. * Intensity of the environment e.g. how much the environment will light the object
  124198. * either through harmonics for rough material or through the refelction for shiny ones.
  124199. */
  124200. protected _environmentIntensity: number;
  124201. /**
  124202. * This is a special control allowing the reduction of the specular highlights coming from the
  124203. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124204. */
  124205. protected _specularIntensity: number;
  124206. /**
  124207. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124208. */
  124209. private _lightingInfos;
  124210. /**
  124211. * Debug Control allowing disabling the bump map on this material.
  124212. */
  124213. protected _disableBumpMap: boolean;
  124214. /**
  124215. * AKA Diffuse Texture in standard nomenclature.
  124216. */
  124217. protected _albedoTexture: Nullable<BaseTexture>;
  124218. /**
  124219. * AKA Occlusion Texture in other nomenclature.
  124220. */
  124221. protected _ambientTexture: Nullable<BaseTexture>;
  124222. /**
  124223. * AKA Occlusion Texture Intensity in other nomenclature.
  124224. */
  124225. protected _ambientTextureStrength: number;
  124226. /**
  124227. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124228. * 1 means it completely occludes it
  124229. * 0 mean it has no impact
  124230. */
  124231. protected _ambientTextureImpactOnAnalyticalLights: number;
  124232. /**
  124233. * Stores the alpha values in a texture.
  124234. */
  124235. protected _opacityTexture: Nullable<BaseTexture>;
  124236. /**
  124237. * Stores the reflection values in a texture.
  124238. */
  124239. protected _reflectionTexture: Nullable<BaseTexture>;
  124240. /**
  124241. * Stores the emissive values in a texture.
  124242. */
  124243. protected _emissiveTexture: Nullable<BaseTexture>;
  124244. /**
  124245. * AKA Specular texture in other nomenclature.
  124246. */
  124247. protected _reflectivityTexture: Nullable<BaseTexture>;
  124248. /**
  124249. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124250. */
  124251. protected _metallicTexture: Nullable<BaseTexture>;
  124252. /**
  124253. * Specifies the metallic scalar of the metallic/roughness workflow.
  124254. * Can also be used to scale the metalness values of the metallic texture.
  124255. */
  124256. protected _metallic: Nullable<number>;
  124257. /**
  124258. * Specifies the roughness scalar of the metallic/roughness workflow.
  124259. * Can also be used to scale the roughness values of the metallic texture.
  124260. */
  124261. protected _roughness: Nullable<number>;
  124262. /**
  124263. * Specifies the an F0 factor to help configuring the material F0.
  124264. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124265. * to 0.5 the previously hard coded value stays the same.
  124266. * Can also be used to scale the F0 values of the metallic texture.
  124267. */
  124268. protected _metallicF0Factor: number;
  124269. /**
  124270. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124271. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124272. * your expectation as it multiplies with the texture data.
  124273. */
  124274. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124275. /**
  124276. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124277. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124278. */
  124279. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124280. /**
  124281. * Stores surface normal data used to displace a mesh in a texture.
  124282. */
  124283. protected _bumpTexture: Nullable<BaseTexture>;
  124284. /**
  124285. * Stores the pre-calculated light information of a mesh in a texture.
  124286. */
  124287. protected _lightmapTexture: Nullable<BaseTexture>;
  124288. /**
  124289. * The color of a material in ambient lighting.
  124290. */
  124291. protected _ambientColor: Color3;
  124292. /**
  124293. * AKA Diffuse Color in other nomenclature.
  124294. */
  124295. protected _albedoColor: Color3;
  124296. /**
  124297. * AKA Specular Color in other nomenclature.
  124298. */
  124299. protected _reflectivityColor: Color3;
  124300. /**
  124301. * The color applied when light is reflected from a material.
  124302. */
  124303. protected _reflectionColor: Color3;
  124304. /**
  124305. * The color applied when light is emitted from a material.
  124306. */
  124307. protected _emissiveColor: Color3;
  124308. /**
  124309. * AKA Glossiness in other nomenclature.
  124310. */
  124311. protected _microSurface: number;
  124312. /**
  124313. * Specifies that the material will use the light map as a show map.
  124314. */
  124315. protected _useLightmapAsShadowmap: boolean;
  124316. /**
  124317. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124318. * makes the reflect vector face the model (under horizon).
  124319. */
  124320. protected _useHorizonOcclusion: boolean;
  124321. /**
  124322. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124323. * too much the area relying on ambient texture to define their ambient occlusion.
  124324. */
  124325. protected _useRadianceOcclusion: boolean;
  124326. /**
  124327. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124328. */
  124329. protected _useAlphaFromAlbedoTexture: boolean;
  124330. /**
  124331. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124332. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124333. */
  124334. protected _useSpecularOverAlpha: boolean;
  124335. /**
  124336. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124337. */
  124338. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124339. /**
  124340. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124341. */
  124342. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124343. /**
  124344. * Specifies if the metallic texture contains the roughness information in its green channel.
  124345. */
  124346. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124347. /**
  124348. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124349. */
  124350. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124351. /**
  124352. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124353. */
  124354. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124355. /**
  124356. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124357. */
  124358. protected _useAmbientInGrayScale: boolean;
  124359. /**
  124360. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124361. * The material will try to infer what glossiness each pixel should be.
  124362. */
  124363. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124364. /**
  124365. * Defines the falloff type used in this material.
  124366. * It by default is Physical.
  124367. */
  124368. protected _lightFalloff: number;
  124369. /**
  124370. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124371. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124372. */
  124373. protected _useRadianceOverAlpha: boolean;
  124374. /**
  124375. * Allows using an object space normal map (instead of tangent space).
  124376. */
  124377. protected _useObjectSpaceNormalMap: boolean;
  124378. /**
  124379. * Allows using the bump map in parallax mode.
  124380. */
  124381. protected _useParallax: boolean;
  124382. /**
  124383. * Allows using the bump map in parallax occlusion mode.
  124384. */
  124385. protected _useParallaxOcclusion: boolean;
  124386. /**
  124387. * Controls the scale bias of the parallax mode.
  124388. */
  124389. protected _parallaxScaleBias: number;
  124390. /**
  124391. * If sets to true, disables all the lights affecting the material.
  124392. */
  124393. protected _disableLighting: boolean;
  124394. /**
  124395. * Number of Simultaneous lights allowed on the material.
  124396. */
  124397. protected _maxSimultaneousLights: number;
  124398. /**
  124399. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124400. */
  124401. protected _invertNormalMapX: boolean;
  124402. /**
  124403. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124404. */
  124405. protected _invertNormalMapY: boolean;
  124406. /**
  124407. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124408. */
  124409. protected _twoSidedLighting: boolean;
  124410. /**
  124411. * Defines the alpha limits in alpha test mode.
  124412. */
  124413. protected _alphaCutOff: number;
  124414. /**
  124415. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124416. */
  124417. protected _forceAlphaTest: boolean;
  124418. /**
  124419. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124420. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124421. */
  124422. protected _useAlphaFresnel: boolean;
  124423. /**
  124424. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124425. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124426. */
  124427. protected _useLinearAlphaFresnel: boolean;
  124428. /**
  124429. * The transparency mode of the material.
  124430. */
  124431. protected _transparencyMode: Nullable<number>;
  124432. /**
  124433. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124434. * from cos thetav and roughness:
  124435. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124436. */
  124437. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124438. /**
  124439. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124440. */
  124441. protected _forceIrradianceInFragment: boolean;
  124442. /**
  124443. * Force normal to face away from face.
  124444. */
  124445. protected _forceNormalForward: boolean;
  124446. /**
  124447. * Enables specular anti aliasing in the PBR shader.
  124448. * It will both interacts on the Geometry for analytical and IBL lighting.
  124449. * It also prefilter the roughness map based on the bump values.
  124450. */
  124451. protected _enableSpecularAntiAliasing: boolean;
  124452. /**
  124453. * Default configuration related to image processing available in the PBR Material.
  124454. */
  124455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124456. /**
  124457. * Keep track of the image processing observer to allow dispose and replace.
  124458. */
  124459. private _imageProcessingObserver;
  124460. /**
  124461. * Attaches a new image processing configuration to the PBR Material.
  124462. * @param configuration
  124463. */
  124464. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124465. /**
  124466. * Stores the available render targets.
  124467. */
  124468. private _renderTargets;
  124469. /**
  124470. * Sets the global ambient color for the material used in lighting calculations.
  124471. */
  124472. private _globalAmbientColor;
  124473. /**
  124474. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124475. */
  124476. private _useLogarithmicDepth;
  124477. /**
  124478. * If set to true, no lighting calculations will be applied.
  124479. */
  124480. private _unlit;
  124481. private _debugMode;
  124482. /**
  124483. * @hidden
  124484. * This is reserved for the inspector.
  124485. * Defines the material debug mode.
  124486. * It helps seeing only some components of the material while troubleshooting.
  124487. */
  124488. debugMode: number;
  124489. /**
  124490. * @hidden
  124491. * This is reserved for the inspector.
  124492. * Specify from where on screen the debug mode should start.
  124493. * The value goes from -1 (full screen) to 1 (not visible)
  124494. * It helps with side by side comparison against the final render
  124495. * This defaults to -1
  124496. */
  124497. private debugLimit;
  124498. /**
  124499. * @hidden
  124500. * This is reserved for the inspector.
  124501. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124502. * You can use the factor to better multiply the final value.
  124503. */
  124504. private debugFactor;
  124505. /**
  124506. * Defines the clear coat layer parameters for the material.
  124507. */
  124508. readonly clearCoat: PBRClearCoatConfiguration;
  124509. /**
  124510. * Defines the anisotropic parameters for the material.
  124511. */
  124512. readonly anisotropy: PBRAnisotropicConfiguration;
  124513. /**
  124514. * Defines the BRDF parameters for the material.
  124515. */
  124516. readonly brdf: PBRBRDFConfiguration;
  124517. /**
  124518. * Defines the Sheen parameters for the material.
  124519. */
  124520. readonly sheen: PBRSheenConfiguration;
  124521. /**
  124522. * Defines the SubSurface parameters for the material.
  124523. */
  124524. readonly subSurface: PBRSubSurfaceConfiguration;
  124525. /**
  124526. * Custom callback helping to override the default shader used in the material.
  124527. */
  124528. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124529. protected _rebuildInParallel: boolean;
  124530. /**
  124531. * Instantiates a new PBRMaterial instance.
  124532. *
  124533. * @param name The material name
  124534. * @param scene The scene the material will be use in.
  124535. */
  124536. constructor(name: string, scene: Scene);
  124537. /**
  124538. * Gets a boolean indicating that current material needs to register RTT
  124539. */
  124540. get hasRenderTargetTextures(): boolean;
  124541. /**
  124542. * Gets the name of the material class.
  124543. */
  124544. getClassName(): string;
  124545. /**
  124546. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124547. */
  124548. get useLogarithmicDepth(): boolean;
  124549. /**
  124550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124551. */
  124552. set useLogarithmicDepth(value: boolean);
  124553. /**
  124554. * Gets the current transparency mode.
  124555. */
  124556. get transparencyMode(): Nullable<number>;
  124557. /**
  124558. * Sets the transparency mode of the material.
  124559. *
  124560. * | Value | Type | Description |
  124561. * | ----- | ----------------------------------- | ----------- |
  124562. * | 0 | OPAQUE | |
  124563. * | 1 | ALPHATEST | |
  124564. * | 2 | ALPHABLEND | |
  124565. * | 3 | ALPHATESTANDBLEND | |
  124566. *
  124567. */
  124568. set transparencyMode(value: Nullable<number>);
  124569. /**
  124570. * Returns true if alpha blending should be disabled.
  124571. */
  124572. private get _disableAlphaBlending();
  124573. /**
  124574. * Specifies whether or not this material should be rendered in alpha blend mode.
  124575. */
  124576. needAlphaBlending(): boolean;
  124577. /**
  124578. * Specifies if the mesh will require alpha blending.
  124579. * @param mesh - BJS mesh.
  124580. */
  124581. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124582. /**
  124583. * Specifies whether or not this material should be rendered in alpha test mode.
  124584. */
  124585. needAlphaTesting(): boolean;
  124586. /**
  124587. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124588. */
  124589. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124590. /**
  124591. * Gets the texture used for the alpha test.
  124592. */
  124593. getAlphaTestTexture(): Nullable<BaseTexture>;
  124594. /**
  124595. * Specifies that the submesh is ready to be used.
  124596. * @param mesh - BJS mesh.
  124597. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124598. * @param useInstances - Specifies that instances should be used.
  124599. * @returns - boolean indicating that the submesh is ready or not.
  124600. */
  124601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124602. /**
  124603. * Specifies if the material uses metallic roughness workflow.
  124604. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124605. */
  124606. isMetallicWorkflow(): boolean;
  124607. private _prepareEffect;
  124608. private _prepareDefines;
  124609. /**
  124610. * Force shader compilation
  124611. */
  124612. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124613. /**
  124614. * Initializes the uniform buffer layout for the shader.
  124615. */
  124616. buildUniformLayout(): void;
  124617. /**
  124618. * Unbinds the material from the mesh
  124619. */
  124620. unbind(): void;
  124621. /**
  124622. * Binds the submesh data.
  124623. * @param world - The world matrix.
  124624. * @param mesh - The BJS mesh.
  124625. * @param subMesh - A submesh of the BJS mesh.
  124626. */
  124627. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124628. /**
  124629. * Returns the animatable textures.
  124630. * @returns - Array of animatable textures.
  124631. */
  124632. getAnimatables(): IAnimatable[];
  124633. /**
  124634. * Returns the texture used for reflections.
  124635. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124636. */
  124637. private _getReflectionTexture;
  124638. /**
  124639. * Returns an array of the actively used textures.
  124640. * @returns - Array of BaseTextures
  124641. */
  124642. getActiveTextures(): BaseTexture[];
  124643. /**
  124644. * Checks to see if a texture is used in the material.
  124645. * @param texture - Base texture to use.
  124646. * @returns - Boolean specifying if a texture is used in the material.
  124647. */
  124648. hasTexture(texture: BaseTexture): boolean;
  124649. /**
  124650. * Disposes the resources of the material.
  124651. * @param forceDisposeEffect - Forces the disposal of effects.
  124652. * @param forceDisposeTextures - Forces the disposal of all textures.
  124653. */
  124654. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124655. }
  124656. }
  124657. declare module BABYLON {
  124658. /**
  124659. * The Physically based material of BJS.
  124660. *
  124661. * This offers the main features of a standard PBR material.
  124662. * For more information, please refer to the documentation :
  124663. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124664. */
  124665. export class PBRMaterial extends PBRBaseMaterial {
  124666. /**
  124667. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124668. */
  124669. static readonly PBRMATERIAL_OPAQUE: number;
  124670. /**
  124671. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124672. */
  124673. static readonly PBRMATERIAL_ALPHATEST: number;
  124674. /**
  124675. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124676. */
  124677. static readonly PBRMATERIAL_ALPHABLEND: number;
  124678. /**
  124679. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124680. * They are also discarded below the alpha cutoff threshold to improve performances.
  124681. */
  124682. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124683. /**
  124684. * Defines the default value of how much AO map is occluding the analytical lights
  124685. * (point spot...).
  124686. */
  124687. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124688. /**
  124689. * Intensity of the direct lights e.g. the four lights available in your scene.
  124690. * This impacts both the direct diffuse and specular highlights.
  124691. */
  124692. directIntensity: number;
  124693. /**
  124694. * Intensity of the emissive part of the material.
  124695. * This helps controlling the emissive effect without modifying the emissive color.
  124696. */
  124697. emissiveIntensity: number;
  124698. /**
  124699. * Intensity of the environment e.g. how much the environment will light the object
  124700. * either through harmonics for rough material or through the refelction for shiny ones.
  124701. */
  124702. environmentIntensity: number;
  124703. /**
  124704. * This is a special control allowing the reduction of the specular highlights coming from the
  124705. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124706. */
  124707. specularIntensity: number;
  124708. /**
  124709. * Debug Control allowing disabling the bump map on this material.
  124710. */
  124711. disableBumpMap: boolean;
  124712. /**
  124713. * AKA Diffuse Texture in standard nomenclature.
  124714. */
  124715. albedoTexture: BaseTexture;
  124716. /**
  124717. * AKA Occlusion Texture in other nomenclature.
  124718. */
  124719. ambientTexture: BaseTexture;
  124720. /**
  124721. * AKA Occlusion Texture Intensity in other nomenclature.
  124722. */
  124723. ambientTextureStrength: number;
  124724. /**
  124725. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124726. * 1 means it completely occludes it
  124727. * 0 mean it has no impact
  124728. */
  124729. ambientTextureImpactOnAnalyticalLights: number;
  124730. /**
  124731. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124732. */
  124733. opacityTexture: BaseTexture;
  124734. /**
  124735. * Stores the reflection values in a texture.
  124736. */
  124737. reflectionTexture: Nullable<BaseTexture>;
  124738. /**
  124739. * Stores the emissive values in a texture.
  124740. */
  124741. emissiveTexture: BaseTexture;
  124742. /**
  124743. * AKA Specular texture in other nomenclature.
  124744. */
  124745. reflectivityTexture: BaseTexture;
  124746. /**
  124747. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124748. */
  124749. metallicTexture: BaseTexture;
  124750. /**
  124751. * Specifies the metallic scalar of the metallic/roughness workflow.
  124752. * Can also be used to scale the metalness values of the metallic texture.
  124753. */
  124754. metallic: Nullable<number>;
  124755. /**
  124756. * Specifies the roughness scalar of the metallic/roughness workflow.
  124757. * Can also be used to scale the roughness values of the metallic texture.
  124758. */
  124759. roughness: Nullable<number>;
  124760. /**
  124761. * Specifies the an F0 factor to help configuring the material F0.
  124762. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124763. * to 0.5 the previously hard coded value stays the same.
  124764. * Can also be used to scale the F0 values of the metallic texture.
  124765. */
  124766. metallicF0Factor: number;
  124767. /**
  124768. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124769. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124770. * your expectation as it multiplies with the texture data.
  124771. */
  124772. useMetallicF0FactorFromMetallicTexture: boolean;
  124773. /**
  124774. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124775. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124776. */
  124777. microSurfaceTexture: BaseTexture;
  124778. /**
  124779. * Stores surface normal data used to displace a mesh in a texture.
  124780. */
  124781. bumpTexture: BaseTexture;
  124782. /**
  124783. * Stores the pre-calculated light information of a mesh in a texture.
  124784. */
  124785. lightmapTexture: BaseTexture;
  124786. /**
  124787. * Stores the refracted light information in a texture.
  124788. */
  124789. get refractionTexture(): Nullable<BaseTexture>;
  124790. set refractionTexture(value: Nullable<BaseTexture>);
  124791. /**
  124792. * The color of a material in ambient lighting.
  124793. */
  124794. ambientColor: Color3;
  124795. /**
  124796. * AKA Diffuse Color in other nomenclature.
  124797. */
  124798. albedoColor: Color3;
  124799. /**
  124800. * AKA Specular Color in other nomenclature.
  124801. */
  124802. reflectivityColor: Color3;
  124803. /**
  124804. * The color reflected from the material.
  124805. */
  124806. reflectionColor: Color3;
  124807. /**
  124808. * The color emitted from the material.
  124809. */
  124810. emissiveColor: Color3;
  124811. /**
  124812. * AKA Glossiness in other nomenclature.
  124813. */
  124814. microSurface: number;
  124815. /**
  124816. * source material index of refraction (IOR)' / 'destination material IOR.
  124817. */
  124818. get indexOfRefraction(): number;
  124819. set indexOfRefraction(value: number);
  124820. /**
  124821. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124822. */
  124823. get invertRefractionY(): boolean;
  124824. set invertRefractionY(value: boolean);
  124825. /**
  124826. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124827. * Materials half opaque for instance using refraction could benefit from this control.
  124828. */
  124829. get linkRefractionWithTransparency(): boolean;
  124830. set linkRefractionWithTransparency(value: boolean);
  124831. /**
  124832. * If true, the light map contains occlusion information instead of lighting info.
  124833. */
  124834. useLightmapAsShadowmap: boolean;
  124835. /**
  124836. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124837. */
  124838. useAlphaFromAlbedoTexture: boolean;
  124839. /**
  124840. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124841. */
  124842. forceAlphaTest: boolean;
  124843. /**
  124844. * Defines the alpha limits in alpha test mode.
  124845. */
  124846. alphaCutOff: number;
  124847. /**
  124848. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124849. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124850. */
  124851. useSpecularOverAlpha: boolean;
  124852. /**
  124853. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124854. */
  124855. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124856. /**
  124857. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124858. */
  124859. useRoughnessFromMetallicTextureAlpha: boolean;
  124860. /**
  124861. * Specifies if the metallic texture contains the roughness information in its green channel.
  124862. */
  124863. useRoughnessFromMetallicTextureGreen: boolean;
  124864. /**
  124865. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124866. */
  124867. useMetallnessFromMetallicTextureBlue: boolean;
  124868. /**
  124869. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124870. */
  124871. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124872. /**
  124873. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124874. */
  124875. useAmbientInGrayScale: boolean;
  124876. /**
  124877. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124878. * The material will try to infer what glossiness each pixel should be.
  124879. */
  124880. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124881. /**
  124882. * BJS is using an harcoded light falloff based on a manually sets up range.
  124883. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124884. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124885. */
  124886. get usePhysicalLightFalloff(): boolean;
  124887. /**
  124888. * BJS is using an harcoded light falloff based on a manually sets up range.
  124889. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124890. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124891. */
  124892. set usePhysicalLightFalloff(value: boolean);
  124893. /**
  124894. * In order to support the falloff compatibility with gltf, a special mode has been added
  124895. * to reproduce the gltf light falloff.
  124896. */
  124897. get useGLTFLightFalloff(): boolean;
  124898. /**
  124899. * In order to support the falloff compatibility with gltf, a special mode has been added
  124900. * to reproduce the gltf light falloff.
  124901. */
  124902. set useGLTFLightFalloff(value: boolean);
  124903. /**
  124904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124906. */
  124907. useRadianceOverAlpha: boolean;
  124908. /**
  124909. * Allows using an object space normal map (instead of tangent space).
  124910. */
  124911. useObjectSpaceNormalMap: boolean;
  124912. /**
  124913. * Allows using the bump map in parallax mode.
  124914. */
  124915. useParallax: boolean;
  124916. /**
  124917. * Allows using the bump map in parallax occlusion mode.
  124918. */
  124919. useParallaxOcclusion: boolean;
  124920. /**
  124921. * Controls the scale bias of the parallax mode.
  124922. */
  124923. parallaxScaleBias: number;
  124924. /**
  124925. * If sets to true, disables all the lights affecting the material.
  124926. */
  124927. disableLighting: boolean;
  124928. /**
  124929. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124930. */
  124931. forceIrradianceInFragment: boolean;
  124932. /**
  124933. * Number of Simultaneous lights allowed on the material.
  124934. */
  124935. maxSimultaneousLights: number;
  124936. /**
  124937. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124938. */
  124939. invertNormalMapX: boolean;
  124940. /**
  124941. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124942. */
  124943. invertNormalMapY: boolean;
  124944. /**
  124945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124946. */
  124947. twoSidedLighting: boolean;
  124948. /**
  124949. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124950. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124951. */
  124952. useAlphaFresnel: boolean;
  124953. /**
  124954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124955. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124956. */
  124957. useLinearAlphaFresnel: boolean;
  124958. /**
  124959. * Let user defines the brdf lookup texture used for IBL.
  124960. * A default 8bit version is embedded but you could point at :
  124961. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124962. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124963. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124964. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124965. */
  124966. environmentBRDFTexture: Nullable<BaseTexture>;
  124967. /**
  124968. * Force normal to face away from face.
  124969. */
  124970. forceNormalForward: boolean;
  124971. /**
  124972. * Enables specular anti aliasing in the PBR shader.
  124973. * It will both interacts on the Geometry for analytical and IBL lighting.
  124974. * It also prefilter the roughness map based on the bump values.
  124975. */
  124976. enableSpecularAntiAliasing: boolean;
  124977. /**
  124978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124979. * makes the reflect vector face the model (under horizon).
  124980. */
  124981. useHorizonOcclusion: boolean;
  124982. /**
  124983. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124984. * too much the area relying on ambient texture to define their ambient occlusion.
  124985. */
  124986. useRadianceOcclusion: boolean;
  124987. /**
  124988. * If set to true, no lighting calculations will be applied.
  124989. */
  124990. unlit: boolean;
  124991. /**
  124992. * Gets the image processing configuration used either in this material.
  124993. */
  124994. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124995. /**
  124996. * Sets the Default image processing configuration used either in the this material.
  124997. *
  124998. * If sets to null, the scene one is in use.
  124999. */
  125000. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125001. /**
  125002. * Gets wether the color curves effect is enabled.
  125003. */
  125004. get cameraColorCurvesEnabled(): boolean;
  125005. /**
  125006. * Sets wether the color curves effect is enabled.
  125007. */
  125008. set cameraColorCurvesEnabled(value: boolean);
  125009. /**
  125010. * Gets wether the color grading effect is enabled.
  125011. */
  125012. get cameraColorGradingEnabled(): boolean;
  125013. /**
  125014. * Gets wether the color grading effect is enabled.
  125015. */
  125016. set cameraColorGradingEnabled(value: boolean);
  125017. /**
  125018. * Gets wether tonemapping is enabled or not.
  125019. */
  125020. get cameraToneMappingEnabled(): boolean;
  125021. /**
  125022. * Sets wether tonemapping is enabled or not
  125023. */
  125024. set cameraToneMappingEnabled(value: boolean);
  125025. /**
  125026. * The camera exposure used on this material.
  125027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125028. * This corresponds to a photographic exposure.
  125029. */
  125030. get cameraExposure(): number;
  125031. /**
  125032. * The camera exposure used on this material.
  125033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125034. * This corresponds to a photographic exposure.
  125035. */
  125036. set cameraExposure(value: number);
  125037. /**
  125038. * Gets The camera contrast used on this material.
  125039. */
  125040. get cameraContrast(): number;
  125041. /**
  125042. * Sets The camera contrast used on this material.
  125043. */
  125044. set cameraContrast(value: number);
  125045. /**
  125046. * Gets the Color Grading 2D Lookup Texture.
  125047. */
  125048. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125049. /**
  125050. * Sets the Color Grading 2D Lookup Texture.
  125051. */
  125052. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125053. /**
  125054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125056. * 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;
  125057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125058. */
  125059. get cameraColorCurves(): Nullable<ColorCurves>;
  125060. /**
  125061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125063. * 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;
  125064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125065. */
  125066. set cameraColorCurves(value: Nullable<ColorCurves>);
  125067. /**
  125068. * Instantiates a new PBRMaterial instance.
  125069. *
  125070. * @param name The material name
  125071. * @param scene The scene the material will be use in.
  125072. */
  125073. constructor(name: string, scene: Scene);
  125074. /**
  125075. * Returns the name of this material class.
  125076. */
  125077. getClassName(): string;
  125078. /**
  125079. * Makes a duplicate of the current material.
  125080. * @param name - name to use for the new material.
  125081. */
  125082. clone(name: string): PBRMaterial;
  125083. /**
  125084. * Serializes this PBR Material.
  125085. * @returns - An object with the serialized material.
  125086. */
  125087. serialize(): any;
  125088. /**
  125089. * Parses a PBR Material from a serialized object.
  125090. * @param source - Serialized object.
  125091. * @param scene - BJS scene instance.
  125092. * @param rootUrl - url for the scene object
  125093. * @returns - PBRMaterial
  125094. */
  125095. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125096. }
  125097. }
  125098. declare module BABYLON {
  125099. /**
  125100. * Direct draw surface info
  125101. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125102. */
  125103. export interface DDSInfo {
  125104. /**
  125105. * Width of the texture
  125106. */
  125107. width: number;
  125108. /**
  125109. * Width of the texture
  125110. */
  125111. height: number;
  125112. /**
  125113. * Number of Mipmaps for the texture
  125114. * @see https://en.wikipedia.org/wiki/Mipmap
  125115. */
  125116. mipmapCount: number;
  125117. /**
  125118. * If the textures format is a known fourCC format
  125119. * @see https://www.fourcc.org/
  125120. */
  125121. isFourCC: boolean;
  125122. /**
  125123. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125124. */
  125125. isRGB: boolean;
  125126. /**
  125127. * If the texture is a lumincance format
  125128. */
  125129. isLuminance: boolean;
  125130. /**
  125131. * If this is a cube texture
  125132. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125133. */
  125134. isCube: boolean;
  125135. /**
  125136. * If the texture is a compressed format eg. FOURCC_DXT1
  125137. */
  125138. isCompressed: boolean;
  125139. /**
  125140. * The dxgiFormat of the texture
  125141. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125142. */
  125143. dxgiFormat: number;
  125144. /**
  125145. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125146. */
  125147. textureType: number;
  125148. /**
  125149. * Sphericle polynomial created for the dds texture
  125150. */
  125151. sphericalPolynomial?: SphericalPolynomial;
  125152. }
  125153. /**
  125154. * Class used to provide DDS decompression tools
  125155. */
  125156. export class DDSTools {
  125157. /**
  125158. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125159. */
  125160. static StoreLODInAlphaChannel: boolean;
  125161. /**
  125162. * Gets DDS information from an array buffer
  125163. * @param data defines the array buffer view to read data from
  125164. * @returns the DDS information
  125165. */
  125166. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125167. private static _FloatView;
  125168. private static _Int32View;
  125169. private static _ToHalfFloat;
  125170. private static _FromHalfFloat;
  125171. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125172. private static _GetHalfFloatRGBAArrayBuffer;
  125173. private static _GetFloatRGBAArrayBuffer;
  125174. private static _GetFloatAsUIntRGBAArrayBuffer;
  125175. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125176. private static _GetRGBAArrayBuffer;
  125177. private static _ExtractLongWordOrder;
  125178. private static _GetRGBArrayBuffer;
  125179. private static _GetLuminanceArrayBuffer;
  125180. /**
  125181. * Uploads DDS Levels to a Babylon Texture
  125182. * @hidden
  125183. */
  125184. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125185. }
  125186. interface ThinEngine {
  125187. /**
  125188. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125189. * @param rootUrl defines the url where the file to load is located
  125190. * @param scene defines the current scene
  125191. * @param lodScale defines scale to apply to the mip map selection
  125192. * @param lodOffset defines offset to apply to the mip map selection
  125193. * @param onLoad defines an optional callback raised when the texture is loaded
  125194. * @param onError defines an optional callback raised if there is an issue to load the texture
  125195. * @param format defines the format of the data
  125196. * @param forcedExtension defines the extension to use to pick the right loader
  125197. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125198. * @returns the cube texture as an InternalTexture
  125199. */
  125200. 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;
  125201. }
  125202. }
  125203. declare module BABYLON {
  125204. /**
  125205. * Implementation of the DDS Texture Loader.
  125206. * @hidden
  125207. */
  125208. export class _DDSTextureLoader implements IInternalTextureLoader {
  125209. /**
  125210. * Defines wether the loader supports cascade loading the different faces.
  125211. */
  125212. readonly supportCascades: boolean;
  125213. /**
  125214. * This returns if the loader support the current file information.
  125215. * @param extension defines the file extension of the file being loaded
  125216. * @returns true if the loader can load the specified file
  125217. */
  125218. canLoad(extension: string): boolean;
  125219. /**
  125220. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125221. * @param data contains the texture data
  125222. * @param texture defines the BabylonJS internal texture
  125223. * @param createPolynomials will be true if polynomials have been requested
  125224. * @param onLoad defines the callback to trigger once the texture is ready
  125225. * @param onError defines the callback to trigger in case of error
  125226. */
  125227. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125228. /**
  125229. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125230. * @param data contains the texture data
  125231. * @param texture defines the BabylonJS internal texture
  125232. * @param callback defines the method to call once ready to upload
  125233. */
  125234. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125235. }
  125236. }
  125237. declare module BABYLON {
  125238. /**
  125239. * Implementation of the ENV Texture Loader.
  125240. * @hidden
  125241. */
  125242. export class _ENVTextureLoader implements IInternalTextureLoader {
  125243. /**
  125244. * Defines wether the loader supports cascade loading the different faces.
  125245. */
  125246. readonly supportCascades: boolean;
  125247. /**
  125248. * This returns if the loader support the current file information.
  125249. * @param extension defines the file extension of the file being loaded
  125250. * @returns true if the loader can load the specified file
  125251. */
  125252. canLoad(extension: string): boolean;
  125253. /**
  125254. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125255. * @param data contains the texture data
  125256. * @param texture defines the BabylonJS internal texture
  125257. * @param createPolynomials will be true if polynomials have been requested
  125258. * @param onLoad defines the callback to trigger once the texture is ready
  125259. * @param onError defines the callback to trigger in case of error
  125260. */
  125261. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125262. /**
  125263. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125264. * @param data contains the texture data
  125265. * @param texture defines the BabylonJS internal texture
  125266. * @param callback defines the method to call once ready to upload
  125267. */
  125268. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125269. }
  125270. }
  125271. declare module BABYLON {
  125272. /**
  125273. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125274. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125275. */
  125276. export class KhronosTextureContainer {
  125277. /** contents of the KTX container file */
  125278. data: ArrayBufferView;
  125279. private static HEADER_LEN;
  125280. private static COMPRESSED_2D;
  125281. private static COMPRESSED_3D;
  125282. private static TEX_2D;
  125283. private static TEX_3D;
  125284. /**
  125285. * Gets the openGL type
  125286. */
  125287. glType: number;
  125288. /**
  125289. * Gets the openGL type size
  125290. */
  125291. glTypeSize: number;
  125292. /**
  125293. * Gets the openGL format
  125294. */
  125295. glFormat: number;
  125296. /**
  125297. * Gets the openGL internal format
  125298. */
  125299. glInternalFormat: number;
  125300. /**
  125301. * Gets the base internal format
  125302. */
  125303. glBaseInternalFormat: number;
  125304. /**
  125305. * Gets image width in pixel
  125306. */
  125307. pixelWidth: number;
  125308. /**
  125309. * Gets image height in pixel
  125310. */
  125311. pixelHeight: number;
  125312. /**
  125313. * Gets image depth in pixels
  125314. */
  125315. pixelDepth: number;
  125316. /**
  125317. * Gets the number of array elements
  125318. */
  125319. numberOfArrayElements: number;
  125320. /**
  125321. * Gets the number of faces
  125322. */
  125323. numberOfFaces: number;
  125324. /**
  125325. * Gets the number of mipmap levels
  125326. */
  125327. numberOfMipmapLevels: number;
  125328. /**
  125329. * Gets the bytes of key value data
  125330. */
  125331. bytesOfKeyValueData: number;
  125332. /**
  125333. * Gets the load type
  125334. */
  125335. loadType: number;
  125336. /**
  125337. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125338. */
  125339. isInvalid: boolean;
  125340. /**
  125341. * Creates a new KhronosTextureContainer
  125342. * @param data contents of the KTX container file
  125343. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125344. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125345. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125346. */
  125347. constructor(
  125348. /** contents of the KTX container file */
  125349. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125350. /**
  125351. * Uploads KTX content to a Babylon Texture.
  125352. * It is assumed that the texture has already been created & is currently bound
  125353. * @hidden
  125354. */
  125355. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125356. private _upload2DCompressedLevels;
  125357. /**
  125358. * Checks if the given data starts with a KTX file identifier.
  125359. * @param data the data to check
  125360. * @returns true if the data is a KTX file or false otherwise
  125361. */
  125362. static IsValid(data: ArrayBufferView): boolean;
  125363. }
  125364. }
  125365. declare module BABYLON {
  125366. /**
  125367. * Class for loading KTX2 files
  125368. * !!! Experimental Extension Subject to Changes !!!
  125369. * @hidden
  125370. */
  125371. export class KhronosTextureContainer2 {
  125372. private static _ModulePromise;
  125373. private static _TranscodeFormat;
  125374. constructor(engine: ThinEngine);
  125375. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125376. private _determineTranscodeFormat;
  125377. /**
  125378. * Checks if the given data starts with a KTX2 file identifier.
  125379. * @param data the data to check
  125380. * @returns true if the data is a KTX2 file or false otherwise
  125381. */
  125382. static IsValid(data: ArrayBufferView): boolean;
  125383. }
  125384. }
  125385. declare module BABYLON {
  125386. /**
  125387. * Implementation of the KTX Texture Loader.
  125388. * @hidden
  125389. */
  125390. export class _KTXTextureLoader implements IInternalTextureLoader {
  125391. /**
  125392. * Defines wether the loader supports cascade loading the different faces.
  125393. */
  125394. readonly supportCascades: boolean;
  125395. /**
  125396. * This returns if the loader support the current file information.
  125397. * @param extension defines the file extension of the file being loaded
  125398. * @returns true if the loader can load the specified file
  125399. */
  125400. canLoad(extension: string): boolean;
  125401. /**
  125402. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125403. * @param data contains the texture data
  125404. * @param texture defines the BabylonJS internal texture
  125405. * @param createPolynomials will be true if polynomials have been requested
  125406. * @param onLoad defines the callback to trigger once the texture is ready
  125407. * @param onError defines the callback to trigger in case of error
  125408. */
  125409. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125410. /**
  125411. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125412. * @param data contains the texture data
  125413. * @param texture defines the BabylonJS internal texture
  125414. * @param callback defines the method to call once ready to upload
  125415. */
  125416. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125417. }
  125418. }
  125419. declare module BABYLON {
  125420. /** @hidden */
  125421. export var _forceSceneHelpersToBundle: boolean;
  125422. interface Scene {
  125423. /**
  125424. * Creates a default light for the scene.
  125425. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125426. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125427. */
  125428. createDefaultLight(replace?: boolean): void;
  125429. /**
  125430. * Creates a default camera for the scene.
  125431. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125432. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125433. * @param replace has default false, when true replaces the active camera in the scene
  125434. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125435. */
  125436. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125437. /**
  125438. * Creates a default camera and a default light.
  125439. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125440. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125441. * @param replace has the default false, when true replaces the active camera/light in the scene
  125442. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125443. */
  125444. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125445. /**
  125446. * Creates a new sky box
  125447. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125448. * @param environmentTexture defines the texture to use as environment texture
  125449. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125450. * @param scale defines the overall scale of the skybox
  125451. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125452. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125453. * @returns a new mesh holding the sky box
  125454. */
  125455. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125456. /**
  125457. * Creates a new environment
  125458. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125459. * @param options defines the options you can use to configure the environment
  125460. * @returns the new EnvironmentHelper
  125461. */
  125462. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125463. /**
  125464. * Creates a new VREXperienceHelper
  125465. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125466. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125467. * @returns a new VREXperienceHelper
  125468. */
  125469. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125470. /**
  125471. * Creates a new WebXRDefaultExperience
  125472. * @see http://doc.babylonjs.com/how_to/webxr
  125473. * @param options experience options
  125474. * @returns a promise for a new WebXRDefaultExperience
  125475. */
  125476. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125477. }
  125478. }
  125479. declare module BABYLON {
  125480. /**
  125481. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125482. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125483. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125484. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125485. */
  125486. export class VideoDome extends TransformNode {
  125487. /**
  125488. * Define the video source as a Monoscopic panoramic 360 video.
  125489. */
  125490. static readonly MODE_MONOSCOPIC: number;
  125491. /**
  125492. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125493. */
  125494. static readonly MODE_TOPBOTTOM: number;
  125495. /**
  125496. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125497. */
  125498. static readonly MODE_SIDEBYSIDE: number;
  125499. private _halfDome;
  125500. private _useDirectMapping;
  125501. /**
  125502. * The video texture being displayed on the sphere
  125503. */
  125504. protected _videoTexture: VideoTexture;
  125505. /**
  125506. * Gets the video texture being displayed on the sphere
  125507. */
  125508. get videoTexture(): VideoTexture;
  125509. /**
  125510. * The skybox material
  125511. */
  125512. protected _material: BackgroundMaterial;
  125513. /**
  125514. * The surface used for the skybox
  125515. */
  125516. protected _mesh: Mesh;
  125517. /**
  125518. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125519. */
  125520. private _halfDomeMask;
  125521. /**
  125522. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125523. * Also see the options.resolution property.
  125524. */
  125525. get fovMultiplier(): number;
  125526. set fovMultiplier(value: number);
  125527. private _videoMode;
  125528. /**
  125529. * Gets or set the current video mode for the video. It can be:
  125530. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125531. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125532. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125533. */
  125534. get videoMode(): number;
  125535. set videoMode(value: number);
  125536. /**
  125537. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125538. *
  125539. */
  125540. get halfDome(): boolean;
  125541. /**
  125542. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125543. */
  125544. set halfDome(enabled: boolean);
  125545. /**
  125546. * Oberserver used in Stereoscopic VR Mode.
  125547. */
  125548. private _onBeforeCameraRenderObserver;
  125549. /**
  125550. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125551. * @param name Element's name, child elements will append suffixes for their own names.
  125552. * @param urlsOrVideo defines the url(s) or the video element to use
  125553. * @param options An object containing optional or exposed sub element properties
  125554. */
  125555. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125556. resolution?: number;
  125557. clickToPlay?: boolean;
  125558. autoPlay?: boolean;
  125559. loop?: boolean;
  125560. size?: number;
  125561. poster?: string;
  125562. faceForward?: boolean;
  125563. useDirectMapping?: boolean;
  125564. halfDomeMode?: boolean;
  125565. }, scene: Scene);
  125566. private _changeVideoMode;
  125567. /**
  125568. * Releases resources associated with this node.
  125569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125571. */
  125572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125573. }
  125574. }
  125575. declare module BABYLON {
  125576. /**
  125577. * This class can be used to get instrumentation data from a Babylon engine
  125578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125579. */
  125580. export class EngineInstrumentation implements IDisposable {
  125581. /**
  125582. * Define the instrumented engine.
  125583. */
  125584. engine: Engine;
  125585. private _captureGPUFrameTime;
  125586. private _gpuFrameTimeToken;
  125587. private _gpuFrameTime;
  125588. private _captureShaderCompilationTime;
  125589. private _shaderCompilationTime;
  125590. private _onBeginFrameObserver;
  125591. private _onEndFrameObserver;
  125592. private _onBeforeShaderCompilationObserver;
  125593. private _onAfterShaderCompilationObserver;
  125594. /**
  125595. * Gets the perf counter used for GPU frame time
  125596. */
  125597. get gpuFrameTimeCounter(): PerfCounter;
  125598. /**
  125599. * Gets the GPU frame time capture status
  125600. */
  125601. get captureGPUFrameTime(): boolean;
  125602. /**
  125603. * Enable or disable the GPU frame time capture
  125604. */
  125605. set captureGPUFrameTime(value: boolean);
  125606. /**
  125607. * Gets the perf counter used for shader compilation time
  125608. */
  125609. get shaderCompilationTimeCounter(): PerfCounter;
  125610. /**
  125611. * Gets the shader compilation time capture status
  125612. */
  125613. get captureShaderCompilationTime(): boolean;
  125614. /**
  125615. * Enable or disable the shader compilation time capture
  125616. */
  125617. set captureShaderCompilationTime(value: boolean);
  125618. /**
  125619. * Instantiates a new engine instrumentation.
  125620. * This class can be used to get instrumentation data from a Babylon engine
  125621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125622. * @param engine Defines the engine to instrument
  125623. */
  125624. constructor(
  125625. /**
  125626. * Define the instrumented engine.
  125627. */
  125628. engine: Engine);
  125629. /**
  125630. * Dispose and release associated resources.
  125631. */
  125632. dispose(): void;
  125633. }
  125634. }
  125635. declare module BABYLON {
  125636. /**
  125637. * This class can be used to get instrumentation data from a Babylon engine
  125638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125639. */
  125640. export class SceneInstrumentation implements IDisposable {
  125641. /**
  125642. * Defines the scene to instrument
  125643. */
  125644. scene: Scene;
  125645. private _captureActiveMeshesEvaluationTime;
  125646. private _activeMeshesEvaluationTime;
  125647. private _captureRenderTargetsRenderTime;
  125648. private _renderTargetsRenderTime;
  125649. private _captureFrameTime;
  125650. private _frameTime;
  125651. private _captureRenderTime;
  125652. private _renderTime;
  125653. private _captureInterFrameTime;
  125654. private _interFrameTime;
  125655. private _captureParticlesRenderTime;
  125656. private _particlesRenderTime;
  125657. private _captureSpritesRenderTime;
  125658. private _spritesRenderTime;
  125659. private _capturePhysicsTime;
  125660. private _physicsTime;
  125661. private _captureAnimationsTime;
  125662. private _animationsTime;
  125663. private _captureCameraRenderTime;
  125664. private _cameraRenderTime;
  125665. private _onBeforeActiveMeshesEvaluationObserver;
  125666. private _onAfterActiveMeshesEvaluationObserver;
  125667. private _onBeforeRenderTargetsRenderObserver;
  125668. private _onAfterRenderTargetsRenderObserver;
  125669. private _onAfterRenderObserver;
  125670. private _onBeforeDrawPhaseObserver;
  125671. private _onAfterDrawPhaseObserver;
  125672. private _onBeforeAnimationsObserver;
  125673. private _onBeforeParticlesRenderingObserver;
  125674. private _onAfterParticlesRenderingObserver;
  125675. private _onBeforeSpritesRenderingObserver;
  125676. private _onAfterSpritesRenderingObserver;
  125677. private _onBeforePhysicsObserver;
  125678. private _onAfterPhysicsObserver;
  125679. private _onAfterAnimationsObserver;
  125680. private _onBeforeCameraRenderObserver;
  125681. private _onAfterCameraRenderObserver;
  125682. /**
  125683. * Gets the perf counter used for active meshes evaluation time
  125684. */
  125685. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125686. /**
  125687. * Gets the active meshes evaluation time capture status
  125688. */
  125689. get captureActiveMeshesEvaluationTime(): boolean;
  125690. /**
  125691. * Enable or disable the active meshes evaluation time capture
  125692. */
  125693. set captureActiveMeshesEvaluationTime(value: boolean);
  125694. /**
  125695. * Gets the perf counter used for render targets render time
  125696. */
  125697. get renderTargetsRenderTimeCounter(): PerfCounter;
  125698. /**
  125699. * Gets the render targets render time capture status
  125700. */
  125701. get captureRenderTargetsRenderTime(): boolean;
  125702. /**
  125703. * Enable or disable the render targets render time capture
  125704. */
  125705. set captureRenderTargetsRenderTime(value: boolean);
  125706. /**
  125707. * Gets the perf counter used for particles render time
  125708. */
  125709. get particlesRenderTimeCounter(): PerfCounter;
  125710. /**
  125711. * Gets the particles render time capture status
  125712. */
  125713. get captureParticlesRenderTime(): boolean;
  125714. /**
  125715. * Enable or disable the particles render time capture
  125716. */
  125717. set captureParticlesRenderTime(value: boolean);
  125718. /**
  125719. * Gets the perf counter used for sprites render time
  125720. */
  125721. get spritesRenderTimeCounter(): PerfCounter;
  125722. /**
  125723. * Gets the sprites render time capture status
  125724. */
  125725. get captureSpritesRenderTime(): boolean;
  125726. /**
  125727. * Enable or disable the sprites render time capture
  125728. */
  125729. set captureSpritesRenderTime(value: boolean);
  125730. /**
  125731. * Gets the perf counter used for physics time
  125732. */
  125733. get physicsTimeCounter(): PerfCounter;
  125734. /**
  125735. * Gets the physics time capture status
  125736. */
  125737. get capturePhysicsTime(): boolean;
  125738. /**
  125739. * Enable or disable the physics time capture
  125740. */
  125741. set capturePhysicsTime(value: boolean);
  125742. /**
  125743. * Gets the perf counter used for animations time
  125744. */
  125745. get animationsTimeCounter(): PerfCounter;
  125746. /**
  125747. * Gets the animations time capture status
  125748. */
  125749. get captureAnimationsTime(): boolean;
  125750. /**
  125751. * Enable or disable the animations time capture
  125752. */
  125753. set captureAnimationsTime(value: boolean);
  125754. /**
  125755. * Gets the perf counter used for frame time capture
  125756. */
  125757. get frameTimeCounter(): PerfCounter;
  125758. /**
  125759. * Gets the frame time capture status
  125760. */
  125761. get captureFrameTime(): boolean;
  125762. /**
  125763. * Enable or disable the frame time capture
  125764. */
  125765. set captureFrameTime(value: boolean);
  125766. /**
  125767. * Gets the perf counter used for inter-frames time capture
  125768. */
  125769. get interFrameTimeCounter(): PerfCounter;
  125770. /**
  125771. * Gets the inter-frames time capture status
  125772. */
  125773. get captureInterFrameTime(): boolean;
  125774. /**
  125775. * Enable or disable the inter-frames time capture
  125776. */
  125777. set captureInterFrameTime(value: boolean);
  125778. /**
  125779. * Gets the perf counter used for render time capture
  125780. */
  125781. get renderTimeCounter(): PerfCounter;
  125782. /**
  125783. * Gets the render time capture status
  125784. */
  125785. get captureRenderTime(): boolean;
  125786. /**
  125787. * Enable or disable the render time capture
  125788. */
  125789. set captureRenderTime(value: boolean);
  125790. /**
  125791. * Gets the perf counter used for camera render time capture
  125792. */
  125793. get cameraRenderTimeCounter(): PerfCounter;
  125794. /**
  125795. * Gets the camera render time capture status
  125796. */
  125797. get captureCameraRenderTime(): boolean;
  125798. /**
  125799. * Enable or disable the camera render time capture
  125800. */
  125801. set captureCameraRenderTime(value: boolean);
  125802. /**
  125803. * Gets the perf counter used for draw calls
  125804. */
  125805. get drawCallsCounter(): PerfCounter;
  125806. /**
  125807. * Instantiates a new scene instrumentation.
  125808. * This class can be used to get instrumentation data from a Babylon engine
  125809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125810. * @param scene Defines the scene to instrument
  125811. */
  125812. constructor(
  125813. /**
  125814. * Defines the scene to instrument
  125815. */
  125816. scene: Scene);
  125817. /**
  125818. * Dispose and release associated resources.
  125819. */
  125820. dispose(): void;
  125821. }
  125822. }
  125823. declare module BABYLON {
  125824. /** @hidden */
  125825. export var glowMapGenerationPixelShader: {
  125826. name: string;
  125827. shader: string;
  125828. };
  125829. }
  125830. declare module BABYLON {
  125831. /** @hidden */
  125832. export var glowMapGenerationVertexShader: {
  125833. name: string;
  125834. shader: string;
  125835. };
  125836. }
  125837. declare module BABYLON {
  125838. /**
  125839. * Effect layer options. This helps customizing the behaviour
  125840. * of the effect layer.
  125841. */
  125842. export interface IEffectLayerOptions {
  125843. /**
  125844. * Multiplication factor apply to the canvas size to compute the render target size
  125845. * used to generated the objects (the smaller the faster).
  125846. */
  125847. mainTextureRatio: number;
  125848. /**
  125849. * Enforces a fixed size texture to ensure effect stability across devices.
  125850. */
  125851. mainTextureFixedSize?: number;
  125852. /**
  125853. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125854. */
  125855. alphaBlendingMode: number;
  125856. /**
  125857. * The camera attached to the layer.
  125858. */
  125859. camera: Nullable<Camera>;
  125860. /**
  125861. * The rendering group to draw the layer in.
  125862. */
  125863. renderingGroupId: number;
  125864. }
  125865. /**
  125866. * The effect layer Helps adding post process effect blended with the main pass.
  125867. *
  125868. * This can be for instance use to generate glow or higlight effects on the scene.
  125869. *
  125870. * The effect layer class can not be used directly and is intented to inherited from to be
  125871. * customized per effects.
  125872. */
  125873. export abstract class EffectLayer {
  125874. private _vertexBuffers;
  125875. private _indexBuffer;
  125876. private _cachedDefines;
  125877. private _effectLayerMapGenerationEffect;
  125878. private _effectLayerOptions;
  125879. private _mergeEffect;
  125880. protected _scene: Scene;
  125881. protected _engine: Engine;
  125882. protected _maxSize: number;
  125883. protected _mainTextureDesiredSize: ISize;
  125884. protected _mainTexture: RenderTargetTexture;
  125885. protected _shouldRender: boolean;
  125886. protected _postProcesses: PostProcess[];
  125887. protected _textures: BaseTexture[];
  125888. protected _emissiveTextureAndColor: {
  125889. texture: Nullable<BaseTexture>;
  125890. color: Color4;
  125891. };
  125892. /**
  125893. * The name of the layer
  125894. */
  125895. name: string;
  125896. /**
  125897. * The clear color of the texture used to generate the glow map.
  125898. */
  125899. neutralColor: Color4;
  125900. /**
  125901. * Specifies whether the highlight layer is enabled or not.
  125902. */
  125903. isEnabled: boolean;
  125904. /**
  125905. * Gets the camera attached to the layer.
  125906. */
  125907. get camera(): Nullable<Camera>;
  125908. /**
  125909. * Gets the rendering group id the layer should render in.
  125910. */
  125911. get renderingGroupId(): number;
  125912. set renderingGroupId(renderingGroupId: number);
  125913. /**
  125914. * An event triggered when the effect layer has been disposed.
  125915. */
  125916. onDisposeObservable: Observable<EffectLayer>;
  125917. /**
  125918. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125919. */
  125920. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125921. /**
  125922. * An event triggered when the generated texture is being merged in the scene.
  125923. */
  125924. onBeforeComposeObservable: Observable<EffectLayer>;
  125925. /**
  125926. * An event triggered when the mesh is rendered into the effect render target.
  125927. */
  125928. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125929. /**
  125930. * An event triggered after the mesh has been rendered into the effect render target.
  125931. */
  125932. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125933. /**
  125934. * An event triggered when the generated texture has been merged in the scene.
  125935. */
  125936. onAfterComposeObservable: Observable<EffectLayer>;
  125937. /**
  125938. * An event triggered when the efffect layer changes its size.
  125939. */
  125940. onSizeChangedObservable: Observable<EffectLayer>;
  125941. /** @hidden */
  125942. static _SceneComponentInitialization: (scene: Scene) => void;
  125943. /**
  125944. * Instantiates a new effect Layer and references it in the scene.
  125945. * @param name The name of the layer
  125946. * @param scene The scene to use the layer in
  125947. */
  125948. constructor(
  125949. /** The Friendly of the effect in the scene */
  125950. name: string, scene: Scene);
  125951. /**
  125952. * Get the effect name of the layer.
  125953. * @return The effect name
  125954. */
  125955. abstract getEffectName(): string;
  125956. /**
  125957. * Checks for the readiness of the element composing the layer.
  125958. * @param subMesh the mesh to check for
  125959. * @param useInstances specify whether or not to use instances to render the mesh
  125960. * @return true if ready otherwise, false
  125961. */
  125962. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125963. /**
  125964. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125965. * @returns true if the effect requires stencil during the main canvas render pass.
  125966. */
  125967. abstract needStencil(): boolean;
  125968. /**
  125969. * Create the merge effect. This is the shader use to blit the information back
  125970. * to the main canvas at the end of the scene rendering.
  125971. * @returns The effect containing the shader used to merge the effect on the main canvas
  125972. */
  125973. protected abstract _createMergeEffect(): Effect;
  125974. /**
  125975. * Creates the render target textures and post processes used in the effect layer.
  125976. */
  125977. protected abstract _createTextureAndPostProcesses(): void;
  125978. /**
  125979. * Implementation specific of rendering the generating effect on the main canvas.
  125980. * @param effect The effect used to render through
  125981. */
  125982. protected abstract _internalRender(effect: Effect): void;
  125983. /**
  125984. * Sets the required values for both the emissive texture and and the main color.
  125985. */
  125986. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125987. /**
  125988. * Free any resources and references associated to a mesh.
  125989. * Internal use
  125990. * @param mesh The mesh to free.
  125991. */
  125992. abstract _disposeMesh(mesh: Mesh): void;
  125993. /**
  125994. * Serializes this layer (Glow or Highlight for example)
  125995. * @returns a serialized layer object
  125996. */
  125997. abstract serialize?(): any;
  125998. /**
  125999. * Initializes the effect layer with the required options.
  126000. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126001. */
  126002. protected _init(options: Partial<IEffectLayerOptions>): void;
  126003. /**
  126004. * Generates the index buffer of the full screen quad blending to the main canvas.
  126005. */
  126006. private _generateIndexBuffer;
  126007. /**
  126008. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126009. */
  126010. private _generateVertexBuffer;
  126011. /**
  126012. * Sets the main texture desired size which is the closest power of two
  126013. * of the engine canvas size.
  126014. */
  126015. private _setMainTextureSize;
  126016. /**
  126017. * Creates the main texture for the effect layer.
  126018. */
  126019. protected _createMainTexture(): void;
  126020. /**
  126021. * Adds specific effects defines.
  126022. * @param defines The defines to add specifics to.
  126023. */
  126024. protected _addCustomEffectDefines(defines: string[]): void;
  126025. /**
  126026. * Checks for the readiness of the element composing the layer.
  126027. * @param subMesh the mesh to check for
  126028. * @param useInstances specify whether or not to use instances to render the mesh
  126029. * @param emissiveTexture the associated emissive texture used to generate the glow
  126030. * @return true if ready otherwise, false
  126031. */
  126032. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126033. /**
  126034. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126035. */
  126036. render(): void;
  126037. /**
  126038. * Determine if a given mesh will be used in the current effect.
  126039. * @param mesh mesh to test
  126040. * @returns true if the mesh will be used
  126041. */
  126042. hasMesh(mesh: AbstractMesh): boolean;
  126043. /**
  126044. * Returns true if the layer contains information to display, otherwise false.
  126045. * @returns true if the glow layer should be rendered
  126046. */
  126047. shouldRender(): boolean;
  126048. /**
  126049. * Returns true if the mesh should render, otherwise false.
  126050. * @param mesh The mesh to render
  126051. * @returns true if it should render otherwise false
  126052. */
  126053. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126054. /**
  126055. * Returns true if the mesh can be rendered, otherwise false.
  126056. * @param mesh The mesh to render
  126057. * @param material The material used on the mesh
  126058. * @returns true if it can be rendered otherwise false
  126059. */
  126060. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126061. /**
  126062. * Returns true if the mesh should render, otherwise false.
  126063. * @param mesh The mesh to render
  126064. * @returns true if it should render otherwise false
  126065. */
  126066. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126067. /**
  126068. * Renders the submesh passed in parameter to the generation map.
  126069. */
  126070. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126071. /**
  126072. * Defines whether the current material of the mesh should be use to render the effect.
  126073. * @param mesh defines the current mesh to render
  126074. */
  126075. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126076. /**
  126077. * Rebuild the required buffers.
  126078. * @hidden Internal use only.
  126079. */
  126080. _rebuild(): void;
  126081. /**
  126082. * Dispose only the render target textures and post process.
  126083. */
  126084. private _disposeTextureAndPostProcesses;
  126085. /**
  126086. * Dispose the highlight layer and free resources.
  126087. */
  126088. dispose(): void;
  126089. /**
  126090. * Gets the class name of the effect layer
  126091. * @returns the string with the class name of the effect layer
  126092. */
  126093. getClassName(): string;
  126094. /**
  126095. * Creates an effect layer from parsed effect layer data
  126096. * @param parsedEffectLayer defines effect layer data
  126097. * @param scene defines the current scene
  126098. * @param rootUrl defines the root URL containing the effect layer information
  126099. * @returns a parsed effect Layer
  126100. */
  126101. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126102. }
  126103. }
  126104. declare module BABYLON {
  126105. interface AbstractScene {
  126106. /**
  126107. * The list of effect layers (highlights/glow) added to the scene
  126108. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126109. * @see http://doc.babylonjs.com/how_to/glow_layer
  126110. */
  126111. effectLayers: Array<EffectLayer>;
  126112. /**
  126113. * Removes the given effect layer from this scene.
  126114. * @param toRemove defines the effect layer to remove
  126115. * @returns the index of the removed effect layer
  126116. */
  126117. removeEffectLayer(toRemove: EffectLayer): number;
  126118. /**
  126119. * Adds the given effect layer to this scene
  126120. * @param newEffectLayer defines the effect layer to add
  126121. */
  126122. addEffectLayer(newEffectLayer: EffectLayer): void;
  126123. }
  126124. /**
  126125. * Defines the layer scene component responsible to manage any effect layers
  126126. * in a given scene.
  126127. */
  126128. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126129. /**
  126130. * The component name helpfull to identify the component in the list of scene components.
  126131. */
  126132. readonly name: string;
  126133. /**
  126134. * The scene the component belongs to.
  126135. */
  126136. scene: Scene;
  126137. private _engine;
  126138. private _renderEffects;
  126139. private _needStencil;
  126140. private _previousStencilState;
  126141. /**
  126142. * Creates a new instance of the component for the given scene
  126143. * @param scene Defines the scene to register the component in
  126144. */
  126145. constructor(scene: Scene);
  126146. /**
  126147. * Registers the component in a given scene
  126148. */
  126149. register(): void;
  126150. /**
  126151. * Rebuilds the elements related to this component in case of
  126152. * context lost for instance.
  126153. */
  126154. rebuild(): void;
  126155. /**
  126156. * Serializes the component data to the specified json object
  126157. * @param serializationObject The object to serialize to
  126158. */
  126159. serialize(serializationObject: any): void;
  126160. /**
  126161. * Adds all the elements from the container to the scene
  126162. * @param container the container holding the elements
  126163. */
  126164. addFromContainer(container: AbstractScene): void;
  126165. /**
  126166. * Removes all the elements in the container from the scene
  126167. * @param container contains the elements to remove
  126168. * @param dispose if the removed element should be disposed (default: false)
  126169. */
  126170. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126171. /**
  126172. * Disposes the component and the associated ressources.
  126173. */
  126174. dispose(): void;
  126175. private _isReadyForMesh;
  126176. private _renderMainTexture;
  126177. private _setStencil;
  126178. private _setStencilBack;
  126179. private _draw;
  126180. private _drawCamera;
  126181. private _drawRenderingGroup;
  126182. }
  126183. }
  126184. declare module BABYLON {
  126185. /** @hidden */
  126186. export var glowMapMergePixelShader: {
  126187. name: string;
  126188. shader: string;
  126189. };
  126190. }
  126191. declare module BABYLON {
  126192. /** @hidden */
  126193. export var glowMapMergeVertexShader: {
  126194. name: string;
  126195. shader: string;
  126196. };
  126197. }
  126198. declare module BABYLON {
  126199. interface AbstractScene {
  126200. /**
  126201. * Return a the first highlight layer of the scene with a given name.
  126202. * @param name The name of the highlight layer to look for.
  126203. * @return The highlight layer if found otherwise null.
  126204. */
  126205. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126206. }
  126207. /**
  126208. * Glow layer options. This helps customizing the behaviour
  126209. * of the glow layer.
  126210. */
  126211. export interface IGlowLayerOptions {
  126212. /**
  126213. * Multiplication factor apply to the canvas size to compute the render target size
  126214. * used to generated the glowing objects (the smaller the faster).
  126215. */
  126216. mainTextureRatio: number;
  126217. /**
  126218. * Enforces a fixed size texture to ensure resize independant blur.
  126219. */
  126220. mainTextureFixedSize?: number;
  126221. /**
  126222. * How big is the kernel of the blur texture.
  126223. */
  126224. blurKernelSize: number;
  126225. /**
  126226. * The camera attached to the layer.
  126227. */
  126228. camera: Nullable<Camera>;
  126229. /**
  126230. * Enable MSAA by chosing the number of samples.
  126231. */
  126232. mainTextureSamples?: number;
  126233. /**
  126234. * The rendering group to draw the layer in.
  126235. */
  126236. renderingGroupId: number;
  126237. }
  126238. /**
  126239. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126240. *
  126241. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126242. *
  126243. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126244. */
  126245. export class GlowLayer extends EffectLayer {
  126246. /**
  126247. * Effect Name of the layer.
  126248. */
  126249. static readonly EffectName: string;
  126250. /**
  126251. * The default blur kernel size used for the glow.
  126252. */
  126253. static DefaultBlurKernelSize: number;
  126254. /**
  126255. * The default texture size ratio used for the glow.
  126256. */
  126257. static DefaultTextureRatio: number;
  126258. /**
  126259. * Sets the kernel size of the blur.
  126260. */
  126261. set blurKernelSize(value: number);
  126262. /**
  126263. * Gets the kernel size of the blur.
  126264. */
  126265. get blurKernelSize(): number;
  126266. /**
  126267. * Sets the glow intensity.
  126268. */
  126269. set intensity(value: number);
  126270. /**
  126271. * Gets the glow intensity.
  126272. */
  126273. get intensity(): number;
  126274. private _options;
  126275. private _intensity;
  126276. private _horizontalBlurPostprocess1;
  126277. private _verticalBlurPostprocess1;
  126278. private _horizontalBlurPostprocess2;
  126279. private _verticalBlurPostprocess2;
  126280. private _blurTexture1;
  126281. private _blurTexture2;
  126282. private _postProcesses1;
  126283. private _postProcesses2;
  126284. private _includedOnlyMeshes;
  126285. private _excludedMeshes;
  126286. private _meshesUsingTheirOwnMaterials;
  126287. /**
  126288. * Callback used to let the user override the color selection on a per mesh basis
  126289. */
  126290. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126291. /**
  126292. * Callback used to let the user override the texture selection on a per mesh basis
  126293. */
  126294. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126295. /**
  126296. * Instantiates a new glow Layer and references it to the scene.
  126297. * @param name The name of the layer
  126298. * @param scene The scene to use the layer in
  126299. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126300. */
  126301. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126302. /**
  126303. * Get the effect name of the layer.
  126304. * @return The effect name
  126305. */
  126306. getEffectName(): string;
  126307. /**
  126308. * Create the merge effect. This is the shader use to blit the information back
  126309. * to the main canvas at the end of the scene rendering.
  126310. */
  126311. protected _createMergeEffect(): Effect;
  126312. /**
  126313. * Creates the render target textures and post processes used in the glow layer.
  126314. */
  126315. protected _createTextureAndPostProcesses(): void;
  126316. /**
  126317. * Checks for the readiness of the element composing the layer.
  126318. * @param subMesh the mesh to check for
  126319. * @param useInstances specify wether or not to use instances to render the mesh
  126320. * @param emissiveTexture the associated emissive texture used to generate the glow
  126321. * @return true if ready otherwise, false
  126322. */
  126323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126324. /**
  126325. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126326. */
  126327. needStencil(): boolean;
  126328. /**
  126329. * Returns true if the mesh can be rendered, otherwise false.
  126330. * @param mesh The mesh to render
  126331. * @param material The material used on the mesh
  126332. * @returns true if it can be rendered otherwise false
  126333. */
  126334. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126335. /**
  126336. * Implementation specific of rendering the generating effect on the main canvas.
  126337. * @param effect The effect used to render through
  126338. */
  126339. protected _internalRender(effect: Effect): void;
  126340. /**
  126341. * Sets the required values for both the emissive texture and and the main color.
  126342. */
  126343. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126344. /**
  126345. * Returns true if the mesh should render, otherwise false.
  126346. * @param mesh The mesh to render
  126347. * @returns true if it should render otherwise false
  126348. */
  126349. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126350. /**
  126351. * Adds specific effects defines.
  126352. * @param defines The defines to add specifics to.
  126353. */
  126354. protected _addCustomEffectDefines(defines: string[]): void;
  126355. /**
  126356. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126357. * @param mesh The mesh to exclude from the glow layer
  126358. */
  126359. addExcludedMesh(mesh: Mesh): void;
  126360. /**
  126361. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126362. * @param mesh The mesh to remove
  126363. */
  126364. removeExcludedMesh(mesh: Mesh): void;
  126365. /**
  126366. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126367. * @param mesh The mesh to include in the glow layer
  126368. */
  126369. addIncludedOnlyMesh(mesh: Mesh): void;
  126370. /**
  126371. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126372. * @param mesh The mesh to remove
  126373. */
  126374. removeIncludedOnlyMesh(mesh: Mesh): void;
  126375. /**
  126376. * Determine if a given mesh will be used in the glow layer
  126377. * @param mesh The mesh to test
  126378. * @returns true if the mesh will be highlighted by the current glow layer
  126379. */
  126380. hasMesh(mesh: AbstractMesh): boolean;
  126381. /**
  126382. * Defines whether the current material of the mesh should be use to render the effect.
  126383. * @param mesh defines the current mesh to render
  126384. */
  126385. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126386. /**
  126387. * Add a mesh to be rendered through its own material and not with emissive only.
  126388. * @param mesh The mesh for which we need to use its material
  126389. */
  126390. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126391. /**
  126392. * Remove a mesh from being rendered through its own material and not with emissive only.
  126393. * @param mesh The mesh for which we need to not use its material
  126394. */
  126395. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126396. /**
  126397. * Free any resources and references associated to a mesh.
  126398. * Internal use
  126399. * @param mesh The mesh to free.
  126400. * @hidden
  126401. */
  126402. _disposeMesh(mesh: Mesh): void;
  126403. /**
  126404. * Gets the class name of the effect layer
  126405. * @returns the string with the class name of the effect layer
  126406. */
  126407. getClassName(): string;
  126408. /**
  126409. * Serializes this glow layer
  126410. * @returns a serialized glow layer object
  126411. */
  126412. serialize(): any;
  126413. /**
  126414. * Creates a Glow Layer from parsed glow layer data
  126415. * @param parsedGlowLayer defines glow layer data
  126416. * @param scene defines the current scene
  126417. * @param rootUrl defines the root URL containing the glow layer information
  126418. * @returns a parsed Glow Layer
  126419. */
  126420. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126421. }
  126422. }
  126423. declare module BABYLON {
  126424. /** @hidden */
  126425. export var glowBlurPostProcessPixelShader: {
  126426. name: string;
  126427. shader: string;
  126428. };
  126429. }
  126430. declare module BABYLON {
  126431. interface AbstractScene {
  126432. /**
  126433. * Return a the first highlight layer of the scene with a given name.
  126434. * @param name The name of the highlight layer to look for.
  126435. * @return The highlight layer if found otherwise null.
  126436. */
  126437. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126438. }
  126439. /**
  126440. * Highlight layer options. This helps customizing the behaviour
  126441. * of the highlight layer.
  126442. */
  126443. export interface IHighlightLayerOptions {
  126444. /**
  126445. * Multiplication factor apply to the canvas size to compute the render target size
  126446. * used to generated the glowing objects (the smaller the faster).
  126447. */
  126448. mainTextureRatio: number;
  126449. /**
  126450. * Enforces a fixed size texture to ensure resize independant blur.
  126451. */
  126452. mainTextureFixedSize?: number;
  126453. /**
  126454. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126455. * of the picture to blur (the smaller the faster).
  126456. */
  126457. blurTextureSizeRatio: number;
  126458. /**
  126459. * How big in texel of the blur texture is the vertical blur.
  126460. */
  126461. blurVerticalSize: number;
  126462. /**
  126463. * How big in texel of the blur texture is the horizontal blur.
  126464. */
  126465. blurHorizontalSize: number;
  126466. /**
  126467. * Alpha blending mode used to apply the blur. Default is combine.
  126468. */
  126469. alphaBlendingMode: number;
  126470. /**
  126471. * The camera attached to the layer.
  126472. */
  126473. camera: Nullable<Camera>;
  126474. /**
  126475. * Should we display highlight as a solid stroke?
  126476. */
  126477. isStroke?: boolean;
  126478. /**
  126479. * The rendering group to draw the layer in.
  126480. */
  126481. renderingGroupId: number;
  126482. }
  126483. /**
  126484. * The highlight layer Helps adding a glow effect around a mesh.
  126485. *
  126486. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126487. * glowy meshes to your scene.
  126488. *
  126489. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126490. */
  126491. export class HighlightLayer extends EffectLayer {
  126492. name: string;
  126493. /**
  126494. * Effect Name of the highlight layer.
  126495. */
  126496. static readonly EffectName: string;
  126497. /**
  126498. * The neutral color used during the preparation of the glow effect.
  126499. * This is black by default as the blend operation is a blend operation.
  126500. */
  126501. static NeutralColor: Color4;
  126502. /**
  126503. * Stencil value used for glowing meshes.
  126504. */
  126505. static GlowingMeshStencilReference: number;
  126506. /**
  126507. * Stencil value used for the other meshes in the scene.
  126508. */
  126509. static NormalMeshStencilReference: number;
  126510. /**
  126511. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126512. */
  126513. innerGlow: boolean;
  126514. /**
  126515. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126516. */
  126517. outerGlow: boolean;
  126518. /**
  126519. * Specifies the horizontal size of the blur.
  126520. */
  126521. set blurHorizontalSize(value: number);
  126522. /**
  126523. * Specifies the vertical size of the blur.
  126524. */
  126525. set blurVerticalSize(value: number);
  126526. /**
  126527. * Gets the horizontal size of the blur.
  126528. */
  126529. get blurHorizontalSize(): number;
  126530. /**
  126531. * Gets the vertical size of the blur.
  126532. */
  126533. get blurVerticalSize(): number;
  126534. /**
  126535. * An event triggered when the highlight layer is being blurred.
  126536. */
  126537. onBeforeBlurObservable: Observable<HighlightLayer>;
  126538. /**
  126539. * An event triggered when the highlight layer has been blurred.
  126540. */
  126541. onAfterBlurObservable: Observable<HighlightLayer>;
  126542. private _instanceGlowingMeshStencilReference;
  126543. private _options;
  126544. private _downSamplePostprocess;
  126545. private _horizontalBlurPostprocess;
  126546. private _verticalBlurPostprocess;
  126547. private _blurTexture;
  126548. private _meshes;
  126549. private _excludedMeshes;
  126550. /**
  126551. * Instantiates a new highlight Layer and references it to the scene..
  126552. * @param name The name of the layer
  126553. * @param scene The scene to use the layer in
  126554. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126555. */
  126556. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126557. /**
  126558. * Get the effect name of the layer.
  126559. * @return The effect name
  126560. */
  126561. getEffectName(): string;
  126562. /**
  126563. * Create the merge effect. This is the shader use to blit the information back
  126564. * to the main canvas at the end of the scene rendering.
  126565. */
  126566. protected _createMergeEffect(): Effect;
  126567. /**
  126568. * Creates the render target textures and post processes used in the highlight layer.
  126569. */
  126570. protected _createTextureAndPostProcesses(): void;
  126571. /**
  126572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126573. */
  126574. needStencil(): boolean;
  126575. /**
  126576. * Checks for the readiness of the element composing the layer.
  126577. * @param subMesh the mesh to check for
  126578. * @param useInstances specify wether or not to use instances to render the mesh
  126579. * @param emissiveTexture the associated emissive texture used to generate the glow
  126580. * @return true if ready otherwise, false
  126581. */
  126582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126583. /**
  126584. * Implementation specific of rendering the generating effect on the main canvas.
  126585. * @param effect The effect used to render through
  126586. */
  126587. protected _internalRender(effect: Effect): void;
  126588. /**
  126589. * Returns true if the layer contains information to display, otherwise false.
  126590. */
  126591. shouldRender(): boolean;
  126592. /**
  126593. * Returns true if the mesh should render, otherwise false.
  126594. * @param mesh The mesh to render
  126595. * @returns true if it should render otherwise false
  126596. */
  126597. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126598. /**
  126599. * Sets the required values for both the emissive texture and and the main color.
  126600. */
  126601. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126602. /**
  126603. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126604. * @param mesh The mesh to exclude from the highlight layer
  126605. */
  126606. addExcludedMesh(mesh: Mesh): void;
  126607. /**
  126608. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126609. * @param mesh The mesh to highlight
  126610. */
  126611. removeExcludedMesh(mesh: Mesh): void;
  126612. /**
  126613. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126614. * @param mesh mesh to test
  126615. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126616. */
  126617. hasMesh(mesh: AbstractMesh): boolean;
  126618. /**
  126619. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126620. * @param mesh The mesh to highlight
  126621. * @param color The color of the highlight
  126622. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126623. */
  126624. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126625. /**
  126626. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126627. * @param mesh The mesh to highlight
  126628. */
  126629. removeMesh(mesh: Mesh): void;
  126630. /**
  126631. * Remove all the meshes currently referenced in the highlight layer
  126632. */
  126633. removeAllMeshes(): void;
  126634. /**
  126635. * Force the stencil to the normal expected value for none glowing parts
  126636. */
  126637. private _defaultStencilReference;
  126638. /**
  126639. * Free any resources and references associated to a mesh.
  126640. * Internal use
  126641. * @param mesh The mesh to free.
  126642. * @hidden
  126643. */
  126644. _disposeMesh(mesh: Mesh): void;
  126645. /**
  126646. * Dispose the highlight layer and free resources.
  126647. */
  126648. dispose(): void;
  126649. /**
  126650. * Gets the class name of the effect layer
  126651. * @returns the string with the class name of the effect layer
  126652. */
  126653. getClassName(): string;
  126654. /**
  126655. * Serializes this Highlight layer
  126656. * @returns a serialized Highlight layer object
  126657. */
  126658. serialize(): any;
  126659. /**
  126660. * Creates a Highlight layer from parsed Highlight layer data
  126661. * @param parsedHightlightLayer defines the Highlight layer data
  126662. * @param scene defines the current scene
  126663. * @param rootUrl defines the root URL containing the Highlight layer information
  126664. * @returns a parsed Highlight layer
  126665. */
  126666. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126667. }
  126668. }
  126669. declare module BABYLON {
  126670. interface AbstractScene {
  126671. /**
  126672. * The list of layers (background and foreground) of the scene
  126673. */
  126674. layers: Array<Layer>;
  126675. }
  126676. /**
  126677. * Defines the layer scene component responsible to manage any layers
  126678. * in a given scene.
  126679. */
  126680. export class LayerSceneComponent implements ISceneComponent {
  126681. /**
  126682. * The component name helpfull to identify the component in the list of scene components.
  126683. */
  126684. readonly name: string;
  126685. /**
  126686. * The scene the component belongs to.
  126687. */
  126688. scene: Scene;
  126689. private _engine;
  126690. /**
  126691. * Creates a new instance of the component for the given scene
  126692. * @param scene Defines the scene to register the component in
  126693. */
  126694. constructor(scene: Scene);
  126695. /**
  126696. * Registers the component in a given scene
  126697. */
  126698. register(): void;
  126699. /**
  126700. * Rebuilds the elements related to this component in case of
  126701. * context lost for instance.
  126702. */
  126703. rebuild(): void;
  126704. /**
  126705. * Disposes the component and the associated ressources.
  126706. */
  126707. dispose(): void;
  126708. private _draw;
  126709. private _drawCameraPredicate;
  126710. private _drawCameraBackground;
  126711. private _drawCameraForeground;
  126712. private _drawRenderTargetPredicate;
  126713. private _drawRenderTargetBackground;
  126714. private _drawRenderTargetForeground;
  126715. /**
  126716. * Adds all the elements from the container to the scene
  126717. * @param container the container holding the elements
  126718. */
  126719. addFromContainer(container: AbstractScene): void;
  126720. /**
  126721. * Removes all the elements in the container from the scene
  126722. * @param container contains the elements to remove
  126723. * @param dispose if the removed element should be disposed (default: false)
  126724. */
  126725. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126726. }
  126727. }
  126728. declare module BABYLON {
  126729. /** @hidden */
  126730. export var layerPixelShader: {
  126731. name: string;
  126732. shader: string;
  126733. };
  126734. }
  126735. declare module BABYLON {
  126736. /** @hidden */
  126737. export var layerVertexShader: {
  126738. name: string;
  126739. shader: string;
  126740. };
  126741. }
  126742. declare module BABYLON {
  126743. /**
  126744. * This represents a full screen 2d layer.
  126745. * This can be useful to display a picture in the background of your scene for instance.
  126746. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126747. */
  126748. export class Layer {
  126749. /**
  126750. * Define the name of the layer.
  126751. */
  126752. name: string;
  126753. /**
  126754. * Define the texture the layer should display.
  126755. */
  126756. texture: Nullable<Texture>;
  126757. /**
  126758. * Is the layer in background or foreground.
  126759. */
  126760. isBackground: boolean;
  126761. /**
  126762. * Define the color of the layer (instead of texture).
  126763. */
  126764. color: Color4;
  126765. /**
  126766. * Define the scale of the layer in order to zoom in out of the texture.
  126767. */
  126768. scale: Vector2;
  126769. /**
  126770. * Define an offset for the layer in order to shift the texture.
  126771. */
  126772. offset: Vector2;
  126773. /**
  126774. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126775. */
  126776. alphaBlendingMode: number;
  126777. /**
  126778. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126779. * Alpha test will not mix with the background color in case of transparency.
  126780. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126781. */
  126782. alphaTest: boolean;
  126783. /**
  126784. * Define a mask to restrict the layer to only some of the scene cameras.
  126785. */
  126786. layerMask: number;
  126787. /**
  126788. * Define the list of render target the layer is visible into.
  126789. */
  126790. renderTargetTextures: RenderTargetTexture[];
  126791. /**
  126792. * Define if the layer is only used in renderTarget or if it also
  126793. * renders in the main frame buffer of the canvas.
  126794. */
  126795. renderOnlyInRenderTargetTextures: boolean;
  126796. private _scene;
  126797. private _vertexBuffers;
  126798. private _indexBuffer;
  126799. private _effect;
  126800. private _previousDefines;
  126801. /**
  126802. * An event triggered when the layer is disposed.
  126803. */
  126804. onDisposeObservable: Observable<Layer>;
  126805. private _onDisposeObserver;
  126806. /**
  126807. * Back compatibility with callback before the onDisposeObservable existed.
  126808. * The set callback will be triggered when the layer has been disposed.
  126809. */
  126810. set onDispose(callback: () => void);
  126811. /**
  126812. * An event triggered before rendering the scene
  126813. */
  126814. onBeforeRenderObservable: Observable<Layer>;
  126815. private _onBeforeRenderObserver;
  126816. /**
  126817. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126818. * The set callback will be triggered just before rendering the layer.
  126819. */
  126820. set onBeforeRender(callback: () => void);
  126821. /**
  126822. * An event triggered after rendering the scene
  126823. */
  126824. onAfterRenderObservable: Observable<Layer>;
  126825. private _onAfterRenderObserver;
  126826. /**
  126827. * Back compatibility with callback before the onAfterRenderObservable existed.
  126828. * The set callback will be triggered just after rendering the layer.
  126829. */
  126830. set onAfterRender(callback: () => void);
  126831. /**
  126832. * Instantiates a new layer.
  126833. * This represents a full screen 2d layer.
  126834. * This can be useful to display a picture in the background of your scene for instance.
  126835. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126836. * @param name Define the name of the layer in the scene
  126837. * @param imgUrl Define the url of the texture to display in the layer
  126838. * @param scene Define the scene the layer belongs to
  126839. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126840. * @param color Defines a color for the layer
  126841. */
  126842. constructor(
  126843. /**
  126844. * Define the name of the layer.
  126845. */
  126846. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126847. private _createIndexBuffer;
  126848. /** @hidden */
  126849. _rebuild(): void;
  126850. /**
  126851. * Renders the layer in the scene.
  126852. */
  126853. render(): void;
  126854. /**
  126855. * Disposes and releases the associated ressources.
  126856. */
  126857. dispose(): void;
  126858. }
  126859. }
  126860. declare module BABYLON {
  126861. /** @hidden */
  126862. export var lensFlarePixelShader: {
  126863. name: string;
  126864. shader: string;
  126865. };
  126866. }
  126867. declare module BABYLON {
  126868. /** @hidden */
  126869. export var lensFlareVertexShader: {
  126870. name: string;
  126871. shader: string;
  126872. };
  126873. }
  126874. declare module BABYLON {
  126875. /**
  126876. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126877. * It is usually composed of several `lensFlare`.
  126878. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126879. */
  126880. export class LensFlareSystem {
  126881. /**
  126882. * Define the name of the lens flare system
  126883. */
  126884. name: string;
  126885. /**
  126886. * List of lens flares used in this system.
  126887. */
  126888. lensFlares: LensFlare[];
  126889. /**
  126890. * Define a limit from the border the lens flare can be visible.
  126891. */
  126892. borderLimit: number;
  126893. /**
  126894. * Define a viewport border we do not want to see the lens flare in.
  126895. */
  126896. viewportBorder: number;
  126897. /**
  126898. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126899. */
  126900. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126901. /**
  126902. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126903. */
  126904. layerMask: number;
  126905. /**
  126906. * Define the id of the lens flare system in the scene.
  126907. * (equal to name by default)
  126908. */
  126909. id: string;
  126910. private _scene;
  126911. private _emitter;
  126912. private _vertexBuffers;
  126913. private _indexBuffer;
  126914. private _effect;
  126915. private _positionX;
  126916. private _positionY;
  126917. private _isEnabled;
  126918. /** @hidden */
  126919. static _SceneComponentInitialization: (scene: Scene) => void;
  126920. /**
  126921. * Instantiates a lens flare system.
  126922. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126923. * It is usually composed of several `lensFlare`.
  126924. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126925. * @param name Define the name of the lens flare system in the scene
  126926. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126927. * @param scene Define the scene the lens flare system belongs to
  126928. */
  126929. constructor(
  126930. /**
  126931. * Define the name of the lens flare system
  126932. */
  126933. name: string, emitter: any, scene: Scene);
  126934. /**
  126935. * Define if the lens flare system is enabled.
  126936. */
  126937. get isEnabled(): boolean;
  126938. set isEnabled(value: boolean);
  126939. /**
  126940. * Get the scene the effects belongs to.
  126941. * @returns the scene holding the lens flare system
  126942. */
  126943. getScene(): Scene;
  126944. /**
  126945. * Get the emitter of the lens flare system.
  126946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126947. * @returns the emitter of the lens flare system
  126948. */
  126949. getEmitter(): any;
  126950. /**
  126951. * Set the emitter of the lens flare system.
  126952. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126953. * @param newEmitter Define the new emitter of the system
  126954. */
  126955. setEmitter(newEmitter: any): void;
  126956. /**
  126957. * Get the lens flare system emitter position.
  126958. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126959. * @returns the position
  126960. */
  126961. getEmitterPosition(): Vector3;
  126962. /**
  126963. * @hidden
  126964. */
  126965. computeEffectivePosition(globalViewport: Viewport): boolean;
  126966. /** @hidden */
  126967. _isVisible(): boolean;
  126968. /**
  126969. * @hidden
  126970. */
  126971. render(): boolean;
  126972. /**
  126973. * Dispose and release the lens flare with its associated resources.
  126974. */
  126975. dispose(): void;
  126976. /**
  126977. * Parse a lens flare system from a JSON repressentation
  126978. * @param parsedLensFlareSystem Define the JSON to parse
  126979. * @param scene Define the scene the parsed system should be instantiated in
  126980. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126981. * @returns the parsed system
  126982. */
  126983. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126984. /**
  126985. * Serialize the current Lens Flare System into a JSON representation.
  126986. * @returns the serialized JSON
  126987. */
  126988. serialize(): any;
  126989. }
  126990. }
  126991. declare module BABYLON {
  126992. /**
  126993. * This represents one of the lens effect in a `lensFlareSystem`.
  126994. * It controls one of the indiviual texture used in the effect.
  126995. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126996. */
  126997. export class LensFlare {
  126998. /**
  126999. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127000. */
  127001. size: number;
  127002. /**
  127003. * 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.
  127004. */
  127005. position: number;
  127006. /**
  127007. * Define the lens color.
  127008. */
  127009. color: Color3;
  127010. /**
  127011. * Define the lens texture.
  127012. */
  127013. texture: Nullable<Texture>;
  127014. /**
  127015. * Define the alpha mode to render this particular lens.
  127016. */
  127017. alphaMode: number;
  127018. private _system;
  127019. /**
  127020. * Creates a new Lens Flare.
  127021. * This represents one of the lens effect in a `lensFlareSystem`.
  127022. * It controls one of the indiviual texture used in the effect.
  127023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127024. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127025. * @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.
  127026. * @param color Define the lens color
  127027. * @param imgUrl Define the lens texture url
  127028. * @param system Define the `lensFlareSystem` this flare is part of
  127029. * @returns The newly created Lens Flare
  127030. */
  127031. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127032. /**
  127033. * Instantiates a new Lens Flare.
  127034. * This represents one of the lens effect in a `lensFlareSystem`.
  127035. * It controls one of the indiviual texture used in the effect.
  127036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127037. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127038. * @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.
  127039. * @param color Define the lens color
  127040. * @param imgUrl Define the lens texture url
  127041. * @param system Define the `lensFlareSystem` this flare is part of
  127042. */
  127043. constructor(
  127044. /**
  127045. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127046. */
  127047. size: number,
  127048. /**
  127049. * 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.
  127050. */
  127051. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127052. /**
  127053. * Dispose and release the lens flare with its associated resources.
  127054. */
  127055. dispose(): void;
  127056. }
  127057. }
  127058. declare module BABYLON {
  127059. interface AbstractScene {
  127060. /**
  127061. * The list of lens flare system added to the scene
  127062. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127063. */
  127064. lensFlareSystems: Array<LensFlareSystem>;
  127065. /**
  127066. * Removes the given lens flare system from this scene.
  127067. * @param toRemove The lens flare system to remove
  127068. * @returns The index of the removed lens flare system
  127069. */
  127070. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127071. /**
  127072. * Adds the given lens flare system to this scene
  127073. * @param newLensFlareSystem The lens flare system to add
  127074. */
  127075. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127076. /**
  127077. * Gets a lens flare system using its name
  127078. * @param name defines the name to look for
  127079. * @returns the lens flare system or null if not found
  127080. */
  127081. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127082. /**
  127083. * Gets a lens flare system using its id
  127084. * @param id defines the id to look for
  127085. * @returns the lens flare system or null if not found
  127086. */
  127087. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127088. }
  127089. /**
  127090. * Defines the lens flare scene component responsible to manage any lens flares
  127091. * in a given scene.
  127092. */
  127093. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127094. /**
  127095. * The component name helpfull to identify the component in the list of scene components.
  127096. */
  127097. readonly name: string;
  127098. /**
  127099. * The scene the component belongs to.
  127100. */
  127101. scene: Scene;
  127102. /**
  127103. * Creates a new instance of the component for the given scene
  127104. * @param scene Defines the scene to register the component in
  127105. */
  127106. constructor(scene: Scene);
  127107. /**
  127108. * Registers the component in a given scene
  127109. */
  127110. register(): void;
  127111. /**
  127112. * Rebuilds the elements related to this component in case of
  127113. * context lost for instance.
  127114. */
  127115. rebuild(): void;
  127116. /**
  127117. * Adds all the elements from the container to the scene
  127118. * @param container the container holding the elements
  127119. */
  127120. addFromContainer(container: AbstractScene): void;
  127121. /**
  127122. * Removes all the elements in the container from the scene
  127123. * @param container contains the elements to remove
  127124. * @param dispose if the removed element should be disposed (default: false)
  127125. */
  127126. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127127. /**
  127128. * Serializes the component data to the specified json object
  127129. * @param serializationObject The object to serialize to
  127130. */
  127131. serialize(serializationObject: any): void;
  127132. /**
  127133. * Disposes the component and the associated ressources.
  127134. */
  127135. dispose(): void;
  127136. private _draw;
  127137. }
  127138. }
  127139. declare module BABYLON {
  127140. /** @hidden */
  127141. export var depthPixelShader: {
  127142. name: string;
  127143. shader: string;
  127144. };
  127145. }
  127146. declare module BABYLON {
  127147. /** @hidden */
  127148. export var depthVertexShader: {
  127149. name: string;
  127150. shader: string;
  127151. };
  127152. }
  127153. declare module BABYLON {
  127154. /**
  127155. * This represents a depth renderer in Babylon.
  127156. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127157. */
  127158. export class DepthRenderer {
  127159. private _scene;
  127160. private _depthMap;
  127161. private _effect;
  127162. private readonly _storeNonLinearDepth;
  127163. private readonly _clearColor;
  127164. /** Get if the depth renderer is using packed depth or not */
  127165. readonly isPacked: boolean;
  127166. private _cachedDefines;
  127167. private _camera;
  127168. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127169. enabled: boolean;
  127170. /**
  127171. * Specifiess that the depth renderer will only be used within
  127172. * the camera it is created for.
  127173. * This can help forcing its rendering during the camera processing.
  127174. */
  127175. useOnlyInActiveCamera: boolean;
  127176. /** @hidden */
  127177. static _SceneComponentInitialization: (scene: Scene) => void;
  127178. /**
  127179. * Instantiates a depth renderer
  127180. * @param scene The scene the renderer belongs to
  127181. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127182. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127183. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127184. */
  127185. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127186. /**
  127187. * Creates the depth rendering effect and checks if the effect is ready.
  127188. * @param subMesh The submesh to be used to render the depth map of
  127189. * @param useInstances If multiple world instances should be used
  127190. * @returns if the depth renderer is ready to render the depth map
  127191. */
  127192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127193. /**
  127194. * Gets the texture which the depth map will be written to.
  127195. * @returns The depth map texture
  127196. */
  127197. getDepthMap(): RenderTargetTexture;
  127198. /**
  127199. * Disposes of the depth renderer.
  127200. */
  127201. dispose(): void;
  127202. }
  127203. }
  127204. declare module BABYLON {
  127205. /** @hidden */
  127206. export var minmaxReduxPixelShader: {
  127207. name: string;
  127208. shader: string;
  127209. };
  127210. }
  127211. declare module BABYLON {
  127212. /**
  127213. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127214. * and maximum values from all values of the texture.
  127215. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127216. * The source values are read from the red channel of the texture.
  127217. */
  127218. export class MinMaxReducer {
  127219. /**
  127220. * Observable triggered when the computation has been performed
  127221. */
  127222. onAfterReductionPerformed: Observable<{
  127223. min: number;
  127224. max: number;
  127225. }>;
  127226. protected _camera: Camera;
  127227. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127228. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127229. protected _postProcessManager: PostProcessManager;
  127230. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127231. protected _forceFullscreenViewport: boolean;
  127232. /**
  127233. * Creates a min/max reducer
  127234. * @param camera The camera to use for the post processes
  127235. */
  127236. constructor(camera: Camera);
  127237. /**
  127238. * Gets the texture used to read the values from.
  127239. */
  127240. get sourceTexture(): Nullable<RenderTargetTexture>;
  127241. /**
  127242. * Sets the source texture to read the values from.
  127243. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127244. * because in such textures '1' value must not be taken into account to compute the maximum
  127245. * as this value is used to clear the texture.
  127246. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127247. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127248. * @param depthRedux Indicates if the texture is a depth texture or not
  127249. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127250. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127251. */
  127252. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127253. /**
  127254. * Defines the refresh rate of the computation.
  127255. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127256. */
  127257. get refreshRate(): number;
  127258. set refreshRate(value: number);
  127259. protected _activated: boolean;
  127260. /**
  127261. * Gets the activation status of the reducer
  127262. */
  127263. get activated(): boolean;
  127264. /**
  127265. * Activates the reduction computation.
  127266. * When activated, the observers registered in onAfterReductionPerformed are
  127267. * called after the compuation is performed
  127268. */
  127269. activate(): void;
  127270. /**
  127271. * Deactivates the reduction computation.
  127272. */
  127273. deactivate(): void;
  127274. /**
  127275. * Disposes the min/max reducer
  127276. * @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.
  127277. */
  127278. dispose(disposeAll?: boolean): void;
  127279. }
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127284. */
  127285. export class DepthReducer extends MinMaxReducer {
  127286. private _depthRenderer;
  127287. private _depthRendererId;
  127288. /**
  127289. * Gets the depth renderer used for the computation.
  127290. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127291. */
  127292. get depthRenderer(): Nullable<DepthRenderer>;
  127293. /**
  127294. * Creates a depth reducer
  127295. * @param camera The camera used to render the depth texture
  127296. */
  127297. constructor(camera: Camera);
  127298. /**
  127299. * Sets the depth renderer to use to generate the depth map
  127300. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127301. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127302. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127303. */
  127304. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127305. /** @hidden */
  127306. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127307. /**
  127308. * Activates the reduction computation.
  127309. * When activated, the observers registered in onAfterReductionPerformed are
  127310. * called after the compuation is performed
  127311. */
  127312. activate(): void;
  127313. /**
  127314. * Deactivates the reduction computation.
  127315. */
  127316. deactivate(): void;
  127317. /**
  127318. * Disposes the depth reducer
  127319. * @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.
  127320. */
  127321. dispose(disposeAll?: boolean): void;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * A CSM implementation allowing casting shadows on large scenes.
  127327. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127328. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127329. */
  127330. export class CascadedShadowGenerator extends ShadowGenerator {
  127331. private static readonly frustumCornersNDCSpace;
  127332. /**
  127333. * Name of the CSM class
  127334. */
  127335. static CLASSNAME: string;
  127336. /**
  127337. * Defines the default number of cascades used by the CSM.
  127338. */
  127339. static readonly DEFAULT_CASCADES_COUNT: number;
  127340. /**
  127341. * Defines the minimum number of cascades used by the CSM.
  127342. */
  127343. static readonly MIN_CASCADES_COUNT: number;
  127344. /**
  127345. * Defines the maximum number of cascades used by the CSM.
  127346. */
  127347. static readonly MAX_CASCADES_COUNT: number;
  127348. protected _validateFilter(filter: number): number;
  127349. /**
  127350. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127351. */
  127352. penumbraDarkness: number;
  127353. private _numCascades;
  127354. /**
  127355. * Gets or set the number of cascades used by the CSM.
  127356. */
  127357. get numCascades(): number;
  127358. set numCascades(value: number);
  127359. /**
  127360. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127361. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127362. */
  127363. stabilizeCascades: boolean;
  127364. private _freezeShadowCastersBoundingInfo;
  127365. private _freezeShadowCastersBoundingInfoObservable;
  127366. /**
  127367. * Enables or disables the shadow casters bounding info computation.
  127368. * If your shadow casters don't move, you can disable this feature.
  127369. * If it is enabled, the bounding box computation is done every frame.
  127370. */
  127371. get freezeShadowCastersBoundingInfo(): boolean;
  127372. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127373. private _scbiMin;
  127374. private _scbiMax;
  127375. protected _computeShadowCastersBoundingInfo(): void;
  127376. protected _shadowCastersBoundingInfo: BoundingInfo;
  127377. /**
  127378. * Gets or sets the shadow casters bounding info.
  127379. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127380. * so that the system won't overwrite the bounds you provide
  127381. */
  127382. get shadowCastersBoundingInfo(): BoundingInfo;
  127383. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127384. protected _breaksAreDirty: boolean;
  127385. protected _minDistance: number;
  127386. protected _maxDistance: number;
  127387. /**
  127388. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127389. *
  127390. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127391. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127392. * @param min minimal distance for the breaks (default to 0.)
  127393. * @param max maximal distance for the breaks (default to 1.)
  127394. */
  127395. setMinMaxDistance(min: number, max: number): void;
  127396. /** Gets the minimal distance used in the cascade break computation */
  127397. get minDistance(): number;
  127398. /** Gets the maximal distance used in the cascade break computation */
  127399. get maxDistance(): number;
  127400. /**
  127401. * Gets the class name of that object
  127402. * @returns "CascadedShadowGenerator"
  127403. */
  127404. getClassName(): string;
  127405. private _cascadeMinExtents;
  127406. private _cascadeMaxExtents;
  127407. /**
  127408. * Gets a cascade minimum extents
  127409. * @param cascadeIndex index of the cascade
  127410. * @returns the minimum cascade extents
  127411. */
  127412. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127413. /**
  127414. * Gets a cascade maximum extents
  127415. * @param cascadeIndex index of the cascade
  127416. * @returns the maximum cascade extents
  127417. */
  127418. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127419. private _cascades;
  127420. private _currentLayer;
  127421. private _viewSpaceFrustumsZ;
  127422. private _viewMatrices;
  127423. private _projectionMatrices;
  127424. private _transformMatrices;
  127425. private _transformMatricesAsArray;
  127426. private _frustumLengths;
  127427. private _lightSizeUVCorrection;
  127428. private _depthCorrection;
  127429. private _frustumCornersWorldSpace;
  127430. private _frustumCenter;
  127431. private _shadowCameraPos;
  127432. private _shadowMaxZ;
  127433. /**
  127434. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127435. * It defaults to camera.maxZ
  127436. */
  127437. get shadowMaxZ(): number;
  127438. /**
  127439. * Sets the shadow max z distance.
  127440. */
  127441. set shadowMaxZ(value: number);
  127442. protected _debug: boolean;
  127443. /**
  127444. * Gets or sets the debug flag.
  127445. * When enabled, the cascades are materialized by different colors on the screen.
  127446. */
  127447. get debug(): boolean;
  127448. set debug(dbg: boolean);
  127449. private _depthClamp;
  127450. /**
  127451. * Gets or sets the depth clamping value.
  127452. *
  127453. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127454. * to account for the shadow casters far away.
  127455. *
  127456. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127457. */
  127458. get depthClamp(): boolean;
  127459. set depthClamp(value: boolean);
  127460. private _cascadeBlendPercentage;
  127461. /**
  127462. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127463. * It defaults to 0.1 (10% blending).
  127464. */
  127465. get cascadeBlendPercentage(): number;
  127466. set cascadeBlendPercentage(value: number);
  127467. private _lambda;
  127468. /**
  127469. * Gets or set the lambda parameter.
  127470. * This parameter is used to split the camera frustum and create the cascades.
  127471. * 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.
  127472. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127473. */
  127474. get lambda(): number;
  127475. set lambda(value: number);
  127476. /**
  127477. * Gets the view matrix corresponding to a given cascade
  127478. * @param cascadeNum cascade to retrieve the view matrix from
  127479. * @returns the cascade view matrix
  127480. */
  127481. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127482. /**
  127483. * Gets the projection matrix corresponding to a given cascade
  127484. * @param cascadeNum cascade to retrieve the projection matrix from
  127485. * @returns the cascade projection matrix
  127486. */
  127487. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127488. /**
  127489. * Gets the transformation matrix corresponding to a given cascade
  127490. * @param cascadeNum cascade to retrieve the transformation matrix from
  127491. * @returns the cascade transformation matrix
  127492. */
  127493. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127494. private _depthRenderer;
  127495. /**
  127496. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127497. *
  127498. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127499. *
  127500. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127501. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127502. * @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
  127503. */
  127504. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127505. private _depthReducer;
  127506. private _autoCalcDepthBounds;
  127507. /**
  127508. * Gets or sets the autoCalcDepthBounds property.
  127509. *
  127510. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127511. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127512. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127513. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127514. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127515. */
  127516. get autoCalcDepthBounds(): boolean;
  127517. set autoCalcDepthBounds(value: boolean);
  127518. /**
  127519. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127520. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127521. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127522. * for setting the refresh rate on the renderer yourself!
  127523. */
  127524. get autoCalcDepthBoundsRefreshRate(): number;
  127525. set autoCalcDepthBoundsRefreshRate(value: number);
  127526. /**
  127527. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127528. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127529. * you change the camera near/far planes!
  127530. */
  127531. splitFrustum(): void;
  127532. private _splitFrustum;
  127533. private _computeMatrices;
  127534. private _computeFrustumInWorldSpace;
  127535. private _computeCascadeFrustum;
  127536. /** @hidden */
  127537. static _SceneComponentInitialization: (scene: Scene) => void;
  127538. /**
  127539. * Creates a Cascaded Shadow Generator object.
  127540. * A ShadowGenerator is the required tool to use the shadows.
  127541. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127542. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127543. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127544. * @param light The directional light object generating the shadows.
  127545. * @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.
  127546. */
  127547. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127548. protected _initializeGenerator(): void;
  127549. protected _createTargetRenderTexture(): void;
  127550. protected _initializeShadowMap(): void;
  127551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127552. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127553. /**
  127554. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127555. * @param defines Defines of the material we want to update
  127556. * @param lightIndex Index of the light in the enabled light list of the material
  127557. */
  127558. prepareDefines(defines: any, lightIndex: number): void;
  127559. /**
  127560. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127561. * defined in the generator but impacting the effect).
  127562. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127563. * @param effect The effect we are binfing the information for
  127564. */
  127565. bindShadowLight(lightIndex: string, effect: Effect): void;
  127566. /**
  127567. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127568. * (eq to view projection * shadow projection matrices)
  127569. * @returns The transform matrix used to create the shadow map
  127570. */
  127571. getTransformMatrix(): Matrix;
  127572. /**
  127573. * Disposes the ShadowGenerator.
  127574. * Returns nothing.
  127575. */
  127576. dispose(): void;
  127577. /**
  127578. * Serializes the shadow generator setup to a json object.
  127579. * @returns The serialized JSON object
  127580. */
  127581. serialize(): any;
  127582. /**
  127583. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127584. * @param parsedShadowGenerator The JSON object to parse
  127585. * @param scene The scene to create the shadow map for
  127586. * @returns The parsed shadow generator
  127587. */
  127588. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127589. }
  127590. }
  127591. declare module BABYLON {
  127592. /**
  127593. * Defines the shadow generator component responsible to manage any shadow generators
  127594. * in a given scene.
  127595. */
  127596. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127597. /**
  127598. * The component name helpfull to identify the component in the list of scene components.
  127599. */
  127600. readonly name: string;
  127601. /**
  127602. * The scene the component belongs to.
  127603. */
  127604. scene: Scene;
  127605. /**
  127606. * Creates a new instance of the component for the given scene
  127607. * @param scene Defines the scene to register the component in
  127608. */
  127609. constructor(scene: Scene);
  127610. /**
  127611. * Registers the component in a given scene
  127612. */
  127613. register(): void;
  127614. /**
  127615. * Rebuilds the elements related to this component in case of
  127616. * context lost for instance.
  127617. */
  127618. rebuild(): void;
  127619. /**
  127620. * Serializes the component data to the specified json object
  127621. * @param serializationObject The object to serialize to
  127622. */
  127623. serialize(serializationObject: any): void;
  127624. /**
  127625. * Adds all the elements from the container to the scene
  127626. * @param container the container holding the elements
  127627. */
  127628. addFromContainer(container: AbstractScene): void;
  127629. /**
  127630. * Removes all the elements in the container from the scene
  127631. * @param container contains the elements to remove
  127632. * @param dispose if the removed element should be disposed (default: false)
  127633. */
  127634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127635. /**
  127636. * Rebuilds the elements related to this component in case of
  127637. * context lost for instance.
  127638. */
  127639. dispose(): void;
  127640. private _gatherRenderTargets;
  127641. }
  127642. }
  127643. declare module BABYLON {
  127644. /**
  127645. * A point light is a light defined by an unique point in world space.
  127646. * The light is emitted in every direction from this point.
  127647. * A good example of a point light is a standard light bulb.
  127648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127649. */
  127650. export class PointLight extends ShadowLight {
  127651. private _shadowAngle;
  127652. /**
  127653. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127654. * This specifies what angle the shadow will use to be created.
  127655. *
  127656. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127657. */
  127658. get shadowAngle(): number;
  127659. /**
  127660. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127661. * This specifies what angle the shadow will use to be created.
  127662. *
  127663. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127664. */
  127665. set shadowAngle(value: number);
  127666. /**
  127667. * Gets the direction if it has been set.
  127668. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127669. */
  127670. get direction(): Vector3;
  127671. /**
  127672. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127673. */
  127674. set direction(value: Vector3);
  127675. /**
  127676. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127677. * A PointLight emits the light in every direction.
  127678. * It can cast shadows.
  127679. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127680. * ```javascript
  127681. * var pointLight = new PointLight("pl", camera.position, scene);
  127682. * ```
  127683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127684. * @param name The light friendly name
  127685. * @param position The position of the point light in the scene
  127686. * @param scene The scene the lights belongs to
  127687. */
  127688. constructor(name: string, position: Vector3, scene: Scene);
  127689. /**
  127690. * Returns the string "PointLight"
  127691. * @returns the class name
  127692. */
  127693. getClassName(): string;
  127694. /**
  127695. * Returns the integer 0.
  127696. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127697. */
  127698. getTypeID(): number;
  127699. /**
  127700. * Specifies wether or not the shadowmap should be a cube texture.
  127701. * @returns true if the shadowmap needs to be a cube texture.
  127702. */
  127703. needCube(): boolean;
  127704. /**
  127705. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127708. */
  127709. getShadowDirection(faceIndex?: number): Vector3;
  127710. /**
  127711. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127712. * - fov = PI / 2
  127713. * - aspect ratio : 1.0
  127714. * - z-near and far equal to the active camera minZ and maxZ.
  127715. * Returns the PointLight.
  127716. */
  127717. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127718. protected _buildUniformLayout(): void;
  127719. /**
  127720. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127721. * @param effect The effect to update
  127722. * @param lightIndex The index of the light in the effect to update
  127723. * @returns The point light
  127724. */
  127725. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127727. /**
  127728. * Prepares the list of defines specific to the light type.
  127729. * @param defines the list of defines
  127730. * @param lightIndex defines the index of the light for the effect
  127731. */
  127732. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127733. }
  127734. }
  127735. declare module BABYLON {
  127736. /**
  127737. * Header information of HDR texture files.
  127738. */
  127739. export interface HDRInfo {
  127740. /**
  127741. * The height of the texture in pixels.
  127742. */
  127743. height: number;
  127744. /**
  127745. * The width of the texture in pixels.
  127746. */
  127747. width: number;
  127748. /**
  127749. * The index of the beginning of the data in the binary file.
  127750. */
  127751. dataPosition: number;
  127752. }
  127753. /**
  127754. * This groups tools to convert HDR texture to native colors array.
  127755. */
  127756. export class HDRTools {
  127757. private static Ldexp;
  127758. private static Rgbe2float;
  127759. private static readStringLine;
  127760. /**
  127761. * Reads header information from an RGBE texture stored in a native array.
  127762. * More information on this format are available here:
  127763. * https://en.wikipedia.org/wiki/RGBE_image_format
  127764. *
  127765. * @param uint8array The binary file stored in native array.
  127766. * @return The header information.
  127767. */
  127768. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127769. /**
  127770. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127771. * This RGBE texture needs to store the information as a panorama.
  127772. *
  127773. * More information on this format are available here:
  127774. * https://en.wikipedia.org/wiki/RGBE_image_format
  127775. *
  127776. * @param buffer The binary file stored in an array buffer.
  127777. * @param size The expected size of the extracted cubemap.
  127778. * @return The Cube Map information.
  127779. */
  127780. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127781. /**
  127782. * Returns the pixels data extracted from an RGBE texture.
  127783. * This pixels will be stored left to right up to down in the R G B order in one array.
  127784. *
  127785. * More information on this format are available here:
  127786. * https://en.wikipedia.org/wiki/RGBE_image_format
  127787. *
  127788. * @param uint8array The binary file stored in an array buffer.
  127789. * @param hdrInfo The header information of the file.
  127790. * @return The pixels data in RGB right to left up to down order.
  127791. */
  127792. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127793. private static RGBE_ReadPixels_RLE;
  127794. }
  127795. }
  127796. declare module BABYLON {
  127797. /**
  127798. * This represents a texture coming from an HDR input.
  127799. *
  127800. * The only supported format is currently panorama picture stored in RGBE format.
  127801. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127802. */
  127803. export class HDRCubeTexture extends BaseTexture {
  127804. private static _facesMapping;
  127805. private _generateHarmonics;
  127806. private _noMipmap;
  127807. private _textureMatrix;
  127808. private _size;
  127809. private _onLoad;
  127810. private _onError;
  127811. /**
  127812. * The texture URL.
  127813. */
  127814. url: string;
  127815. /**
  127816. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127817. */
  127818. coordinatesMode: number;
  127819. protected _isBlocking: boolean;
  127820. /**
  127821. * Sets wether or not the texture is blocking during loading.
  127822. */
  127823. set isBlocking(value: boolean);
  127824. /**
  127825. * Gets wether or not the texture is blocking during loading.
  127826. */
  127827. get isBlocking(): boolean;
  127828. protected _rotationY: number;
  127829. /**
  127830. * Sets texture matrix rotation angle around Y axis in radians.
  127831. */
  127832. set rotationY(value: number);
  127833. /**
  127834. * Gets texture matrix rotation angle around Y axis radians.
  127835. */
  127836. get rotationY(): number;
  127837. /**
  127838. * Gets or sets the center of the bounding box associated with the cube texture
  127839. * It must define where the camera used to render the texture was set
  127840. */
  127841. boundingBoxPosition: Vector3;
  127842. private _boundingBoxSize;
  127843. /**
  127844. * Gets or sets the size of the bounding box associated with the cube texture
  127845. * When defined, the cubemap will switch to local mode
  127846. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127847. * @example https://www.babylonjs-playground.com/#RNASML
  127848. */
  127849. set boundingBoxSize(value: Vector3);
  127850. get boundingBoxSize(): Vector3;
  127851. /**
  127852. * Instantiates an HDRTexture from the following parameters.
  127853. *
  127854. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127855. * @param scene The scene the texture will be used in
  127856. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127857. * @param noMipmap Forces to not generate the mipmap if true
  127858. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127859. * @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)
  127860. * @param reserved Reserved flag for internal use.
  127861. */
  127862. 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>);
  127863. /**
  127864. * Get the current class name of the texture useful for serialization or dynamic coding.
  127865. * @returns "HDRCubeTexture"
  127866. */
  127867. getClassName(): string;
  127868. /**
  127869. * Occurs when the file is raw .hdr file.
  127870. */
  127871. private loadTexture;
  127872. clone(): HDRCubeTexture;
  127873. delayLoad(): void;
  127874. /**
  127875. * Get the texture reflection matrix used to rotate/transform the reflection.
  127876. * @returns the reflection matrix
  127877. */
  127878. getReflectionTextureMatrix(): Matrix;
  127879. /**
  127880. * Set the texture reflection matrix used to rotate/transform the reflection.
  127881. * @param value Define the reflection matrix to set
  127882. */
  127883. setReflectionTextureMatrix(value: Matrix): void;
  127884. /**
  127885. * Parses a JSON representation of an HDR Texture in order to create the texture
  127886. * @param parsedTexture Define the JSON representation
  127887. * @param scene Define the scene the texture should be created in
  127888. * @param rootUrl Define the root url in case we need to load relative dependencies
  127889. * @returns the newly created texture after parsing
  127890. */
  127891. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127892. serialize(): any;
  127893. }
  127894. }
  127895. declare module BABYLON {
  127896. /**
  127897. * Class used to control physics engine
  127898. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127899. */
  127900. export class PhysicsEngine implements IPhysicsEngine {
  127901. private _physicsPlugin;
  127902. /**
  127903. * Global value used to control the smallest number supported by the simulation
  127904. */
  127905. static Epsilon: number;
  127906. private _impostors;
  127907. private _joints;
  127908. private _subTimeStep;
  127909. /**
  127910. * Gets the gravity vector used by the simulation
  127911. */
  127912. gravity: Vector3;
  127913. /**
  127914. * Factory used to create the default physics plugin.
  127915. * @returns The default physics plugin
  127916. */
  127917. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127918. /**
  127919. * Creates a new Physics Engine
  127920. * @param gravity defines the gravity vector used by the simulation
  127921. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127922. */
  127923. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127924. /**
  127925. * Sets the gravity vector used by the simulation
  127926. * @param gravity defines the gravity vector to use
  127927. */
  127928. setGravity(gravity: Vector3): void;
  127929. /**
  127930. * Set the time step of the physics engine.
  127931. * Default is 1/60.
  127932. * To slow it down, enter 1/600 for example.
  127933. * To speed it up, 1/30
  127934. * @param newTimeStep defines the new timestep to apply to this world.
  127935. */
  127936. setTimeStep(newTimeStep?: number): void;
  127937. /**
  127938. * Get the time step of the physics engine.
  127939. * @returns the current time step
  127940. */
  127941. getTimeStep(): number;
  127942. /**
  127943. * Set the sub time step of the physics engine.
  127944. * Default is 0 meaning there is no sub steps
  127945. * To increase physics resolution precision, set a small value (like 1 ms)
  127946. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127947. */
  127948. setSubTimeStep(subTimeStep?: number): void;
  127949. /**
  127950. * Get the sub time step of the physics engine.
  127951. * @returns the current sub time step
  127952. */
  127953. getSubTimeStep(): number;
  127954. /**
  127955. * Release all resources
  127956. */
  127957. dispose(): void;
  127958. /**
  127959. * Gets the name of the current physics plugin
  127960. * @returns the name of the plugin
  127961. */
  127962. getPhysicsPluginName(): string;
  127963. /**
  127964. * Adding a new impostor for the impostor tracking.
  127965. * This will be done by the impostor itself.
  127966. * @param impostor the impostor to add
  127967. */
  127968. addImpostor(impostor: PhysicsImpostor): void;
  127969. /**
  127970. * Remove an impostor from the engine.
  127971. * This impostor and its mesh will not longer be updated by the physics engine.
  127972. * @param impostor the impostor to remove
  127973. */
  127974. removeImpostor(impostor: PhysicsImpostor): void;
  127975. /**
  127976. * Add a joint to the physics engine
  127977. * @param mainImpostor defines the main impostor to which the joint is added.
  127978. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127979. * @param joint defines the joint that will connect both impostors.
  127980. */
  127981. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127982. /**
  127983. * Removes a joint from the simulation
  127984. * @param mainImpostor defines the impostor used with the joint
  127985. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127986. * @param joint defines the joint to remove
  127987. */
  127988. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127989. /**
  127990. * Called by the scene. No need to call it.
  127991. * @param delta defines the timespam between frames
  127992. */
  127993. _step(delta: number): void;
  127994. /**
  127995. * Gets the current plugin used to run the simulation
  127996. * @returns current plugin
  127997. */
  127998. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127999. /**
  128000. * Gets the list of physic impostors
  128001. * @returns an array of PhysicsImpostor
  128002. */
  128003. getImpostors(): Array<PhysicsImpostor>;
  128004. /**
  128005. * Gets the impostor for a physics enabled object
  128006. * @param object defines the object impersonated by the impostor
  128007. * @returns the PhysicsImpostor or null if not found
  128008. */
  128009. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128010. /**
  128011. * Gets the impostor for a physics body object
  128012. * @param body defines physics body used by the impostor
  128013. * @returns the PhysicsImpostor or null if not found
  128014. */
  128015. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128016. /**
  128017. * Does a raycast in the physics world
  128018. * @param from when should the ray start?
  128019. * @param to when should the ray end?
  128020. * @returns PhysicsRaycastResult
  128021. */
  128022. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128023. }
  128024. }
  128025. declare module BABYLON {
  128026. /** @hidden */
  128027. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128028. private _useDeltaForWorldStep;
  128029. world: any;
  128030. name: string;
  128031. private _physicsMaterials;
  128032. private _fixedTimeStep;
  128033. private _cannonRaycastResult;
  128034. private _raycastResult;
  128035. private _physicsBodysToRemoveAfterStep;
  128036. BJSCANNON: any;
  128037. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128038. setGravity(gravity: Vector3): void;
  128039. setTimeStep(timeStep: number): void;
  128040. getTimeStep(): number;
  128041. executeStep(delta: number): void;
  128042. private _removeMarkedPhysicsBodiesFromWorld;
  128043. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128044. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128045. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128046. private _processChildMeshes;
  128047. removePhysicsBody(impostor: PhysicsImpostor): void;
  128048. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128049. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128050. private _addMaterial;
  128051. private _checkWithEpsilon;
  128052. private _createShape;
  128053. private _createHeightmap;
  128054. private _minus90X;
  128055. private _plus90X;
  128056. private _tmpPosition;
  128057. private _tmpDeltaPosition;
  128058. private _tmpUnityRotation;
  128059. private _updatePhysicsBodyTransformation;
  128060. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128061. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128062. isSupported(): boolean;
  128063. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128064. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128065. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128066. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128067. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128068. getBodyMass(impostor: PhysicsImpostor): number;
  128069. getBodyFriction(impostor: PhysicsImpostor): number;
  128070. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128071. getBodyRestitution(impostor: PhysicsImpostor): number;
  128072. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128073. sleepBody(impostor: PhysicsImpostor): void;
  128074. wakeUpBody(impostor: PhysicsImpostor): void;
  128075. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128076. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128077. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128078. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128079. getRadius(impostor: PhysicsImpostor): number;
  128080. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128081. dispose(): void;
  128082. private _extendNamespace;
  128083. /**
  128084. * Does a raycast in the physics world
  128085. * @param from when should the ray start?
  128086. * @param to when should the ray end?
  128087. * @returns PhysicsRaycastResult
  128088. */
  128089. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128090. }
  128091. }
  128092. declare module BABYLON {
  128093. /** @hidden */
  128094. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128095. world: any;
  128096. name: string;
  128097. BJSOIMO: any;
  128098. private _raycastResult;
  128099. constructor(iterations?: number, oimoInjection?: any);
  128100. setGravity(gravity: Vector3): void;
  128101. setTimeStep(timeStep: number): void;
  128102. getTimeStep(): number;
  128103. private _tmpImpostorsArray;
  128104. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128105. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128106. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128107. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128108. private _tmpPositionVector;
  128109. removePhysicsBody(impostor: PhysicsImpostor): void;
  128110. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128111. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128112. isSupported(): boolean;
  128113. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128114. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128115. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128116. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128117. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128118. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128119. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128120. getBodyMass(impostor: PhysicsImpostor): number;
  128121. getBodyFriction(impostor: PhysicsImpostor): number;
  128122. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128123. getBodyRestitution(impostor: PhysicsImpostor): number;
  128124. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128125. sleepBody(impostor: PhysicsImpostor): void;
  128126. wakeUpBody(impostor: PhysicsImpostor): void;
  128127. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128128. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128129. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128130. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128131. getRadius(impostor: PhysicsImpostor): number;
  128132. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128133. dispose(): void;
  128134. /**
  128135. * Does a raycast in the physics world
  128136. * @param from when should the ray start?
  128137. * @param to when should the ray end?
  128138. * @returns PhysicsRaycastResult
  128139. */
  128140. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128141. }
  128142. }
  128143. declare module BABYLON {
  128144. /**
  128145. * Class containing static functions to help procedurally build meshes
  128146. */
  128147. export class RibbonBuilder {
  128148. /**
  128149. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128150. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128151. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128152. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128153. * * 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
  128154. * * 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
  128155. * * 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
  128156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128159. * * 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
  128160. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128161. * * 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
  128162. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128164. * @param name defines the name of the mesh
  128165. * @param options defines the options used to create the mesh
  128166. * @param scene defines the hosting scene
  128167. * @returns the ribbon mesh
  128168. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128170. */
  128171. static CreateRibbon(name: string, options: {
  128172. pathArray: Vector3[][];
  128173. closeArray?: boolean;
  128174. closePath?: boolean;
  128175. offset?: number;
  128176. updatable?: boolean;
  128177. sideOrientation?: number;
  128178. frontUVs?: Vector4;
  128179. backUVs?: Vector4;
  128180. instance?: Mesh;
  128181. invertUV?: boolean;
  128182. uvs?: Vector2[];
  128183. colors?: Color4[];
  128184. }, scene?: Nullable<Scene>): Mesh;
  128185. }
  128186. }
  128187. declare module BABYLON {
  128188. /**
  128189. * Class containing static functions to help procedurally build meshes
  128190. */
  128191. export class ShapeBuilder {
  128192. /**
  128193. * 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.
  128194. * * 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.
  128195. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128196. * * 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.
  128197. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128198. * * 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
  128199. * * 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
  128200. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128205. * @param name defines the name of the mesh
  128206. * @param options defines the options used to create the mesh
  128207. * @param scene defines the hosting scene
  128208. * @returns the extruded shape mesh
  128209. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128211. */
  128212. static ExtrudeShape(name: string, options: {
  128213. shape: Vector3[];
  128214. path: Vector3[];
  128215. scale?: number;
  128216. rotation?: number;
  128217. cap?: number;
  128218. updatable?: boolean;
  128219. sideOrientation?: number;
  128220. frontUVs?: Vector4;
  128221. backUVs?: Vector4;
  128222. instance?: Mesh;
  128223. invertUV?: boolean;
  128224. }, scene?: Nullable<Scene>): Mesh;
  128225. /**
  128226. * Creates an custom extruded shape mesh.
  128227. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128228. * * 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.
  128229. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128230. * * 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
  128231. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128232. * * 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
  128233. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128234. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128235. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128236. * * 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
  128237. * * 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
  128238. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128243. * @param name defines the name of the mesh
  128244. * @param options defines the options used to create the mesh
  128245. * @param scene defines the hosting scene
  128246. * @returns the custom extruded shape mesh
  128247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128250. */
  128251. static ExtrudeShapeCustom(name: string, options: {
  128252. shape: Vector3[];
  128253. path: Vector3[];
  128254. scaleFunction?: any;
  128255. rotationFunction?: any;
  128256. ribbonCloseArray?: boolean;
  128257. ribbonClosePath?: boolean;
  128258. cap?: number;
  128259. updatable?: boolean;
  128260. sideOrientation?: number;
  128261. frontUVs?: Vector4;
  128262. backUVs?: Vector4;
  128263. instance?: Mesh;
  128264. invertUV?: boolean;
  128265. }, scene?: Nullable<Scene>): Mesh;
  128266. private static _ExtrudeShapeGeneric;
  128267. }
  128268. }
  128269. declare module BABYLON {
  128270. /**
  128271. * AmmoJS Physics plugin
  128272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128273. * @see https://github.com/kripken/ammo.js/
  128274. */
  128275. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128276. private _useDeltaForWorldStep;
  128277. /**
  128278. * Reference to the Ammo library
  128279. */
  128280. bjsAMMO: any;
  128281. /**
  128282. * Created ammoJS world which physics bodies are added to
  128283. */
  128284. world: any;
  128285. /**
  128286. * Name of the plugin
  128287. */
  128288. name: string;
  128289. private _timeStep;
  128290. private _fixedTimeStep;
  128291. private _maxSteps;
  128292. private _tmpQuaternion;
  128293. private _tmpAmmoTransform;
  128294. private _tmpAmmoQuaternion;
  128295. private _tmpAmmoConcreteContactResultCallback;
  128296. private _collisionConfiguration;
  128297. private _dispatcher;
  128298. private _overlappingPairCache;
  128299. private _solver;
  128300. private _softBodySolver;
  128301. private _tmpAmmoVectorA;
  128302. private _tmpAmmoVectorB;
  128303. private _tmpAmmoVectorC;
  128304. private _tmpAmmoVectorD;
  128305. private _tmpContactCallbackResult;
  128306. private _tmpAmmoVectorRCA;
  128307. private _tmpAmmoVectorRCB;
  128308. private _raycastResult;
  128309. private static readonly DISABLE_COLLISION_FLAG;
  128310. private static readonly KINEMATIC_FLAG;
  128311. private static readonly DISABLE_DEACTIVATION_FLAG;
  128312. /**
  128313. * Initializes the ammoJS plugin
  128314. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128315. * @param ammoInjection can be used to inject your own ammo reference
  128316. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128317. */
  128318. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128319. /**
  128320. * Sets the gravity of the physics world (m/(s^2))
  128321. * @param gravity Gravity to set
  128322. */
  128323. setGravity(gravity: Vector3): void;
  128324. /**
  128325. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128326. * @param timeStep timestep to use in seconds
  128327. */
  128328. setTimeStep(timeStep: number): void;
  128329. /**
  128330. * 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)
  128331. * @param fixedTimeStep fixedTimeStep to use in seconds
  128332. */
  128333. setFixedTimeStep(fixedTimeStep: number): void;
  128334. /**
  128335. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128336. * @param maxSteps the maximum number of steps by the physics engine per frame
  128337. */
  128338. setMaxSteps(maxSteps: number): void;
  128339. /**
  128340. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128341. * @returns the current timestep in seconds
  128342. */
  128343. getTimeStep(): number;
  128344. /**
  128345. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128346. */
  128347. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128348. private _isImpostorInContact;
  128349. private _isImpostorPairInContact;
  128350. private _stepSimulation;
  128351. /**
  128352. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128353. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128354. * After the step the babylon meshes are set to the position of the physics imposters
  128355. * @param delta amount of time to step forward
  128356. * @param impostors array of imposters to update before/after the step
  128357. */
  128358. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128359. /**
  128360. * Update babylon mesh to match physics world object
  128361. * @param impostor imposter to match
  128362. */
  128363. private _afterSoftStep;
  128364. /**
  128365. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128366. * @param impostor imposter to match
  128367. */
  128368. private _ropeStep;
  128369. /**
  128370. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128371. * @param impostor imposter to match
  128372. */
  128373. private _softbodyOrClothStep;
  128374. private _tmpVector;
  128375. private _tmpMatrix;
  128376. /**
  128377. * Applies an impulse on the imposter
  128378. * @param impostor imposter to apply impulse to
  128379. * @param force amount of force to be applied to the imposter
  128380. * @param contactPoint the location to apply the impulse on the imposter
  128381. */
  128382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128383. /**
  128384. * Applies a force on the imposter
  128385. * @param impostor imposter to apply force
  128386. * @param force amount of force to be applied to the imposter
  128387. * @param contactPoint the location to apply the force on the imposter
  128388. */
  128389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128390. /**
  128391. * Creates a physics body using the plugin
  128392. * @param impostor the imposter to create the physics body on
  128393. */
  128394. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128395. /**
  128396. * Removes the physics body from the imposter and disposes of the body's memory
  128397. * @param impostor imposter to remove the physics body from
  128398. */
  128399. removePhysicsBody(impostor: PhysicsImpostor): void;
  128400. /**
  128401. * Generates a joint
  128402. * @param impostorJoint the imposter joint to create the joint with
  128403. */
  128404. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128405. /**
  128406. * Removes a joint
  128407. * @param impostorJoint the imposter joint to remove the joint from
  128408. */
  128409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128410. private _addMeshVerts;
  128411. /**
  128412. * Initialise the soft body vertices to match its object's (mesh) vertices
  128413. * Softbody vertices (nodes) are in world space and to match this
  128414. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128415. * @param impostor to create the softbody for
  128416. */
  128417. private _softVertexData;
  128418. /**
  128419. * Create an impostor's soft body
  128420. * @param impostor to create the softbody for
  128421. */
  128422. private _createSoftbody;
  128423. /**
  128424. * Create cloth for an impostor
  128425. * @param impostor to create the softbody for
  128426. */
  128427. private _createCloth;
  128428. /**
  128429. * Create rope for an impostor
  128430. * @param impostor to create the softbody for
  128431. */
  128432. private _createRope;
  128433. /**
  128434. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128435. * @param impostor to create the custom physics shape for
  128436. */
  128437. private _createCustom;
  128438. private _addHullVerts;
  128439. private _createShape;
  128440. /**
  128441. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128442. * @param impostor imposter containing the physics body and babylon object
  128443. */
  128444. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128445. /**
  128446. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128447. * @param impostor imposter containing the physics body and babylon object
  128448. * @param newPosition new position
  128449. * @param newRotation new rotation
  128450. */
  128451. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128452. /**
  128453. * If this plugin is supported
  128454. * @returns true if its supported
  128455. */
  128456. isSupported(): boolean;
  128457. /**
  128458. * Sets the linear velocity of the physics body
  128459. * @param impostor imposter to set the velocity on
  128460. * @param velocity velocity to set
  128461. */
  128462. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128463. /**
  128464. * Sets the angular velocity of the physics body
  128465. * @param impostor imposter to set the velocity on
  128466. * @param velocity velocity to set
  128467. */
  128468. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128469. /**
  128470. * gets the linear velocity
  128471. * @param impostor imposter to get linear velocity from
  128472. * @returns linear velocity
  128473. */
  128474. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128475. /**
  128476. * gets the angular velocity
  128477. * @param impostor imposter to get angular velocity from
  128478. * @returns angular velocity
  128479. */
  128480. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128481. /**
  128482. * Sets the mass of physics body
  128483. * @param impostor imposter to set the mass on
  128484. * @param mass mass to set
  128485. */
  128486. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128487. /**
  128488. * Gets the mass of the physics body
  128489. * @param impostor imposter to get the mass from
  128490. * @returns mass
  128491. */
  128492. getBodyMass(impostor: PhysicsImpostor): number;
  128493. /**
  128494. * Gets friction of the impostor
  128495. * @param impostor impostor to get friction from
  128496. * @returns friction value
  128497. */
  128498. getBodyFriction(impostor: PhysicsImpostor): number;
  128499. /**
  128500. * Sets friction of the impostor
  128501. * @param impostor impostor to set friction on
  128502. * @param friction friction value
  128503. */
  128504. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128505. /**
  128506. * Gets restitution of the impostor
  128507. * @param impostor impostor to get restitution from
  128508. * @returns restitution value
  128509. */
  128510. getBodyRestitution(impostor: PhysicsImpostor): number;
  128511. /**
  128512. * Sets resitution of the impostor
  128513. * @param impostor impostor to set resitution on
  128514. * @param restitution resitution value
  128515. */
  128516. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128517. /**
  128518. * Gets pressure inside the impostor
  128519. * @param impostor impostor to get pressure from
  128520. * @returns pressure value
  128521. */
  128522. getBodyPressure(impostor: PhysicsImpostor): number;
  128523. /**
  128524. * Sets pressure inside a soft body impostor
  128525. * Cloth and rope must remain 0 pressure
  128526. * @param impostor impostor to set pressure on
  128527. * @param pressure pressure value
  128528. */
  128529. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128530. /**
  128531. * Gets stiffness of the impostor
  128532. * @param impostor impostor to get stiffness from
  128533. * @returns pressure value
  128534. */
  128535. getBodyStiffness(impostor: PhysicsImpostor): number;
  128536. /**
  128537. * Sets stiffness of the impostor
  128538. * @param impostor impostor to set stiffness on
  128539. * @param stiffness stiffness value from 0 to 1
  128540. */
  128541. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128542. /**
  128543. * Gets velocityIterations of the impostor
  128544. * @param impostor impostor to get velocity iterations from
  128545. * @returns velocityIterations value
  128546. */
  128547. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128548. /**
  128549. * Sets velocityIterations of the impostor
  128550. * @param impostor impostor to set velocity iterations on
  128551. * @param velocityIterations velocityIterations value
  128552. */
  128553. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128554. /**
  128555. * Gets positionIterations of the impostor
  128556. * @param impostor impostor to get position iterations from
  128557. * @returns positionIterations value
  128558. */
  128559. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128560. /**
  128561. * Sets positionIterations of the impostor
  128562. * @param impostor impostor to set position on
  128563. * @param positionIterations positionIterations value
  128564. */
  128565. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128566. /**
  128567. * Append an anchor to a cloth object
  128568. * @param impostor is the cloth impostor to add anchor to
  128569. * @param otherImpostor is the rigid impostor to anchor to
  128570. * @param width ratio across width from 0 to 1
  128571. * @param height ratio up height from 0 to 1
  128572. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128573. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128574. */
  128575. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128576. /**
  128577. * Append an hook to a rope object
  128578. * @param impostor is the rope impostor to add hook to
  128579. * @param otherImpostor is the rigid impostor to hook to
  128580. * @param length ratio along the rope from 0 to 1
  128581. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128582. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128583. */
  128584. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128585. /**
  128586. * Sleeps the physics body and stops it from being active
  128587. * @param impostor impostor to sleep
  128588. */
  128589. sleepBody(impostor: PhysicsImpostor): void;
  128590. /**
  128591. * Activates the physics body
  128592. * @param impostor impostor to activate
  128593. */
  128594. wakeUpBody(impostor: PhysicsImpostor): void;
  128595. /**
  128596. * Updates the distance parameters of the joint
  128597. * @param joint joint to update
  128598. * @param maxDistance maximum distance of the joint
  128599. * @param minDistance minimum distance of the joint
  128600. */
  128601. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128602. /**
  128603. * Sets a motor on the joint
  128604. * @param joint joint to set motor on
  128605. * @param speed speed of the motor
  128606. * @param maxForce maximum force of the motor
  128607. * @param motorIndex index of the motor
  128608. */
  128609. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128610. /**
  128611. * Sets the motors limit
  128612. * @param joint joint to set limit on
  128613. * @param upperLimit upper limit
  128614. * @param lowerLimit lower limit
  128615. */
  128616. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128617. /**
  128618. * Syncs the position and rotation of a mesh with the impostor
  128619. * @param mesh mesh to sync
  128620. * @param impostor impostor to update the mesh with
  128621. */
  128622. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128623. /**
  128624. * Gets the radius of the impostor
  128625. * @param impostor impostor to get radius from
  128626. * @returns the radius
  128627. */
  128628. getRadius(impostor: PhysicsImpostor): number;
  128629. /**
  128630. * Gets the box size of the impostor
  128631. * @param impostor impostor to get box size from
  128632. * @param result the resulting box size
  128633. */
  128634. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128635. /**
  128636. * Disposes of the impostor
  128637. */
  128638. dispose(): void;
  128639. /**
  128640. * Does a raycast in the physics world
  128641. * @param from when should the ray start?
  128642. * @param to when should the ray end?
  128643. * @returns PhysicsRaycastResult
  128644. */
  128645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128646. }
  128647. }
  128648. declare module BABYLON {
  128649. interface AbstractScene {
  128650. /**
  128651. * The list of reflection probes added to the scene
  128652. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128653. */
  128654. reflectionProbes: Array<ReflectionProbe>;
  128655. /**
  128656. * Removes the given reflection probe from this scene.
  128657. * @param toRemove The reflection probe to remove
  128658. * @returns The index of the removed reflection probe
  128659. */
  128660. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128661. /**
  128662. * Adds the given reflection probe to this scene.
  128663. * @param newReflectionProbe The reflection probe to add
  128664. */
  128665. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128666. }
  128667. /**
  128668. * Class used to generate realtime reflection / refraction cube textures
  128669. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128670. */
  128671. export class ReflectionProbe {
  128672. /** defines the name of the probe */
  128673. name: string;
  128674. private _scene;
  128675. private _renderTargetTexture;
  128676. private _projectionMatrix;
  128677. private _viewMatrix;
  128678. private _target;
  128679. private _add;
  128680. private _attachedMesh;
  128681. private _invertYAxis;
  128682. /** Gets or sets probe position (center of the cube map) */
  128683. position: Vector3;
  128684. /**
  128685. * Creates a new reflection probe
  128686. * @param name defines the name of the probe
  128687. * @param size defines the texture resolution (for each face)
  128688. * @param scene defines the hosting scene
  128689. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128690. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128691. */
  128692. constructor(
  128693. /** defines the name of the probe */
  128694. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128695. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128696. get samples(): number;
  128697. set samples(value: number);
  128698. /** Gets or sets the refresh rate to use (on every frame by default) */
  128699. get refreshRate(): number;
  128700. set refreshRate(value: number);
  128701. /**
  128702. * Gets the hosting scene
  128703. * @returns a Scene
  128704. */
  128705. getScene(): Scene;
  128706. /** Gets the internal CubeTexture used to render to */
  128707. get cubeTexture(): RenderTargetTexture;
  128708. /** Gets the list of meshes to render */
  128709. get renderList(): Nullable<AbstractMesh[]>;
  128710. /**
  128711. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128712. * @param mesh defines the mesh to attach to
  128713. */
  128714. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128715. /**
  128716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128717. * @param renderingGroupId The rendering group id corresponding to its index
  128718. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128719. */
  128720. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128721. /**
  128722. * Clean all associated resources
  128723. */
  128724. dispose(): void;
  128725. /**
  128726. * Converts the reflection probe information to a readable string for debug purpose.
  128727. * @param fullDetails Supports for multiple levels of logging within scene loading
  128728. * @returns the human readable reflection probe info
  128729. */
  128730. toString(fullDetails?: boolean): string;
  128731. /**
  128732. * Get the class name of the relfection probe.
  128733. * @returns "ReflectionProbe"
  128734. */
  128735. getClassName(): string;
  128736. /**
  128737. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128738. * @returns The JSON representation of the texture
  128739. */
  128740. serialize(): any;
  128741. /**
  128742. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128743. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128744. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128745. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128746. * @returns The parsed reflection probe if successful
  128747. */
  128748. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128749. }
  128750. }
  128751. declare module BABYLON {
  128752. /** @hidden */
  128753. export var _BabylonLoaderRegistered: boolean;
  128754. /**
  128755. * Helps setting up some configuration for the babylon file loader.
  128756. */
  128757. export class BabylonFileLoaderConfiguration {
  128758. /**
  128759. * The loader does not allow injecting custom physix engine into the plugins.
  128760. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128761. * So you could set this variable to your engine import to make it work.
  128762. */
  128763. static LoaderInjectedPhysicsEngine: any;
  128764. }
  128765. }
  128766. declare module BABYLON {
  128767. /**
  128768. * The Physically based simple base material of BJS.
  128769. *
  128770. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128771. * It is used as the base class for both the specGloss and metalRough conventions.
  128772. */
  128773. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128774. /**
  128775. * Number of Simultaneous lights allowed on the material.
  128776. */
  128777. maxSimultaneousLights: number;
  128778. /**
  128779. * If sets to true, disables all the lights affecting the material.
  128780. */
  128781. disableLighting: boolean;
  128782. /**
  128783. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128784. */
  128785. environmentTexture: BaseTexture;
  128786. /**
  128787. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128788. */
  128789. invertNormalMapX: boolean;
  128790. /**
  128791. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128792. */
  128793. invertNormalMapY: boolean;
  128794. /**
  128795. * Normal map used in the model.
  128796. */
  128797. normalTexture: BaseTexture;
  128798. /**
  128799. * Emissivie color used to self-illuminate the model.
  128800. */
  128801. emissiveColor: Color3;
  128802. /**
  128803. * Emissivie texture used to self-illuminate the model.
  128804. */
  128805. emissiveTexture: BaseTexture;
  128806. /**
  128807. * Occlusion Channel Strenght.
  128808. */
  128809. occlusionStrength: number;
  128810. /**
  128811. * Occlusion Texture of the material (adding extra occlusion effects).
  128812. */
  128813. occlusionTexture: BaseTexture;
  128814. /**
  128815. * Defines the alpha limits in alpha test mode.
  128816. */
  128817. alphaCutOff: number;
  128818. /**
  128819. * Gets the current double sided mode.
  128820. */
  128821. get doubleSided(): boolean;
  128822. /**
  128823. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128824. */
  128825. set doubleSided(value: boolean);
  128826. /**
  128827. * Stores the pre-calculated light information of a mesh in a texture.
  128828. */
  128829. lightmapTexture: BaseTexture;
  128830. /**
  128831. * If true, the light map contains occlusion information instead of lighting info.
  128832. */
  128833. useLightmapAsShadowmap: boolean;
  128834. /**
  128835. * Instantiates a new PBRMaterial instance.
  128836. *
  128837. * @param name The material name
  128838. * @param scene The scene the material will be use in.
  128839. */
  128840. constructor(name: string, scene: Scene);
  128841. getClassName(): string;
  128842. }
  128843. }
  128844. declare module BABYLON {
  128845. /**
  128846. * The PBR material of BJS following the metal roughness convention.
  128847. *
  128848. * This fits to the PBR convention in the GLTF definition:
  128849. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128850. */
  128851. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128852. /**
  128853. * The base color has two different interpretations depending on the value of metalness.
  128854. * When the material is a metal, the base color is the specific measured reflectance value
  128855. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128856. * of the material.
  128857. */
  128858. baseColor: Color3;
  128859. /**
  128860. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128861. * well as opacity information in the alpha channel.
  128862. */
  128863. baseTexture: BaseTexture;
  128864. /**
  128865. * Specifies the metallic scalar value of the material.
  128866. * Can also be used to scale the metalness values of the metallic texture.
  128867. */
  128868. metallic: number;
  128869. /**
  128870. * Specifies the roughness scalar value of the material.
  128871. * Can also be used to scale the roughness values of the metallic texture.
  128872. */
  128873. roughness: number;
  128874. /**
  128875. * Texture containing both the metallic value in the B channel and the
  128876. * roughness value in the G channel to keep better precision.
  128877. */
  128878. metallicRoughnessTexture: BaseTexture;
  128879. /**
  128880. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128881. *
  128882. * @param name The material name
  128883. * @param scene The scene the material will be use in.
  128884. */
  128885. constructor(name: string, scene: Scene);
  128886. /**
  128887. * Return the currrent class name of the material.
  128888. */
  128889. getClassName(): string;
  128890. /**
  128891. * Makes a duplicate of the current material.
  128892. * @param name - name to use for the new material.
  128893. */
  128894. clone(name: string): PBRMetallicRoughnessMaterial;
  128895. /**
  128896. * Serialize the material to a parsable JSON object.
  128897. */
  128898. serialize(): any;
  128899. /**
  128900. * Parses a JSON object correponding to the serialize function.
  128901. */
  128902. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128903. }
  128904. }
  128905. declare module BABYLON {
  128906. /**
  128907. * The PBR material of BJS following the specular glossiness convention.
  128908. *
  128909. * This fits to the PBR convention in the GLTF definition:
  128910. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128911. */
  128912. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128913. /**
  128914. * Specifies the diffuse color of the material.
  128915. */
  128916. diffuseColor: Color3;
  128917. /**
  128918. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128919. * channel.
  128920. */
  128921. diffuseTexture: BaseTexture;
  128922. /**
  128923. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128924. */
  128925. specularColor: Color3;
  128926. /**
  128927. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128928. */
  128929. glossiness: number;
  128930. /**
  128931. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128932. */
  128933. specularGlossinessTexture: BaseTexture;
  128934. /**
  128935. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128936. *
  128937. * @param name The material name
  128938. * @param scene The scene the material will be use in.
  128939. */
  128940. constructor(name: string, scene: Scene);
  128941. /**
  128942. * Return the currrent class name of the material.
  128943. */
  128944. getClassName(): string;
  128945. /**
  128946. * Makes a duplicate of the current material.
  128947. * @param name - name to use for the new material.
  128948. */
  128949. clone(name: string): PBRSpecularGlossinessMaterial;
  128950. /**
  128951. * Serialize the material to a parsable JSON object.
  128952. */
  128953. serialize(): any;
  128954. /**
  128955. * Parses a JSON object correponding to the serialize function.
  128956. */
  128957. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128958. }
  128959. }
  128960. declare module BABYLON {
  128961. /**
  128962. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128963. * It can help converting any input color in a desired output one. This can then be used to create effects
  128964. * from sepia, black and white to sixties or futuristic rendering...
  128965. *
  128966. * The only supported format is currently 3dl.
  128967. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128968. */
  128969. export class ColorGradingTexture extends BaseTexture {
  128970. /**
  128971. * The current texture matrix. (will always be identity in color grading texture)
  128972. */
  128973. private _textureMatrix;
  128974. /**
  128975. * The texture URL.
  128976. */
  128977. url: string;
  128978. /**
  128979. * Empty line regex stored for GC.
  128980. */
  128981. private static _noneEmptyLineRegex;
  128982. private _engine;
  128983. /**
  128984. * Instantiates a ColorGradingTexture from the following parameters.
  128985. *
  128986. * @param url The location of the color gradind data (currently only supporting 3dl)
  128987. * @param scene The scene the texture will be used in
  128988. */
  128989. constructor(url: string, scene: Scene);
  128990. /**
  128991. * Returns the texture matrix used in most of the material.
  128992. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128993. */
  128994. getTextureMatrix(): Matrix;
  128995. /**
  128996. * Occurs when the file being loaded is a .3dl LUT file.
  128997. */
  128998. private load3dlTexture;
  128999. /**
  129000. * Starts the loading process of the texture.
  129001. */
  129002. private loadTexture;
  129003. /**
  129004. * Clones the color gradind texture.
  129005. */
  129006. clone(): ColorGradingTexture;
  129007. /**
  129008. * Called during delayed load for textures.
  129009. */
  129010. delayLoad(): void;
  129011. /**
  129012. * Parses a color grading texture serialized by Babylon.
  129013. * @param parsedTexture The texture information being parsedTexture
  129014. * @param scene The scene to load the texture in
  129015. * @param rootUrl The root url of the data assets to load
  129016. * @return A color gradind texture
  129017. */
  129018. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129019. /**
  129020. * Serializes the LUT texture to json format.
  129021. */
  129022. serialize(): any;
  129023. }
  129024. }
  129025. declare module BABYLON {
  129026. /**
  129027. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129028. */
  129029. export class EquiRectangularCubeTexture extends BaseTexture {
  129030. /** The six faces of the cube. */
  129031. private static _FacesMapping;
  129032. private _noMipmap;
  129033. private _onLoad;
  129034. private _onError;
  129035. /** The size of the cubemap. */
  129036. private _size;
  129037. /** The buffer of the image. */
  129038. private _buffer;
  129039. /** The width of the input image. */
  129040. private _width;
  129041. /** The height of the input image. */
  129042. private _height;
  129043. /** The URL to the image. */
  129044. url: string;
  129045. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129046. coordinatesMode: number;
  129047. /**
  129048. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129049. * @param url The location of the image
  129050. * @param scene The scene the texture will be used in
  129051. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129052. * @param noMipmap Forces to not generate the mipmap if true
  129053. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129054. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129055. * @param onLoad — defines a callback called when texture is loaded
  129056. * @param onError — defines a callback called if there is an error
  129057. */
  129058. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129059. /**
  129060. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129061. */
  129062. private loadImage;
  129063. /**
  129064. * Convert the image buffer into a cubemap and create a CubeTexture.
  129065. */
  129066. private loadTexture;
  129067. /**
  129068. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129069. * @param buffer The ArrayBuffer that should be converted.
  129070. * @returns The buffer as Float32Array.
  129071. */
  129072. private getFloat32ArrayFromArrayBuffer;
  129073. /**
  129074. * Get the current class name of the texture useful for serialization or dynamic coding.
  129075. * @returns "EquiRectangularCubeTexture"
  129076. */
  129077. getClassName(): string;
  129078. /**
  129079. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129080. * @returns A clone of the current EquiRectangularCubeTexture.
  129081. */
  129082. clone(): EquiRectangularCubeTexture;
  129083. }
  129084. }
  129085. declare module BABYLON {
  129086. /**
  129087. * Based on jsTGALoader - Javascript loader for TGA file
  129088. * By Vincent Thibault
  129089. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129090. */
  129091. export class TGATools {
  129092. private static _TYPE_INDEXED;
  129093. private static _TYPE_RGB;
  129094. private static _TYPE_GREY;
  129095. private static _TYPE_RLE_INDEXED;
  129096. private static _TYPE_RLE_RGB;
  129097. private static _TYPE_RLE_GREY;
  129098. private static _ORIGIN_MASK;
  129099. private static _ORIGIN_SHIFT;
  129100. private static _ORIGIN_BL;
  129101. private static _ORIGIN_BR;
  129102. private static _ORIGIN_UL;
  129103. private static _ORIGIN_UR;
  129104. /**
  129105. * Gets the header of a TGA file
  129106. * @param data defines the TGA data
  129107. * @returns the header
  129108. */
  129109. static GetTGAHeader(data: Uint8Array): any;
  129110. /**
  129111. * Uploads TGA content to a Babylon Texture
  129112. * @hidden
  129113. */
  129114. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129115. /** @hidden */
  129116. 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;
  129117. /** @hidden */
  129118. 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;
  129119. /** @hidden */
  129120. 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;
  129121. /** @hidden */
  129122. 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;
  129123. /** @hidden */
  129124. 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;
  129125. /** @hidden */
  129126. 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;
  129127. }
  129128. }
  129129. declare module BABYLON {
  129130. /**
  129131. * Implementation of the TGA Texture Loader.
  129132. * @hidden
  129133. */
  129134. export class _TGATextureLoader implements IInternalTextureLoader {
  129135. /**
  129136. * Defines wether the loader supports cascade loading the different faces.
  129137. */
  129138. readonly supportCascades: boolean;
  129139. /**
  129140. * This returns if the loader support the current file information.
  129141. * @param extension defines the file extension of the file being loaded
  129142. * @returns true if the loader can load the specified file
  129143. */
  129144. canLoad(extension: string): boolean;
  129145. /**
  129146. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129147. * @param data contains the texture data
  129148. * @param texture defines the BabylonJS internal texture
  129149. * @param createPolynomials will be true if polynomials have been requested
  129150. * @param onLoad defines the callback to trigger once the texture is ready
  129151. * @param onError defines the callback to trigger in case of error
  129152. */
  129153. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129154. /**
  129155. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129156. * @param data contains the texture data
  129157. * @param texture defines the BabylonJS internal texture
  129158. * @param callback defines the method to call once ready to upload
  129159. */
  129160. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129161. }
  129162. }
  129163. declare module BABYLON {
  129164. /**
  129165. * Info about the .basis files
  129166. */
  129167. class BasisFileInfo {
  129168. /**
  129169. * If the file has alpha
  129170. */
  129171. hasAlpha: boolean;
  129172. /**
  129173. * Info about each image of the basis file
  129174. */
  129175. images: Array<{
  129176. levels: Array<{
  129177. width: number;
  129178. height: number;
  129179. transcodedPixels: ArrayBufferView;
  129180. }>;
  129181. }>;
  129182. }
  129183. /**
  129184. * Result of transcoding a basis file
  129185. */
  129186. class TranscodeResult {
  129187. /**
  129188. * Info about the .basis file
  129189. */
  129190. fileInfo: BasisFileInfo;
  129191. /**
  129192. * Format to use when loading the file
  129193. */
  129194. format: number;
  129195. }
  129196. /**
  129197. * Configuration options for the Basis transcoder
  129198. */
  129199. export class BasisTranscodeConfiguration {
  129200. /**
  129201. * Supported compression formats used to determine the supported output format of the transcoder
  129202. */
  129203. supportedCompressionFormats?: {
  129204. /**
  129205. * etc1 compression format
  129206. */
  129207. etc1?: boolean;
  129208. /**
  129209. * s3tc compression format
  129210. */
  129211. s3tc?: boolean;
  129212. /**
  129213. * pvrtc compression format
  129214. */
  129215. pvrtc?: boolean;
  129216. /**
  129217. * etc2 compression format
  129218. */
  129219. etc2?: boolean;
  129220. };
  129221. /**
  129222. * If mipmap levels should be loaded for transcoded images (Default: true)
  129223. */
  129224. loadMipmapLevels?: boolean;
  129225. /**
  129226. * Index of a single image to load (Default: all images)
  129227. */
  129228. loadSingleImage?: number;
  129229. }
  129230. /**
  129231. * Used to load .Basis files
  129232. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129233. */
  129234. export class BasisTools {
  129235. private static _IgnoreSupportedFormats;
  129236. /**
  129237. * URL to use when loading the basis transcoder
  129238. */
  129239. static JSModuleURL: string;
  129240. /**
  129241. * URL to use when loading the wasm module for the transcoder
  129242. */
  129243. static WasmModuleURL: string;
  129244. /**
  129245. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129246. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129247. * @returns internal format corresponding to the Basis format
  129248. */
  129249. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129250. private static _WorkerPromise;
  129251. private static _Worker;
  129252. private static _actionId;
  129253. private static _CreateWorkerAsync;
  129254. /**
  129255. * Transcodes a loaded image file to compressed pixel data
  129256. * @param data image data to transcode
  129257. * @param config configuration options for the transcoding
  129258. * @returns a promise resulting in the transcoded image
  129259. */
  129260. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129261. /**
  129262. * Loads a texture from the transcode result
  129263. * @param texture texture load to
  129264. * @param transcodeResult the result of transcoding the basis file to load from
  129265. */
  129266. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129267. }
  129268. }
  129269. declare module BABYLON {
  129270. /**
  129271. * Loader for .basis file format
  129272. */
  129273. export class _BasisTextureLoader implements IInternalTextureLoader {
  129274. /**
  129275. * Defines whether the loader supports cascade loading the different faces.
  129276. */
  129277. readonly supportCascades: boolean;
  129278. /**
  129279. * This returns if the loader support the current file information.
  129280. * @param extension defines the file extension of the file being loaded
  129281. * @returns true if the loader can load the specified file
  129282. */
  129283. canLoad(extension: string): boolean;
  129284. /**
  129285. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129286. * @param data contains the texture data
  129287. * @param texture defines the BabylonJS internal texture
  129288. * @param createPolynomials will be true if polynomials have been requested
  129289. * @param onLoad defines the callback to trigger once the texture is ready
  129290. * @param onError defines the callback to trigger in case of error
  129291. */
  129292. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129293. /**
  129294. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129295. * @param data contains the texture data
  129296. * @param texture defines the BabylonJS internal texture
  129297. * @param callback defines the method to call once ready to upload
  129298. */
  129299. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129300. }
  129301. }
  129302. declare module BABYLON {
  129303. /**
  129304. * 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.
  129305. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129306. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129307. */
  129308. export class CustomProceduralTexture extends ProceduralTexture {
  129309. private _animate;
  129310. private _time;
  129311. private _config;
  129312. private _texturePath;
  129313. /**
  129314. * Instantiates a new Custom Procedural Texture.
  129315. * 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.
  129316. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129317. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129318. * @param name Define the name of the texture
  129319. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129320. * @param size Define the size of the texture to create
  129321. * @param scene Define the scene the texture belongs to
  129322. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129323. * @param generateMipMaps Define if the texture should creates mip maps or not
  129324. */
  129325. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129326. private _loadJson;
  129327. /**
  129328. * Is the texture ready to be used ? (rendered at least once)
  129329. * @returns true if ready, otherwise, false.
  129330. */
  129331. isReady(): boolean;
  129332. /**
  129333. * Render the texture to its associated render target.
  129334. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129335. */
  129336. render(useCameraPostProcess?: boolean): void;
  129337. /**
  129338. * Update the list of dependant textures samplers in the shader.
  129339. */
  129340. updateTextures(): void;
  129341. /**
  129342. * Update the uniform values of the procedural texture in the shader.
  129343. */
  129344. updateShaderUniforms(): void;
  129345. /**
  129346. * Define if the texture animates or not.
  129347. */
  129348. get animate(): boolean;
  129349. set animate(value: boolean);
  129350. }
  129351. }
  129352. declare module BABYLON {
  129353. /** @hidden */
  129354. export var noisePixelShader: {
  129355. name: string;
  129356. shader: string;
  129357. };
  129358. }
  129359. declare module BABYLON {
  129360. /**
  129361. * Class used to generate noise procedural textures
  129362. */
  129363. export class NoiseProceduralTexture extends ProceduralTexture {
  129364. private _time;
  129365. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129366. brightness: number;
  129367. /** Defines the number of octaves to process */
  129368. octaves: number;
  129369. /** Defines the level of persistence (0.8 by default) */
  129370. persistence: number;
  129371. /** Gets or sets animation speed factor (default is 1) */
  129372. animationSpeedFactor: number;
  129373. /**
  129374. * Creates a new NoiseProceduralTexture
  129375. * @param name defines the name fo the texture
  129376. * @param size defines the size of the texture (default is 256)
  129377. * @param scene defines the hosting scene
  129378. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129379. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129380. */
  129381. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129382. private _updateShaderUniforms;
  129383. protected _getDefines(): string;
  129384. /** Generate the current state of the procedural texture */
  129385. render(useCameraPostProcess?: boolean): void;
  129386. /**
  129387. * Serializes this noise procedural texture
  129388. * @returns a serialized noise procedural texture object
  129389. */
  129390. serialize(): any;
  129391. /**
  129392. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129393. * @param parsedTexture defines parsed texture data
  129394. * @param scene defines the current scene
  129395. * @param rootUrl defines the root URL containing noise procedural texture information
  129396. * @returns a parsed NoiseProceduralTexture
  129397. */
  129398. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129399. }
  129400. }
  129401. declare module BABYLON {
  129402. /**
  129403. * Raw cube texture where the raw buffers are passed in
  129404. */
  129405. export class RawCubeTexture extends CubeTexture {
  129406. /**
  129407. * Creates a cube texture where the raw buffers are passed in.
  129408. * @param scene defines the scene the texture is attached to
  129409. * @param data defines the array of data to use to create each face
  129410. * @param size defines the size of the textures
  129411. * @param format defines the format of the data
  129412. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129413. * @param generateMipMaps defines if the engine should generate the mip levels
  129414. * @param invertY defines if data must be stored with Y axis inverted
  129415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129416. * @param compression defines the compression used (null by default)
  129417. */
  129418. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129419. /**
  129420. * Updates the raw cube texture.
  129421. * @param data defines the data to store
  129422. * @param format defines the data format
  129423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129424. * @param invertY defines if data must be stored with Y axis inverted
  129425. * @param compression defines the compression used (null by default)
  129426. * @param level defines which level of the texture to update
  129427. */
  129428. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129429. /**
  129430. * Updates a raw cube texture with RGBD encoded data.
  129431. * @param data defines the array of data [mipmap][face] to use to create each face
  129432. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129433. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129434. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129435. * @returns a promsie that resolves when the operation is complete
  129436. */
  129437. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129438. /**
  129439. * Clones the raw cube texture.
  129440. * @return a new cube texture
  129441. */
  129442. clone(): CubeTexture;
  129443. /** @hidden */
  129444. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129445. }
  129446. }
  129447. declare module BABYLON {
  129448. /**
  129449. * Class used to store 3D textures containing user data
  129450. */
  129451. export class RawTexture3D extends Texture {
  129452. /** Gets or sets the texture format to use */
  129453. format: number;
  129454. private _engine;
  129455. /**
  129456. * Create a new RawTexture3D
  129457. * @param data defines the data of the texture
  129458. * @param width defines the width of the texture
  129459. * @param height defines the height of the texture
  129460. * @param depth defines the depth of the texture
  129461. * @param format defines the texture format to use
  129462. * @param scene defines the hosting scene
  129463. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129464. * @param invertY defines if texture must be stored with Y axis inverted
  129465. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129466. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129467. */
  129468. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129469. /** Gets or sets the texture format to use */
  129470. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129471. /**
  129472. * Update the texture with new data
  129473. * @param data defines the data to store in the texture
  129474. */
  129475. update(data: ArrayBufferView): void;
  129476. }
  129477. }
  129478. declare module BABYLON {
  129479. /**
  129480. * Class used to store 2D array textures containing user data
  129481. */
  129482. export class RawTexture2DArray extends Texture {
  129483. /** Gets or sets the texture format to use */
  129484. format: number;
  129485. private _engine;
  129486. /**
  129487. * Create a new RawTexture2DArray
  129488. * @param data defines the data of the texture
  129489. * @param width defines the width of the texture
  129490. * @param height defines the height of the texture
  129491. * @param depth defines the number of layers of the texture
  129492. * @param format defines the texture format to use
  129493. * @param scene defines the hosting scene
  129494. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129495. * @param invertY defines if texture must be stored with Y axis inverted
  129496. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129497. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129498. */
  129499. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129500. /** Gets or sets the texture format to use */
  129501. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129502. /**
  129503. * Update the texture with new data
  129504. * @param data defines the data to store in the texture
  129505. */
  129506. update(data: ArrayBufferView): void;
  129507. }
  129508. }
  129509. declare module BABYLON {
  129510. /**
  129511. * Creates a refraction texture used by refraction channel of the standard material.
  129512. * It is like a mirror but to see through a material.
  129513. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129514. */
  129515. export class RefractionTexture extends RenderTargetTexture {
  129516. /**
  129517. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129518. * 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.
  129519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129520. */
  129521. refractionPlane: Plane;
  129522. /**
  129523. * Define how deep under the surface we should see.
  129524. */
  129525. depth: number;
  129526. /**
  129527. * Creates a refraction texture used by refraction channel of the standard material.
  129528. * It is like a mirror but to see through a material.
  129529. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129530. * @param name Define the texture name
  129531. * @param size Define the size of the underlying texture
  129532. * @param scene Define the scene the refraction belongs to
  129533. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129534. */
  129535. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129536. /**
  129537. * Clone the refraction texture.
  129538. * @returns the cloned texture
  129539. */
  129540. clone(): RefractionTexture;
  129541. /**
  129542. * Serialize the texture to a JSON representation you could use in Parse later on
  129543. * @returns the serialized JSON representation
  129544. */
  129545. serialize(): any;
  129546. }
  129547. }
  129548. declare module BABYLON {
  129549. /**
  129550. * Defines the options related to the creation of an HtmlElementTexture
  129551. */
  129552. export interface IHtmlElementTextureOptions {
  129553. /**
  129554. * Defines wether mip maps should be created or not.
  129555. */
  129556. generateMipMaps?: boolean;
  129557. /**
  129558. * Defines the sampling mode of the texture.
  129559. */
  129560. samplingMode?: number;
  129561. /**
  129562. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129563. */
  129564. engine: Nullable<ThinEngine>;
  129565. /**
  129566. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129567. */
  129568. scene: Nullable<Scene>;
  129569. }
  129570. /**
  129571. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129572. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129573. * is automatically managed.
  129574. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129575. * in your application.
  129576. *
  129577. * As the update is not automatic, you need to call them manually.
  129578. */
  129579. export class HtmlElementTexture extends BaseTexture {
  129580. /**
  129581. * The texture URL.
  129582. */
  129583. element: HTMLVideoElement | HTMLCanvasElement;
  129584. private static readonly DefaultOptions;
  129585. private _textureMatrix;
  129586. private _engine;
  129587. private _isVideo;
  129588. private _generateMipMaps;
  129589. private _samplingMode;
  129590. /**
  129591. * Instantiates a HtmlElementTexture from the following parameters.
  129592. *
  129593. * @param name Defines the name of the texture
  129594. * @param element Defines the video or canvas the texture is filled with
  129595. * @param options Defines the other none mandatory texture creation options
  129596. */
  129597. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129598. private _createInternalTexture;
  129599. /**
  129600. * Returns the texture matrix used in most of the material.
  129601. */
  129602. getTextureMatrix(): Matrix;
  129603. /**
  129604. * Updates the content of the texture.
  129605. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129606. */
  129607. update(invertY?: Nullable<boolean>): void;
  129608. }
  129609. }
  129610. declare module BABYLON {
  129611. /**
  129612. * Defines the basic options interface of a TexturePacker Frame
  129613. */
  129614. export interface ITexturePackerFrame {
  129615. /**
  129616. * The frame ID
  129617. */
  129618. id: number;
  129619. /**
  129620. * The frames Scale
  129621. */
  129622. scale: Vector2;
  129623. /**
  129624. * The Frames offset
  129625. */
  129626. offset: Vector2;
  129627. }
  129628. /**
  129629. * This is a support class for frame Data on texture packer sets.
  129630. */
  129631. export class TexturePackerFrame implements ITexturePackerFrame {
  129632. /**
  129633. * The frame ID
  129634. */
  129635. id: number;
  129636. /**
  129637. * The frames Scale
  129638. */
  129639. scale: Vector2;
  129640. /**
  129641. * The Frames offset
  129642. */
  129643. offset: Vector2;
  129644. /**
  129645. * Initializes a texture package frame.
  129646. * @param id The numerical frame identifier
  129647. * @param scale Scalar Vector2 for UV frame
  129648. * @param offset Vector2 for the frame position in UV units.
  129649. * @returns TexturePackerFrame
  129650. */
  129651. constructor(id: number, scale: Vector2, offset: Vector2);
  129652. }
  129653. }
  129654. declare module BABYLON {
  129655. /**
  129656. * Defines the basic options interface of a TexturePacker
  129657. */
  129658. export interface ITexturePackerOptions {
  129659. /**
  129660. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129661. */
  129662. map?: string[];
  129663. /**
  129664. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129665. */
  129666. uvsIn?: string;
  129667. /**
  129668. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129669. */
  129670. uvsOut?: string;
  129671. /**
  129672. * number representing the layout style. Defaults to LAYOUT_STRIP
  129673. */
  129674. layout?: number;
  129675. /**
  129676. * number of columns if using custom column count layout(2). This defaults to 4.
  129677. */
  129678. colnum?: number;
  129679. /**
  129680. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129681. */
  129682. updateInputMeshes?: boolean;
  129683. /**
  129684. * boolean flag to dispose all the source textures. Defaults to true.
  129685. */
  129686. disposeSources?: boolean;
  129687. /**
  129688. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129689. */
  129690. fillBlanks?: boolean;
  129691. /**
  129692. * string value representing the context fill style color. Defaults to 'black'.
  129693. */
  129694. customFillColor?: string;
  129695. /**
  129696. * Width and Height Value of each Frame in the TexturePacker Sets
  129697. */
  129698. frameSize?: number;
  129699. /**
  129700. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129701. */
  129702. paddingRatio?: number;
  129703. /**
  129704. * Number that declares the fill method for the padding gutter.
  129705. */
  129706. paddingMode?: number;
  129707. /**
  129708. * If in SUBUV_COLOR padding mode what color to use.
  129709. */
  129710. paddingColor?: Color3 | Color4;
  129711. }
  129712. /**
  129713. * Defines the basic interface of a TexturePacker JSON File
  129714. */
  129715. export interface ITexturePackerJSON {
  129716. /**
  129717. * The frame ID
  129718. */
  129719. name: string;
  129720. /**
  129721. * The base64 channel data
  129722. */
  129723. sets: any;
  129724. /**
  129725. * The options of the Packer
  129726. */
  129727. options: ITexturePackerOptions;
  129728. /**
  129729. * The frame data of the Packer
  129730. */
  129731. frames: Array<number>;
  129732. }
  129733. /**
  129734. * This is a support class that generates a series of packed texture sets.
  129735. * @see https://doc.babylonjs.com/babylon101/materials
  129736. */
  129737. export class TexturePacker {
  129738. /** Packer Layout Constant 0 */
  129739. static readonly LAYOUT_STRIP: number;
  129740. /** Packer Layout Constant 1 */
  129741. static readonly LAYOUT_POWER2: number;
  129742. /** Packer Layout Constant 2 */
  129743. static readonly LAYOUT_COLNUM: number;
  129744. /** Packer Layout Constant 0 */
  129745. static readonly SUBUV_WRAP: number;
  129746. /** Packer Layout Constant 1 */
  129747. static readonly SUBUV_EXTEND: number;
  129748. /** Packer Layout Constant 2 */
  129749. static readonly SUBUV_COLOR: number;
  129750. /** The Name of the Texture Package */
  129751. name: string;
  129752. /** The scene scope of the TexturePacker */
  129753. scene: Scene;
  129754. /** The Meshes to target */
  129755. meshes: AbstractMesh[];
  129756. /** Arguments passed with the Constructor */
  129757. options: ITexturePackerOptions;
  129758. /** The promise that is started upon initialization */
  129759. promise: Nullable<Promise<TexturePacker | string>>;
  129760. /** The Container object for the channel sets that are generated */
  129761. sets: object;
  129762. /** The Container array for the frames that are generated */
  129763. frames: TexturePackerFrame[];
  129764. /** The expected number of textures the system is parsing. */
  129765. private _expecting;
  129766. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129767. private _paddingValue;
  129768. /**
  129769. * Initializes a texture package series from an array of meshes or a single mesh.
  129770. * @param name The name of the package
  129771. * @param meshes The target meshes to compose the package from
  129772. * @param options The arguments that texture packer should follow while building.
  129773. * @param scene The scene which the textures are scoped to.
  129774. * @returns TexturePacker
  129775. */
  129776. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129777. /**
  129778. * Starts the package process
  129779. * @param resolve The promises resolution function
  129780. * @returns TexturePacker
  129781. */
  129782. private _createFrames;
  129783. /**
  129784. * Calculates the Size of the Channel Sets
  129785. * @returns Vector2
  129786. */
  129787. private _calculateSize;
  129788. /**
  129789. * Calculates the UV data for the frames.
  129790. * @param baseSize the base frameSize
  129791. * @param padding the base frame padding
  129792. * @param dtSize size of the Dynamic Texture for that channel
  129793. * @param dtUnits is 1/dtSize
  129794. * @param update flag to update the input meshes
  129795. */
  129796. private _calculateMeshUVFrames;
  129797. /**
  129798. * Calculates the frames Offset.
  129799. * @param index of the frame
  129800. * @returns Vector2
  129801. */
  129802. private _getFrameOffset;
  129803. /**
  129804. * Updates a Mesh to the frame data
  129805. * @param mesh that is the target
  129806. * @param frameID or the frame index
  129807. */
  129808. private _updateMeshUV;
  129809. /**
  129810. * Updates a Meshes materials to use the texture packer channels
  129811. * @param m is the mesh to target
  129812. * @param force all channels on the packer to be set.
  129813. */
  129814. private _updateTextureReferences;
  129815. /**
  129816. * Public method to set a Mesh to a frame
  129817. * @param m that is the target
  129818. * @param frameID or the frame index
  129819. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129820. */
  129821. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129822. /**
  129823. * Starts the async promise to compile the texture packer.
  129824. * @returns Promise<void>
  129825. */
  129826. processAsync(): Promise<void>;
  129827. /**
  129828. * Disposes all textures associated with this packer
  129829. */
  129830. dispose(): void;
  129831. /**
  129832. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129833. * @param imageType is the image type to use.
  129834. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129835. */
  129836. download(imageType?: string, quality?: number): void;
  129837. /**
  129838. * Public method to load a texturePacker JSON file.
  129839. * @param data of the JSON file in string format.
  129840. */
  129841. updateFromJSON(data: string): void;
  129842. }
  129843. }
  129844. declare module BABYLON {
  129845. /**
  129846. * Enum used to define the target of a block
  129847. */
  129848. export enum NodeMaterialBlockTargets {
  129849. /** Vertex shader */
  129850. Vertex = 1,
  129851. /** Fragment shader */
  129852. Fragment = 2,
  129853. /** Neutral */
  129854. Neutral = 4,
  129855. /** Vertex and Fragment */
  129856. VertexAndFragment = 3
  129857. }
  129858. }
  129859. declare module BABYLON {
  129860. /**
  129861. * Defines the kind of connection point for node based material
  129862. */
  129863. export enum NodeMaterialBlockConnectionPointTypes {
  129864. /** Float */
  129865. Float = 1,
  129866. /** Int */
  129867. Int = 2,
  129868. /** Vector2 */
  129869. Vector2 = 4,
  129870. /** Vector3 */
  129871. Vector3 = 8,
  129872. /** Vector4 */
  129873. Vector4 = 16,
  129874. /** Color3 */
  129875. Color3 = 32,
  129876. /** Color4 */
  129877. Color4 = 64,
  129878. /** Matrix */
  129879. Matrix = 128,
  129880. /** Detect type based on connection */
  129881. AutoDetect = 1024,
  129882. /** Output type that will be defined by input type */
  129883. BasedOnInput = 2048
  129884. }
  129885. }
  129886. declare module BABYLON {
  129887. /**
  129888. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129889. */
  129890. export enum NodeMaterialBlockConnectionPointMode {
  129891. /** Value is an uniform */
  129892. Uniform = 0,
  129893. /** Value is a mesh attribute */
  129894. Attribute = 1,
  129895. /** Value is a varying between vertex and fragment shaders */
  129896. Varying = 2,
  129897. /** Mode is undefined */
  129898. Undefined = 3
  129899. }
  129900. }
  129901. declare module BABYLON {
  129902. /**
  129903. * Enum used to define system values e.g. values automatically provided by the system
  129904. */
  129905. export enum NodeMaterialSystemValues {
  129906. /** World */
  129907. World = 1,
  129908. /** View */
  129909. View = 2,
  129910. /** Projection */
  129911. Projection = 3,
  129912. /** ViewProjection */
  129913. ViewProjection = 4,
  129914. /** WorldView */
  129915. WorldView = 5,
  129916. /** WorldViewProjection */
  129917. WorldViewProjection = 6,
  129918. /** CameraPosition */
  129919. CameraPosition = 7,
  129920. /** Fog Color */
  129921. FogColor = 8,
  129922. /** Delta time */
  129923. DeltaTime = 9
  129924. }
  129925. }
  129926. declare module BABYLON {
  129927. /**
  129928. * Root class for all node material optimizers
  129929. */
  129930. export class NodeMaterialOptimizer {
  129931. /**
  129932. * Function used to optimize a NodeMaterial graph
  129933. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129934. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129935. */
  129936. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129937. }
  129938. }
  129939. declare module BABYLON {
  129940. /**
  129941. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129942. */
  129943. export class TransformBlock extends NodeMaterialBlock {
  129944. /**
  129945. * Defines the value to use to complement W value to transform it to a Vector4
  129946. */
  129947. complementW: number;
  129948. /**
  129949. * Defines the value to use to complement z value to transform it to a Vector4
  129950. */
  129951. complementZ: number;
  129952. /**
  129953. * Creates a new TransformBlock
  129954. * @param name defines the block name
  129955. */
  129956. constructor(name: string);
  129957. /**
  129958. * Gets the current class name
  129959. * @returns the class name
  129960. */
  129961. getClassName(): string;
  129962. /**
  129963. * Gets the vector input
  129964. */
  129965. get vector(): NodeMaterialConnectionPoint;
  129966. /**
  129967. * Gets the output component
  129968. */
  129969. get output(): NodeMaterialConnectionPoint;
  129970. /**
  129971. * Gets the matrix transform input
  129972. */
  129973. get transform(): NodeMaterialConnectionPoint;
  129974. protected _buildBlock(state: NodeMaterialBuildState): this;
  129975. serialize(): any;
  129976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129977. protected _dumpPropertiesCode(): string;
  129978. }
  129979. }
  129980. declare module BABYLON {
  129981. /**
  129982. * Block used to output the vertex position
  129983. */
  129984. export class VertexOutputBlock extends NodeMaterialBlock {
  129985. /**
  129986. * Creates a new VertexOutputBlock
  129987. * @param name defines the block name
  129988. */
  129989. constructor(name: string);
  129990. /**
  129991. * Gets the current class name
  129992. * @returns the class name
  129993. */
  129994. getClassName(): string;
  129995. /**
  129996. * Gets the vector input component
  129997. */
  129998. get vector(): NodeMaterialConnectionPoint;
  129999. protected _buildBlock(state: NodeMaterialBuildState): this;
  130000. }
  130001. }
  130002. declare module BABYLON {
  130003. /**
  130004. * Block used to output the final color
  130005. */
  130006. export class FragmentOutputBlock extends NodeMaterialBlock {
  130007. /**
  130008. * Create a new FragmentOutputBlock
  130009. * @param name defines the block name
  130010. */
  130011. constructor(name: string);
  130012. /**
  130013. * Gets the current class name
  130014. * @returns the class name
  130015. */
  130016. getClassName(): string;
  130017. /**
  130018. * Gets the rgba input component
  130019. */
  130020. get rgba(): NodeMaterialConnectionPoint;
  130021. /**
  130022. * Gets the rgb input component
  130023. */
  130024. get rgb(): NodeMaterialConnectionPoint;
  130025. /**
  130026. * Gets the a input component
  130027. */
  130028. get a(): NodeMaterialConnectionPoint;
  130029. protected _buildBlock(state: NodeMaterialBuildState): this;
  130030. }
  130031. }
  130032. declare module BABYLON {
  130033. /**
  130034. * Block used to read a reflection texture from a sampler
  130035. */
  130036. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130037. private _define3DName;
  130038. private _defineCubicName;
  130039. private _defineExplicitName;
  130040. private _defineProjectionName;
  130041. private _defineLocalCubicName;
  130042. private _defineSphericalName;
  130043. private _definePlanarName;
  130044. private _defineEquirectangularName;
  130045. private _defineMirroredEquirectangularFixedName;
  130046. private _defineEquirectangularFixedName;
  130047. private _defineSkyboxName;
  130048. private _cubeSamplerName;
  130049. private _2DSamplerName;
  130050. private _positionUVWName;
  130051. private _directionWName;
  130052. private _reflectionCoordsName;
  130053. private _reflection2DCoordsName;
  130054. private _reflectionColorName;
  130055. private _reflectionMatrixName;
  130056. /**
  130057. * Gets or sets the texture associated with the node
  130058. */
  130059. texture: Nullable<BaseTexture>;
  130060. /**
  130061. * Create a new TextureBlock
  130062. * @param name defines the block name
  130063. */
  130064. constructor(name: string);
  130065. /**
  130066. * Gets the current class name
  130067. * @returns the class name
  130068. */
  130069. getClassName(): string;
  130070. /**
  130071. * Gets the world position input component
  130072. */
  130073. get position(): NodeMaterialConnectionPoint;
  130074. /**
  130075. * Gets the world position input component
  130076. */
  130077. get worldPosition(): NodeMaterialConnectionPoint;
  130078. /**
  130079. * Gets the world normal input component
  130080. */
  130081. get worldNormal(): NodeMaterialConnectionPoint;
  130082. /**
  130083. * Gets the world input component
  130084. */
  130085. get world(): NodeMaterialConnectionPoint;
  130086. /**
  130087. * Gets the camera (or eye) position component
  130088. */
  130089. get cameraPosition(): NodeMaterialConnectionPoint;
  130090. /**
  130091. * Gets the view input component
  130092. */
  130093. get view(): NodeMaterialConnectionPoint;
  130094. /**
  130095. * Gets the rgb output component
  130096. */
  130097. get rgb(): NodeMaterialConnectionPoint;
  130098. /**
  130099. * Gets the r output component
  130100. */
  130101. get r(): NodeMaterialConnectionPoint;
  130102. /**
  130103. * Gets the g output component
  130104. */
  130105. get g(): NodeMaterialConnectionPoint;
  130106. /**
  130107. * Gets the b output component
  130108. */
  130109. get b(): NodeMaterialConnectionPoint;
  130110. autoConfigure(material: NodeMaterial): void;
  130111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130112. isReady(): boolean;
  130113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130114. private _injectVertexCode;
  130115. private _writeOutput;
  130116. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130117. protected _dumpPropertiesCode(): string;
  130118. serialize(): any;
  130119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130120. }
  130121. }
  130122. declare module BABYLON {
  130123. /**
  130124. * Interface used to configure the node material editor
  130125. */
  130126. export interface INodeMaterialEditorOptions {
  130127. /** Define the URl to load node editor script */
  130128. editorURL?: string;
  130129. }
  130130. /** @hidden */
  130131. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130132. NORMAL: boolean;
  130133. TANGENT: boolean;
  130134. UV1: boolean;
  130135. /** BONES */
  130136. NUM_BONE_INFLUENCERS: number;
  130137. BonesPerMesh: number;
  130138. BONETEXTURE: boolean;
  130139. /** MORPH TARGETS */
  130140. MORPHTARGETS: boolean;
  130141. MORPHTARGETS_NORMAL: boolean;
  130142. MORPHTARGETS_TANGENT: boolean;
  130143. MORPHTARGETS_UV: boolean;
  130144. NUM_MORPH_INFLUENCERS: number;
  130145. /** IMAGE PROCESSING */
  130146. IMAGEPROCESSING: boolean;
  130147. VIGNETTE: boolean;
  130148. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130149. VIGNETTEBLENDMODEOPAQUE: boolean;
  130150. TONEMAPPING: boolean;
  130151. TONEMAPPING_ACES: boolean;
  130152. CONTRAST: boolean;
  130153. EXPOSURE: boolean;
  130154. COLORCURVES: boolean;
  130155. COLORGRADING: boolean;
  130156. COLORGRADING3D: boolean;
  130157. SAMPLER3DGREENDEPTH: boolean;
  130158. SAMPLER3DBGRMAP: boolean;
  130159. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130160. /** MISC. */
  130161. BUMPDIRECTUV: number;
  130162. constructor();
  130163. setValue(name: string, value: boolean): void;
  130164. }
  130165. /**
  130166. * Class used to configure NodeMaterial
  130167. */
  130168. export interface INodeMaterialOptions {
  130169. /**
  130170. * Defines if blocks should emit comments
  130171. */
  130172. emitComments: boolean;
  130173. }
  130174. /**
  130175. * Class used to create a node based material built by assembling shader blocks
  130176. */
  130177. export class NodeMaterial extends PushMaterial {
  130178. private static _BuildIdGenerator;
  130179. private _options;
  130180. private _vertexCompilationState;
  130181. private _fragmentCompilationState;
  130182. private _sharedData;
  130183. private _buildId;
  130184. private _buildWasSuccessful;
  130185. private _cachedWorldViewMatrix;
  130186. private _cachedWorldViewProjectionMatrix;
  130187. private _optimizers;
  130188. private _animationFrame;
  130189. /** Define the Url to load node editor script */
  130190. static EditorURL: string;
  130191. /** Define the Url to load snippets */
  130192. static SnippetUrl: string;
  130193. private BJSNODEMATERIALEDITOR;
  130194. /** Get the inspector from bundle or global */
  130195. private _getGlobalNodeMaterialEditor;
  130196. /**
  130197. * Gets or sets data used by visual editor
  130198. * @see https://nme.babylonjs.com
  130199. */
  130200. editorData: any;
  130201. /**
  130202. * 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)
  130203. */
  130204. ignoreAlpha: boolean;
  130205. /**
  130206. * Defines the maximum number of lights that can be used in the material
  130207. */
  130208. maxSimultaneousLights: number;
  130209. /**
  130210. * Observable raised when the material is built
  130211. */
  130212. onBuildObservable: Observable<NodeMaterial>;
  130213. /**
  130214. * Gets or sets the root nodes of the material vertex shader
  130215. */
  130216. _vertexOutputNodes: NodeMaterialBlock[];
  130217. /**
  130218. * Gets or sets the root nodes of the material fragment (pixel) shader
  130219. */
  130220. _fragmentOutputNodes: NodeMaterialBlock[];
  130221. /** Gets or sets options to control the node material overall behavior */
  130222. get options(): INodeMaterialOptions;
  130223. set options(options: INodeMaterialOptions);
  130224. /**
  130225. * Default configuration related to image processing available in the standard Material.
  130226. */
  130227. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130228. /**
  130229. * Gets the image processing configuration used either in this material.
  130230. */
  130231. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130232. /**
  130233. * Sets the Default image processing configuration used either in the this material.
  130234. *
  130235. * If sets to null, the scene one is in use.
  130236. */
  130237. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130238. /**
  130239. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130240. */
  130241. attachedBlocks: NodeMaterialBlock[];
  130242. /**
  130243. * Create a new node based material
  130244. * @param name defines the material name
  130245. * @param scene defines the hosting scene
  130246. * @param options defines creation option
  130247. */
  130248. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130249. /**
  130250. * Gets the current class name of the material e.g. "NodeMaterial"
  130251. * @returns the class name
  130252. */
  130253. getClassName(): string;
  130254. /**
  130255. * Keep track of the image processing observer to allow dispose and replace.
  130256. */
  130257. private _imageProcessingObserver;
  130258. /**
  130259. * Attaches a new image processing configuration to the Standard Material.
  130260. * @param configuration
  130261. */
  130262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130263. /**
  130264. * Get a block by its name
  130265. * @param name defines the name of the block to retrieve
  130266. * @returns the required block or null if not found
  130267. */
  130268. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130269. /**
  130270. * Get a block by its name
  130271. * @param predicate defines the predicate used to find the good candidate
  130272. * @returns the required block or null if not found
  130273. */
  130274. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130275. /**
  130276. * Get an input block by its name
  130277. * @param predicate defines the predicate used to find the good candidate
  130278. * @returns the required input block or null if not found
  130279. */
  130280. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130281. /**
  130282. * Gets the list of input blocks attached to this material
  130283. * @returns an array of InputBlocks
  130284. */
  130285. getInputBlocks(): InputBlock[];
  130286. /**
  130287. * Adds a new optimizer to the list of optimizers
  130288. * @param optimizer defines the optimizers to add
  130289. * @returns the current material
  130290. */
  130291. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130292. /**
  130293. * Remove an optimizer from the list of optimizers
  130294. * @param optimizer defines the optimizers to remove
  130295. * @returns the current material
  130296. */
  130297. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130298. /**
  130299. * Add a new block to the list of output nodes
  130300. * @param node defines the node to add
  130301. * @returns the current material
  130302. */
  130303. addOutputNode(node: NodeMaterialBlock): this;
  130304. /**
  130305. * Remove a block from the list of root nodes
  130306. * @param node defines the node to remove
  130307. * @returns the current material
  130308. */
  130309. removeOutputNode(node: NodeMaterialBlock): this;
  130310. private _addVertexOutputNode;
  130311. private _removeVertexOutputNode;
  130312. private _addFragmentOutputNode;
  130313. private _removeFragmentOutputNode;
  130314. /**
  130315. * Specifies if the material will require alpha blending
  130316. * @returns a boolean specifying if alpha blending is needed
  130317. */
  130318. needAlphaBlending(): boolean;
  130319. /**
  130320. * Specifies if this material should be rendered in alpha test mode
  130321. * @returns a boolean specifying if an alpha test is needed.
  130322. */
  130323. needAlphaTesting(): boolean;
  130324. private _initializeBlock;
  130325. private _resetDualBlocks;
  130326. /**
  130327. * Remove a block from the current node material
  130328. * @param block defines the block to remove
  130329. */
  130330. removeBlock(block: NodeMaterialBlock): void;
  130331. /**
  130332. * Build the material and generates the inner effect
  130333. * @param verbose defines if the build should log activity
  130334. */
  130335. build(verbose?: boolean): void;
  130336. /**
  130337. * Runs an otpimization phase to try to improve the shader code
  130338. */
  130339. optimize(): void;
  130340. private _prepareDefinesForAttributes;
  130341. /**
  130342. * Get if the submesh is ready to be used and all its information available.
  130343. * Child classes can use it to update shaders
  130344. * @param mesh defines the mesh to check
  130345. * @param subMesh defines which submesh to check
  130346. * @param useInstances specifies that instances should be used
  130347. * @returns a boolean indicating that the submesh is ready or not
  130348. */
  130349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130350. /**
  130351. * Get a string representing the shaders built by the current node graph
  130352. */
  130353. get compiledShaders(): string;
  130354. /**
  130355. * Binds the world matrix to the material
  130356. * @param world defines the world transformation matrix
  130357. */
  130358. bindOnlyWorldMatrix(world: Matrix): void;
  130359. /**
  130360. * Binds the submesh to this material by preparing the effect and shader to draw
  130361. * @param world defines the world transformation matrix
  130362. * @param mesh defines the mesh containing the submesh
  130363. * @param subMesh defines the submesh to bind the material to
  130364. */
  130365. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130366. /**
  130367. * Gets the active textures from the material
  130368. * @returns an array of textures
  130369. */
  130370. getActiveTextures(): BaseTexture[];
  130371. /**
  130372. * Gets the list of texture blocks
  130373. * @returns an array of texture blocks
  130374. */
  130375. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130376. /**
  130377. * Specifies if the material uses a texture
  130378. * @param texture defines the texture to check against the material
  130379. * @returns a boolean specifying if the material uses the texture
  130380. */
  130381. hasTexture(texture: BaseTexture): boolean;
  130382. /**
  130383. * Disposes the material
  130384. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130385. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130386. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130387. */
  130388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130389. /** Creates the node editor window. */
  130390. private _createNodeEditor;
  130391. /**
  130392. * Launch the node material editor
  130393. * @param config Define the configuration of the editor
  130394. * @return a promise fulfilled when the node editor is visible
  130395. */
  130396. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130397. /**
  130398. * Clear the current material
  130399. */
  130400. clear(): void;
  130401. /**
  130402. * Clear the current material and set it to a default state
  130403. */
  130404. setToDefault(): void;
  130405. /**
  130406. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130407. * @param url defines the url to load from
  130408. * @returns a promise that will fullfil when the material is fully loaded
  130409. */
  130410. loadAsync(url: string): Promise<void>;
  130411. private _gatherBlocks;
  130412. /**
  130413. * Generate a string containing the code declaration required to create an equivalent of this material
  130414. * @returns a string
  130415. */
  130416. generateCode(): string;
  130417. /**
  130418. * Serializes this material in a JSON representation
  130419. * @returns the serialized material object
  130420. */
  130421. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130422. private _restoreConnections;
  130423. /**
  130424. * Clear the current graph and load a new one from a serialization object
  130425. * @param source defines the JSON representation of the material
  130426. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130427. */
  130428. loadFromSerialization(source: any, rootUrl?: string): void;
  130429. /**
  130430. * Creates a node material from parsed material data
  130431. * @param source defines the JSON representation of the material
  130432. * @param scene defines the hosting scene
  130433. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130434. * @returns a new node material
  130435. */
  130436. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130437. /**
  130438. * Creates a node material from a snippet saved in a remote file
  130439. * @param name defines the name of the material to create
  130440. * @param url defines the url to load from
  130441. * @param scene defines the hosting scene
  130442. * @returns a promise that will resolve to the new node material
  130443. */
  130444. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130445. /**
  130446. * Creates a node material from a snippet saved by the node material editor
  130447. * @param snippetId defines the snippet to load
  130448. * @param scene defines the hosting scene
  130449. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130450. * @returns a promise that will resolve to the new node material
  130451. */
  130452. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130453. /**
  130454. * Creates a new node material set to default basic configuration
  130455. * @param name defines the name of the material
  130456. * @param scene defines the hosting scene
  130457. * @returns a new NodeMaterial
  130458. */
  130459. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130460. }
  130461. }
  130462. declare module BABYLON {
  130463. /**
  130464. * Block used to read a texture from a sampler
  130465. */
  130466. export class TextureBlock extends NodeMaterialBlock {
  130467. private _defineName;
  130468. private _linearDefineName;
  130469. private _tempTextureRead;
  130470. private _samplerName;
  130471. private _transformedUVName;
  130472. private _textureTransformName;
  130473. private _textureInfoName;
  130474. private _mainUVName;
  130475. private _mainUVDefineName;
  130476. /**
  130477. * Gets or sets the texture associated with the node
  130478. */
  130479. texture: Nullable<Texture>;
  130480. /**
  130481. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130482. */
  130483. convertToGammaSpace: boolean;
  130484. /**
  130485. * Create a new TextureBlock
  130486. * @param name defines the block name
  130487. */
  130488. constructor(name: string);
  130489. /**
  130490. * Gets the current class name
  130491. * @returns the class name
  130492. */
  130493. getClassName(): string;
  130494. /**
  130495. * Gets the uv input component
  130496. */
  130497. get uv(): NodeMaterialConnectionPoint;
  130498. /**
  130499. * Gets the rgba output component
  130500. */
  130501. get rgba(): NodeMaterialConnectionPoint;
  130502. /**
  130503. * Gets the rgb output component
  130504. */
  130505. get rgb(): NodeMaterialConnectionPoint;
  130506. /**
  130507. * Gets the r output component
  130508. */
  130509. get r(): NodeMaterialConnectionPoint;
  130510. /**
  130511. * Gets the g output component
  130512. */
  130513. get g(): NodeMaterialConnectionPoint;
  130514. /**
  130515. * Gets the b output component
  130516. */
  130517. get b(): NodeMaterialConnectionPoint;
  130518. /**
  130519. * Gets the a output component
  130520. */
  130521. get a(): NodeMaterialConnectionPoint;
  130522. get target(): NodeMaterialBlockTargets;
  130523. autoConfigure(material: NodeMaterial): void;
  130524. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130526. isReady(): boolean;
  130527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130528. private get _isMixed();
  130529. private _injectVertexCode;
  130530. private _writeTextureRead;
  130531. private _writeOutput;
  130532. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130533. protected _dumpPropertiesCode(): string;
  130534. serialize(): any;
  130535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130536. }
  130537. }
  130538. declare module BABYLON {
  130539. /**
  130540. * Class used to store shared data between 2 NodeMaterialBuildState
  130541. */
  130542. export class NodeMaterialBuildStateSharedData {
  130543. /**
  130544. * Gets the list of emitted varyings
  130545. */
  130546. temps: string[];
  130547. /**
  130548. * Gets the list of emitted varyings
  130549. */
  130550. varyings: string[];
  130551. /**
  130552. * Gets the varying declaration string
  130553. */
  130554. varyingDeclaration: string;
  130555. /**
  130556. * Input blocks
  130557. */
  130558. inputBlocks: InputBlock[];
  130559. /**
  130560. * Input blocks
  130561. */
  130562. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130563. /**
  130564. * Bindable blocks (Blocks that need to set data to the effect)
  130565. */
  130566. bindableBlocks: NodeMaterialBlock[];
  130567. /**
  130568. * List of blocks that can provide a compilation fallback
  130569. */
  130570. blocksWithFallbacks: NodeMaterialBlock[];
  130571. /**
  130572. * List of blocks that can provide a define update
  130573. */
  130574. blocksWithDefines: NodeMaterialBlock[];
  130575. /**
  130576. * List of blocks that can provide a repeatable content
  130577. */
  130578. repeatableContentBlocks: NodeMaterialBlock[];
  130579. /**
  130580. * List of blocks that can provide a dynamic list of uniforms
  130581. */
  130582. dynamicUniformBlocks: NodeMaterialBlock[];
  130583. /**
  130584. * List of blocks that can block the isReady function for the material
  130585. */
  130586. blockingBlocks: NodeMaterialBlock[];
  130587. /**
  130588. * Gets the list of animated inputs
  130589. */
  130590. animatedInputs: InputBlock[];
  130591. /**
  130592. * Build Id used to avoid multiple recompilations
  130593. */
  130594. buildId: number;
  130595. /** List of emitted variables */
  130596. variableNames: {
  130597. [key: string]: number;
  130598. };
  130599. /** List of emitted defines */
  130600. defineNames: {
  130601. [key: string]: number;
  130602. };
  130603. /** Should emit comments? */
  130604. emitComments: boolean;
  130605. /** Emit build activity */
  130606. verbose: boolean;
  130607. /** Gets or sets the hosting scene */
  130608. scene: Scene;
  130609. /**
  130610. * Gets the compilation hints emitted at compilation time
  130611. */
  130612. hints: {
  130613. needWorldViewMatrix: boolean;
  130614. needWorldViewProjectionMatrix: boolean;
  130615. needAlphaBlending: boolean;
  130616. needAlphaTesting: boolean;
  130617. };
  130618. /**
  130619. * List of compilation checks
  130620. */
  130621. checks: {
  130622. emitVertex: boolean;
  130623. emitFragment: boolean;
  130624. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130625. };
  130626. /** Creates a new shared data */
  130627. constructor();
  130628. /**
  130629. * Emits console errors and exceptions if there is a failing check
  130630. */
  130631. emitErrors(): void;
  130632. }
  130633. }
  130634. declare module BABYLON {
  130635. /**
  130636. * Class used to store node based material build state
  130637. */
  130638. export class NodeMaterialBuildState {
  130639. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130640. supportUniformBuffers: boolean;
  130641. /**
  130642. * Gets the list of emitted attributes
  130643. */
  130644. attributes: string[];
  130645. /**
  130646. * Gets the list of emitted uniforms
  130647. */
  130648. uniforms: string[];
  130649. /**
  130650. * Gets the list of emitted constants
  130651. */
  130652. constants: string[];
  130653. /**
  130654. * Gets the list of emitted samplers
  130655. */
  130656. samplers: string[];
  130657. /**
  130658. * Gets the list of emitted functions
  130659. */
  130660. functions: {
  130661. [key: string]: string;
  130662. };
  130663. /**
  130664. * Gets the list of emitted extensions
  130665. */
  130666. extensions: {
  130667. [key: string]: string;
  130668. };
  130669. /**
  130670. * Gets the target of the compilation state
  130671. */
  130672. target: NodeMaterialBlockTargets;
  130673. /**
  130674. * Gets the list of emitted counters
  130675. */
  130676. counters: {
  130677. [key: string]: number;
  130678. };
  130679. /**
  130680. * Shared data between multiple NodeMaterialBuildState instances
  130681. */
  130682. sharedData: NodeMaterialBuildStateSharedData;
  130683. /** @hidden */
  130684. _vertexState: NodeMaterialBuildState;
  130685. /** @hidden */
  130686. _attributeDeclaration: string;
  130687. /** @hidden */
  130688. _uniformDeclaration: string;
  130689. /** @hidden */
  130690. _constantDeclaration: string;
  130691. /** @hidden */
  130692. _samplerDeclaration: string;
  130693. /** @hidden */
  130694. _varyingTransfer: string;
  130695. private _repeatableContentAnchorIndex;
  130696. /** @hidden */
  130697. _builtCompilationString: string;
  130698. /**
  130699. * Gets the emitted compilation strings
  130700. */
  130701. compilationString: string;
  130702. /**
  130703. * Finalize the compilation strings
  130704. * @param state defines the current compilation state
  130705. */
  130706. finalize(state: NodeMaterialBuildState): void;
  130707. /** @hidden */
  130708. get _repeatableContentAnchor(): string;
  130709. /** @hidden */
  130710. _getFreeVariableName(prefix: string): string;
  130711. /** @hidden */
  130712. _getFreeDefineName(prefix: string): string;
  130713. /** @hidden */
  130714. _excludeVariableName(name: string): void;
  130715. /** @hidden */
  130716. _emit2DSampler(name: string): void;
  130717. /** @hidden */
  130718. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130719. /** @hidden */
  130720. _emitExtension(name: string, extension: string): void;
  130721. /** @hidden */
  130722. _emitFunction(name: string, code: string, comments: string): void;
  130723. /** @hidden */
  130724. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130725. replaceStrings?: {
  130726. search: RegExp;
  130727. replace: string;
  130728. }[];
  130729. repeatKey?: string;
  130730. }): string;
  130731. /** @hidden */
  130732. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130733. repeatKey?: string;
  130734. removeAttributes?: boolean;
  130735. removeUniforms?: boolean;
  130736. removeVaryings?: boolean;
  130737. removeIfDef?: boolean;
  130738. replaceStrings?: {
  130739. search: RegExp;
  130740. replace: string;
  130741. }[];
  130742. }, storeKey?: string): void;
  130743. /** @hidden */
  130744. _registerTempVariable(name: string): boolean;
  130745. /** @hidden */
  130746. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130747. /** @hidden */
  130748. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130749. /** @hidden */
  130750. _emitFloat(value: number): string;
  130751. }
  130752. }
  130753. declare module BABYLON {
  130754. /**
  130755. * Defines a block that can be used inside a node based material
  130756. */
  130757. export class NodeMaterialBlock {
  130758. private _buildId;
  130759. private _buildTarget;
  130760. private _target;
  130761. private _isFinalMerger;
  130762. private _isInput;
  130763. protected _isUnique: boolean;
  130764. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130765. inputsAreExclusive: boolean;
  130766. /** @hidden */
  130767. _codeVariableName: string;
  130768. /** @hidden */
  130769. _inputs: NodeMaterialConnectionPoint[];
  130770. /** @hidden */
  130771. _outputs: NodeMaterialConnectionPoint[];
  130772. /** @hidden */
  130773. _preparationId: number;
  130774. /**
  130775. * Gets or sets the name of the block
  130776. */
  130777. name: string;
  130778. /**
  130779. * Gets or sets the unique id of the node
  130780. */
  130781. uniqueId: number;
  130782. /**
  130783. * Gets or sets the comments associated with this block
  130784. */
  130785. comments: string;
  130786. /**
  130787. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130788. */
  130789. get isUnique(): boolean;
  130790. /**
  130791. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130792. */
  130793. get isFinalMerger(): boolean;
  130794. /**
  130795. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130796. */
  130797. get isInput(): boolean;
  130798. /**
  130799. * Gets or sets the build Id
  130800. */
  130801. get buildId(): number;
  130802. set buildId(value: number);
  130803. /**
  130804. * Gets or sets the target of the block
  130805. */
  130806. get target(): NodeMaterialBlockTargets;
  130807. set target(value: NodeMaterialBlockTargets);
  130808. /**
  130809. * Gets the list of input points
  130810. */
  130811. get inputs(): NodeMaterialConnectionPoint[];
  130812. /** Gets the list of output points */
  130813. get outputs(): NodeMaterialConnectionPoint[];
  130814. /**
  130815. * Find an input by its name
  130816. * @param name defines the name of the input to look for
  130817. * @returns the input or null if not found
  130818. */
  130819. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130820. /**
  130821. * Find an output by its name
  130822. * @param name defines the name of the outputto look for
  130823. * @returns the output or null if not found
  130824. */
  130825. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130826. /**
  130827. * Creates a new NodeMaterialBlock
  130828. * @param name defines the block name
  130829. * @param target defines the target of that block (Vertex by default)
  130830. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130831. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130832. */
  130833. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130834. /**
  130835. * Initialize the block and prepare the context for build
  130836. * @param state defines the state that will be used for the build
  130837. */
  130838. initialize(state: NodeMaterialBuildState): void;
  130839. /**
  130840. * Bind data to effect. Will only be called for blocks with isBindable === true
  130841. * @param effect defines the effect to bind data to
  130842. * @param nodeMaterial defines the hosting NodeMaterial
  130843. * @param mesh defines the mesh that will be rendered
  130844. */
  130845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130846. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130847. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130848. protected _writeFloat(value: number): string;
  130849. /**
  130850. * Gets the current class name e.g. "NodeMaterialBlock"
  130851. * @returns the class name
  130852. */
  130853. getClassName(): string;
  130854. /**
  130855. * Register a new input. Must be called inside a block constructor
  130856. * @param name defines the connection point name
  130857. * @param type defines the connection point type
  130858. * @param isOptional defines a boolean indicating that this input can be omitted
  130859. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130860. * @returns the current block
  130861. */
  130862. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130863. /**
  130864. * Register a new output. Must be called inside a block constructor
  130865. * @param name defines the connection point name
  130866. * @param type defines the connection point type
  130867. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130868. * @returns the current block
  130869. */
  130870. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130871. /**
  130872. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130873. * @param forOutput defines an optional connection point to check compatibility with
  130874. * @returns the first available input or null
  130875. */
  130876. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130877. /**
  130878. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130879. * @param forBlock defines an optional block to check compatibility with
  130880. * @returns the first available input or null
  130881. */
  130882. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130883. /**
  130884. * Gets the sibling of the given output
  130885. * @param current defines the current output
  130886. * @returns the next output in the list or null
  130887. */
  130888. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130889. /**
  130890. * Connect current block with another block
  130891. * @param other defines the block to connect with
  130892. * @param options define the various options to help pick the right connections
  130893. * @returns the current block
  130894. */
  130895. connectTo(other: NodeMaterialBlock, options?: {
  130896. input?: string;
  130897. output?: string;
  130898. outputSwizzle?: string;
  130899. }): this | undefined;
  130900. protected _buildBlock(state: NodeMaterialBuildState): void;
  130901. /**
  130902. * Add uniforms, samplers and uniform buffers at compilation time
  130903. * @param state defines the state to update
  130904. * @param nodeMaterial defines the node material requesting the update
  130905. * @param defines defines the material defines to update
  130906. * @param uniformBuffers defines the list of uniform buffer names
  130907. */
  130908. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130909. /**
  130910. * Add potential fallbacks if shader compilation fails
  130911. * @param mesh defines the mesh to be rendered
  130912. * @param fallbacks defines the current prioritized list of fallbacks
  130913. */
  130914. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130915. /**
  130916. * Initialize defines for shader compilation
  130917. * @param mesh defines the mesh to be rendered
  130918. * @param nodeMaterial defines the node material requesting the update
  130919. * @param defines defines the material defines to update
  130920. * @param useInstances specifies that instances should be used
  130921. */
  130922. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130923. /**
  130924. * Update defines for shader compilation
  130925. * @param mesh defines the mesh to be rendered
  130926. * @param nodeMaterial defines the node material requesting the update
  130927. * @param defines defines the material defines to update
  130928. * @param useInstances specifies that instances should be used
  130929. */
  130930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130931. /**
  130932. * Lets the block try to connect some inputs automatically
  130933. * @param material defines the hosting NodeMaterial
  130934. */
  130935. autoConfigure(material: NodeMaterial): void;
  130936. /**
  130937. * Function called when a block is declared as repeatable content generator
  130938. * @param vertexShaderState defines the current compilation state for the vertex shader
  130939. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130940. * @param mesh defines the mesh to be rendered
  130941. * @param defines defines the material defines to update
  130942. */
  130943. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130944. /**
  130945. * Checks if the block is ready
  130946. * @param mesh defines the mesh to be rendered
  130947. * @param nodeMaterial defines the node material requesting the update
  130948. * @param defines defines the material defines to update
  130949. * @param useInstances specifies that instances should be used
  130950. * @returns true if the block is ready
  130951. */
  130952. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130953. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130954. private _processBuild;
  130955. /**
  130956. * Compile the current node and generate the shader code
  130957. * @param state defines the current compilation state (uniforms, samplers, current string)
  130958. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130959. * @returns true if already built
  130960. */
  130961. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130962. protected _inputRename(name: string): string;
  130963. protected _outputRename(name: string): string;
  130964. protected _dumpPropertiesCode(): string;
  130965. /** @hidden */
  130966. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130967. /** @hidden */
  130968. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130969. /**
  130970. * Clone the current block to a new identical block
  130971. * @param scene defines the hosting scene
  130972. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130973. * @returns a copy of the current block
  130974. */
  130975. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130976. /**
  130977. * Serializes this block in a JSON representation
  130978. * @returns the serialized block object
  130979. */
  130980. serialize(): any;
  130981. /** @hidden */
  130982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130983. /**
  130984. * Release resources
  130985. */
  130986. dispose(): void;
  130987. }
  130988. }
  130989. declare module BABYLON {
  130990. /**
  130991. * Enum defining the type of animations supported by InputBlock
  130992. */
  130993. export enum AnimatedInputBlockTypes {
  130994. /** No animation */
  130995. None = 0,
  130996. /** Time based animation. Will only work for floats */
  130997. Time = 1
  130998. }
  130999. }
  131000. declare module BABYLON {
  131001. /**
  131002. * Block used to expose an input value
  131003. */
  131004. export class InputBlock extends NodeMaterialBlock {
  131005. private _mode;
  131006. private _associatedVariableName;
  131007. private _storedValue;
  131008. private _valueCallback;
  131009. private _type;
  131010. private _animationType;
  131011. /** Gets or set a value used to limit the range of float values */
  131012. min: number;
  131013. /** Gets or set a value used to limit the range of float values */
  131014. max: number;
  131015. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131016. isBoolean: boolean;
  131017. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131018. matrixMode: number;
  131019. /** @hidden */
  131020. _systemValue: Nullable<NodeMaterialSystemValues>;
  131021. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131022. visibleInInspector: boolean;
  131023. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131024. isConstant: boolean;
  131025. /** Gets or sets the group to use to display this block in the Inspector */
  131026. groupInInspector: string;
  131027. /**
  131028. * Gets or sets the connection point type (default is float)
  131029. */
  131030. get type(): NodeMaterialBlockConnectionPointTypes;
  131031. /**
  131032. * Creates a new InputBlock
  131033. * @param name defines the block name
  131034. * @param target defines the target of that block (Vertex by default)
  131035. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131036. */
  131037. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131038. /**
  131039. * Gets the output component
  131040. */
  131041. get output(): NodeMaterialConnectionPoint;
  131042. /**
  131043. * Set the source of this connection point to a vertex attribute
  131044. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131045. * @returns the current connection point
  131046. */
  131047. setAsAttribute(attributeName?: string): InputBlock;
  131048. /**
  131049. * Set the source of this connection point to a system value
  131050. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131051. * @returns the current connection point
  131052. */
  131053. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131054. /**
  131055. * Gets or sets the value of that point.
  131056. * Please note that this value will be ignored if valueCallback is defined
  131057. */
  131058. get value(): any;
  131059. set value(value: any);
  131060. /**
  131061. * Gets or sets a callback used to get the value of that point.
  131062. * Please note that setting this value will force the connection point to ignore the value property
  131063. */
  131064. get valueCallback(): () => any;
  131065. set valueCallback(value: () => any);
  131066. /**
  131067. * Gets or sets the associated variable name in the shader
  131068. */
  131069. get associatedVariableName(): string;
  131070. set associatedVariableName(value: string);
  131071. /** Gets or sets the type of animation applied to the input */
  131072. get animationType(): AnimatedInputBlockTypes;
  131073. set animationType(value: AnimatedInputBlockTypes);
  131074. /**
  131075. * Gets a boolean indicating that this connection point not defined yet
  131076. */
  131077. get isUndefined(): boolean;
  131078. /**
  131079. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131080. * In this case the connection point name must be the name of the uniform to use.
  131081. * Can only be set on inputs
  131082. */
  131083. get isUniform(): boolean;
  131084. set isUniform(value: boolean);
  131085. /**
  131086. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131087. * In this case the connection point name must be the name of the attribute to use
  131088. * Can only be set on inputs
  131089. */
  131090. get isAttribute(): boolean;
  131091. set isAttribute(value: boolean);
  131092. /**
  131093. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131094. * Can only be set on exit points
  131095. */
  131096. get isVarying(): boolean;
  131097. set isVarying(value: boolean);
  131098. /**
  131099. * Gets a boolean indicating that the current connection point is a system value
  131100. */
  131101. get isSystemValue(): boolean;
  131102. /**
  131103. * Gets or sets the current well known value or null if not defined as a system value
  131104. */
  131105. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131106. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131107. /**
  131108. * Gets the current class name
  131109. * @returns the class name
  131110. */
  131111. getClassName(): string;
  131112. /**
  131113. * Animate the input if animationType !== None
  131114. * @param scene defines the rendering scene
  131115. */
  131116. animate(scene: Scene): void;
  131117. private _emitDefine;
  131118. initialize(state: NodeMaterialBuildState): void;
  131119. /**
  131120. * Set the input block to its default value (based on its type)
  131121. */
  131122. setDefaultValue(): void;
  131123. private _emitConstant;
  131124. private _emit;
  131125. /** @hidden */
  131126. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131127. /** @hidden */
  131128. _transmit(effect: Effect, scene: Scene): void;
  131129. protected _buildBlock(state: NodeMaterialBuildState): void;
  131130. protected _dumpPropertiesCode(): string;
  131131. serialize(): any;
  131132. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131133. }
  131134. }
  131135. declare module BABYLON {
  131136. /**
  131137. * Enum used to define the compatibility state between two connection points
  131138. */
  131139. export enum NodeMaterialConnectionPointCompatibilityStates {
  131140. /** Points are compatibles */
  131141. Compatible = 0,
  131142. /** Points are incompatible because of their types */
  131143. TypeIncompatible = 1,
  131144. /** Points are incompatible because of their targets (vertex vs fragment) */
  131145. TargetIncompatible = 2
  131146. }
  131147. /**
  131148. * Defines the direction of a connection point
  131149. */
  131150. export enum NodeMaterialConnectionPointDirection {
  131151. /** Input */
  131152. Input = 0,
  131153. /** Output */
  131154. Output = 1
  131155. }
  131156. /**
  131157. * Defines a connection point for a block
  131158. */
  131159. export class NodeMaterialConnectionPoint {
  131160. /** @hidden */
  131161. _ownerBlock: NodeMaterialBlock;
  131162. /** @hidden */
  131163. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131164. private _endpoints;
  131165. private _associatedVariableName;
  131166. private _direction;
  131167. /** @hidden */
  131168. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131169. /** @hidden */
  131170. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131171. private _type;
  131172. /** @hidden */
  131173. _enforceAssociatedVariableName: boolean;
  131174. /** Gets the direction of the point */
  131175. get direction(): NodeMaterialConnectionPointDirection;
  131176. /**
  131177. * Gets or sets the additional types supported by this connection point
  131178. */
  131179. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131180. /**
  131181. * Gets or sets the additional types excluded by this connection point
  131182. */
  131183. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131184. /**
  131185. * Observable triggered when this point is connected
  131186. */
  131187. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131188. /**
  131189. * Gets or sets the associated variable name in the shader
  131190. */
  131191. get associatedVariableName(): string;
  131192. set associatedVariableName(value: string);
  131193. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131194. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131195. /**
  131196. * Gets or sets the connection point type (default is float)
  131197. */
  131198. get type(): NodeMaterialBlockConnectionPointTypes;
  131199. set type(value: NodeMaterialBlockConnectionPointTypes);
  131200. /**
  131201. * Gets or sets the connection point name
  131202. */
  131203. name: string;
  131204. /**
  131205. * Gets or sets a boolean indicating that this connection point can be omitted
  131206. */
  131207. isOptional: boolean;
  131208. /**
  131209. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131210. */
  131211. define: string;
  131212. /** @hidden */
  131213. _prioritizeVertex: boolean;
  131214. private _target;
  131215. /** Gets or sets the target of that connection point */
  131216. get target(): NodeMaterialBlockTargets;
  131217. set target(value: NodeMaterialBlockTargets);
  131218. /**
  131219. * Gets a boolean indicating that the current point is connected
  131220. */
  131221. get isConnected(): boolean;
  131222. /**
  131223. * Gets a boolean indicating that the current point is connected to an input block
  131224. */
  131225. get isConnectedToInputBlock(): boolean;
  131226. /**
  131227. * Gets a the connected input block (if any)
  131228. */
  131229. get connectInputBlock(): Nullable<InputBlock>;
  131230. /** Get the other side of the connection (if any) */
  131231. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131232. /** Get the block that owns this connection point */
  131233. get ownerBlock(): NodeMaterialBlock;
  131234. /** Get the block connected on the other side of this connection (if any) */
  131235. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131236. /** Get the block connected on the endpoints of this connection (if any) */
  131237. get connectedBlocks(): Array<NodeMaterialBlock>;
  131238. /** Gets the list of connected endpoints */
  131239. get endpoints(): NodeMaterialConnectionPoint[];
  131240. /** Gets a boolean indicating if that output point is connected to at least one input */
  131241. get hasEndpoints(): boolean;
  131242. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131243. get isConnectedInVertexShader(): boolean;
  131244. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131245. get isConnectedInFragmentShader(): boolean;
  131246. /**
  131247. * Creates a new connection point
  131248. * @param name defines the connection point name
  131249. * @param ownerBlock defines the block hosting this connection point
  131250. * @param direction defines the direction of the connection point
  131251. */
  131252. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131253. /**
  131254. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131255. * @returns the class name
  131256. */
  131257. getClassName(): string;
  131258. /**
  131259. * Gets a boolean indicating if the current point can be connected to another point
  131260. * @param connectionPoint defines the other connection point
  131261. * @returns a boolean
  131262. */
  131263. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131264. /**
  131265. * Gets a number indicating if the current point can be connected to another point
  131266. * @param connectionPoint defines the other connection point
  131267. * @returns a number defining the compatibility state
  131268. */
  131269. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131270. /**
  131271. * Connect this point to another connection point
  131272. * @param connectionPoint defines the other connection point
  131273. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131274. * @returns the current connection point
  131275. */
  131276. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131277. /**
  131278. * Disconnect this point from one of his endpoint
  131279. * @param endpoint defines the other connection point
  131280. * @returns the current connection point
  131281. */
  131282. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131283. /**
  131284. * Serializes this point in a JSON representation
  131285. * @returns the serialized point object
  131286. */
  131287. serialize(): any;
  131288. /**
  131289. * Release resources
  131290. */
  131291. dispose(): void;
  131292. }
  131293. }
  131294. declare module BABYLON {
  131295. /**
  131296. * Block used to add support for vertex skinning (bones)
  131297. */
  131298. export class BonesBlock extends NodeMaterialBlock {
  131299. /**
  131300. * Creates a new BonesBlock
  131301. * @param name defines the block name
  131302. */
  131303. constructor(name: string);
  131304. /**
  131305. * Initialize the block and prepare the context for build
  131306. * @param state defines the state that will be used for the build
  131307. */
  131308. initialize(state: NodeMaterialBuildState): void;
  131309. /**
  131310. * Gets the current class name
  131311. * @returns the class name
  131312. */
  131313. getClassName(): string;
  131314. /**
  131315. * Gets the matrix indices input component
  131316. */
  131317. get matricesIndices(): NodeMaterialConnectionPoint;
  131318. /**
  131319. * Gets the matrix weights input component
  131320. */
  131321. get matricesWeights(): NodeMaterialConnectionPoint;
  131322. /**
  131323. * Gets the extra matrix indices input component
  131324. */
  131325. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131326. /**
  131327. * Gets the extra matrix weights input component
  131328. */
  131329. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131330. /**
  131331. * Gets the world input component
  131332. */
  131333. get world(): NodeMaterialConnectionPoint;
  131334. /**
  131335. * Gets the output component
  131336. */
  131337. get output(): NodeMaterialConnectionPoint;
  131338. autoConfigure(material: NodeMaterial): void;
  131339. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131342. protected _buildBlock(state: NodeMaterialBuildState): this;
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * Block used to add support for instances
  131348. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131349. */
  131350. export class InstancesBlock extends NodeMaterialBlock {
  131351. /**
  131352. * Creates a new InstancesBlock
  131353. * @param name defines the block name
  131354. */
  131355. constructor(name: string);
  131356. /**
  131357. * Gets the current class name
  131358. * @returns the class name
  131359. */
  131360. getClassName(): string;
  131361. /**
  131362. * Gets the first world row input component
  131363. */
  131364. get world0(): NodeMaterialConnectionPoint;
  131365. /**
  131366. * Gets the second world row input component
  131367. */
  131368. get world1(): NodeMaterialConnectionPoint;
  131369. /**
  131370. * Gets the third world row input component
  131371. */
  131372. get world2(): NodeMaterialConnectionPoint;
  131373. /**
  131374. * Gets the forth world row input component
  131375. */
  131376. get world3(): NodeMaterialConnectionPoint;
  131377. /**
  131378. * Gets the world input component
  131379. */
  131380. get world(): NodeMaterialConnectionPoint;
  131381. /**
  131382. * Gets the output component
  131383. */
  131384. get output(): NodeMaterialConnectionPoint;
  131385. /**
  131386. * Gets the isntanceID component
  131387. */
  131388. get instanceID(): NodeMaterialConnectionPoint;
  131389. autoConfigure(material: NodeMaterial): void;
  131390. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131391. protected _buildBlock(state: NodeMaterialBuildState): this;
  131392. }
  131393. }
  131394. declare module BABYLON {
  131395. /**
  131396. * Block used to add morph targets support to vertex shader
  131397. */
  131398. export class MorphTargetsBlock extends NodeMaterialBlock {
  131399. private _repeatableContentAnchor;
  131400. /**
  131401. * Create a new MorphTargetsBlock
  131402. * @param name defines the block name
  131403. */
  131404. constructor(name: string);
  131405. /**
  131406. * Gets the current class name
  131407. * @returns the class name
  131408. */
  131409. getClassName(): string;
  131410. /**
  131411. * Gets the position input component
  131412. */
  131413. get position(): NodeMaterialConnectionPoint;
  131414. /**
  131415. * Gets the normal input component
  131416. */
  131417. get normal(): NodeMaterialConnectionPoint;
  131418. /**
  131419. * Gets the tangent input component
  131420. */
  131421. get tangent(): NodeMaterialConnectionPoint;
  131422. /**
  131423. * Gets the tangent input component
  131424. */
  131425. get uv(): NodeMaterialConnectionPoint;
  131426. /**
  131427. * Gets the position output component
  131428. */
  131429. get positionOutput(): NodeMaterialConnectionPoint;
  131430. /**
  131431. * Gets the normal output component
  131432. */
  131433. get normalOutput(): NodeMaterialConnectionPoint;
  131434. /**
  131435. * Gets the tangent output component
  131436. */
  131437. get tangentOutput(): NodeMaterialConnectionPoint;
  131438. /**
  131439. * Gets the tangent output component
  131440. */
  131441. get uvOutput(): NodeMaterialConnectionPoint;
  131442. initialize(state: NodeMaterialBuildState): void;
  131443. autoConfigure(material: NodeMaterial): void;
  131444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131445. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131446. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131447. protected _buildBlock(state: NodeMaterialBuildState): this;
  131448. }
  131449. }
  131450. declare module BABYLON {
  131451. /**
  131452. * Block used to get data information from a light
  131453. */
  131454. export class LightInformationBlock extends NodeMaterialBlock {
  131455. private _lightDataUniformName;
  131456. private _lightColorUniformName;
  131457. private _lightTypeDefineName;
  131458. /**
  131459. * Gets or sets the light associated with this block
  131460. */
  131461. light: Nullable<Light>;
  131462. /**
  131463. * Creates a new LightInformationBlock
  131464. * @param name defines the block name
  131465. */
  131466. constructor(name: string);
  131467. /**
  131468. * Gets the current class name
  131469. * @returns the class name
  131470. */
  131471. getClassName(): string;
  131472. /**
  131473. * Gets the world position input component
  131474. */
  131475. get worldPosition(): NodeMaterialConnectionPoint;
  131476. /**
  131477. * Gets the direction output component
  131478. */
  131479. get direction(): NodeMaterialConnectionPoint;
  131480. /**
  131481. * Gets the direction output component
  131482. */
  131483. get color(): NodeMaterialConnectionPoint;
  131484. /**
  131485. * Gets the direction output component
  131486. */
  131487. get intensity(): NodeMaterialConnectionPoint;
  131488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131490. protected _buildBlock(state: NodeMaterialBuildState): this;
  131491. serialize(): any;
  131492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131493. }
  131494. }
  131495. declare module BABYLON {
  131496. /**
  131497. * Block used to add image processing support to fragment shader
  131498. */
  131499. export class ImageProcessingBlock extends NodeMaterialBlock {
  131500. /**
  131501. * Create a new ImageProcessingBlock
  131502. * @param name defines the block name
  131503. */
  131504. constructor(name: string);
  131505. /**
  131506. * Gets the current class name
  131507. * @returns the class name
  131508. */
  131509. getClassName(): string;
  131510. /**
  131511. * Gets the color input component
  131512. */
  131513. get color(): NodeMaterialConnectionPoint;
  131514. /**
  131515. * Gets the output component
  131516. */
  131517. get output(): NodeMaterialConnectionPoint;
  131518. /**
  131519. * Initialize the block and prepare the context for build
  131520. * @param state defines the state that will be used for the build
  131521. */
  131522. initialize(state: NodeMaterialBuildState): void;
  131523. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131526. protected _buildBlock(state: NodeMaterialBuildState): this;
  131527. }
  131528. }
  131529. declare module BABYLON {
  131530. /**
  131531. * Block used to pertub normals based on a normal map
  131532. */
  131533. export class PerturbNormalBlock extends NodeMaterialBlock {
  131534. private _tangentSpaceParameterName;
  131535. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131536. invertX: boolean;
  131537. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131538. invertY: boolean;
  131539. /**
  131540. * Create a new PerturbNormalBlock
  131541. * @param name defines the block name
  131542. */
  131543. constructor(name: string);
  131544. /**
  131545. * Gets the current class name
  131546. * @returns the class name
  131547. */
  131548. getClassName(): string;
  131549. /**
  131550. * Gets the world position input component
  131551. */
  131552. get worldPosition(): NodeMaterialConnectionPoint;
  131553. /**
  131554. * Gets the world normal input component
  131555. */
  131556. get worldNormal(): NodeMaterialConnectionPoint;
  131557. /**
  131558. * Gets the world tangent input component
  131559. */
  131560. get worldTangent(): NodeMaterialConnectionPoint;
  131561. /**
  131562. * Gets the uv input component
  131563. */
  131564. get uv(): NodeMaterialConnectionPoint;
  131565. /**
  131566. * Gets the normal map color input component
  131567. */
  131568. get normalMapColor(): NodeMaterialConnectionPoint;
  131569. /**
  131570. * Gets the strength input component
  131571. */
  131572. get strength(): NodeMaterialConnectionPoint;
  131573. /**
  131574. * Gets the output component
  131575. */
  131576. get output(): NodeMaterialConnectionPoint;
  131577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131579. autoConfigure(material: NodeMaterial): void;
  131580. protected _buildBlock(state: NodeMaterialBuildState): this;
  131581. protected _dumpPropertiesCode(): string;
  131582. serialize(): any;
  131583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131584. }
  131585. }
  131586. declare module BABYLON {
  131587. /**
  131588. * Block used to discard a pixel if a value is smaller than a cutoff
  131589. */
  131590. export class DiscardBlock extends NodeMaterialBlock {
  131591. /**
  131592. * Create a new DiscardBlock
  131593. * @param name defines the block name
  131594. */
  131595. constructor(name: string);
  131596. /**
  131597. * Gets the current class name
  131598. * @returns the class name
  131599. */
  131600. getClassName(): string;
  131601. /**
  131602. * Gets the color input component
  131603. */
  131604. get value(): NodeMaterialConnectionPoint;
  131605. /**
  131606. * Gets the cutoff input component
  131607. */
  131608. get cutoff(): NodeMaterialConnectionPoint;
  131609. protected _buildBlock(state: NodeMaterialBuildState): this;
  131610. }
  131611. }
  131612. declare module BABYLON {
  131613. /**
  131614. * Block used to test if the fragment shader is front facing
  131615. */
  131616. export class FrontFacingBlock extends NodeMaterialBlock {
  131617. /**
  131618. * Creates a new FrontFacingBlock
  131619. * @param name defines the block name
  131620. */
  131621. constructor(name: string);
  131622. /**
  131623. * Gets the current class name
  131624. * @returns the class name
  131625. */
  131626. getClassName(): string;
  131627. /**
  131628. * Gets the output component
  131629. */
  131630. get output(): NodeMaterialConnectionPoint;
  131631. protected _buildBlock(state: NodeMaterialBuildState): this;
  131632. }
  131633. }
  131634. declare module BABYLON {
  131635. /**
  131636. * Block used to get the derivative value on x and y of a given input
  131637. */
  131638. export class DerivativeBlock extends NodeMaterialBlock {
  131639. /**
  131640. * Create a new DerivativeBlock
  131641. * @param name defines the block name
  131642. */
  131643. constructor(name: string);
  131644. /**
  131645. * Gets the current class name
  131646. * @returns the class name
  131647. */
  131648. getClassName(): string;
  131649. /**
  131650. * Gets the input component
  131651. */
  131652. get input(): NodeMaterialConnectionPoint;
  131653. /**
  131654. * Gets the derivative output on x
  131655. */
  131656. get dx(): NodeMaterialConnectionPoint;
  131657. /**
  131658. * Gets the derivative output on y
  131659. */
  131660. get dy(): NodeMaterialConnectionPoint;
  131661. protected _buildBlock(state: NodeMaterialBuildState): this;
  131662. }
  131663. }
  131664. declare module BABYLON {
  131665. /**
  131666. * Block used to add support for scene fog
  131667. */
  131668. export class FogBlock extends NodeMaterialBlock {
  131669. private _fogDistanceName;
  131670. private _fogParameters;
  131671. /**
  131672. * Create a new FogBlock
  131673. * @param name defines the block name
  131674. */
  131675. constructor(name: string);
  131676. /**
  131677. * Gets the current class name
  131678. * @returns the class name
  131679. */
  131680. getClassName(): string;
  131681. /**
  131682. * Gets the world position input component
  131683. */
  131684. get worldPosition(): NodeMaterialConnectionPoint;
  131685. /**
  131686. * Gets the view input component
  131687. */
  131688. get view(): NodeMaterialConnectionPoint;
  131689. /**
  131690. * Gets the color input component
  131691. */
  131692. get input(): NodeMaterialConnectionPoint;
  131693. /**
  131694. * Gets the fog color input component
  131695. */
  131696. get fogColor(): NodeMaterialConnectionPoint;
  131697. /**
  131698. * Gets the output component
  131699. */
  131700. get output(): NodeMaterialConnectionPoint;
  131701. autoConfigure(material: NodeMaterial): void;
  131702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131704. protected _buildBlock(state: NodeMaterialBuildState): this;
  131705. }
  131706. }
  131707. declare module BABYLON {
  131708. /**
  131709. * Block used to add light in the fragment shader
  131710. */
  131711. export class LightBlock extends NodeMaterialBlock {
  131712. private _lightId;
  131713. /**
  131714. * Gets or sets the light associated with this block
  131715. */
  131716. light: Nullable<Light>;
  131717. /**
  131718. * Create a new LightBlock
  131719. * @param name defines the block name
  131720. */
  131721. constructor(name: string);
  131722. /**
  131723. * Gets the current class name
  131724. * @returns the class name
  131725. */
  131726. getClassName(): string;
  131727. /**
  131728. * Gets the world position input component
  131729. */
  131730. get worldPosition(): NodeMaterialConnectionPoint;
  131731. /**
  131732. * Gets the world normal input component
  131733. */
  131734. get worldNormal(): NodeMaterialConnectionPoint;
  131735. /**
  131736. * Gets the camera (or eye) position component
  131737. */
  131738. get cameraPosition(): NodeMaterialConnectionPoint;
  131739. /**
  131740. * Gets the glossiness component
  131741. */
  131742. get glossiness(): NodeMaterialConnectionPoint;
  131743. /**
  131744. * Gets the glossinness power component
  131745. */
  131746. get glossPower(): NodeMaterialConnectionPoint;
  131747. /**
  131748. * Gets the diffuse color component
  131749. */
  131750. get diffuseColor(): NodeMaterialConnectionPoint;
  131751. /**
  131752. * Gets the specular color component
  131753. */
  131754. get specularColor(): NodeMaterialConnectionPoint;
  131755. /**
  131756. * Gets the diffuse output component
  131757. */
  131758. get diffuseOutput(): NodeMaterialConnectionPoint;
  131759. /**
  131760. * Gets the specular output component
  131761. */
  131762. get specularOutput(): NodeMaterialConnectionPoint;
  131763. /**
  131764. * Gets the shadow output component
  131765. */
  131766. get shadow(): NodeMaterialConnectionPoint;
  131767. autoConfigure(material: NodeMaterial): void;
  131768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131769. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131770. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131771. private _injectVertexCode;
  131772. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131773. serialize(): any;
  131774. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131775. }
  131776. }
  131777. declare module BABYLON {
  131778. /**
  131779. * Block used to multiply 2 values
  131780. */
  131781. export class MultiplyBlock extends NodeMaterialBlock {
  131782. /**
  131783. * Creates a new MultiplyBlock
  131784. * @param name defines the block name
  131785. */
  131786. constructor(name: string);
  131787. /**
  131788. * Gets the current class name
  131789. * @returns the class name
  131790. */
  131791. getClassName(): string;
  131792. /**
  131793. * Gets the left operand input component
  131794. */
  131795. get left(): NodeMaterialConnectionPoint;
  131796. /**
  131797. * Gets the right operand input component
  131798. */
  131799. get right(): 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 add 2 vectors
  131810. */
  131811. export class AddBlock extends NodeMaterialBlock {
  131812. /**
  131813. * Creates a new AddBlock
  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 left operand input component
  131824. */
  131825. get left(): NodeMaterialConnectionPoint;
  131826. /**
  131827. * Gets the right operand input component
  131828. */
  131829. get right(): NodeMaterialConnectionPoint;
  131830. /**
  131831. * Gets the output component
  131832. */
  131833. get output(): NodeMaterialConnectionPoint;
  131834. protected _buildBlock(state: NodeMaterialBuildState): this;
  131835. }
  131836. }
  131837. declare module BABYLON {
  131838. /**
  131839. * Block used to scale a vector by a float
  131840. */
  131841. export class ScaleBlock extends NodeMaterialBlock {
  131842. /**
  131843. * Creates a new ScaleBlock
  131844. * @param name defines the block name
  131845. */
  131846. constructor(name: string);
  131847. /**
  131848. * Gets the current class name
  131849. * @returns the class name
  131850. */
  131851. getClassName(): string;
  131852. /**
  131853. * Gets the input component
  131854. */
  131855. get input(): NodeMaterialConnectionPoint;
  131856. /**
  131857. * Gets the factor input component
  131858. */
  131859. get factor(): NodeMaterialConnectionPoint;
  131860. /**
  131861. * Gets the output component
  131862. */
  131863. get output(): NodeMaterialConnectionPoint;
  131864. protected _buildBlock(state: NodeMaterialBuildState): this;
  131865. }
  131866. }
  131867. declare module BABYLON {
  131868. /**
  131869. * Block used to clamp a float
  131870. */
  131871. export class ClampBlock extends NodeMaterialBlock {
  131872. /** Gets or sets the minimum range */
  131873. minimum: number;
  131874. /** Gets or sets the maximum range */
  131875. maximum: number;
  131876. /**
  131877. * Creates a new ClampBlock
  131878. * @param name defines the block name
  131879. */
  131880. constructor(name: string);
  131881. /**
  131882. * Gets the current class name
  131883. * @returns the class name
  131884. */
  131885. getClassName(): string;
  131886. /**
  131887. * Gets the value input component
  131888. */
  131889. get value(): NodeMaterialConnectionPoint;
  131890. /**
  131891. * Gets the output component
  131892. */
  131893. get output(): NodeMaterialConnectionPoint;
  131894. protected _buildBlock(state: NodeMaterialBuildState): this;
  131895. protected _dumpPropertiesCode(): string;
  131896. serialize(): any;
  131897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131898. }
  131899. }
  131900. declare module BABYLON {
  131901. /**
  131902. * Block used to apply a cross product between 2 vectors
  131903. */
  131904. export class CrossBlock extends NodeMaterialBlock {
  131905. /**
  131906. * Creates a new CrossBlock
  131907. * @param name defines the block name
  131908. */
  131909. constructor(name: string);
  131910. /**
  131911. * Gets the current class name
  131912. * @returns the class name
  131913. */
  131914. getClassName(): string;
  131915. /**
  131916. * Gets the left operand input component
  131917. */
  131918. get left(): NodeMaterialConnectionPoint;
  131919. /**
  131920. * Gets the right operand input component
  131921. */
  131922. get right(): NodeMaterialConnectionPoint;
  131923. /**
  131924. * Gets the output component
  131925. */
  131926. get output(): NodeMaterialConnectionPoint;
  131927. protected _buildBlock(state: NodeMaterialBuildState): this;
  131928. }
  131929. }
  131930. declare module BABYLON {
  131931. /**
  131932. * Block used to apply a dot product between 2 vectors
  131933. */
  131934. export class DotBlock extends NodeMaterialBlock {
  131935. /**
  131936. * Creates a new DotBlock
  131937. * @param name defines the block name
  131938. */
  131939. constructor(name: string);
  131940. /**
  131941. * Gets the current class name
  131942. * @returns the class name
  131943. */
  131944. getClassName(): string;
  131945. /**
  131946. * Gets the left operand input component
  131947. */
  131948. get left(): NodeMaterialConnectionPoint;
  131949. /**
  131950. * Gets the right operand input component
  131951. */
  131952. get right(): NodeMaterialConnectionPoint;
  131953. /**
  131954. * Gets the output component
  131955. */
  131956. get output(): NodeMaterialConnectionPoint;
  131957. protected _buildBlock(state: NodeMaterialBuildState): this;
  131958. }
  131959. }
  131960. declare module BABYLON {
  131961. /**
  131962. * Block used to remap a float from a range to a new one
  131963. */
  131964. export class RemapBlock extends NodeMaterialBlock {
  131965. /**
  131966. * Gets or sets the source range
  131967. */
  131968. sourceRange: Vector2;
  131969. /**
  131970. * Gets or sets the target range
  131971. */
  131972. targetRange: Vector2;
  131973. /**
  131974. * Creates a new RemapBlock
  131975. * @param name defines the block name
  131976. */
  131977. constructor(name: string);
  131978. /**
  131979. * Gets the current class name
  131980. * @returns the class name
  131981. */
  131982. getClassName(): string;
  131983. /**
  131984. * Gets the input component
  131985. */
  131986. get input(): NodeMaterialConnectionPoint;
  131987. /**
  131988. * Gets the source min input component
  131989. */
  131990. get sourceMin(): NodeMaterialConnectionPoint;
  131991. /**
  131992. * Gets the source max input component
  131993. */
  131994. get sourceMax(): NodeMaterialConnectionPoint;
  131995. /**
  131996. * Gets the target min input component
  131997. */
  131998. get targetMin(): NodeMaterialConnectionPoint;
  131999. /**
  132000. * Gets the target max input component
  132001. */
  132002. get targetMax(): NodeMaterialConnectionPoint;
  132003. /**
  132004. * Gets the output component
  132005. */
  132006. get output(): NodeMaterialConnectionPoint;
  132007. protected _buildBlock(state: NodeMaterialBuildState): this;
  132008. protected _dumpPropertiesCode(): string;
  132009. serialize(): any;
  132010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132011. }
  132012. }
  132013. declare module BABYLON {
  132014. /**
  132015. * Block used to normalize a vector
  132016. */
  132017. export class NormalizeBlock extends NodeMaterialBlock {
  132018. /**
  132019. * Creates a new NormalizeBlock
  132020. * @param name defines the block name
  132021. */
  132022. constructor(name: string);
  132023. /**
  132024. * Gets the current class name
  132025. * @returns the class name
  132026. */
  132027. getClassName(): string;
  132028. /**
  132029. * Gets the input component
  132030. */
  132031. get input(): NodeMaterialConnectionPoint;
  132032. /**
  132033. * Gets the output component
  132034. */
  132035. get output(): NodeMaterialConnectionPoint;
  132036. protected _buildBlock(state: NodeMaterialBuildState): this;
  132037. }
  132038. }
  132039. declare module BABYLON {
  132040. /**
  132041. * Operations supported by the Trigonometry block
  132042. */
  132043. export enum TrigonometryBlockOperations {
  132044. /** Cos */
  132045. Cos = 0,
  132046. /** Sin */
  132047. Sin = 1,
  132048. /** Abs */
  132049. Abs = 2,
  132050. /** Exp */
  132051. Exp = 3,
  132052. /** Exp2 */
  132053. Exp2 = 4,
  132054. /** Round */
  132055. Round = 5,
  132056. /** Floor */
  132057. Floor = 6,
  132058. /** Ceiling */
  132059. Ceiling = 7,
  132060. /** Square root */
  132061. Sqrt = 8,
  132062. /** Log */
  132063. Log = 9,
  132064. /** Tangent */
  132065. Tan = 10,
  132066. /** Arc tangent */
  132067. ArcTan = 11,
  132068. /** Arc cosinus */
  132069. ArcCos = 12,
  132070. /** Arc sinus */
  132071. ArcSin = 13,
  132072. /** Fraction */
  132073. Fract = 14,
  132074. /** Sign */
  132075. Sign = 15,
  132076. /** To radians (from degrees) */
  132077. Radians = 16,
  132078. /** To degrees (from radians) */
  132079. Degrees = 17
  132080. }
  132081. /**
  132082. * Block used to apply trigonometry operation to floats
  132083. */
  132084. export class TrigonometryBlock extends NodeMaterialBlock {
  132085. /**
  132086. * Gets or sets the operation applied by the block
  132087. */
  132088. operation: TrigonometryBlockOperations;
  132089. /**
  132090. * Creates a new TrigonometryBlock
  132091. * @param name defines the block name
  132092. */
  132093. constructor(name: string);
  132094. /**
  132095. * Gets the current class name
  132096. * @returns the class name
  132097. */
  132098. getClassName(): string;
  132099. /**
  132100. * Gets the input component
  132101. */
  132102. get input(): NodeMaterialConnectionPoint;
  132103. /**
  132104. * Gets the output component
  132105. */
  132106. get output(): NodeMaterialConnectionPoint;
  132107. protected _buildBlock(state: NodeMaterialBuildState): this;
  132108. serialize(): any;
  132109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132110. protected _dumpPropertiesCode(): string;
  132111. }
  132112. }
  132113. declare module BABYLON {
  132114. /**
  132115. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132116. */
  132117. export class ColorMergerBlock extends NodeMaterialBlock {
  132118. /**
  132119. * Create a new ColorMergerBlock
  132120. * @param name defines the block name
  132121. */
  132122. constructor(name: string);
  132123. /**
  132124. * Gets the current class name
  132125. * @returns the class name
  132126. */
  132127. getClassName(): string;
  132128. /**
  132129. * Gets the rgb component (input)
  132130. */
  132131. get rgbIn(): NodeMaterialConnectionPoint;
  132132. /**
  132133. * Gets the r component (input)
  132134. */
  132135. get r(): NodeMaterialConnectionPoint;
  132136. /**
  132137. * Gets the g component (input)
  132138. */
  132139. get g(): NodeMaterialConnectionPoint;
  132140. /**
  132141. * Gets the b component (input)
  132142. */
  132143. get b(): NodeMaterialConnectionPoint;
  132144. /**
  132145. * Gets the a component (input)
  132146. */
  132147. get a(): NodeMaterialConnectionPoint;
  132148. /**
  132149. * Gets the rgba component (output)
  132150. */
  132151. get rgba(): NodeMaterialConnectionPoint;
  132152. /**
  132153. * Gets the rgb component (output)
  132154. */
  132155. get rgbOut(): NodeMaterialConnectionPoint;
  132156. /**
  132157. * Gets the rgb component (output)
  132158. * @deprecated Please use rgbOut instead.
  132159. */
  132160. get rgb(): NodeMaterialConnectionPoint;
  132161. protected _buildBlock(state: NodeMaterialBuildState): this;
  132162. }
  132163. }
  132164. declare module BABYLON {
  132165. /**
  132166. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132167. */
  132168. export class VectorMergerBlock extends NodeMaterialBlock {
  132169. /**
  132170. * Create a new VectorMergerBlock
  132171. * @param name defines the block name
  132172. */
  132173. constructor(name: string);
  132174. /**
  132175. * Gets the current class name
  132176. * @returns the class name
  132177. */
  132178. getClassName(): string;
  132179. /**
  132180. * Gets the xyz component (input)
  132181. */
  132182. get xyzIn(): NodeMaterialConnectionPoint;
  132183. /**
  132184. * Gets the xy component (input)
  132185. */
  132186. get xyIn(): NodeMaterialConnectionPoint;
  132187. /**
  132188. * Gets the x component (input)
  132189. */
  132190. get x(): NodeMaterialConnectionPoint;
  132191. /**
  132192. * Gets the y component (input)
  132193. */
  132194. get y(): NodeMaterialConnectionPoint;
  132195. /**
  132196. * Gets the z component (input)
  132197. */
  132198. get z(): NodeMaterialConnectionPoint;
  132199. /**
  132200. * Gets the w component (input)
  132201. */
  132202. get w(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the xyzw component (output)
  132205. */
  132206. get xyzw(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the xyz component (output)
  132209. */
  132210. get xyzOut(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the xy component (output)
  132213. */
  132214. get xyOut(): NodeMaterialConnectionPoint;
  132215. /**
  132216. * Gets the xy component (output)
  132217. * @deprecated Please use xyOut instead.
  132218. */
  132219. get xy(): NodeMaterialConnectionPoint;
  132220. /**
  132221. * Gets the xyz component (output)
  132222. * @deprecated Please use xyzOut instead.
  132223. */
  132224. get xyz(): NodeMaterialConnectionPoint;
  132225. protected _buildBlock(state: NodeMaterialBuildState): this;
  132226. }
  132227. }
  132228. declare module BABYLON {
  132229. /**
  132230. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132231. */
  132232. export class ColorSplitterBlock extends NodeMaterialBlock {
  132233. /**
  132234. * Create a new ColorSplitterBlock
  132235. * @param name defines the block name
  132236. */
  132237. constructor(name: string);
  132238. /**
  132239. * Gets the current class name
  132240. * @returns the class name
  132241. */
  132242. getClassName(): string;
  132243. /**
  132244. * Gets the rgba component (input)
  132245. */
  132246. get rgba(): NodeMaterialConnectionPoint;
  132247. /**
  132248. * Gets the rgb component (input)
  132249. */
  132250. get rgbIn(): NodeMaterialConnectionPoint;
  132251. /**
  132252. * Gets the rgb component (output)
  132253. */
  132254. get rgbOut(): NodeMaterialConnectionPoint;
  132255. /**
  132256. * Gets the r component (output)
  132257. */
  132258. get r(): NodeMaterialConnectionPoint;
  132259. /**
  132260. * Gets the g component (output)
  132261. */
  132262. get g(): NodeMaterialConnectionPoint;
  132263. /**
  132264. * Gets the b component (output)
  132265. */
  132266. get b(): NodeMaterialConnectionPoint;
  132267. /**
  132268. * Gets the a component (output)
  132269. */
  132270. get a(): NodeMaterialConnectionPoint;
  132271. protected _inputRename(name: string): string;
  132272. protected _outputRename(name: string): string;
  132273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132274. }
  132275. }
  132276. declare module BABYLON {
  132277. /**
  132278. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132279. */
  132280. export class VectorSplitterBlock extends NodeMaterialBlock {
  132281. /**
  132282. * Create a new VectorSplitterBlock
  132283. * @param name defines the block name
  132284. */
  132285. constructor(name: string);
  132286. /**
  132287. * Gets the current class name
  132288. * @returns the class name
  132289. */
  132290. getClassName(): string;
  132291. /**
  132292. * Gets the xyzw component (input)
  132293. */
  132294. get xyzw(): NodeMaterialConnectionPoint;
  132295. /**
  132296. * Gets the xyz component (input)
  132297. */
  132298. get xyzIn(): NodeMaterialConnectionPoint;
  132299. /**
  132300. * Gets the xy component (input)
  132301. */
  132302. get xyIn(): NodeMaterialConnectionPoint;
  132303. /**
  132304. * Gets the xyz component (output)
  132305. */
  132306. get xyzOut(): NodeMaterialConnectionPoint;
  132307. /**
  132308. * Gets the xy component (output)
  132309. */
  132310. get xyOut(): NodeMaterialConnectionPoint;
  132311. /**
  132312. * Gets the x component (output)
  132313. */
  132314. get x(): NodeMaterialConnectionPoint;
  132315. /**
  132316. * Gets the y component (output)
  132317. */
  132318. get y(): NodeMaterialConnectionPoint;
  132319. /**
  132320. * Gets the z component (output)
  132321. */
  132322. get z(): NodeMaterialConnectionPoint;
  132323. /**
  132324. * Gets the w component (output)
  132325. */
  132326. get w(): NodeMaterialConnectionPoint;
  132327. protected _inputRename(name: string): string;
  132328. protected _outputRename(name: string): string;
  132329. protected _buildBlock(state: NodeMaterialBuildState): this;
  132330. }
  132331. }
  132332. declare module BABYLON {
  132333. /**
  132334. * Block used to lerp between 2 values
  132335. */
  132336. export class LerpBlock extends NodeMaterialBlock {
  132337. /**
  132338. * Creates a new LerpBlock
  132339. * @param name defines the block name
  132340. */
  132341. constructor(name: string);
  132342. /**
  132343. * Gets the current class name
  132344. * @returns the class name
  132345. */
  132346. getClassName(): string;
  132347. /**
  132348. * Gets the left operand input component
  132349. */
  132350. get left(): NodeMaterialConnectionPoint;
  132351. /**
  132352. * Gets the right operand input component
  132353. */
  132354. get right(): NodeMaterialConnectionPoint;
  132355. /**
  132356. * Gets the gradient operand input component
  132357. */
  132358. get gradient(): NodeMaterialConnectionPoint;
  132359. /**
  132360. * Gets the output component
  132361. */
  132362. get output(): NodeMaterialConnectionPoint;
  132363. protected _buildBlock(state: NodeMaterialBuildState): this;
  132364. }
  132365. }
  132366. declare module BABYLON {
  132367. /**
  132368. * Block used to divide 2 vectors
  132369. */
  132370. export class DivideBlock extends NodeMaterialBlock {
  132371. /**
  132372. * Creates a new DivideBlock
  132373. * @param name defines the block name
  132374. */
  132375. constructor(name: string);
  132376. /**
  132377. * Gets the current class name
  132378. * @returns the class name
  132379. */
  132380. getClassName(): string;
  132381. /**
  132382. * Gets the left operand input component
  132383. */
  132384. get left(): NodeMaterialConnectionPoint;
  132385. /**
  132386. * Gets the right operand input component
  132387. */
  132388. get right(): NodeMaterialConnectionPoint;
  132389. /**
  132390. * Gets the output component
  132391. */
  132392. get output(): NodeMaterialConnectionPoint;
  132393. protected _buildBlock(state: NodeMaterialBuildState): this;
  132394. }
  132395. }
  132396. declare module BABYLON {
  132397. /**
  132398. * Block used to subtract 2 vectors
  132399. */
  132400. export class SubtractBlock extends NodeMaterialBlock {
  132401. /**
  132402. * Creates a new SubtractBlock
  132403. * @param name defines the block name
  132404. */
  132405. constructor(name: string);
  132406. /**
  132407. * Gets the current class name
  132408. * @returns the class name
  132409. */
  132410. getClassName(): string;
  132411. /**
  132412. * Gets the left operand input component
  132413. */
  132414. get left(): NodeMaterialConnectionPoint;
  132415. /**
  132416. * Gets the right operand input component
  132417. */
  132418. get right(): NodeMaterialConnectionPoint;
  132419. /**
  132420. * Gets the output component
  132421. */
  132422. get output(): NodeMaterialConnectionPoint;
  132423. protected _buildBlock(state: NodeMaterialBuildState): this;
  132424. }
  132425. }
  132426. declare module BABYLON {
  132427. /**
  132428. * Block used to step a value
  132429. */
  132430. export class StepBlock extends NodeMaterialBlock {
  132431. /**
  132432. * Creates a new StepBlock
  132433. * @param name defines the block name
  132434. */
  132435. constructor(name: string);
  132436. /**
  132437. * Gets the current class name
  132438. * @returns the class name
  132439. */
  132440. getClassName(): string;
  132441. /**
  132442. * Gets the value operand input component
  132443. */
  132444. get value(): NodeMaterialConnectionPoint;
  132445. /**
  132446. * Gets the edge operand input component
  132447. */
  132448. get edge(): NodeMaterialConnectionPoint;
  132449. /**
  132450. * Gets the output component
  132451. */
  132452. get output(): NodeMaterialConnectionPoint;
  132453. protected _buildBlock(state: NodeMaterialBuildState): this;
  132454. }
  132455. }
  132456. declare module BABYLON {
  132457. /**
  132458. * Block used to get the opposite (1 - x) of a value
  132459. */
  132460. export class OneMinusBlock extends NodeMaterialBlock {
  132461. /**
  132462. * Creates a new OneMinusBlock
  132463. * @param name defines the block name
  132464. */
  132465. constructor(name: string);
  132466. /**
  132467. * Gets the current class name
  132468. * @returns the class name
  132469. */
  132470. getClassName(): string;
  132471. /**
  132472. * Gets the input component
  132473. */
  132474. get input(): NodeMaterialConnectionPoint;
  132475. /**
  132476. * Gets the output component
  132477. */
  132478. get output(): NodeMaterialConnectionPoint;
  132479. protected _buildBlock(state: NodeMaterialBuildState): this;
  132480. }
  132481. }
  132482. declare module BABYLON {
  132483. /**
  132484. * Block used to get the view direction
  132485. */
  132486. export class ViewDirectionBlock extends NodeMaterialBlock {
  132487. /**
  132488. * Creates a new ViewDirectionBlock
  132489. * @param name defines the block name
  132490. */
  132491. constructor(name: string);
  132492. /**
  132493. * Gets the current class name
  132494. * @returns the class name
  132495. */
  132496. getClassName(): string;
  132497. /**
  132498. * Gets the world position component
  132499. */
  132500. get worldPosition(): NodeMaterialConnectionPoint;
  132501. /**
  132502. * Gets the camera position component
  132503. */
  132504. get cameraPosition(): NodeMaterialConnectionPoint;
  132505. /**
  132506. * Gets the output component
  132507. */
  132508. get output(): NodeMaterialConnectionPoint;
  132509. autoConfigure(material: NodeMaterial): void;
  132510. protected _buildBlock(state: NodeMaterialBuildState): this;
  132511. }
  132512. }
  132513. declare module BABYLON {
  132514. /**
  132515. * Block used to compute fresnel value
  132516. */
  132517. export class FresnelBlock extends NodeMaterialBlock {
  132518. /**
  132519. * Create a new FresnelBlock
  132520. * @param name defines the block name
  132521. */
  132522. constructor(name: string);
  132523. /**
  132524. * Gets the current class name
  132525. * @returns the class name
  132526. */
  132527. getClassName(): string;
  132528. /**
  132529. * Gets the world normal input component
  132530. */
  132531. get worldNormal(): NodeMaterialConnectionPoint;
  132532. /**
  132533. * Gets the view direction input component
  132534. */
  132535. get viewDirection(): NodeMaterialConnectionPoint;
  132536. /**
  132537. * Gets the bias input component
  132538. */
  132539. get bias(): NodeMaterialConnectionPoint;
  132540. /**
  132541. * Gets the camera (or eye) position component
  132542. */
  132543. get power(): NodeMaterialConnectionPoint;
  132544. /**
  132545. * Gets the fresnel output component
  132546. */
  132547. get fresnel(): NodeMaterialConnectionPoint;
  132548. autoConfigure(material: NodeMaterial): void;
  132549. protected _buildBlock(state: NodeMaterialBuildState): this;
  132550. }
  132551. }
  132552. declare module BABYLON {
  132553. /**
  132554. * Block used to get the max of 2 values
  132555. */
  132556. export class MaxBlock extends NodeMaterialBlock {
  132557. /**
  132558. * Creates a new MaxBlock
  132559. * @param name defines the block name
  132560. */
  132561. constructor(name: string);
  132562. /**
  132563. * Gets the current class name
  132564. * @returns the class name
  132565. */
  132566. getClassName(): string;
  132567. /**
  132568. * Gets the left operand input component
  132569. */
  132570. get left(): NodeMaterialConnectionPoint;
  132571. /**
  132572. * Gets the right operand input component
  132573. */
  132574. get right(): NodeMaterialConnectionPoint;
  132575. /**
  132576. * Gets the output component
  132577. */
  132578. get output(): NodeMaterialConnectionPoint;
  132579. protected _buildBlock(state: NodeMaterialBuildState): this;
  132580. }
  132581. }
  132582. declare module BABYLON {
  132583. /**
  132584. * Block used to get the min of 2 values
  132585. */
  132586. export class MinBlock extends NodeMaterialBlock {
  132587. /**
  132588. * Creates a new MinBlock
  132589. * @param name defines the block name
  132590. */
  132591. constructor(name: string);
  132592. /**
  132593. * Gets the current class name
  132594. * @returns the class name
  132595. */
  132596. getClassName(): string;
  132597. /**
  132598. * Gets the left operand input component
  132599. */
  132600. get left(): NodeMaterialConnectionPoint;
  132601. /**
  132602. * Gets the right operand input component
  132603. */
  132604. get right(): NodeMaterialConnectionPoint;
  132605. /**
  132606. * Gets the output component
  132607. */
  132608. get output(): NodeMaterialConnectionPoint;
  132609. protected _buildBlock(state: NodeMaterialBuildState): this;
  132610. }
  132611. }
  132612. declare module BABYLON {
  132613. /**
  132614. * Block used to get the distance between 2 values
  132615. */
  132616. export class DistanceBlock extends NodeMaterialBlock {
  132617. /**
  132618. * Creates a new DistanceBlock
  132619. * @param name defines the block name
  132620. */
  132621. constructor(name: string);
  132622. /**
  132623. * Gets the current class name
  132624. * @returns the class name
  132625. */
  132626. getClassName(): string;
  132627. /**
  132628. * Gets the left operand input component
  132629. */
  132630. get left(): NodeMaterialConnectionPoint;
  132631. /**
  132632. * Gets the right operand input component
  132633. */
  132634. get right(): NodeMaterialConnectionPoint;
  132635. /**
  132636. * Gets the output component
  132637. */
  132638. get output(): NodeMaterialConnectionPoint;
  132639. protected _buildBlock(state: NodeMaterialBuildState): this;
  132640. }
  132641. }
  132642. declare module BABYLON {
  132643. /**
  132644. * Block used to get the length of a vector
  132645. */
  132646. export class LengthBlock extends NodeMaterialBlock {
  132647. /**
  132648. * Creates a new LengthBlock
  132649. * @param name defines the block name
  132650. */
  132651. constructor(name: string);
  132652. /**
  132653. * Gets the current class name
  132654. * @returns the class name
  132655. */
  132656. getClassName(): string;
  132657. /**
  132658. * Gets the value input component
  132659. */
  132660. get value(): NodeMaterialConnectionPoint;
  132661. /**
  132662. * Gets the output component
  132663. */
  132664. get output(): NodeMaterialConnectionPoint;
  132665. protected _buildBlock(state: NodeMaterialBuildState): this;
  132666. }
  132667. }
  132668. declare module BABYLON {
  132669. /**
  132670. * Block used to get negative version of a value (i.e. x * -1)
  132671. */
  132672. export class NegateBlock extends NodeMaterialBlock {
  132673. /**
  132674. * Creates a new NegateBlock
  132675. * @param name defines the block name
  132676. */
  132677. constructor(name: string);
  132678. /**
  132679. * Gets the current class name
  132680. * @returns the class name
  132681. */
  132682. getClassName(): string;
  132683. /**
  132684. * Gets the value input component
  132685. */
  132686. get value(): NodeMaterialConnectionPoint;
  132687. /**
  132688. * Gets the output component
  132689. */
  132690. get output(): NodeMaterialConnectionPoint;
  132691. protected _buildBlock(state: NodeMaterialBuildState): this;
  132692. }
  132693. }
  132694. declare module BABYLON {
  132695. /**
  132696. * Block used to get the value of the first parameter raised to the power of the second
  132697. */
  132698. export class PowBlock extends NodeMaterialBlock {
  132699. /**
  132700. * Creates a new PowBlock
  132701. * @param name defines the block name
  132702. */
  132703. constructor(name: string);
  132704. /**
  132705. * Gets the current class name
  132706. * @returns the class name
  132707. */
  132708. getClassName(): string;
  132709. /**
  132710. * Gets the value operand input component
  132711. */
  132712. get value(): NodeMaterialConnectionPoint;
  132713. /**
  132714. * Gets the power operand input component
  132715. */
  132716. get power(): NodeMaterialConnectionPoint;
  132717. /**
  132718. * Gets the output component
  132719. */
  132720. get output(): NodeMaterialConnectionPoint;
  132721. protected _buildBlock(state: NodeMaterialBuildState): this;
  132722. }
  132723. }
  132724. declare module BABYLON {
  132725. /**
  132726. * Block used to get a random number
  132727. */
  132728. export class RandomNumberBlock extends NodeMaterialBlock {
  132729. /**
  132730. * Creates a new RandomNumberBlock
  132731. * @param name defines the block name
  132732. */
  132733. constructor(name: string);
  132734. /**
  132735. * Gets the current class name
  132736. * @returns the class name
  132737. */
  132738. getClassName(): string;
  132739. /**
  132740. * Gets the seed input component
  132741. */
  132742. get seed(): NodeMaterialConnectionPoint;
  132743. /**
  132744. * Gets the output component
  132745. */
  132746. get output(): NodeMaterialConnectionPoint;
  132747. protected _buildBlock(state: NodeMaterialBuildState): this;
  132748. }
  132749. }
  132750. declare module BABYLON {
  132751. /**
  132752. * Block used to compute arc tangent of 2 values
  132753. */
  132754. export class ArcTan2Block extends NodeMaterialBlock {
  132755. /**
  132756. * Creates a new ArcTan2Block
  132757. * @param name defines the block name
  132758. */
  132759. constructor(name: string);
  132760. /**
  132761. * Gets the current class name
  132762. * @returns the class name
  132763. */
  132764. getClassName(): string;
  132765. /**
  132766. * Gets the x operand input component
  132767. */
  132768. get x(): NodeMaterialConnectionPoint;
  132769. /**
  132770. * Gets the y operand input component
  132771. */
  132772. get y(): NodeMaterialConnectionPoint;
  132773. /**
  132774. * Gets the output component
  132775. */
  132776. get output(): NodeMaterialConnectionPoint;
  132777. protected _buildBlock(state: NodeMaterialBuildState): this;
  132778. }
  132779. }
  132780. declare module BABYLON {
  132781. /**
  132782. * Block used to smooth step a value
  132783. */
  132784. export class SmoothStepBlock extends NodeMaterialBlock {
  132785. /**
  132786. * Creates a new SmoothStepBlock
  132787. * @param name defines the block name
  132788. */
  132789. constructor(name: string);
  132790. /**
  132791. * Gets the current class name
  132792. * @returns the class name
  132793. */
  132794. getClassName(): string;
  132795. /**
  132796. * Gets the value operand input component
  132797. */
  132798. get value(): NodeMaterialConnectionPoint;
  132799. /**
  132800. * Gets the first edge operand input component
  132801. */
  132802. get edge0(): NodeMaterialConnectionPoint;
  132803. /**
  132804. * Gets the second edge operand input component
  132805. */
  132806. get edge1(): NodeMaterialConnectionPoint;
  132807. /**
  132808. * Gets the output component
  132809. */
  132810. get output(): NodeMaterialConnectionPoint;
  132811. protected _buildBlock(state: NodeMaterialBuildState): this;
  132812. }
  132813. }
  132814. declare module BABYLON {
  132815. /**
  132816. * Block used to get the reciprocal (1 / x) of a value
  132817. */
  132818. export class ReciprocalBlock extends NodeMaterialBlock {
  132819. /**
  132820. * Creates a new ReciprocalBlock
  132821. * @param name defines the block name
  132822. */
  132823. constructor(name: string);
  132824. /**
  132825. * Gets the current class name
  132826. * @returns the class name
  132827. */
  132828. getClassName(): string;
  132829. /**
  132830. * Gets the input component
  132831. */
  132832. get input(): NodeMaterialConnectionPoint;
  132833. /**
  132834. * Gets the output component
  132835. */
  132836. get output(): NodeMaterialConnectionPoint;
  132837. protected _buildBlock(state: NodeMaterialBuildState): this;
  132838. }
  132839. }
  132840. declare module BABYLON {
  132841. /**
  132842. * Block used to replace a color by another one
  132843. */
  132844. export class ReplaceColorBlock extends NodeMaterialBlock {
  132845. /**
  132846. * Creates a new ReplaceColorBlock
  132847. * @param name defines the block name
  132848. */
  132849. constructor(name: string);
  132850. /**
  132851. * Gets the current class name
  132852. * @returns the class name
  132853. */
  132854. getClassName(): string;
  132855. /**
  132856. * Gets the value input component
  132857. */
  132858. get value(): NodeMaterialConnectionPoint;
  132859. /**
  132860. * Gets the reference input component
  132861. */
  132862. get reference(): NodeMaterialConnectionPoint;
  132863. /**
  132864. * Gets the distance input component
  132865. */
  132866. get distance(): NodeMaterialConnectionPoint;
  132867. /**
  132868. * Gets the replacement input component
  132869. */
  132870. get replacement(): NodeMaterialConnectionPoint;
  132871. /**
  132872. * Gets the output component
  132873. */
  132874. get output(): NodeMaterialConnectionPoint;
  132875. protected _buildBlock(state: NodeMaterialBuildState): this;
  132876. }
  132877. }
  132878. declare module BABYLON {
  132879. /**
  132880. * Block used to posterize a value
  132881. * @see https://en.wikipedia.org/wiki/Posterization
  132882. */
  132883. export class PosterizeBlock extends NodeMaterialBlock {
  132884. /**
  132885. * Creates a new PosterizeBlock
  132886. * @param name defines the block name
  132887. */
  132888. constructor(name: string);
  132889. /**
  132890. * Gets the current class name
  132891. * @returns the class name
  132892. */
  132893. getClassName(): string;
  132894. /**
  132895. * Gets the value input component
  132896. */
  132897. get value(): NodeMaterialConnectionPoint;
  132898. /**
  132899. * Gets the steps input component
  132900. */
  132901. get steps(): NodeMaterialConnectionPoint;
  132902. /**
  132903. * Gets the output component
  132904. */
  132905. get output(): NodeMaterialConnectionPoint;
  132906. protected _buildBlock(state: NodeMaterialBuildState): this;
  132907. }
  132908. }
  132909. declare module BABYLON {
  132910. /**
  132911. * Operations supported by the Wave block
  132912. */
  132913. export enum WaveBlockKind {
  132914. /** SawTooth */
  132915. SawTooth = 0,
  132916. /** Square */
  132917. Square = 1,
  132918. /** Triangle */
  132919. Triangle = 2
  132920. }
  132921. /**
  132922. * Block used to apply wave operation to floats
  132923. */
  132924. export class WaveBlock extends NodeMaterialBlock {
  132925. /**
  132926. * Gets or sets the kibnd of wave to be applied by the block
  132927. */
  132928. kind: WaveBlockKind;
  132929. /**
  132930. * Creates a new WaveBlock
  132931. * @param name defines the block name
  132932. */
  132933. constructor(name: string);
  132934. /**
  132935. * Gets the current class name
  132936. * @returns the class name
  132937. */
  132938. getClassName(): string;
  132939. /**
  132940. * Gets the input component
  132941. */
  132942. get input(): NodeMaterialConnectionPoint;
  132943. /**
  132944. * Gets the output component
  132945. */
  132946. get output(): NodeMaterialConnectionPoint;
  132947. protected _buildBlock(state: NodeMaterialBuildState): this;
  132948. serialize(): any;
  132949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132950. }
  132951. }
  132952. declare module BABYLON {
  132953. /**
  132954. * Class used to store a color step for the GradientBlock
  132955. */
  132956. export class GradientBlockColorStep {
  132957. /**
  132958. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132959. */
  132960. step: number;
  132961. /**
  132962. * Gets or sets the color associated with this step
  132963. */
  132964. color: Color3;
  132965. /**
  132966. * Creates a new GradientBlockColorStep
  132967. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132968. * @param color defines the color associated with this step
  132969. */
  132970. constructor(
  132971. /**
  132972. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132973. */
  132974. step: number,
  132975. /**
  132976. * Gets or sets the color associated with this step
  132977. */
  132978. color: Color3);
  132979. }
  132980. /**
  132981. * Block used to return a color from a gradient based on an input value between 0 and 1
  132982. */
  132983. export class GradientBlock extends NodeMaterialBlock {
  132984. /**
  132985. * Gets or sets the list of color steps
  132986. */
  132987. colorSteps: GradientBlockColorStep[];
  132988. /**
  132989. * Creates a new GradientBlock
  132990. * @param name defines the block name
  132991. */
  132992. constructor(name: string);
  132993. /**
  132994. * Gets the current class name
  132995. * @returns the class name
  132996. */
  132997. getClassName(): string;
  132998. /**
  132999. * Gets the gradient input component
  133000. */
  133001. get gradient(): NodeMaterialConnectionPoint;
  133002. /**
  133003. * Gets the output component
  133004. */
  133005. get output(): NodeMaterialConnectionPoint;
  133006. private _writeColorConstant;
  133007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133008. serialize(): any;
  133009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133010. protected _dumpPropertiesCode(): string;
  133011. }
  133012. }
  133013. declare module BABYLON {
  133014. /**
  133015. * Block used to normalize lerp between 2 values
  133016. */
  133017. export class NLerpBlock extends NodeMaterialBlock {
  133018. /**
  133019. * Creates a new NLerpBlock
  133020. * @param name defines the block name
  133021. */
  133022. constructor(name: string);
  133023. /**
  133024. * Gets the current class name
  133025. * @returns the class name
  133026. */
  133027. getClassName(): string;
  133028. /**
  133029. * Gets the left operand input component
  133030. */
  133031. get left(): NodeMaterialConnectionPoint;
  133032. /**
  133033. * Gets the right operand input component
  133034. */
  133035. get right(): NodeMaterialConnectionPoint;
  133036. /**
  133037. * Gets the gradient operand input component
  133038. */
  133039. get gradient(): NodeMaterialConnectionPoint;
  133040. /**
  133041. * Gets the output component
  133042. */
  133043. get output(): NodeMaterialConnectionPoint;
  133044. protected _buildBlock(state: NodeMaterialBuildState): this;
  133045. }
  133046. }
  133047. declare module BABYLON {
  133048. /**
  133049. * block used to Generate a Worley Noise 3D Noise Pattern
  133050. */
  133051. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133052. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133053. manhattanDistance: boolean;
  133054. /**
  133055. * Creates a new WorleyNoise3DBlock
  133056. * @param name defines the block name
  133057. */
  133058. constructor(name: string);
  133059. /**
  133060. * Gets the current class name
  133061. * @returns the class name
  133062. */
  133063. getClassName(): string;
  133064. /**
  133065. * Gets the seed input component
  133066. */
  133067. get seed(): NodeMaterialConnectionPoint;
  133068. /**
  133069. * Gets the jitter input component
  133070. */
  133071. get jitter(): NodeMaterialConnectionPoint;
  133072. /**
  133073. * Gets the output component
  133074. */
  133075. get output(): NodeMaterialConnectionPoint;
  133076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133077. /**
  133078. * Exposes the properties to the UI?
  133079. */
  133080. protected _dumpPropertiesCode(): string;
  133081. /**
  133082. * Exposes the properties to the Seralize?
  133083. */
  133084. serialize(): any;
  133085. /**
  133086. * Exposes the properties to the deseralize?
  133087. */
  133088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133089. }
  133090. }
  133091. declare module BABYLON {
  133092. /**
  133093. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133094. */
  133095. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133096. /**
  133097. * Creates a new SimplexPerlin3DBlock
  133098. * @param name defines the block name
  133099. */
  133100. constructor(name: string);
  133101. /**
  133102. * Gets the current class name
  133103. * @returns the class name
  133104. */
  133105. getClassName(): string;
  133106. /**
  133107. * Gets the seed operand input component
  133108. */
  133109. get seed(): NodeMaterialConnectionPoint;
  133110. /**
  133111. * Gets the output component
  133112. */
  133113. get output(): NodeMaterialConnectionPoint;
  133114. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133115. }
  133116. }
  133117. declare module BABYLON {
  133118. /**
  133119. * Block used to blend normals
  133120. */
  133121. export class NormalBlendBlock extends NodeMaterialBlock {
  133122. /**
  133123. * Creates a new NormalBlendBlock
  133124. * @param name defines the block name
  133125. */
  133126. constructor(name: string);
  133127. /**
  133128. * Gets the current class name
  133129. * @returns the class name
  133130. */
  133131. getClassName(): string;
  133132. /**
  133133. * Gets the first input component
  133134. */
  133135. get normalMap0(): NodeMaterialConnectionPoint;
  133136. /**
  133137. * Gets the second input component
  133138. */
  133139. get normalMap1(): NodeMaterialConnectionPoint;
  133140. /**
  133141. * Gets the output component
  133142. */
  133143. get output(): NodeMaterialConnectionPoint;
  133144. protected _buildBlock(state: NodeMaterialBuildState): this;
  133145. }
  133146. }
  133147. declare module BABYLON {
  133148. /**
  133149. * Block used to rotate a 2d vector by a given angle
  133150. */
  133151. export class Rotate2dBlock extends NodeMaterialBlock {
  133152. /**
  133153. * Creates a new Rotate2dBlock
  133154. * @param name defines the block name
  133155. */
  133156. constructor(name: string);
  133157. /**
  133158. * Gets the current class name
  133159. * @returns the class name
  133160. */
  133161. getClassName(): string;
  133162. /**
  133163. * Gets the input vector
  133164. */
  133165. get input(): NodeMaterialConnectionPoint;
  133166. /**
  133167. * Gets the input angle
  133168. */
  133169. get angle(): NodeMaterialConnectionPoint;
  133170. /**
  133171. * Gets the output component
  133172. */
  133173. get output(): NodeMaterialConnectionPoint;
  133174. autoConfigure(material: NodeMaterial): void;
  133175. protected _buildBlock(state: NodeMaterialBuildState): this;
  133176. }
  133177. }
  133178. declare module BABYLON {
  133179. /**
  133180. * Block used to get the reflected vector from a direction and a normal
  133181. */
  133182. export class ReflectBlock extends NodeMaterialBlock {
  133183. /**
  133184. * Creates a new ReflectBlock
  133185. * @param name defines the block name
  133186. */
  133187. constructor(name: string);
  133188. /**
  133189. * Gets the current class name
  133190. * @returns the class name
  133191. */
  133192. getClassName(): string;
  133193. /**
  133194. * Gets the incident component
  133195. */
  133196. get incident(): NodeMaterialConnectionPoint;
  133197. /**
  133198. * Gets the normal component
  133199. */
  133200. get normal(): NodeMaterialConnectionPoint;
  133201. /**
  133202. * Gets the output component
  133203. */
  133204. get output(): NodeMaterialConnectionPoint;
  133205. protected _buildBlock(state: NodeMaterialBuildState): this;
  133206. }
  133207. }
  133208. declare module BABYLON {
  133209. /**
  133210. * Block used to get the refracted vector from a direction and a normal
  133211. */
  133212. export class RefractBlock extends NodeMaterialBlock {
  133213. /**
  133214. * Creates a new RefractBlock
  133215. * @param name defines the block name
  133216. */
  133217. constructor(name: string);
  133218. /**
  133219. * Gets the current class name
  133220. * @returns the class name
  133221. */
  133222. getClassName(): string;
  133223. /**
  133224. * Gets the incident component
  133225. */
  133226. get incident(): NodeMaterialConnectionPoint;
  133227. /**
  133228. * Gets the normal component
  133229. */
  133230. get normal(): NodeMaterialConnectionPoint;
  133231. /**
  133232. * Gets the index of refraction component
  133233. */
  133234. get ior(): NodeMaterialConnectionPoint;
  133235. /**
  133236. * Gets the output component
  133237. */
  133238. get output(): NodeMaterialConnectionPoint;
  133239. protected _buildBlock(state: NodeMaterialBuildState): this;
  133240. }
  133241. }
  133242. declare module BABYLON {
  133243. /**
  133244. * Block used to desaturate a color
  133245. */
  133246. export class DesaturateBlock extends NodeMaterialBlock {
  133247. /**
  133248. * Creates a new DesaturateBlock
  133249. * @param name defines the block name
  133250. */
  133251. constructor(name: string);
  133252. /**
  133253. * Gets the current class name
  133254. * @returns the class name
  133255. */
  133256. getClassName(): string;
  133257. /**
  133258. * Gets the color operand input component
  133259. */
  133260. get color(): NodeMaterialConnectionPoint;
  133261. /**
  133262. * Gets the level operand input component
  133263. */
  133264. get level(): NodeMaterialConnectionPoint;
  133265. /**
  133266. * Gets the output component
  133267. */
  133268. get output(): NodeMaterialConnectionPoint;
  133269. protected _buildBlock(state: NodeMaterialBuildState): this;
  133270. }
  133271. }
  133272. declare module BABYLON {
  133273. /**
  133274. * Effect Render Options
  133275. */
  133276. export interface IEffectRendererOptions {
  133277. /**
  133278. * Defines the vertices positions.
  133279. */
  133280. positions?: number[];
  133281. /**
  133282. * Defines the indices.
  133283. */
  133284. indices?: number[];
  133285. }
  133286. /**
  133287. * Helper class to render one or more effects
  133288. */
  133289. export class EffectRenderer {
  133290. private engine;
  133291. private static _DefaultOptions;
  133292. private _vertexBuffers;
  133293. private _indexBuffer;
  133294. private _ringBufferIndex;
  133295. private _ringScreenBuffer;
  133296. private _fullscreenViewport;
  133297. private _getNextFrameBuffer;
  133298. /**
  133299. * Creates an effect renderer
  133300. * @param engine the engine to use for rendering
  133301. * @param options defines the options of the effect renderer
  133302. */
  133303. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133304. /**
  133305. * Sets the current viewport in normalized coordinates 0-1
  133306. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133307. */
  133308. setViewport(viewport?: Viewport): void;
  133309. /**
  133310. * Binds the embedded attributes buffer to the effect.
  133311. * @param effect Defines the effect to bind the attributes for
  133312. */
  133313. bindBuffers(effect: Effect): void;
  133314. /**
  133315. * Sets the current effect wrapper to use during draw.
  133316. * The effect needs to be ready before calling this api.
  133317. * This also sets the default full screen position attribute.
  133318. * @param effectWrapper Defines the effect to draw with
  133319. */
  133320. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133321. /**
  133322. * Draws a full screen quad.
  133323. */
  133324. draw(): void;
  133325. /**
  133326. * renders one or more effects to a specified texture
  133327. * @param effectWrappers list of effects to renderer
  133328. * @param outputTexture texture to draw to, if null it will render to the screen
  133329. */
  133330. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133331. /**
  133332. * Disposes of the effect renderer
  133333. */
  133334. dispose(): void;
  133335. }
  133336. /**
  133337. * Options to create an EffectWrapper
  133338. */
  133339. interface EffectWrapperCreationOptions {
  133340. /**
  133341. * Engine to use to create the effect
  133342. */
  133343. engine: ThinEngine;
  133344. /**
  133345. * Fragment shader for the effect
  133346. */
  133347. fragmentShader: string;
  133348. /**
  133349. * Vertex shader for the effect
  133350. */
  133351. vertexShader?: string;
  133352. /**
  133353. * Attributes to use in the shader
  133354. */
  133355. attributeNames?: Array<string>;
  133356. /**
  133357. * Uniforms to use in the shader
  133358. */
  133359. uniformNames?: Array<string>;
  133360. /**
  133361. * Texture sampler names to use in the shader
  133362. */
  133363. samplerNames?: Array<string>;
  133364. /**
  133365. * The friendly name of the effect displayed in Spector.
  133366. */
  133367. name?: string;
  133368. }
  133369. /**
  133370. * Wraps an effect to be used for rendering
  133371. */
  133372. export class EffectWrapper {
  133373. /**
  133374. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133375. */
  133376. onApplyObservable: Observable<{}>;
  133377. /**
  133378. * The underlying effect
  133379. */
  133380. effect: Effect;
  133381. /**
  133382. * Creates an effect to be renderer
  133383. * @param creationOptions options to create the effect
  133384. */
  133385. constructor(creationOptions: EffectWrapperCreationOptions);
  133386. /**
  133387. * Disposes of the effect wrapper
  133388. */
  133389. dispose(): void;
  133390. }
  133391. }
  133392. declare module BABYLON {
  133393. /**
  133394. * Helper class to push actions to a pool of workers.
  133395. */
  133396. export class WorkerPool implements IDisposable {
  133397. private _workerInfos;
  133398. private _pendingActions;
  133399. /**
  133400. * Constructor
  133401. * @param workers Array of workers to use for actions
  133402. */
  133403. constructor(workers: Array<Worker>);
  133404. /**
  133405. * Terminates all workers and clears any pending actions.
  133406. */
  133407. dispose(): void;
  133408. /**
  133409. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133410. * pended until a worker has completed its action.
  133411. * @param action The action to perform. Call onComplete when the action is complete.
  133412. */
  133413. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133414. private _execute;
  133415. }
  133416. }
  133417. declare module BABYLON {
  133418. /**
  133419. * Configuration for Draco compression
  133420. */
  133421. export interface IDracoCompressionConfiguration {
  133422. /**
  133423. * Configuration for the decoder.
  133424. */
  133425. decoder: {
  133426. /**
  133427. * The url to the WebAssembly module.
  133428. */
  133429. wasmUrl?: string;
  133430. /**
  133431. * The url to the WebAssembly binary.
  133432. */
  133433. wasmBinaryUrl?: string;
  133434. /**
  133435. * The url to the fallback JavaScript module.
  133436. */
  133437. fallbackUrl?: string;
  133438. };
  133439. }
  133440. /**
  133441. * Draco compression (https://google.github.io/draco/)
  133442. *
  133443. * This class wraps the Draco module.
  133444. *
  133445. * **Encoder**
  133446. *
  133447. * The encoder is not currently implemented.
  133448. *
  133449. * **Decoder**
  133450. *
  133451. * 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.
  133452. *
  133453. * To update the configuration, use the following code:
  133454. * ```javascript
  133455. * DracoCompression.Configuration = {
  133456. * decoder: {
  133457. * wasmUrl: "<url to the WebAssembly library>",
  133458. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133459. * fallbackUrl: "<url to the fallback JavaScript library>",
  133460. * }
  133461. * };
  133462. * ```
  133463. *
  133464. * 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.
  133465. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133466. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133467. *
  133468. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133469. * ```javascript
  133470. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133471. * ```
  133472. *
  133473. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133474. */
  133475. export class DracoCompression implements IDisposable {
  133476. private _workerPoolPromise?;
  133477. private _decoderModulePromise?;
  133478. /**
  133479. * The configuration. Defaults to the following urls:
  133480. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133481. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133482. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133483. */
  133484. static Configuration: IDracoCompressionConfiguration;
  133485. /**
  133486. * Returns true if the decoder configuration is available.
  133487. */
  133488. static get DecoderAvailable(): boolean;
  133489. /**
  133490. * Default number of workers to create when creating the draco compression object.
  133491. */
  133492. static DefaultNumWorkers: number;
  133493. private static GetDefaultNumWorkers;
  133494. private static _Default;
  133495. /**
  133496. * Default instance for the draco compression object.
  133497. */
  133498. static get Default(): DracoCompression;
  133499. /**
  133500. * Constructor
  133501. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133502. */
  133503. constructor(numWorkers?: number);
  133504. /**
  133505. * Stop all async operations and release resources.
  133506. */
  133507. dispose(): void;
  133508. /**
  133509. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133510. * @returns a promise that resolves when ready
  133511. */
  133512. whenReadyAsync(): Promise<void>;
  133513. /**
  133514. * Decode Draco compressed mesh data to vertex data.
  133515. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133516. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133517. * @returns A promise that resolves with the decoded vertex data
  133518. */
  133519. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133520. [kind: string]: number;
  133521. }): Promise<VertexData>;
  133522. }
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * Class for building Constructive Solid Geometry
  133527. */
  133528. export class CSG {
  133529. private polygons;
  133530. /**
  133531. * The world matrix
  133532. */
  133533. matrix: Matrix;
  133534. /**
  133535. * Stores the position
  133536. */
  133537. position: Vector3;
  133538. /**
  133539. * Stores the rotation
  133540. */
  133541. rotation: Vector3;
  133542. /**
  133543. * Stores the rotation quaternion
  133544. */
  133545. rotationQuaternion: Nullable<Quaternion>;
  133546. /**
  133547. * Stores the scaling vector
  133548. */
  133549. scaling: Vector3;
  133550. /**
  133551. * Convert the Mesh to CSG
  133552. * @param mesh The Mesh to convert to CSG
  133553. * @returns A new CSG from the Mesh
  133554. */
  133555. static FromMesh(mesh: Mesh): CSG;
  133556. /**
  133557. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133558. * @param polygons Polygons used to construct a CSG solid
  133559. */
  133560. private static FromPolygons;
  133561. /**
  133562. * Clones, or makes a deep copy, of the CSG
  133563. * @returns A new CSG
  133564. */
  133565. clone(): CSG;
  133566. /**
  133567. * Unions this CSG with another CSG
  133568. * @param csg The CSG to union against this CSG
  133569. * @returns The unioned CSG
  133570. */
  133571. union(csg: CSG): CSG;
  133572. /**
  133573. * Unions this CSG with another CSG in place
  133574. * @param csg The CSG to union against this CSG
  133575. */
  133576. unionInPlace(csg: CSG): void;
  133577. /**
  133578. * Subtracts this CSG with another CSG
  133579. * @param csg The CSG to subtract against this CSG
  133580. * @returns A new CSG
  133581. */
  133582. subtract(csg: CSG): CSG;
  133583. /**
  133584. * Subtracts this CSG with another CSG in place
  133585. * @param csg The CSG to subtact against this CSG
  133586. */
  133587. subtractInPlace(csg: CSG): void;
  133588. /**
  133589. * Intersect this CSG with another CSG
  133590. * @param csg The CSG to intersect against this CSG
  133591. * @returns A new CSG
  133592. */
  133593. intersect(csg: CSG): CSG;
  133594. /**
  133595. * Intersects this CSG with another CSG in place
  133596. * @param csg The CSG to intersect against this CSG
  133597. */
  133598. intersectInPlace(csg: CSG): void;
  133599. /**
  133600. * Return a new CSG solid with solid and empty space switched. This solid is
  133601. * not modified.
  133602. * @returns A new CSG solid with solid and empty space switched
  133603. */
  133604. inverse(): CSG;
  133605. /**
  133606. * Inverses the CSG in place
  133607. */
  133608. inverseInPlace(): void;
  133609. /**
  133610. * This is used to keep meshes transformations so they can be restored
  133611. * when we build back a Babylon Mesh
  133612. * NB : All CSG operations are performed in world coordinates
  133613. * @param csg The CSG to copy the transform attributes from
  133614. * @returns This CSG
  133615. */
  133616. copyTransformAttributes(csg: CSG): CSG;
  133617. /**
  133618. * Build Raw mesh from CSG
  133619. * Coordinates here are in world space
  133620. * @param name The name of the mesh geometry
  133621. * @param scene The Scene
  133622. * @param keepSubMeshes Specifies if the submeshes should be kept
  133623. * @returns A new Mesh
  133624. */
  133625. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133626. /**
  133627. * Build Mesh from CSG taking material and transforms into account
  133628. * @param name The name of the Mesh
  133629. * @param material The material of the Mesh
  133630. * @param scene The Scene
  133631. * @param keepSubMeshes Specifies if submeshes should be kept
  133632. * @returns The new Mesh
  133633. */
  133634. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133635. }
  133636. }
  133637. declare module BABYLON {
  133638. /**
  133639. * Class used to create a trail following a mesh
  133640. */
  133641. export class TrailMesh extends Mesh {
  133642. private _generator;
  133643. private _autoStart;
  133644. private _running;
  133645. private _diameter;
  133646. private _length;
  133647. private _sectionPolygonPointsCount;
  133648. private _sectionVectors;
  133649. private _sectionNormalVectors;
  133650. private _beforeRenderObserver;
  133651. /**
  133652. * @constructor
  133653. * @param name The value used by scene.getMeshByName() to do a lookup.
  133654. * @param generator The mesh or transform node to generate a trail.
  133655. * @param scene The scene to add this mesh to.
  133656. * @param diameter Diameter of trailing mesh. Default is 1.
  133657. * @param length Length of trailing mesh. Default is 60.
  133658. * @param autoStart Automatically start trailing mesh. Default true.
  133659. */
  133660. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133661. /**
  133662. * "TrailMesh"
  133663. * @returns "TrailMesh"
  133664. */
  133665. getClassName(): string;
  133666. private _createMesh;
  133667. /**
  133668. * Start trailing mesh.
  133669. */
  133670. start(): void;
  133671. /**
  133672. * Stop trailing mesh.
  133673. */
  133674. stop(): void;
  133675. /**
  133676. * Update trailing mesh geometry.
  133677. */
  133678. update(): void;
  133679. /**
  133680. * Returns a new TrailMesh object.
  133681. * @param name is a string, the name given to the new mesh
  133682. * @param newGenerator use new generator object for cloned trail mesh
  133683. * @returns a new mesh
  133684. */
  133685. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133686. /**
  133687. * Serializes this trail mesh
  133688. * @param serializationObject object to write serialization to
  133689. */
  133690. serialize(serializationObject: any): void;
  133691. /**
  133692. * Parses a serialized trail mesh
  133693. * @param parsedMesh the serialized mesh
  133694. * @param scene the scene to create the trail mesh in
  133695. * @returns the created trail mesh
  133696. */
  133697. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133698. }
  133699. }
  133700. declare module BABYLON {
  133701. /**
  133702. * Class containing static functions to help procedurally build meshes
  133703. */
  133704. export class TiledBoxBuilder {
  133705. /**
  133706. * Creates a box mesh
  133707. * 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)
  133708. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133710. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  133713. * @param options defines the options used to create the mesh
  133714. * @param scene defines the hosting scene
  133715. * @returns the box mesh
  133716. */
  133717. static CreateTiledBox(name: string, options: {
  133718. pattern?: number;
  133719. width?: number;
  133720. height?: number;
  133721. depth?: number;
  133722. tileSize?: number;
  133723. tileWidth?: number;
  133724. tileHeight?: number;
  133725. alignHorizontal?: number;
  133726. alignVertical?: number;
  133727. faceUV?: Vector4[];
  133728. faceColors?: Color4[];
  133729. sideOrientation?: number;
  133730. updatable?: boolean;
  133731. }, scene?: Nullable<Scene>): Mesh;
  133732. }
  133733. }
  133734. declare module BABYLON {
  133735. /**
  133736. * Class containing static functions to help procedurally build meshes
  133737. */
  133738. export class TorusKnotBuilder {
  133739. /**
  133740. * Creates a torus knot mesh
  133741. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133742. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133743. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133744. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133748. * @param name defines the name of the mesh
  133749. * @param options defines the options used to create the mesh
  133750. * @param scene defines the hosting scene
  133751. * @returns the torus knot mesh
  133752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133753. */
  133754. static CreateTorusKnot(name: string, options: {
  133755. radius?: number;
  133756. tube?: number;
  133757. radialSegments?: number;
  133758. tubularSegments?: number;
  133759. p?: number;
  133760. q?: number;
  133761. updatable?: boolean;
  133762. sideOrientation?: number;
  133763. frontUVs?: Vector4;
  133764. backUVs?: Vector4;
  133765. }, scene: any): Mesh;
  133766. }
  133767. }
  133768. declare module BABYLON {
  133769. /**
  133770. * Polygon
  133771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133772. */
  133773. export class Polygon {
  133774. /**
  133775. * Creates a rectangle
  133776. * @param xmin bottom X coord
  133777. * @param ymin bottom Y coord
  133778. * @param xmax top X coord
  133779. * @param ymax top Y coord
  133780. * @returns points that make the resulting rectation
  133781. */
  133782. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133783. /**
  133784. * Creates a circle
  133785. * @param radius radius of circle
  133786. * @param cx scale in x
  133787. * @param cy scale in y
  133788. * @param numberOfSides number of sides that make up the circle
  133789. * @returns points that make the resulting circle
  133790. */
  133791. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133792. /**
  133793. * Creates a polygon from input string
  133794. * @param input Input polygon data
  133795. * @returns the parsed points
  133796. */
  133797. static Parse(input: string): Vector2[];
  133798. /**
  133799. * Starts building a polygon from x and y coordinates
  133800. * @param x x coordinate
  133801. * @param y y coordinate
  133802. * @returns the started path2
  133803. */
  133804. static StartingAt(x: number, y: number): Path2;
  133805. }
  133806. /**
  133807. * Builds a polygon
  133808. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133809. */
  133810. export class PolygonMeshBuilder {
  133811. private _points;
  133812. private _outlinepoints;
  133813. private _holes;
  133814. private _name;
  133815. private _scene;
  133816. private _epoints;
  133817. private _eholes;
  133818. private _addToepoint;
  133819. /**
  133820. * Babylon reference to the earcut plugin.
  133821. */
  133822. bjsEarcut: any;
  133823. /**
  133824. * Creates a PolygonMeshBuilder
  133825. * @param name name of the builder
  133826. * @param contours Path of the polygon
  133827. * @param scene scene to add to when creating the mesh
  133828. * @param earcutInjection can be used to inject your own earcut reference
  133829. */
  133830. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133831. /**
  133832. * Adds a whole within the polygon
  133833. * @param hole Array of points defining the hole
  133834. * @returns this
  133835. */
  133836. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133837. /**
  133838. * Creates the polygon
  133839. * @param updatable If the mesh should be updatable
  133840. * @param depth The depth of the mesh created
  133841. * @returns the created mesh
  133842. */
  133843. build(updatable?: boolean, depth?: number): Mesh;
  133844. /**
  133845. * Creates the polygon
  133846. * @param depth The depth of the mesh created
  133847. * @returns the created VertexData
  133848. */
  133849. buildVertexData(depth?: number): VertexData;
  133850. /**
  133851. * Adds a side to the polygon
  133852. * @param positions points that make the polygon
  133853. * @param normals normals of the polygon
  133854. * @param uvs uvs of the polygon
  133855. * @param indices indices of the polygon
  133856. * @param bounds bounds of the polygon
  133857. * @param points points of the polygon
  133858. * @param depth depth of the polygon
  133859. * @param flip flip of the polygon
  133860. */
  133861. private addSide;
  133862. }
  133863. }
  133864. declare module BABYLON {
  133865. /**
  133866. * Class containing static functions to help procedurally build meshes
  133867. */
  133868. export class PolygonBuilder {
  133869. /**
  133870. * Creates a polygon mesh
  133871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133872. * * 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
  133873. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133876. * * Remember you can only change the shape positions, not their number when updating a polygon
  133877. * @param name defines the name of the mesh
  133878. * @param options defines the options used to create the mesh
  133879. * @param scene defines the hosting scene
  133880. * @param earcutInjection can be used to inject your own earcut reference
  133881. * @returns the polygon mesh
  133882. */
  133883. static CreatePolygon(name: string, options: {
  133884. shape: Vector3[];
  133885. holes?: Vector3[][];
  133886. depth?: number;
  133887. faceUV?: Vector4[];
  133888. faceColors?: Color4[];
  133889. updatable?: boolean;
  133890. sideOrientation?: number;
  133891. frontUVs?: Vector4;
  133892. backUVs?: Vector4;
  133893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133894. /**
  133895. * Creates an extruded polygon mesh, with depth in the Y direction.
  133896. * * 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)
  133897. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133898. * @param name defines the name of the mesh
  133899. * @param options defines the options used to create the mesh
  133900. * @param scene defines the hosting scene
  133901. * @param earcutInjection can be used to inject your own earcut reference
  133902. * @returns the polygon mesh
  133903. */
  133904. static ExtrudePolygon(name: string, options: {
  133905. shape: Vector3[];
  133906. holes?: Vector3[][];
  133907. depth?: number;
  133908. faceUV?: Vector4[];
  133909. faceColors?: Color4[];
  133910. updatable?: boolean;
  133911. sideOrientation?: number;
  133912. frontUVs?: Vector4;
  133913. backUVs?: Vector4;
  133914. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133915. }
  133916. }
  133917. declare module BABYLON {
  133918. /**
  133919. * Class containing static functions to help procedurally build meshes
  133920. */
  133921. export class LatheBuilder {
  133922. /**
  133923. * Creates lathe mesh.
  133924. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133925. * * 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
  133926. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133927. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133928. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133929. * * 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
  133930. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133931. * * 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
  133932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133936. * @param name defines the name of the mesh
  133937. * @param options defines the options used to create the mesh
  133938. * @param scene defines the hosting scene
  133939. * @returns the lathe mesh
  133940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133941. */
  133942. static CreateLathe(name: string, options: {
  133943. shape: Vector3[];
  133944. radius?: number;
  133945. tessellation?: number;
  133946. clip?: number;
  133947. arc?: number;
  133948. closed?: boolean;
  133949. updatable?: boolean;
  133950. sideOrientation?: number;
  133951. frontUVs?: Vector4;
  133952. backUVs?: Vector4;
  133953. cap?: number;
  133954. invertUV?: boolean;
  133955. }, scene?: Nullable<Scene>): Mesh;
  133956. }
  133957. }
  133958. declare module BABYLON {
  133959. /**
  133960. * Class containing static functions to help procedurally build meshes
  133961. */
  133962. export class TiledPlaneBuilder {
  133963. /**
  133964. * Creates a tiled plane mesh
  133965. * * The parameter `pattern` will, depending on value, do nothing or
  133966. * * * flip (reflect about central vertical) alternate tiles across and up
  133967. * * * flip every tile on alternate rows
  133968. * * * rotate (180 degs) alternate tiles across and up
  133969. * * * rotate every tile on alternate rows
  133970. * * * flip and rotate alternate tiles across and up
  133971. * * * flip and rotate every tile on alternate rows
  133972. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133973. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133975. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133976. * * 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)
  133977. * * 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)
  133978. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133979. * @param name defines the name of the mesh
  133980. * @param options defines the options used to create the mesh
  133981. * @param scene defines the hosting scene
  133982. * @returns the box mesh
  133983. */
  133984. static CreateTiledPlane(name: string, options: {
  133985. pattern?: number;
  133986. tileSize?: number;
  133987. tileWidth?: number;
  133988. tileHeight?: number;
  133989. size?: number;
  133990. width?: number;
  133991. height?: number;
  133992. alignHorizontal?: number;
  133993. alignVertical?: number;
  133994. sideOrientation?: number;
  133995. frontUVs?: Vector4;
  133996. backUVs?: Vector4;
  133997. updatable?: boolean;
  133998. }, scene?: Nullable<Scene>): Mesh;
  133999. }
  134000. }
  134001. declare module BABYLON {
  134002. /**
  134003. * Class containing static functions to help procedurally build meshes
  134004. */
  134005. export class TubeBuilder {
  134006. /**
  134007. * Creates a tube mesh.
  134008. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134009. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134010. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134011. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134012. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134013. * * 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)
  134014. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134015. * * 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
  134016. * * 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
  134017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134021. * @param name defines the name of the mesh
  134022. * @param options defines the options used to create the mesh
  134023. * @param scene defines the hosting scene
  134024. * @returns the tube mesh
  134025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134026. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134027. */
  134028. static CreateTube(name: string, options: {
  134029. path: Vector3[];
  134030. radius?: number;
  134031. tessellation?: number;
  134032. radiusFunction?: {
  134033. (i: number, distance: number): number;
  134034. };
  134035. cap?: number;
  134036. arc?: number;
  134037. updatable?: boolean;
  134038. sideOrientation?: number;
  134039. frontUVs?: Vector4;
  134040. backUVs?: Vector4;
  134041. instance?: Mesh;
  134042. invertUV?: boolean;
  134043. }, scene?: Nullable<Scene>): Mesh;
  134044. }
  134045. }
  134046. declare module BABYLON {
  134047. /**
  134048. * Class containing static functions to help procedurally build meshes
  134049. */
  134050. export class IcoSphereBuilder {
  134051. /**
  134052. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134053. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134054. * * 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`)
  134055. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134056. * * 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
  134057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134060. * @param name defines the name of the mesh
  134061. * @param options defines the options used to create the mesh
  134062. * @param scene defines the hosting scene
  134063. * @returns the icosahedron mesh
  134064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134065. */
  134066. static CreateIcoSphere(name: string, options: {
  134067. radius?: number;
  134068. radiusX?: number;
  134069. radiusY?: number;
  134070. radiusZ?: number;
  134071. flat?: boolean;
  134072. subdivisions?: number;
  134073. sideOrientation?: number;
  134074. frontUVs?: Vector4;
  134075. backUVs?: Vector4;
  134076. updatable?: boolean;
  134077. }, scene?: Nullable<Scene>): Mesh;
  134078. }
  134079. }
  134080. declare module BABYLON {
  134081. /**
  134082. * Class containing static functions to help procedurally build meshes
  134083. */
  134084. export class DecalBuilder {
  134085. /**
  134086. * Creates a decal mesh.
  134087. * 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
  134088. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134089. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134090. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134091. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134092. * @param name defines the name of the mesh
  134093. * @param sourceMesh defines the mesh where the decal must be applied
  134094. * @param options defines the options used to create the mesh
  134095. * @param scene defines the hosting scene
  134096. * @returns the decal mesh
  134097. * @see https://doc.babylonjs.com/how_to/decals
  134098. */
  134099. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134100. position?: Vector3;
  134101. normal?: Vector3;
  134102. size?: Vector3;
  134103. angle?: number;
  134104. }): Mesh;
  134105. }
  134106. }
  134107. declare module BABYLON {
  134108. /**
  134109. * Class containing static functions to help procedurally build meshes
  134110. */
  134111. export class MeshBuilder {
  134112. /**
  134113. * Creates a box mesh
  134114. * * The parameter `size` sets the size (float) of each box side (default 1)
  134115. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134116. * * 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)
  134117. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134121. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134122. * @param name defines the name of the mesh
  134123. * @param options defines the options used to create the mesh
  134124. * @param scene defines the hosting scene
  134125. * @returns the box mesh
  134126. */
  134127. static CreateBox(name: string, options: {
  134128. size?: number;
  134129. width?: number;
  134130. height?: number;
  134131. depth?: number;
  134132. faceUV?: Vector4[];
  134133. faceColors?: Color4[];
  134134. sideOrientation?: number;
  134135. frontUVs?: Vector4;
  134136. backUVs?: Vector4;
  134137. updatable?: boolean;
  134138. }, scene?: Nullable<Scene>): Mesh;
  134139. /**
  134140. * Creates a tiled box mesh
  134141. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134143. * @param name defines the name of the mesh
  134144. * @param options defines the options used to create the mesh
  134145. * @param scene defines the hosting scene
  134146. * @returns the tiled box mesh
  134147. */
  134148. static CreateTiledBox(name: string, options: {
  134149. pattern?: number;
  134150. size?: number;
  134151. width?: number;
  134152. height?: number;
  134153. depth: number;
  134154. tileSize?: number;
  134155. tileWidth?: number;
  134156. tileHeight?: number;
  134157. faceUV?: Vector4[];
  134158. faceColors?: Color4[];
  134159. alignHorizontal?: number;
  134160. alignVertical?: number;
  134161. sideOrientation?: number;
  134162. updatable?: boolean;
  134163. }, scene?: Nullable<Scene>): Mesh;
  134164. /**
  134165. * Creates a sphere mesh
  134166. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134167. * * 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`)
  134168. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134169. * * 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
  134170. * * 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)
  134171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134174. * @param name defines the name of the mesh
  134175. * @param options defines the options used to create the mesh
  134176. * @param scene defines the hosting scene
  134177. * @returns the sphere mesh
  134178. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134179. */
  134180. static CreateSphere(name: string, options: {
  134181. segments?: number;
  134182. diameter?: number;
  134183. diameterX?: number;
  134184. diameterY?: number;
  134185. diameterZ?: number;
  134186. arc?: number;
  134187. slice?: number;
  134188. sideOrientation?: number;
  134189. frontUVs?: Vector4;
  134190. backUVs?: Vector4;
  134191. updatable?: boolean;
  134192. }, scene?: Nullable<Scene>): Mesh;
  134193. /**
  134194. * Creates a plane polygonal mesh. By default, this is a disc
  134195. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134196. * * 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
  134197. * * 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
  134198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134201. * @param name defines the name of the mesh
  134202. * @param options defines the options used to create the mesh
  134203. * @param scene defines the hosting scene
  134204. * @returns the plane polygonal mesh
  134205. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134206. */
  134207. static CreateDisc(name: string, options: {
  134208. radius?: number;
  134209. tessellation?: number;
  134210. arc?: number;
  134211. updatable?: boolean;
  134212. sideOrientation?: number;
  134213. frontUVs?: Vector4;
  134214. backUVs?: Vector4;
  134215. }, scene?: Nullable<Scene>): Mesh;
  134216. /**
  134217. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134218. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134219. * * 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`)
  134220. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134221. * * 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
  134222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134225. * @param name defines the name of the mesh
  134226. * @param options defines the options used to create the mesh
  134227. * @param scene defines the hosting scene
  134228. * @returns the icosahedron mesh
  134229. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134230. */
  134231. static CreateIcoSphere(name: string, options: {
  134232. radius?: number;
  134233. radiusX?: number;
  134234. radiusY?: number;
  134235. radiusZ?: number;
  134236. flat?: boolean;
  134237. subdivisions?: number;
  134238. sideOrientation?: number;
  134239. frontUVs?: Vector4;
  134240. backUVs?: Vector4;
  134241. updatable?: boolean;
  134242. }, scene?: Nullable<Scene>): Mesh;
  134243. /**
  134244. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134245. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134246. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134247. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134248. * * 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
  134249. * * 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
  134250. * * 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
  134251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134254. * * 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
  134255. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134256. * * 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
  134257. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134259. * @param name defines the name of the mesh
  134260. * @param options defines the options used to create the mesh
  134261. * @param scene defines the hosting scene
  134262. * @returns the ribbon mesh
  134263. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134265. */
  134266. static CreateRibbon(name: string, options: {
  134267. pathArray: Vector3[][];
  134268. closeArray?: boolean;
  134269. closePath?: boolean;
  134270. offset?: number;
  134271. updatable?: boolean;
  134272. sideOrientation?: number;
  134273. frontUVs?: Vector4;
  134274. backUVs?: Vector4;
  134275. instance?: Mesh;
  134276. invertUV?: boolean;
  134277. uvs?: Vector2[];
  134278. colors?: Color4[];
  134279. }, scene?: Nullable<Scene>): Mesh;
  134280. /**
  134281. * Creates a cylinder or a cone mesh
  134282. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134283. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134284. * * 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.
  134285. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134286. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134287. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134288. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134289. * * 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).
  134290. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134291. * * 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).
  134292. * * 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
  134293. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134294. * * 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
  134295. * * 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.
  134296. * * If `enclose` is false, a ring surface is one element.
  134297. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134298. * * 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
  134299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134302. * @param name defines the name of the mesh
  134303. * @param options defines the options used to create the mesh
  134304. * @param scene defines the hosting scene
  134305. * @returns the cylinder mesh
  134306. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134307. */
  134308. static CreateCylinder(name: string, options: {
  134309. height?: number;
  134310. diameterTop?: number;
  134311. diameterBottom?: number;
  134312. diameter?: number;
  134313. tessellation?: number;
  134314. subdivisions?: number;
  134315. arc?: number;
  134316. faceColors?: Color4[];
  134317. faceUV?: Vector4[];
  134318. updatable?: boolean;
  134319. hasRings?: boolean;
  134320. enclose?: boolean;
  134321. cap?: number;
  134322. sideOrientation?: number;
  134323. frontUVs?: Vector4;
  134324. backUVs?: Vector4;
  134325. }, scene?: Nullable<Scene>): Mesh;
  134326. /**
  134327. * Creates a torus mesh
  134328. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134329. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134330. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134334. * @param name defines the name of the mesh
  134335. * @param options defines the options used to create the mesh
  134336. * @param scene defines the hosting scene
  134337. * @returns the torus mesh
  134338. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134339. */
  134340. static CreateTorus(name: string, options: {
  134341. diameter?: number;
  134342. thickness?: number;
  134343. tessellation?: number;
  134344. updatable?: boolean;
  134345. sideOrientation?: number;
  134346. frontUVs?: Vector4;
  134347. backUVs?: Vector4;
  134348. }, scene?: Nullable<Scene>): Mesh;
  134349. /**
  134350. * Creates a torus knot mesh
  134351. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134352. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134353. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134354. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134358. * @param name defines the name of the mesh
  134359. * @param options defines the options used to create the mesh
  134360. * @param scene defines the hosting scene
  134361. * @returns the torus knot mesh
  134362. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134363. */
  134364. static CreateTorusKnot(name: string, options: {
  134365. radius?: number;
  134366. tube?: number;
  134367. radialSegments?: number;
  134368. tubularSegments?: number;
  134369. p?: number;
  134370. q?: number;
  134371. updatable?: boolean;
  134372. sideOrientation?: number;
  134373. frontUVs?: Vector4;
  134374. backUVs?: Vector4;
  134375. }, scene?: Nullable<Scene>): Mesh;
  134376. /**
  134377. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134378. * * 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
  134379. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134380. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134381. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134382. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134383. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134384. * * 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
  134385. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134388. * @param name defines the name of the new line system
  134389. * @param options defines the options used to create the line system
  134390. * @param scene defines the hosting scene
  134391. * @returns a new line system mesh
  134392. */
  134393. static CreateLineSystem(name: string, options: {
  134394. lines: Vector3[][];
  134395. updatable?: boolean;
  134396. instance?: Nullable<LinesMesh>;
  134397. colors?: Nullable<Color4[][]>;
  134398. useVertexAlpha?: boolean;
  134399. }, scene: Nullable<Scene>): LinesMesh;
  134400. /**
  134401. * Creates a line mesh
  134402. * 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
  134403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134404. * * The parameter `points` is an array successive Vector3
  134405. * * 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
  134406. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134407. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134408. * * When updating an instance, remember that only point positions can change, not the number of points
  134409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134411. * @param name defines the name of the new line system
  134412. * @param options defines the options used to create the line system
  134413. * @param scene defines the hosting scene
  134414. * @returns a new line mesh
  134415. */
  134416. static CreateLines(name: string, options: {
  134417. points: Vector3[];
  134418. updatable?: boolean;
  134419. instance?: Nullable<LinesMesh>;
  134420. colors?: Color4[];
  134421. useVertexAlpha?: boolean;
  134422. }, scene?: Nullable<Scene>): LinesMesh;
  134423. /**
  134424. * Creates a dashed line mesh
  134425. * * 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
  134426. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134427. * * The parameter `points` is an array successive Vector3
  134428. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134429. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134430. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134431. * * 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
  134432. * * When updating an instance, remember that only point positions can change, not the number of points
  134433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134434. * @param name defines the name of the mesh
  134435. * @param options defines the options used to create the mesh
  134436. * @param scene defines the hosting scene
  134437. * @returns the dashed line mesh
  134438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134439. */
  134440. static CreateDashedLines(name: string, options: {
  134441. points: Vector3[];
  134442. dashSize?: number;
  134443. gapSize?: number;
  134444. dashNb?: number;
  134445. updatable?: boolean;
  134446. instance?: LinesMesh;
  134447. }, scene?: Nullable<Scene>): LinesMesh;
  134448. /**
  134449. * 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.
  134450. * * 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.
  134451. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134452. * * 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.
  134453. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134454. * * 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
  134455. * * 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
  134456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134461. * @param name defines the name of the mesh
  134462. * @param options defines the options used to create the mesh
  134463. * @param scene defines the hosting scene
  134464. * @returns the extruded shape mesh
  134465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134467. */
  134468. static ExtrudeShape(name: string, options: {
  134469. shape: Vector3[];
  134470. path: Vector3[];
  134471. scale?: number;
  134472. rotation?: number;
  134473. cap?: number;
  134474. updatable?: boolean;
  134475. sideOrientation?: number;
  134476. frontUVs?: Vector4;
  134477. backUVs?: Vector4;
  134478. instance?: Mesh;
  134479. invertUV?: boolean;
  134480. }, scene?: Nullable<Scene>): Mesh;
  134481. /**
  134482. * Creates an custom extruded shape mesh.
  134483. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134484. * * 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.
  134485. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134486. * * 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
  134487. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134488. * * 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
  134489. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134490. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134491. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134492. * * 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
  134493. * * 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
  134494. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134497. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134499. * @param name defines the name of the mesh
  134500. * @param options defines the options used to create the mesh
  134501. * @param scene defines the hosting scene
  134502. * @returns the custom extruded shape mesh
  134503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134504. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134506. */
  134507. static ExtrudeShapeCustom(name: string, options: {
  134508. shape: Vector3[];
  134509. path: Vector3[];
  134510. scaleFunction?: any;
  134511. rotationFunction?: any;
  134512. ribbonCloseArray?: boolean;
  134513. ribbonClosePath?: boolean;
  134514. cap?: number;
  134515. updatable?: boolean;
  134516. sideOrientation?: number;
  134517. frontUVs?: Vector4;
  134518. backUVs?: Vector4;
  134519. instance?: Mesh;
  134520. invertUV?: boolean;
  134521. }, scene?: Nullable<Scene>): Mesh;
  134522. /**
  134523. * Creates lathe mesh.
  134524. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134525. * * 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
  134526. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134527. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134528. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134529. * * 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
  134530. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134531. * * 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
  134532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134534. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134536. * @param name defines the name of the mesh
  134537. * @param options defines the options used to create the mesh
  134538. * @param scene defines the hosting scene
  134539. * @returns the lathe mesh
  134540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134541. */
  134542. static CreateLathe(name: string, options: {
  134543. shape: Vector3[];
  134544. radius?: number;
  134545. tessellation?: number;
  134546. clip?: number;
  134547. arc?: number;
  134548. closed?: boolean;
  134549. updatable?: boolean;
  134550. sideOrientation?: number;
  134551. frontUVs?: Vector4;
  134552. backUVs?: Vector4;
  134553. cap?: number;
  134554. invertUV?: boolean;
  134555. }, scene?: Nullable<Scene>): Mesh;
  134556. /**
  134557. * Creates a tiled plane mesh
  134558. * * You can set a limited pattern arrangement with the tiles
  134559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134562. * @param name defines the name of the mesh
  134563. * @param options defines the options used to create the mesh
  134564. * @param scene defines the hosting scene
  134565. * @returns the plane mesh
  134566. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134567. */
  134568. static CreateTiledPlane(name: string, options: {
  134569. pattern?: number;
  134570. tileSize?: number;
  134571. tileWidth?: number;
  134572. tileHeight?: number;
  134573. size?: number;
  134574. width?: number;
  134575. height?: number;
  134576. alignHorizontal?: number;
  134577. alignVertical?: number;
  134578. sideOrientation?: number;
  134579. frontUVs?: Vector4;
  134580. backUVs?: Vector4;
  134581. updatable?: boolean;
  134582. }, scene?: Nullable<Scene>): Mesh;
  134583. /**
  134584. * Creates a plane mesh
  134585. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134586. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134587. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134591. * @param name defines the name of the mesh
  134592. * @param options defines the options used to create the mesh
  134593. * @param scene defines the hosting scene
  134594. * @returns the plane mesh
  134595. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134596. */
  134597. static CreatePlane(name: string, options: {
  134598. size?: number;
  134599. width?: number;
  134600. height?: number;
  134601. sideOrientation?: number;
  134602. frontUVs?: Vector4;
  134603. backUVs?: Vector4;
  134604. updatable?: boolean;
  134605. sourcePlane?: Plane;
  134606. }, scene?: Nullable<Scene>): Mesh;
  134607. /**
  134608. * Creates a ground mesh
  134609. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134610. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134612. * @param name defines the name of the mesh
  134613. * @param options defines the options used to create the mesh
  134614. * @param scene defines the hosting scene
  134615. * @returns the ground mesh
  134616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134617. */
  134618. static CreateGround(name: string, options: {
  134619. width?: number;
  134620. height?: number;
  134621. subdivisions?: number;
  134622. subdivisionsX?: number;
  134623. subdivisionsY?: number;
  134624. updatable?: boolean;
  134625. }, scene?: Nullable<Scene>): Mesh;
  134626. /**
  134627. * Creates a tiled ground mesh
  134628. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134629. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134630. * * 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
  134631. * * 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
  134632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134633. * @param name defines the name of the mesh
  134634. * @param options defines the options used to create the mesh
  134635. * @param scene defines the hosting scene
  134636. * @returns the tiled ground mesh
  134637. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134638. */
  134639. static CreateTiledGround(name: string, options: {
  134640. xmin: number;
  134641. zmin: number;
  134642. xmax: number;
  134643. zmax: number;
  134644. subdivisions?: {
  134645. w: number;
  134646. h: number;
  134647. };
  134648. precision?: {
  134649. w: number;
  134650. h: number;
  134651. };
  134652. updatable?: boolean;
  134653. }, scene?: Nullable<Scene>): Mesh;
  134654. /**
  134655. * Creates a ground mesh from a height map
  134656. * * The parameter `url` sets the URL of the height map image resource.
  134657. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134658. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134659. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134660. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134661. * * 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.
  134662. * * 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).
  134663. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134665. * @param name defines the name of the mesh
  134666. * @param url defines the url to the height map
  134667. * @param options defines the options used to create the mesh
  134668. * @param scene defines the hosting scene
  134669. * @returns the ground mesh
  134670. * @see https://doc.babylonjs.com/babylon101/height_map
  134671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134672. */
  134673. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134674. width?: number;
  134675. height?: number;
  134676. subdivisions?: number;
  134677. minHeight?: number;
  134678. maxHeight?: number;
  134679. colorFilter?: Color3;
  134680. alphaFilter?: number;
  134681. updatable?: boolean;
  134682. onReady?: (mesh: GroundMesh) => void;
  134683. }, scene?: Nullable<Scene>): GroundMesh;
  134684. /**
  134685. * Creates a polygon mesh
  134686. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134687. * * 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
  134688. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134691. * * Remember you can only change the shape positions, not their number when updating a polygon
  134692. * @param name defines the name of the mesh
  134693. * @param options defines the options used to create the mesh
  134694. * @param scene defines the hosting scene
  134695. * @param earcutInjection can be used to inject your own earcut reference
  134696. * @returns the polygon mesh
  134697. */
  134698. static CreatePolygon(name: string, options: {
  134699. shape: Vector3[];
  134700. holes?: Vector3[][];
  134701. depth?: number;
  134702. faceUV?: Vector4[];
  134703. faceColors?: Color4[];
  134704. updatable?: boolean;
  134705. sideOrientation?: number;
  134706. frontUVs?: Vector4;
  134707. backUVs?: Vector4;
  134708. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134709. /**
  134710. * Creates an extruded polygon mesh, with depth in the Y direction.
  134711. * * 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)
  134712. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134713. * @param name defines the name of the mesh
  134714. * @param options defines the options used to create the mesh
  134715. * @param scene defines the hosting scene
  134716. * @param earcutInjection can be used to inject your own earcut reference
  134717. * @returns the polygon mesh
  134718. */
  134719. static ExtrudePolygon(name: string, options: {
  134720. shape: Vector3[];
  134721. holes?: Vector3[][];
  134722. depth?: number;
  134723. faceUV?: Vector4[];
  134724. faceColors?: Color4[];
  134725. updatable?: boolean;
  134726. sideOrientation?: number;
  134727. frontUVs?: Vector4;
  134728. backUVs?: Vector4;
  134729. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134730. /**
  134731. * Creates a tube mesh.
  134732. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134733. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134734. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134735. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134736. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134737. * * 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)
  134738. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134739. * * 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
  134740. * * 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
  134741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134743. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134745. * @param name defines the name of the mesh
  134746. * @param options defines the options used to create the mesh
  134747. * @param scene defines the hosting scene
  134748. * @returns the tube mesh
  134749. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134750. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134751. */
  134752. static CreateTube(name: string, options: {
  134753. path: Vector3[];
  134754. radius?: number;
  134755. tessellation?: number;
  134756. radiusFunction?: {
  134757. (i: number, distance: number): number;
  134758. };
  134759. cap?: number;
  134760. arc?: number;
  134761. updatable?: boolean;
  134762. sideOrientation?: number;
  134763. frontUVs?: Vector4;
  134764. backUVs?: Vector4;
  134765. instance?: Mesh;
  134766. invertUV?: boolean;
  134767. }, scene?: Nullable<Scene>): Mesh;
  134768. /**
  134769. * Creates a polyhedron mesh
  134770. * * 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
  134771. * * The parameter `size` (positive float, default 1) sets the polygon size
  134772. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134773. * * 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`
  134774. * * 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
  134775. * * 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)`)
  134776. * * 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
  134777. * * 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
  134778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134781. * @param name defines the name of the mesh
  134782. * @param options defines the options used to create the mesh
  134783. * @param scene defines the hosting scene
  134784. * @returns the polyhedron mesh
  134785. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134786. */
  134787. static CreatePolyhedron(name: string, options: {
  134788. type?: number;
  134789. size?: number;
  134790. sizeX?: number;
  134791. sizeY?: number;
  134792. sizeZ?: number;
  134793. custom?: any;
  134794. faceUV?: Vector4[];
  134795. faceColors?: Color4[];
  134796. flat?: boolean;
  134797. updatable?: boolean;
  134798. sideOrientation?: number;
  134799. frontUVs?: Vector4;
  134800. backUVs?: Vector4;
  134801. }, scene?: Nullable<Scene>): Mesh;
  134802. /**
  134803. * Creates a decal mesh.
  134804. * 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
  134805. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134806. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134807. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134808. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134809. * @param name defines the name of the mesh
  134810. * @param sourceMesh defines the mesh where the decal must be applied
  134811. * @param options defines the options used to create the mesh
  134812. * @param scene defines the hosting scene
  134813. * @returns the decal mesh
  134814. * @see https://doc.babylonjs.com/how_to/decals
  134815. */
  134816. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134817. position?: Vector3;
  134818. normal?: Vector3;
  134819. size?: Vector3;
  134820. angle?: number;
  134821. }): Mesh;
  134822. }
  134823. }
  134824. declare module BABYLON {
  134825. /**
  134826. * A simplifier interface for future simplification implementations
  134827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134828. */
  134829. export interface ISimplifier {
  134830. /**
  134831. * Simplification of a given mesh according to the given settings.
  134832. * Since this requires computation, it is assumed that the function runs async.
  134833. * @param settings The settings of the simplification, including quality and distance
  134834. * @param successCallback A callback that will be called after the mesh was simplified.
  134835. * @param errorCallback in case of an error, this callback will be called. optional.
  134836. */
  134837. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134838. }
  134839. /**
  134840. * Expected simplification settings.
  134841. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134843. */
  134844. export interface ISimplificationSettings {
  134845. /**
  134846. * Gets or sets the expected quality
  134847. */
  134848. quality: number;
  134849. /**
  134850. * Gets or sets the distance when this optimized version should be used
  134851. */
  134852. distance: number;
  134853. /**
  134854. * Gets an already optimized mesh
  134855. */
  134856. optimizeMesh?: boolean;
  134857. }
  134858. /**
  134859. * Class used to specify simplification options
  134860. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134861. */
  134862. export class SimplificationSettings implements ISimplificationSettings {
  134863. /** expected quality */
  134864. quality: number;
  134865. /** distance when this optimized version should be used */
  134866. distance: number;
  134867. /** already optimized mesh */
  134868. optimizeMesh?: boolean | undefined;
  134869. /**
  134870. * Creates a SimplificationSettings
  134871. * @param quality expected quality
  134872. * @param distance distance when this optimized version should be used
  134873. * @param optimizeMesh already optimized mesh
  134874. */
  134875. constructor(
  134876. /** expected quality */
  134877. quality: number,
  134878. /** distance when this optimized version should be used */
  134879. distance: number,
  134880. /** already optimized mesh */
  134881. optimizeMesh?: boolean | undefined);
  134882. }
  134883. /**
  134884. * Interface used to define a simplification task
  134885. */
  134886. export interface ISimplificationTask {
  134887. /**
  134888. * Array of settings
  134889. */
  134890. settings: Array<ISimplificationSettings>;
  134891. /**
  134892. * Simplification type
  134893. */
  134894. simplificationType: SimplificationType;
  134895. /**
  134896. * Mesh to simplify
  134897. */
  134898. mesh: Mesh;
  134899. /**
  134900. * Callback called on success
  134901. */
  134902. successCallback?: () => void;
  134903. /**
  134904. * Defines if parallel processing can be used
  134905. */
  134906. parallelProcessing: boolean;
  134907. }
  134908. /**
  134909. * Queue used to order the simplification tasks
  134910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134911. */
  134912. export class SimplificationQueue {
  134913. private _simplificationArray;
  134914. /**
  134915. * Gets a boolean indicating that the process is still running
  134916. */
  134917. running: boolean;
  134918. /**
  134919. * Creates a new queue
  134920. */
  134921. constructor();
  134922. /**
  134923. * Adds a new simplification task
  134924. * @param task defines a task to add
  134925. */
  134926. addTask(task: ISimplificationTask): void;
  134927. /**
  134928. * Execute next task
  134929. */
  134930. executeNext(): void;
  134931. /**
  134932. * Execute a simplification task
  134933. * @param task defines the task to run
  134934. */
  134935. runSimplification(task: ISimplificationTask): void;
  134936. private getSimplifier;
  134937. }
  134938. /**
  134939. * The implemented types of simplification
  134940. * At the moment only Quadratic Error Decimation is implemented
  134941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134942. */
  134943. export enum SimplificationType {
  134944. /** Quadratic error decimation */
  134945. QUADRATIC = 0
  134946. }
  134947. }
  134948. declare module BABYLON {
  134949. interface Scene {
  134950. /** @hidden (Backing field) */
  134951. _simplificationQueue: SimplificationQueue;
  134952. /**
  134953. * Gets or sets the simplification queue attached to the scene
  134954. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134955. */
  134956. simplificationQueue: SimplificationQueue;
  134957. }
  134958. interface Mesh {
  134959. /**
  134960. * Simplify the mesh according to the given array of settings.
  134961. * Function will return immediately and will simplify async
  134962. * @param settings a collection of simplification settings
  134963. * @param parallelProcessing should all levels calculate parallel or one after the other
  134964. * @param simplificationType the type of simplification to run
  134965. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134966. * @returns the current mesh
  134967. */
  134968. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134969. }
  134970. /**
  134971. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134972. * created in a scene
  134973. */
  134974. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134975. /**
  134976. * The component name helpfull to identify the component in the list of scene components.
  134977. */
  134978. readonly name: string;
  134979. /**
  134980. * The scene the component belongs to.
  134981. */
  134982. scene: Scene;
  134983. /**
  134984. * Creates a new instance of the component for the given scene
  134985. * @param scene Defines the scene to register the component in
  134986. */
  134987. constructor(scene: Scene);
  134988. /**
  134989. * Registers the component in a given scene
  134990. */
  134991. register(): void;
  134992. /**
  134993. * Rebuilds the elements related to this component in case of
  134994. * context lost for instance.
  134995. */
  134996. rebuild(): void;
  134997. /**
  134998. * Disposes the component and the associated ressources
  134999. */
  135000. dispose(): void;
  135001. private _beforeCameraUpdate;
  135002. }
  135003. }
  135004. declare module BABYLON {
  135005. /**
  135006. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135007. */
  135008. export interface INavigationEnginePlugin {
  135009. /**
  135010. * plugin name
  135011. */
  135012. name: string;
  135013. /**
  135014. * Creates a navigation mesh
  135015. * @param meshes array of all the geometry used to compute the navigatio mesh
  135016. * @param parameters bunch of parameters used to filter geometry
  135017. */
  135018. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135019. /**
  135020. * Create a navigation mesh debug mesh
  135021. * @param scene is where the mesh will be added
  135022. * @returns debug display mesh
  135023. */
  135024. createDebugNavMesh(scene: Scene): Mesh;
  135025. /**
  135026. * Get a navigation mesh constrained position, closest to the parameter position
  135027. * @param position world position
  135028. * @returns the closest point to position constrained by the navigation mesh
  135029. */
  135030. getClosestPoint(position: Vector3): Vector3;
  135031. /**
  135032. * Get a navigation mesh constrained position, within a particular radius
  135033. * @param position world position
  135034. * @param maxRadius the maximum distance to the constrained world position
  135035. * @returns the closest point to position constrained by the navigation mesh
  135036. */
  135037. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135038. /**
  135039. * Compute the final position from a segment made of destination-position
  135040. * @param position world position
  135041. * @param destination world position
  135042. * @returns the resulting point along the navmesh
  135043. */
  135044. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135045. /**
  135046. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135047. * @param start world position
  135048. * @param end world position
  135049. * @returns array containing world position composing the path
  135050. */
  135051. computePath(start: Vector3, end: Vector3): Vector3[];
  135052. /**
  135053. * If this plugin is supported
  135054. * @returns true if plugin is supported
  135055. */
  135056. isSupported(): boolean;
  135057. /**
  135058. * Create a new Crowd so you can add agents
  135059. * @param maxAgents the maximum agent count in the crowd
  135060. * @param maxAgentRadius the maximum radius an agent can have
  135061. * @param scene to attach the crowd to
  135062. * @returns the crowd you can add agents to
  135063. */
  135064. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135065. /**
  135066. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135067. * The queries will try to find a solution within those bounds
  135068. * default is (1,1,1)
  135069. * @param extent x,y,z value that define the extent around the queries point of reference
  135070. */
  135071. setDefaultQueryExtent(extent: Vector3): void;
  135072. /**
  135073. * Get the Bounding box extent specified by setDefaultQueryExtent
  135074. * @returns the box extent values
  135075. */
  135076. getDefaultQueryExtent(): Vector3;
  135077. /**
  135078. * Release all resources
  135079. */
  135080. dispose(): void;
  135081. }
  135082. /**
  135083. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135084. */
  135085. export interface ICrowd {
  135086. /**
  135087. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135088. * You can attach anything to that node. The node position is updated in the scene update tick.
  135089. * @param pos world position that will be constrained by the navigation mesh
  135090. * @param parameters agent parameters
  135091. * @param transform hooked to the agent that will be update by the scene
  135092. * @returns agent index
  135093. */
  135094. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135095. /**
  135096. * Returns the agent position in world space
  135097. * @param index agent index returned by addAgent
  135098. * @returns world space position
  135099. */
  135100. getAgentPosition(index: number): Vector3;
  135101. /**
  135102. * Gets the agent velocity in world space
  135103. * @param index agent index returned by addAgent
  135104. * @returns world space velocity
  135105. */
  135106. getAgentVelocity(index: number): Vector3;
  135107. /**
  135108. * remove a particular agent previously created
  135109. * @param index agent index returned by addAgent
  135110. */
  135111. removeAgent(index: number): void;
  135112. /**
  135113. * get the list of all agents attached to this crowd
  135114. * @returns list of agent indices
  135115. */
  135116. getAgents(): number[];
  135117. /**
  135118. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135119. * @param deltaTime in seconds
  135120. */
  135121. update(deltaTime: number): void;
  135122. /**
  135123. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135124. * @param index agent index returned by addAgent
  135125. * @param destination targeted world position
  135126. */
  135127. agentGoto(index: number, destination: Vector3): void;
  135128. /**
  135129. * Teleport the agent to a new position
  135130. * @param index agent index returned by addAgent
  135131. * @param destination targeted world position
  135132. */
  135133. agentTeleport(index: number, destination: Vector3): void;
  135134. /**
  135135. * Update agent parameters
  135136. * @param index agent index returned by addAgent
  135137. * @param parameters agent parameters
  135138. */
  135139. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135140. /**
  135141. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135142. * The queries will try to find a solution within those bounds
  135143. * default is (1,1,1)
  135144. * @param extent x,y,z value that define the extent around the queries point of reference
  135145. */
  135146. setDefaultQueryExtent(extent: Vector3): void;
  135147. /**
  135148. * Get the Bounding box extent specified by setDefaultQueryExtent
  135149. * @returns the box extent values
  135150. */
  135151. getDefaultQueryExtent(): Vector3;
  135152. /**
  135153. * Release all resources
  135154. */
  135155. dispose(): void;
  135156. }
  135157. /**
  135158. * Configures an agent
  135159. */
  135160. export interface IAgentParameters {
  135161. /**
  135162. * Agent radius. [Limit: >= 0]
  135163. */
  135164. radius: number;
  135165. /**
  135166. * Agent height. [Limit: > 0]
  135167. */
  135168. height: number;
  135169. /**
  135170. * Maximum allowed acceleration. [Limit: >= 0]
  135171. */
  135172. maxAcceleration: number;
  135173. /**
  135174. * Maximum allowed speed. [Limit: >= 0]
  135175. */
  135176. maxSpeed: number;
  135177. /**
  135178. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135179. */
  135180. collisionQueryRange: number;
  135181. /**
  135182. * The path visibility optimization range. [Limit: > 0]
  135183. */
  135184. pathOptimizationRange: number;
  135185. /**
  135186. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135187. */
  135188. separationWeight: number;
  135189. }
  135190. /**
  135191. * Configures the navigation mesh creation
  135192. */
  135193. export interface INavMeshParameters {
  135194. /**
  135195. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135196. */
  135197. cs: number;
  135198. /**
  135199. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135200. */
  135201. ch: number;
  135202. /**
  135203. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135204. */
  135205. walkableSlopeAngle: number;
  135206. /**
  135207. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135208. * be considered walkable. [Limit: >= 3] [Units: vx]
  135209. */
  135210. walkableHeight: number;
  135211. /**
  135212. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135213. */
  135214. walkableClimb: number;
  135215. /**
  135216. * The distance to erode/shrink the walkable area of the heightfield away from
  135217. * obstructions. [Limit: >=0] [Units: vx]
  135218. */
  135219. walkableRadius: number;
  135220. /**
  135221. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135222. */
  135223. maxEdgeLen: number;
  135224. /**
  135225. * The maximum distance a simplfied contour's border edges should deviate
  135226. * the original raw contour. [Limit: >=0] [Units: vx]
  135227. */
  135228. maxSimplificationError: number;
  135229. /**
  135230. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135231. */
  135232. minRegionArea: number;
  135233. /**
  135234. * Any regions with a span count smaller than this value will, if possible,
  135235. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135236. */
  135237. mergeRegionArea: number;
  135238. /**
  135239. * The maximum number of vertices allowed for polygons generated during the
  135240. * contour to polygon conversion process. [Limit: >= 3]
  135241. */
  135242. maxVertsPerPoly: number;
  135243. /**
  135244. * Sets the sampling distance to use when generating the detail mesh.
  135245. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135246. */
  135247. detailSampleDist: number;
  135248. /**
  135249. * The maximum distance the detail mesh surface should deviate from heightfield
  135250. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135251. */
  135252. detailSampleMaxError: number;
  135253. }
  135254. }
  135255. declare module BABYLON {
  135256. /**
  135257. * RecastJS navigation plugin
  135258. */
  135259. export class RecastJSPlugin implements INavigationEnginePlugin {
  135260. /**
  135261. * Reference to the Recast library
  135262. */
  135263. bjsRECAST: any;
  135264. /**
  135265. * plugin name
  135266. */
  135267. name: string;
  135268. /**
  135269. * the first navmesh created. We might extend this to support multiple navmeshes
  135270. */
  135271. navMesh: any;
  135272. /**
  135273. * Initializes the recastJS plugin
  135274. * @param recastInjection can be used to inject your own recast reference
  135275. */
  135276. constructor(recastInjection?: any);
  135277. /**
  135278. * Creates a navigation mesh
  135279. * @param meshes array of all the geometry used to compute the navigatio mesh
  135280. * @param parameters bunch of parameters used to filter geometry
  135281. */
  135282. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135283. /**
  135284. * Create a navigation mesh debug mesh
  135285. * @param scene is where the mesh will be added
  135286. * @returns debug display mesh
  135287. */
  135288. createDebugNavMesh(scene: Scene): Mesh;
  135289. /**
  135290. * Get a navigation mesh constrained position, closest to the parameter position
  135291. * @param position world position
  135292. * @returns the closest point to position constrained by the navigation mesh
  135293. */
  135294. getClosestPoint(position: Vector3): Vector3;
  135295. /**
  135296. * Get a navigation mesh constrained position, within a particular radius
  135297. * @param position world position
  135298. * @param maxRadius the maximum distance to the constrained world position
  135299. * @returns the closest point to position constrained by the navigation mesh
  135300. */
  135301. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135302. /**
  135303. * Compute the final position from a segment made of destination-position
  135304. * @param position world position
  135305. * @param destination world position
  135306. * @returns the resulting point along the navmesh
  135307. */
  135308. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135309. /**
  135310. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135311. * @param start world position
  135312. * @param end world position
  135313. * @returns array containing world position composing the path
  135314. */
  135315. computePath(start: Vector3, end: Vector3): Vector3[];
  135316. /**
  135317. * Create a new Crowd so you can add agents
  135318. * @param maxAgents the maximum agent count in the crowd
  135319. * @param maxAgentRadius the maximum radius an agent can have
  135320. * @param scene to attach the crowd to
  135321. * @returns the crowd you can add agents to
  135322. */
  135323. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135324. /**
  135325. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135326. * The queries will try to find a solution within those bounds
  135327. * default is (1,1,1)
  135328. * @param extent x,y,z value that define the extent around the queries point of reference
  135329. */
  135330. setDefaultQueryExtent(extent: Vector3): void;
  135331. /**
  135332. * Get the Bounding box extent specified by setDefaultQueryExtent
  135333. * @returns the box extent values
  135334. */
  135335. getDefaultQueryExtent(): Vector3;
  135336. /**
  135337. * Disposes
  135338. */
  135339. dispose(): void;
  135340. /**
  135341. * If this plugin is supported
  135342. * @returns true if plugin is supported
  135343. */
  135344. isSupported(): boolean;
  135345. }
  135346. /**
  135347. * Recast detour crowd implementation
  135348. */
  135349. export class RecastJSCrowd implements ICrowd {
  135350. /**
  135351. * Recast/detour plugin
  135352. */
  135353. bjsRECASTPlugin: RecastJSPlugin;
  135354. /**
  135355. * Link to the detour crowd
  135356. */
  135357. recastCrowd: any;
  135358. /**
  135359. * One transform per agent
  135360. */
  135361. transforms: TransformNode[];
  135362. /**
  135363. * All agents created
  135364. */
  135365. agents: number[];
  135366. /**
  135367. * Link to the scene is kept to unregister the crowd from the scene
  135368. */
  135369. private _scene;
  135370. /**
  135371. * Observer for crowd updates
  135372. */
  135373. private _onBeforeAnimationsObserver;
  135374. /**
  135375. * Constructor
  135376. * @param plugin recastJS plugin
  135377. * @param maxAgents the maximum agent count in the crowd
  135378. * @param maxAgentRadius the maximum radius an agent can have
  135379. * @param scene to attach the crowd to
  135380. * @returns the crowd you can add agents to
  135381. */
  135382. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135383. /**
  135384. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135385. * You can attach anything to that node. The node position is updated in the scene update tick.
  135386. * @param pos world position that will be constrained by the navigation mesh
  135387. * @param parameters agent parameters
  135388. * @param transform hooked to the agent that will be update by the scene
  135389. * @returns agent index
  135390. */
  135391. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135392. /**
  135393. * Returns the agent position in world space
  135394. * @param index agent index returned by addAgent
  135395. * @returns world space position
  135396. */
  135397. getAgentPosition(index: number): Vector3;
  135398. /**
  135399. * Returns the agent velocity in world space
  135400. * @param index agent index returned by addAgent
  135401. * @returns world space velocity
  135402. */
  135403. getAgentVelocity(index: number): Vector3;
  135404. /**
  135405. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135406. * @param index agent index returned by addAgent
  135407. * @param destination targeted world position
  135408. */
  135409. agentGoto(index: number, destination: Vector3): void;
  135410. /**
  135411. * Teleport the agent to a new position
  135412. * @param index agent index returned by addAgent
  135413. * @param destination targeted world position
  135414. */
  135415. agentTeleport(index: number, destination: Vector3): void;
  135416. /**
  135417. * Update agent parameters
  135418. * @param index agent index returned by addAgent
  135419. * @param parameters agent parameters
  135420. */
  135421. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135422. /**
  135423. * remove a particular agent previously created
  135424. * @param index agent index returned by addAgent
  135425. */
  135426. removeAgent(index: number): void;
  135427. /**
  135428. * get the list of all agents attached to this crowd
  135429. * @returns list of agent indices
  135430. */
  135431. getAgents(): number[];
  135432. /**
  135433. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135434. * @param deltaTime in seconds
  135435. */
  135436. update(deltaTime: number): void;
  135437. /**
  135438. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135439. * The queries will try to find a solution within those bounds
  135440. * default is (1,1,1)
  135441. * @param extent x,y,z value that define the extent around the queries point of reference
  135442. */
  135443. setDefaultQueryExtent(extent: Vector3): void;
  135444. /**
  135445. * Get the Bounding box extent specified by setDefaultQueryExtent
  135446. * @returns the box extent values
  135447. */
  135448. getDefaultQueryExtent(): Vector3;
  135449. /**
  135450. * Release all resources
  135451. */
  135452. dispose(): void;
  135453. }
  135454. }
  135455. declare module BABYLON {
  135456. /**
  135457. * Class used to enable access to IndexedDB
  135458. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135459. */
  135460. export class Database implements IOfflineProvider {
  135461. private _callbackManifestChecked;
  135462. private _currentSceneUrl;
  135463. private _db;
  135464. private _enableSceneOffline;
  135465. private _enableTexturesOffline;
  135466. private _manifestVersionFound;
  135467. private _mustUpdateRessources;
  135468. private _hasReachedQuota;
  135469. private _isSupported;
  135470. private _idbFactory;
  135471. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135472. private static IsUASupportingBlobStorage;
  135473. /**
  135474. * Gets a boolean indicating if Database storate is enabled (off by default)
  135475. */
  135476. static IDBStorageEnabled: boolean;
  135477. /**
  135478. * Gets a boolean indicating if scene must be saved in the database
  135479. */
  135480. get enableSceneOffline(): boolean;
  135481. /**
  135482. * Gets a boolean indicating if textures must be saved in the database
  135483. */
  135484. get enableTexturesOffline(): boolean;
  135485. /**
  135486. * Creates a new Database
  135487. * @param urlToScene defines the url to load the scene
  135488. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135489. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135490. */
  135491. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135492. private static _ParseURL;
  135493. private static _ReturnFullUrlLocation;
  135494. private _checkManifestFile;
  135495. /**
  135496. * Open the database and make it available
  135497. * @param successCallback defines the callback to call on success
  135498. * @param errorCallback defines the callback to call on error
  135499. */
  135500. open(successCallback: () => void, errorCallback: () => void): void;
  135501. /**
  135502. * Loads an image from the database
  135503. * @param url defines the url to load from
  135504. * @param image defines the target DOM image
  135505. */
  135506. loadImage(url: string, image: HTMLImageElement): void;
  135507. private _loadImageFromDBAsync;
  135508. private _saveImageIntoDBAsync;
  135509. private _checkVersionFromDB;
  135510. private _loadVersionFromDBAsync;
  135511. private _saveVersionIntoDBAsync;
  135512. /**
  135513. * Loads a file from database
  135514. * @param url defines the URL to load from
  135515. * @param sceneLoaded defines a callback to call on success
  135516. * @param progressCallBack defines a callback to call when progress changed
  135517. * @param errorCallback defines a callback to call on error
  135518. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135519. */
  135520. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135521. private _loadFileAsync;
  135522. private _saveFileAsync;
  135523. /**
  135524. * Validates if xhr data is correct
  135525. * @param xhr defines the request to validate
  135526. * @param dataType defines the expected data type
  135527. * @returns true if data is correct
  135528. */
  135529. private static _ValidateXHRData;
  135530. }
  135531. }
  135532. declare module BABYLON {
  135533. /** @hidden */
  135534. export var gpuUpdateParticlesPixelShader: {
  135535. name: string;
  135536. shader: string;
  135537. };
  135538. }
  135539. declare module BABYLON {
  135540. /** @hidden */
  135541. export var gpuUpdateParticlesVertexShader: {
  135542. name: string;
  135543. shader: string;
  135544. };
  135545. }
  135546. declare module BABYLON {
  135547. /** @hidden */
  135548. export var clipPlaneFragmentDeclaration2: {
  135549. name: string;
  135550. shader: string;
  135551. };
  135552. }
  135553. declare module BABYLON {
  135554. /** @hidden */
  135555. export var gpuRenderParticlesPixelShader: {
  135556. name: string;
  135557. shader: string;
  135558. };
  135559. }
  135560. declare module BABYLON {
  135561. /** @hidden */
  135562. export var clipPlaneVertexDeclaration2: {
  135563. name: string;
  135564. shader: string;
  135565. };
  135566. }
  135567. declare module BABYLON {
  135568. /** @hidden */
  135569. export var gpuRenderParticlesVertexShader: {
  135570. name: string;
  135571. shader: string;
  135572. };
  135573. }
  135574. declare module BABYLON {
  135575. /**
  135576. * This represents a GPU particle system in Babylon
  135577. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135578. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135579. */
  135580. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135581. /**
  135582. * The layer mask we are rendering the particles through.
  135583. */
  135584. layerMask: number;
  135585. private _capacity;
  135586. private _activeCount;
  135587. private _currentActiveCount;
  135588. private _accumulatedCount;
  135589. private _renderEffect;
  135590. private _updateEffect;
  135591. private _buffer0;
  135592. private _buffer1;
  135593. private _spriteBuffer;
  135594. private _updateVAO;
  135595. private _renderVAO;
  135596. private _targetIndex;
  135597. private _sourceBuffer;
  135598. private _targetBuffer;
  135599. private _engine;
  135600. private _currentRenderId;
  135601. private _started;
  135602. private _stopped;
  135603. private _timeDelta;
  135604. private _randomTexture;
  135605. private _randomTexture2;
  135606. private _attributesStrideSize;
  135607. private _updateEffectOptions;
  135608. private _randomTextureSize;
  135609. private _actualFrame;
  135610. private readonly _rawTextureWidth;
  135611. /**
  135612. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135613. */
  135614. static get IsSupported(): boolean;
  135615. /**
  135616. * An event triggered when the system is disposed.
  135617. */
  135618. onDisposeObservable: Observable<GPUParticleSystem>;
  135619. /**
  135620. * Gets the maximum number of particles active at the same time.
  135621. * @returns The max number of active particles.
  135622. */
  135623. getCapacity(): number;
  135624. /**
  135625. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135626. * to override the particles.
  135627. */
  135628. forceDepthWrite: boolean;
  135629. /**
  135630. * Gets or set the number of active particles
  135631. */
  135632. get activeParticleCount(): number;
  135633. set activeParticleCount(value: number);
  135634. private _preWarmDone;
  135635. /**
  135636. * Is this system ready to be used/rendered
  135637. * @return true if the system is ready
  135638. */
  135639. isReady(): boolean;
  135640. /**
  135641. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135642. * @returns True if it has been started, otherwise false.
  135643. */
  135644. isStarted(): boolean;
  135645. /**
  135646. * Starts the particle system and begins to emit
  135647. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135648. */
  135649. start(delay?: number): void;
  135650. /**
  135651. * Stops the particle system.
  135652. */
  135653. stop(): void;
  135654. /**
  135655. * Remove all active particles
  135656. */
  135657. reset(): void;
  135658. /**
  135659. * Returns the string "GPUParticleSystem"
  135660. * @returns a string containing the class name
  135661. */
  135662. getClassName(): string;
  135663. private _colorGradientsTexture;
  135664. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135665. /**
  135666. * Adds a new color gradient
  135667. * @param gradient defines the gradient to use (between 0 and 1)
  135668. * @param color1 defines the color to affect to the specified gradient
  135669. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135670. * @returns the current particle system
  135671. */
  135672. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135673. /**
  135674. * Remove a specific color gradient
  135675. * @param gradient defines the gradient to remove
  135676. * @returns the current particle system
  135677. */
  135678. removeColorGradient(gradient: number): GPUParticleSystem;
  135679. private _angularSpeedGradientsTexture;
  135680. private _sizeGradientsTexture;
  135681. private _velocityGradientsTexture;
  135682. private _limitVelocityGradientsTexture;
  135683. private _dragGradientsTexture;
  135684. private _addFactorGradient;
  135685. /**
  135686. * Adds a new size gradient
  135687. * @param gradient defines the gradient to use (between 0 and 1)
  135688. * @param factor defines the size factor to affect to the specified gradient
  135689. * @returns the current particle system
  135690. */
  135691. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135692. /**
  135693. * Remove a specific size gradient
  135694. * @param gradient defines the gradient to remove
  135695. * @returns the current particle system
  135696. */
  135697. removeSizeGradient(gradient: number): GPUParticleSystem;
  135698. /**
  135699. * Adds a new angular speed gradient
  135700. * @param gradient defines the gradient to use (between 0 and 1)
  135701. * @param factor defines the angular speed to affect to the specified gradient
  135702. * @returns the current particle system
  135703. */
  135704. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135705. /**
  135706. * Remove a specific angular speed gradient
  135707. * @param gradient defines the gradient to remove
  135708. * @returns the current particle system
  135709. */
  135710. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135711. /**
  135712. * Adds a new velocity gradient
  135713. * @param gradient defines the gradient to use (between 0 and 1)
  135714. * @param factor defines the velocity to affect to the specified gradient
  135715. * @returns the current particle system
  135716. */
  135717. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135718. /**
  135719. * Remove a specific velocity gradient
  135720. * @param gradient defines the gradient to remove
  135721. * @returns the current particle system
  135722. */
  135723. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135724. /**
  135725. * Adds a new limit velocity gradient
  135726. * @param gradient defines the gradient to use (between 0 and 1)
  135727. * @param factor defines the limit velocity value to affect to the specified gradient
  135728. * @returns the current particle system
  135729. */
  135730. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135731. /**
  135732. * Remove a specific limit velocity gradient
  135733. * @param gradient defines the gradient to remove
  135734. * @returns the current particle system
  135735. */
  135736. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135737. /**
  135738. * Adds a new drag gradient
  135739. * @param gradient defines the gradient to use (between 0 and 1)
  135740. * @param factor defines the drag value to affect to the specified gradient
  135741. * @returns the current particle system
  135742. */
  135743. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135744. /**
  135745. * Remove a specific drag gradient
  135746. * @param gradient defines the gradient to remove
  135747. * @returns the current particle system
  135748. */
  135749. removeDragGradient(gradient: number): GPUParticleSystem;
  135750. /**
  135751. * Not supported by GPUParticleSystem
  135752. * @param gradient defines the gradient to use (between 0 and 1)
  135753. * @param factor defines the emit rate value to affect to the specified gradient
  135754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135755. * @returns the current particle system
  135756. */
  135757. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135758. /**
  135759. * Not supported by GPUParticleSystem
  135760. * @param gradient defines the gradient to remove
  135761. * @returns the current particle system
  135762. */
  135763. removeEmitRateGradient(gradient: number): IParticleSystem;
  135764. /**
  135765. * Not supported by GPUParticleSystem
  135766. * @param gradient defines the gradient to use (between 0 and 1)
  135767. * @param factor defines the start size value to affect to the specified gradient
  135768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135769. * @returns the current particle system
  135770. */
  135771. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135772. /**
  135773. * Not supported by GPUParticleSystem
  135774. * @param gradient defines the gradient to remove
  135775. * @returns the current particle system
  135776. */
  135777. removeStartSizeGradient(gradient: number): IParticleSystem;
  135778. /**
  135779. * Not supported by GPUParticleSystem
  135780. * @param gradient defines the gradient to use (between 0 and 1)
  135781. * @param min defines the color remap minimal range
  135782. * @param max defines the color remap maximal range
  135783. * @returns the current particle system
  135784. */
  135785. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135786. /**
  135787. * Not supported by GPUParticleSystem
  135788. * @param gradient defines the gradient to remove
  135789. * @returns the current particle system
  135790. */
  135791. removeColorRemapGradient(): IParticleSystem;
  135792. /**
  135793. * Not supported by GPUParticleSystem
  135794. * @param gradient defines the gradient to use (between 0 and 1)
  135795. * @param min defines the alpha remap minimal range
  135796. * @param max defines the alpha remap maximal range
  135797. * @returns the current particle system
  135798. */
  135799. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135800. /**
  135801. * Not supported by GPUParticleSystem
  135802. * @param gradient defines the gradient to remove
  135803. * @returns the current particle system
  135804. */
  135805. removeAlphaRemapGradient(): IParticleSystem;
  135806. /**
  135807. * Not supported by GPUParticleSystem
  135808. * @param gradient defines the gradient to use (between 0 and 1)
  135809. * @param color defines the color to affect to the specified gradient
  135810. * @returns the current particle system
  135811. */
  135812. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135813. /**
  135814. * Not supported by GPUParticleSystem
  135815. * @param gradient defines the gradient to remove
  135816. * @returns the current particle system
  135817. */
  135818. removeRampGradient(): IParticleSystem;
  135819. /**
  135820. * Not supported by GPUParticleSystem
  135821. * @returns the list of ramp gradients
  135822. */
  135823. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135824. /**
  135825. * Not supported by GPUParticleSystem
  135826. * Gets or sets a boolean indicating that ramp gradients must be used
  135827. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135828. */
  135829. get useRampGradients(): boolean;
  135830. set useRampGradients(value: boolean);
  135831. /**
  135832. * Not supported by GPUParticleSystem
  135833. * @param gradient defines the gradient to use (between 0 and 1)
  135834. * @param factor defines the life time factor to affect to the specified gradient
  135835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135836. * @returns the current particle system
  135837. */
  135838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135839. /**
  135840. * Not supported by GPUParticleSystem
  135841. * @param gradient defines the gradient to remove
  135842. * @returns the current particle system
  135843. */
  135844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135845. /**
  135846. * Instantiates a GPU particle system.
  135847. * 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.
  135848. * @param name The name of the particle system
  135849. * @param options The options used to create the system
  135850. * @param scene The scene the particle system belongs to
  135851. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135852. */
  135853. constructor(name: string, options: Partial<{
  135854. capacity: number;
  135855. randomTextureSize: number;
  135856. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135857. protected _reset(): void;
  135858. private _createUpdateVAO;
  135859. private _createRenderVAO;
  135860. private _initialize;
  135861. /** @hidden */
  135862. _recreateUpdateEffect(): void;
  135863. /** @hidden */
  135864. _recreateRenderEffect(): void;
  135865. /**
  135866. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135867. * @param preWarm defines if we are in the pre-warmimg phase
  135868. */
  135869. animate(preWarm?: boolean): void;
  135870. private _createFactorGradientTexture;
  135871. private _createSizeGradientTexture;
  135872. private _createAngularSpeedGradientTexture;
  135873. private _createVelocityGradientTexture;
  135874. private _createLimitVelocityGradientTexture;
  135875. private _createDragGradientTexture;
  135876. private _createColorGradientTexture;
  135877. /**
  135878. * Renders the particle system in its current state
  135879. * @param preWarm defines if the system should only update the particles but not render them
  135880. * @returns the current number of particles
  135881. */
  135882. render(preWarm?: boolean): number;
  135883. /**
  135884. * Rebuilds the particle system
  135885. */
  135886. rebuild(): void;
  135887. private _releaseBuffers;
  135888. private _releaseVAOs;
  135889. /**
  135890. * Disposes the particle system and free the associated resources
  135891. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135892. */
  135893. dispose(disposeTexture?: boolean): void;
  135894. /**
  135895. * Clones the particle system.
  135896. * @param name The name of the cloned object
  135897. * @param newEmitter The new emitter to use
  135898. * @returns the cloned particle system
  135899. */
  135900. clone(name: string, newEmitter: any): GPUParticleSystem;
  135901. /**
  135902. * Serializes the particle system to a JSON object.
  135903. * @returns the JSON object
  135904. */
  135905. serialize(): any;
  135906. /**
  135907. * Parses a JSON object to create a GPU particle system.
  135908. * @param parsedParticleSystem The JSON object to parse
  135909. * @param scene The scene to create the particle system in
  135910. * @param rootUrl The root url to use to load external dependencies like texture
  135911. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135912. * @returns the parsed GPU particle system
  135913. */
  135914. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135915. }
  135916. }
  135917. declare module BABYLON {
  135918. /**
  135919. * Represents a set of particle systems working together to create a specific effect
  135920. */
  135921. export class ParticleSystemSet implements IDisposable {
  135922. /**
  135923. * Gets or sets base Assets URL
  135924. */
  135925. static BaseAssetsUrl: string;
  135926. private _emitterCreationOptions;
  135927. private _emitterNode;
  135928. /**
  135929. * Gets the particle system list
  135930. */
  135931. systems: IParticleSystem[];
  135932. /**
  135933. * Gets the emitter node used with this set
  135934. */
  135935. get emitterNode(): Nullable<TransformNode>;
  135936. /**
  135937. * Creates a new emitter mesh as a sphere
  135938. * @param options defines the options used to create the sphere
  135939. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135940. * @param scene defines the hosting scene
  135941. */
  135942. setEmitterAsSphere(options: {
  135943. diameter: number;
  135944. segments: number;
  135945. color: Color3;
  135946. }, renderingGroupId: number, scene: Scene): void;
  135947. /**
  135948. * Starts all particle systems of the set
  135949. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135950. */
  135951. start(emitter?: AbstractMesh): void;
  135952. /**
  135953. * Release all associated resources
  135954. */
  135955. dispose(): void;
  135956. /**
  135957. * Serialize the set into a JSON compatible object
  135958. * @returns a JSON compatible representation of the set
  135959. */
  135960. serialize(): any;
  135961. /**
  135962. * Parse a new ParticleSystemSet from a serialized source
  135963. * @param data defines a JSON compatible representation of the set
  135964. * @param scene defines the hosting scene
  135965. * @param gpu defines if we want GPU particles or CPU particles
  135966. * @returns a new ParticleSystemSet
  135967. */
  135968. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135969. }
  135970. }
  135971. declare module BABYLON {
  135972. /**
  135973. * This class is made for on one-liner static method to help creating particle system set.
  135974. */
  135975. export class ParticleHelper {
  135976. /**
  135977. * Gets or sets base Assets URL
  135978. */
  135979. static BaseAssetsUrl: string;
  135980. /**
  135981. * Create a default particle system that you can tweak
  135982. * @param emitter defines the emitter to use
  135983. * @param capacity defines the system capacity (default is 500 particles)
  135984. * @param scene defines the hosting scene
  135985. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135986. * @returns the new Particle system
  135987. */
  135988. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135989. /**
  135990. * This is the main static method (one-liner) of this helper to create different particle systems
  135991. * @param type This string represents the type to the particle system to create
  135992. * @param scene The scene where the particle system should live
  135993. * @param gpu If the system will use gpu
  135994. * @returns the ParticleSystemSet created
  135995. */
  135996. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135997. /**
  135998. * Static function used to export a particle system to a ParticleSystemSet variable.
  135999. * Please note that the emitter shape is not exported
  136000. * @param systems defines the particle systems to export
  136001. * @returns the created particle system set
  136002. */
  136003. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136004. }
  136005. }
  136006. declare module BABYLON {
  136007. interface Engine {
  136008. /**
  136009. * Create an effect to use with particle systems.
  136010. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136011. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136012. * @param uniformsNames defines a list of attribute names
  136013. * @param samplers defines an array of string used to represent textures
  136014. * @param defines defines the string containing the defines to use to compile the shaders
  136015. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136016. * @param onCompiled defines a function to call when the effect creation is successful
  136017. * @param onError defines a function to call when the effect creation has failed
  136018. * @returns the new Effect
  136019. */
  136020. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136021. }
  136022. interface Mesh {
  136023. /**
  136024. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136025. * @returns an array of IParticleSystem
  136026. */
  136027. getEmittedParticleSystems(): IParticleSystem[];
  136028. /**
  136029. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136030. * @returns an array of IParticleSystem
  136031. */
  136032. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136033. }
  136034. /**
  136035. * @hidden
  136036. */
  136037. export var _IDoNeedToBeInTheBuild: number;
  136038. }
  136039. declare module BABYLON {
  136040. /** Defines the 4 color options */
  136041. export enum PointColor {
  136042. /** color value */
  136043. Color = 2,
  136044. /** uv value */
  136045. UV = 1,
  136046. /** random value */
  136047. Random = 0,
  136048. /** stated value */
  136049. Stated = 3
  136050. }
  136051. /**
  136052. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136053. * 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.
  136054. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136055. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136056. *
  136057. * Full documentation here : TO BE ENTERED
  136058. */
  136059. export class PointsCloudSystem implements IDisposable {
  136060. /**
  136061. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136062. * Example : var p = SPS.particles[i];
  136063. */
  136064. particles: CloudPoint[];
  136065. /**
  136066. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136067. */
  136068. nbParticles: number;
  136069. /**
  136070. * This a counter for your own usage. It's not set by any SPS functions.
  136071. */
  136072. counter: number;
  136073. /**
  136074. * The PCS name. This name is also given to the underlying mesh.
  136075. */
  136076. name: string;
  136077. /**
  136078. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136079. */
  136080. mesh: Mesh;
  136081. /**
  136082. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136083. * Please read :
  136084. */
  136085. vars: any;
  136086. /**
  136087. * @hidden
  136088. */
  136089. _size: number;
  136090. private _scene;
  136091. private _promises;
  136092. private _positions;
  136093. private _indices;
  136094. private _normals;
  136095. private _colors;
  136096. private _uvs;
  136097. private _indices32;
  136098. private _positions32;
  136099. private _colors32;
  136100. private _uvs32;
  136101. private _updatable;
  136102. private _isVisibilityBoxLocked;
  136103. private _alwaysVisible;
  136104. private _groups;
  136105. private _groupCounter;
  136106. private _computeParticleColor;
  136107. private _computeParticleTexture;
  136108. private _computeParticleRotation;
  136109. private _computeBoundingBox;
  136110. private _isReady;
  136111. /**
  136112. * Creates a PCS (Points Cloud System) object
  136113. * @param name (String) is the PCS name, this will be the underlying mesh name
  136114. * @param pointSize (number) is the size for each point
  136115. * @param scene (Scene) is the scene in which the PCS is added
  136116. * @param options defines the options of the PCS e.g.
  136117. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136118. */
  136119. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136120. updatable?: boolean;
  136121. });
  136122. /**
  136123. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136124. * If no points were added to the PCS, the returned mesh is just a single point.
  136125. * @returns a promise for the created mesh
  136126. */
  136127. buildMeshAsync(): Promise<Mesh>;
  136128. /**
  136129. * @hidden
  136130. */
  136131. private _buildMesh;
  136132. private _addParticle;
  136133. private _randomUnitVector;
  136134. private _getColorIndicesForCoord;
  136135. private _setPointsColorOrUV;
  136136. private _colorFromTexture;
  136137. private _calculateDensity;
  136138. /**
  136139. * Adds points to the PCS in random positions within a unit sphere
  136140. * @param nb (positive integer) the number of particles to be created from this model
  136141. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136142. * @returns the number of groups in the system
  136143. */
  136144. addPoints(nb: number, pointFunction?: any): number;
  136145. /**
  136146. * Adds points to the PCS from the surface of the model shape
  136147. * @param mesh is any Mesh object that will be used as a surface model for the points
  136148. * @param nb (positive integer) the number of particles to be created from this model
  136149. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136150. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136151. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136152. * @returns the number of groups in the system
  136153. */
  136154. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136155. /**
  136156. * Adds points to the PCS inside the model shape
  136157. * @param mesh is any Mesh object that will be used as a surface model for the points
  136158. * @param nb (positive integer) the number of particles to be created from this model
  136159. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136160. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136161. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136162. * @returns the number of groups in the system
  136163. */
  136164. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136165. /**
  136166. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136167. * This method calls `updateParticle()` for each particle of the SPS.
  136168. * For an animated SPS, it is usually called within the render loop.
  136169. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136170. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136171. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136172. * @returns the PCS.
  136173. */
  136174. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136175. /**
  136176. * Disposes the PCS.
  136177. */
  136178. dispose(): void;
  136179. /**
  136180. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136181. * doc :
  136182. * @returns the PCS.
  136183. */
  136184. refreshVisibleSize(): PointsCloudSystem;
  136185. /**
  136186. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136187. * @param size the size (float) of the visibility box
  136188. * note : this doesn't lock the PCS mesh bounding box.
  136189. * doc :
  136190. */
  136191. setVisibilityBox(size: number): void;
  136192. /**
  136193. * Gets whether the PCS is always visible or not
  136194. * doc :
  136195. */
  136196. get isAlwaysVisible(): boolean;
  136197. /**
  136198. * Sets the PCS as always visible or not
  136199. * doc :
  136200. */
  136201. set isAlwaysVisible(val: boolean);
  136202. /**
  136203. * Tells to `setParticles()` to compute the particle rotations or not
  136204. * Default value : false. The PCS is faster when it's set to false
  136205. * Note : particle rotations are only applied to parent particles
  136206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136207. */
  136208. set computeParticleRotation(val: boolean);
  136209. /**
  136210. * Tells to `setParticles()` to compute the particle colors or not.
  136211. * Default value : true. The PCS is faster when it's set to false.
  136212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136213. */
  136214. set computeParticleColor(val: boolean);
  136215. set computeParticleTexture(val: boolean);
  136216. /**
  136217. * Gets if `setParticles()` computes the particle colors or not.
  136218. * Default value : false. The PCS is faster when it's set to false.
  136219. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136220. */
  136221. get computeParticleColor(): boolean;
  136222. /**
  136223. * Gets if `setParticles()` computes the particle textures or not.
  136224. * Default value : false. The PCS is faster when it's set to false.
  136225. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136226. */
  136227. get computeParticleTexture(): boolean;
  136228. /**
  136229. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136230. */
  136231. set computeBoundingBox(val: boolean);
  136232. /**
  136233. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136234. */
  136235. get computeBoundingBox(): boolean;
  136236. /**
  136237. * This function does nothing. It may be overwritten to set all the particle first values.
  136238. * The PCS doesn't call this function, you may have to call it by your own.
  136239. * doc :
  136240. */
  136241. initParticles(): void;
  136242. /**
  136243. * This function does nothing. It may be overwritten to recycle a particle
  136244. * The PCS doesn't call this function, you can to call it
  136245. * doc :
  136246. * @param particle The particle to recycle
  136247. * @returns the recycled particle
  136248. */
  136249. recycleParticle(particle: CloudPoint): CloudPoint;
  136250. /**
  136251. * Updates a particle : this function should be overwritten by the user.
  136252. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136253. * doc :
  136254. * @example : just set a particle position or velocity and recycle conditions
  136255. * @param particle The particle to update
  136256. * @returns the updated particle
  136257. */
  136258. updateParticle(particle: CloudPoint): CloudPoint;
  136259. /**
  136260. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136261. * This does nothing and may be overwritten by the user.
  136262. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136263. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136264. * @param update the boolean update value actually passed to setParticles()
  136265. */
  136266. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136267. /**
  136268. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136269. * This will be passed three parameters.
  136270. * This does nothing and may be overwritten by the user.
  136271. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136272. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136273. * @param update the boolean update value actually passed to setParticles()
  136274. */
  136275. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136276. }
  136277. }
  136278. declare module BABYLON {
  136279. /**
  136280. * Represents one particle of a points cloud system.
  136281. */
  136282. export class CloudPoint {
  136283. /**
  136284. * particle global index
  136285. */
  136286. idx: number;
  136287. /**
  136288. * The color of the particle
  136289. */
  136290. color: Nullable<Color4>;
  136291. /**
  136292. * The world space position of the particle.
  136293. */
  136294. position: Vector3;
  136295. /**
  136296. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136297. */
  136298. rotation: Vector3;
  136299. /**
  136300. * The world space rotation quaternion of the particle.
  136301. */
  136302. rotationQuaternion: Nullable<Quaternion>;
  136303. /**
  136304. * The uv of the particle.
  136305. */
  136306. uv: Nullable<Vector2>;
  136307. /**
  136308. * The current speed of the particle.
  136309. */
  136310. velocity: Vector3;
  136311. /**
  136312. * The pivot point in the particle local space.
  136313. */
  136314. pivot: Vector3;
  136315. /**
  136316. * Must the particle be translated from its pivot point in its local space ?
  136317. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136318. * Default : false
  136319. */
  136320. translateFromPivot: boolean;
  136321. /**
  136322. * Index of this particle in the global "positions" array (Internal use)
  136323. * @hidden
  136324. */
  136325. _pos: number;
  136326. /**
  136327. * @hidden Index of this particle in the global "indices" array (Internal use)
  136328. */
  136329. _ind: number;
  136330. /**
  136331. * Group this particle belongs to
  136332. */
  136333. _group: PointsGroup;
  136334. /**
  136335. * Group id of this particle
  136336. */
  136337. groupId: number;
  136338. /**
  136339. * Index of the particle in its group id (Internal use)
  136340. */
  136341. idxInGroup: number;
  136342. /**
  136343. * @hidden Particle BoundingInfo object (Internal use)
  136344. */
  136345. _boundingInfo: BoundingInfo;
  136346. /**
  136347. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136348. */
  136349. _pcs: PointsCloudSystem;
  136350. /**
  136351. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136352. */
  136353. _stillInvisible: boolean;
  136354. /**
  136355. * @hidden Last computed particle rotation matrix
  136356. */
  136357. _rotationMatrix: number[];
  136358. /**
  136359. * Parent particle Id, if any.
  136360. * Default null.
  136361. */
  136362. parentId: Nullable<number>;
  136363. /**
  136364. * @hidden Internal global position in the PCS.
  136365. */
  136366. _globalPosition: Vector3;
  136367. /**
  136368. * Creates a Point Cloud object.
  136369. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136370. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136371. * @param group (PointsGroup) is the group the particle belongs to
  136372. * @param groupId (integer) is the group identifier in the PCS.
  136373. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136374. * @param pcs defines the PCS it is associated to
  136375. */
  136376. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136377. /**
  136378. * get point size
  136379. */
  136380. get size(): Vector3;
  136381. /**
  136382. * Set point size
  136383. */
  136384. set size(scale: Vector3);
  136385. /**
  136386. * Legacy support, changed quaternion to rotationQuaternion
  136387. */
  136388. get quaternion(): Nullable<Quaternion>;
  136389. /**
  136390. * Legacy support, changed quaternion to rotationQuaternion
  136391. */
  136392. set quaternion(q: Nullable<Quaternion>);
  136393. /**
  136394. * Returns a boolean. True if the particle intersects a mesh, else false
  136395. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136396. * @param target is the object (point or mesh) what the intersection is computed against
  136397. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136398. * @returns true if it intersects
  136399. */
  136400. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136401. /**
  136402. * get the rotation matrix of the particle
  136403. * @hidden
  136404. */
  136405. getRotationMatrix(m: Matrix): void;
  136406. }
  136407. /**
  136408. * Represents a group of points in a points cloud system
  136409. * * PCS internal tool, don't use it manually.
  136410. */
  136411. export class PointsGroup {
  136412. /**
  136413. * The group id
  136414. * @hidden
  136415. */
  136416. groupID: number;
  136417. /**
  136418. * image data for group (internal use)
  136419. * @hidden
  136420. */
  136421. _groupImageData: Nullable<ArrayBufferView>;
  136422. /**
  136423. * Image Width (internal use)
  136424. * @hidden
  136425. */
  136426. _groupImgWidth: number;
  136427. /**
  136428. * Image Height (internal use)
  136429. * @hidden
  136430. */
  136431. _groupImgHeight: number;
  136432. /**
  136433. * Custom position function (internal use)
  136434. * @hidden
  136435. */
  136436. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136437. /**
  136438. * density per facet for surface points
  136439. * @hidden
  136440. */
  136441. _groupDensity: number[];
  136442. /**
  136443. * Only when points are colored by texture carries pointer to texture list array
  136444. * @hidden
  136445. */
  136446. _textureNb: number;
  136447. /**
  136448. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136449. * PCS internal tool, don't use it manually.
  136450. * @hidden
  136451. */
  136452. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136453. }
  136454. }
  136455. declare module BABYLON {
  136456. interface Scene {
  136457. /** @hidden (Backing field) */
  136458. _physicsEngine: Nullable<IPhysicsEngine>;
  136459. /** @hidden */
  136460. _physicsTimeAccumulator: number;
  136461. /**
  136462. * Gets the current physics engine
  136463. * @returns a IPhysicsEngine or null if none attached
  136464. */
  136465. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136466. /**
  136467. * Enables physics to the current scene
  136468. * @param gravity defines the scene's gravity for the physics engine
  136469. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136470. * @return a boolean indicating if the physics engine was initialized
  136471. */
  136472. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136473. /**
  136474. * Disables and disposes the physics engine associated with the scene
  136475. */
  136476. disablePhysicsEngine(): void;
  136477. /**
  136478. * Gets a boolean indicating if there is an active physics engine
  136479. * @returns a boolean indicating if there is an active physics engine
  136480. */
  136481. isPhysicsEnabled(): boolean;
  136482. /**
  136483. * Deletes a physics compound impostor
  136484. * @param compound defines the compound to delete
  136485. */
  136486. deleteCompoundImpostor(compound: any): void;
  136487. /**
  136488. * An event triggered when physic simulation is about to be run
  136489. */
  136490. onBeforePhysicsObservable: Observable<Scene>;
  136491. /**
  136492. * An event triggered when physic simulation has been done
  136493. */
  136494. onAfterPhysicsObservable: Observable<Scene>;
  136495. }
  136496. interface AbstractMesh {
  136497. /** @hidden */
  136498. _physicsImpostor: Nullable<PhysicsImpostor>;
  136499. /**
  136500. * Gets or sets impostor used for physic simulation
  136501. * @see http://doc.babylonjs.com/features/physics_engine
  136502. */
  136503. physicsImpostor: Nullable<PhysicsImpostor>;
  136504. /**
  136505. * Gets the current physics impostor
  136506. * @see http://doc.babylonjs.com/features/physics_engine
  136507. * @returns a physics impostor or null
  136508. */
  136509. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136510. /** Apply a physic impulse to the mesh
  136511. * @param force defines the force to apply
  136512. * @param contactPoint defines where to apply the force
  136513. * @returns the current mesh
  136514. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136515. */
  136516. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136517. /**
  136518. * Creates a physic joint between two meshes
  136519. * @param otherMesh defines the other mesh to use
  136520. * @param pivot1 defines the pivot to use on this mesh
  136521. * @param pivot2 defines the pivot to use on the other mesh
  136522. * @param options defines additional options (can be plugin dependent)
  136523. * @returns the current mesh
  136524. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136525. */
  136526. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136527. /** @hidden */
  136528. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136529. }
  136530. /**
  136531. * Defines the physics engine scene component responsible to manage a physics engine
  136532. */
  136533. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136534. /**
  136535. * The component name helpful to identify the component in the list of scene components.
  136536. */
  136537. readonly name: string;
  136538. /**
  136539. * The scene the component belongs to.
  136540. */
  136541. scene: Scene;
  136542. /**
  136543. * Creates a new instance of the component for the given scene
  136544. * @param scene Defines the scene to register the component in
  136545. */
  136546. constructor(scene: Scene);
  136547. /**
  136548. * Registers the component in a given scene
  136549. */
  136550. register(): void;
  136551. /**
  136552. * Rebuilds the elements related to this component in case of
  136553. * context lost for instance.
  136554. */
  136555. rebuild(): void;
  136556. /**
  136557. * Disposes the component and the associated ressources
  136558. */
  136559. dispose(): void;
  136560. }
  136561. }
  136562. declare module BABYLON {
  136563. /**
  136564. * A helper for physics simulations
  136565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136566. */
  136567. export class PhysicsHelper {
  136568. private _scene;
  136569. private _physicsEngine;
  136570. /**
  136571. * Initializes the Physics helper
  136572. * @param scene Babylon.js scene
  136573. */
  136574. constructor(scene: Scene);
  136575. /**
  136576. * Applies a radial explosion impulse
  136577. * @param origin the origin of the explosion
  136578. * @param radiusOrEventOptions the radius or the options of radial explosion
  136579. * @param strength the explosion strength
  136580. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136581. * @returns A physics radial explosion event, or null
  136582. */
  136583. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136584. /**
  136585. * Applies a radial explosion force
  136586. * @param origin the origin of the explosion
  136587. * @param radiusOrEventOptions the radius or the options of radial explosion
  136588. * @param strength the explosion strength
  136589. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136590. * @returns A physics radial explosion event, or null
  136591. */
  136592. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136593. /**
  136594. * Creates a gravitational field
  136595. * @param origin the origin of the explosion
  136596. * @param radiusOrEventOptions the radius or the options of radial explosion
  136597. * @param strength the explosion strength
  136598. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136599. * @returns A physics gravitational field event, or null
  136600. */
  136601. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136602. /**
  136603. * Creates a physics updraft event
  136604. * @param origin the origin of the updraft
  136605. * @param radiusOrEventOptions the radius or the options of the updraft
  136606. * @param strength the strength of the updraft
  136607. * @param height the height of the updraft
  136608. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136609. * @returns A physics updraft event, or null
  136610. */
  136611. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136612. /**
  136613. * Creates a physics vortex event
  136614. * @param origin the of the vortex
  136615. * @param radiusOrEventOptions the radius or the options of the vortex
  136616. * @param strength the strength of the vortex
  136617. * @param height the height of the vortex
  136618. * @returns a Physics vortex event, or null
  136619. * A physics vortex event or null
  136620. */
  136621. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136622. }
  136623. /**
  136624. * Represents a physics radial explosion event
  136625. */
  136626. class PhysicsRadialExplosionEvent {
  136627. private _scene;
  136628. private _options;
  136629. private _sphere;
  136630. private _dataFetched;
  136631. /**
  136632. * Initializes a radial explosioin event
  136633. * @param _scene BabylonJS scene
  136634. * @param _options The options for the vortex event
  136635. */
  136636. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136637. /**
  136638. * Returns the data related to the radial explosion event (sphere).
  136639. * @returns The radial explosion event data
  136640. */
  136641. getData(): PhysicsRadialExplosionEventData;
  136642. /**
  136643. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136644. * @param impostor A physics imposter
  136645. * @param origin the origin of the explosion
  136646. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136647. */
  136648. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136649. /**
  136650. * Triggers affecterd impostors callbacks
  136651. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136652. */
  136653. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136654. /**
  136655. * Disposes the sphere.
  136656. * @param force Specifies if the sphere should be disposed by force
  136657. */
  136658. dispose(force?: boolean): void;
  136659. /*** Helpers ***/
  136660. private _prepareSphere;
  136661. private _intersectsWithSphere;
  136662. }
  136663. /**
  136664. * Represents a gravitational field event
  136665. */
  136666. class PhysicsGravitationalFieldEvent {
  136667. private _physicsHelper;
  136668. private _scene;
  136669. private _origin;
  136670. private _options;
  136671. private _tickCallback;
  136672. private _sphere;
  136673. private _dataFetched;
  136674. /**
  136675. * Initializes the physics gravitational field event
  136676. * @param _physicsHelper A physics helper
  136677. * @param _scene BabylonJS scene
  136678. * @param _origin The origin position of the gravitational field event
  136679. * @param _options The options for the vortex event
  136680. */
  136681. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136682. /**
  136683. * Returns the data related to the gravitational field event (sphere).
  136684. * @returns A gravitational field event
  136685. */
  136686. getData(): PhysicsGravitationalFieldEventData;
  136687. /**
  136688. * Enables the gravitational field.
  136689. */
  136690. enable(): void;
  136691. /**
  136692. * Disables the gravitational field.
  136693. */
  136694. disable(): void;
  136695. /**
  136696. * Disposes the sphere.
  136697. * @param force The force to dispose from the gravitational field event
  136698. */
  136699. dispose(force?: boolean): void;
  136700. private _tick;
  136701. }
  136702. /**
  136703. * Represents a physics updraft event
  136704. */
  136705. class PhysicsUpdraftEvent {
  136706. private _scene;
  136707. private _origin;
  136708. private _options;
  136709. private _physicsEngine;
  136710. private _originTop;
  136711. private _originDirection;
  136712. private _tickCallback;
  136713. private _cylinder;
  136714. private _cylinderPosition;
  136715. private _dataFetched;
  136716. /**
  136717. * Initializes the physics updraft event
  136718. * @param _scene BabylonJS scene
  136719. * @param _origin The origin position of the updraft
  136720. * @param _options The options for the updraft event
  136721. */
  136722. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136723. /**
  136724. * Returns the data related to the updraft event (cylinder).
  136725. * @returns A physics updraft event
  136726. */
  136727. getData(): PhysicsUpdraftEventData;
  136728. /**
  136729. * Enables the updraft.
  136730. */
  136731. enable(): void;
  136732. /**
  136733. * Disables the updraft.
  136734. */
  136735. disable(): void;
  136736. /**
  136737. * Disposes the cylinder.
  136738. * @param force Specifies if the updraft should be disposed by force
  136739. */
  136740. dispose(force?: boolean): void;
  136741. private getImpostorHitData;
  136742. private _tick;
  136743. /*** Helpers ***/
  136744. private _prepareCylinder;
  136745. private _intersectsWithCylinder;
  136746. }
  136747. /**
  136748. * Represents a physics vortex event
  136749. */
  136750. class PhysicsVortexEvent {
  136751. private _scene;
  136752. private _origin;
  136753. private _options;
  136754. private _physicsEngine;
  136755. private _originTop;
  136756. private _tickCallback;
  136757. private _cylinder;
  136758. private _cylinderPosition;
  136759. private _dataFetched;
  136760. /**
  136761. * Initializes the physics vortex event
  136762. * @param _scene The BabylonJS scene
  136763. * @param _origin The origin position of the vortex
  136764. * @param _options The options for the vortex event
  136765. */
  136766. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136767. /**
  136768. * Returns the data related to the vortex event (cylinder).
  136769. * @returns The physics vortex event data
  136770. */
  136771. getData(): PhysicsVortexEventData;
  136772. /**
  136773. * Enables the vortex.
  136774. */
  136775. enable(): void;
  136776. /**
  136777. * Disables the cortex.
  136778. */
  136779. disable(): void;
  136780. /**
  136781. * Disposes the sphere.
  136782. * @param force
  136783. */
  136784. dispose(force?: boolean): void;
  136785. private getImpostorHitData;
  136786. private _tick;
  136787. /*** Helpers ***/
  136788. private _prepareCylinder;
  136789. private _intersectsWithCylinder;
  136790. }
  136791. /**
  136792. * Options fot the radial explosion event
  136793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136794. */
  136795. export class PhysicsRadialExplosionEventOptions {
  136796. /**
  136797. * The radius of the sphere for the radial explosion.
  136798. */
  136799. radius: number;
  136800. /**
  136801. * The strenth of the explosion.
  136802. */
  136803. strength: number;
  136804. /**
  136805. * The strenght of the force in correspondence to the distance of the affected object
  136806. */
  136807. falloff: PhysicsRadialImpulseFalloff;
  136808. /**
  136809. * Sphere options for the radial explosion.
  136810. */
  136811. sphere: {
  136812. segments: number;
  136813. diameter: number;
  136814. };
  136815. /**
  136816. * Sphere options for the radial explosion.
  136817. */
  136818. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136819. }
  136820. /**
  136821. * Options fot the updraft event
  136822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136823. */
  136824. export class PhysicsUpdraftEventOptions {
  136825. /**
  136826. * The radius of the cylinder for the vortex
  136827. */
  136828. radius: number;
  136829. /**
  136830. * The strenth of the updraft.
  136831. */
  136832. strength: number;
  136833. /**
  136834. * The height of the cylinder for the updraft.
  136835. */
  136836. height: number;
  136837. /**
  136838. * The mode for the the updraft.
  136839. */
  136840. updraftMode: PhysicsUpdraftMode;
  136841. }
  136842. /**
  136843. * Options fot the vortex event
  136844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136845. */
  136846. export class PhysicsVortexEventOptions {
  136847. /**
  136848. * The radius of the cylinder for the vortex
  136849. */
  136850. radius: number;
  136851. /**
  136852. * The strenth of the vortex.
  136853. */
  136854. strength: number;
  136855. /**
  136856. * The height of the cylinder for the vortex.
  136857. */
  136858. height: number;
  136859. /**
  136860. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136861. */
  136862. centripetalForceThreshold: number;
  136863. /**
  136864. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136865. */
  136866. centripetalForceMultiplier: number;
  136867. /**
  136868. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136869. */
  136870. centrifugalForceMultiplier: number;
  136871. /**
  136872. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136873. */
  136874. updraftForceMultiplier: number;
  136875. }
  136876. /**
  136877. * The strenght of the force in correspondence to the distance of the affected object
  136878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136879. */
  136880. export enum PhysicsRadialImpulseFalloff {
  136881. /** Defines that impulse is constant in strength across it's whole radius */
  136882. Constant = 0,
  136883. /** Defines that impulse gets weaker if it's further from the origin */
  136884. Linear = 1
  136885. }
  136886. /**
  136887. * The strength of the force in correspondence to the distance of the affected object
  136888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136889. */
  136890. export enum PhysicsUpdraftMode {
  136891. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136892. Center = 0,
  136893. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136894. Perpendicular = 1
  136895. }
  136896. /**
  136897. * Interface for a physics hit data
  136898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136899. */
  136900. export interface PhysicsHitData {
  136901. /**
  136902. * The force applied at the contact point
  136903. */
  136904. force: Vector3;
  136905. /**
  136906. * The contact point
  136907. */
  136908. contactPoint: Vector3;
  136909. /**
  136910. * The distance from the origin to the contact point
  136911. */
  136912. distanceFromOrigin: number;
  136913. }
  136914. /**
  136915. * Interface for radial explosion event data
  136916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136917. */
  136918. export interface PhysicsRadialExplosionEventData {
  136919. /**
  136920. * A sphere used for the radial explosion event
  136921. */
  136922. sphere: Mesh;
  136923. }
  136924. /**
  136925. * Interface for gravitational field event data
  136926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136927. */
  136928. export interface PhysicsGravitationalFieldEventData {
  136929. /**
  136930. * A sphere mesh used for the gravitational field event
  136931. */
  136932. sphere: Mesh;
  136933. }
  136934. /**
  136935. * Interface for updraft event data
  136936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136937. */
  136938. export interface PhysicsUpdraftEventData {
  136939. /**
  136940. * A cylinder used for the updraft event
  136941. */
  136942. cylinder: Mesh;
  136943. }
  136944. /**
  136945. * Interface for vortex event data
  136946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136947. */
  136948. export interface PhysicsVortexEventData {
  136949. /**
  136950. * A cylinder used for the vortex event
  136951. */
  136952. cylinder: Mesh;
  136953. }
  136954. /**
  136955. * Interface for an affected physics impostor
  136956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136957. */
  136958. export interface PhysicsAffectedImpostorWithData {
  136959. /**
  136960. * The impostor affected by the effect
  136961. */
  136962. impostor: PhysicsImpostor;
  136963. /**
  136964. * The data about the hit/horce from the explosion
  136965. */
  136966. hitData: PhysicsHitData;
  136967. }
  136968. }
  136969. declare module BABYLON {
  136970. /** @hidden */
  136971. export var blackAndWhitePixelShader: {
  136972. name: string;
  136973. shader: string;
  136974. };
  136975. }
  136976. declare module BABYLON {
  136977. /**
  136978. * Post process used to render in black and white
  136979. */
  136980. export class BlackAndWhitePostProcess extends PostProcess {
  136981. /**
  136982. * Linear about to convert he result to black and white (default: 1)
  136983. */
  136984. degree: number;
  136985. /**
  136986. * Creates a black and white post process
  136987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136988. * @param name The name of the effect.
  136989. * @param options The required width/height ratio to downsize to before computing the render pass.
  136990. * @param camera The camera to apply the render pass to.
  136991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136992. * @param engine The engine which the post process will be applied. (default: current engine)
  136993. * @param reusable If the post process can be reused on the same frame. (default: false)
  136994. */
  136995. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136996. }
  136997. }
  136998. declare module BABYLON {
  136999. /**
  137000. * This represents a set of one or more post processes in Babylon.
  137001. * A post process can be used to apply a shader to a texture after it is rendered.
  137002. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137003. */
  137004. export class PostProcessRenderEffect {
  137005. private _postProcesses;
  137006. private _getPostProcesses;
  137007. private _singleInstance;
  137008. private _cameras;
  137009. private _indicesForCamera;
  137010. /**
  137011. * Name of the effect
  137012. * @hidden
  137013. */
  137014. _name: string;
  137015. /**
  137016. * Instantiates a post process render effect.
  137017. * A post process can be used to apply a shader to a texture after it is rendered.
  137018. * @param engine The engine the effect is tied to
  137019. * @param name The name of the effect
  137020. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137021. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137022. */
  137023. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137024. /**
  137025. * Checks if all the post processes in the effect are supported.
  137026. */
  137027. get isSupported(): boolean;
  137028. /**
  137029. * Updates the current state of the effect
  137030. * @hidden
  137031. */
  137032. _update(): void;
  137033. /**
  137034. * Attaches the effect on cameras
  137035. * @param cameras The camera to attach to.
  137036. * @hidden
  137037. */
  137038. _attachCameras(cameras: Camera): void;
  137039. /**
  137040. * Attaches the effect on cameras
  137041. * @param cameras The camera to attach to.
  137042. * @hidden
  137043. */
  137044. _attachCameras(cameras: Camera[]): void;
  137045. /**
  137046. * Detaches the effect on cameras
  137047. * @param cameras The camera to detatch from.
  137048. * @hidden
  137049. */
  137050. _detachCameras(cameras: Camera): void;
  137051. /**
  137052. * Detatches the effect on cameras
  137053. * @param cameras The camera to detatch from.
  137054. * @hidden
  137055. */
  137056. _detachCameras(cameras: Camera[]): void;
  137057. /**
  137058. * Enables the effect on given cameras
  137059. * @param cameras The camera to enable.
  137060. * @hidden
  137061. */
  137062. _enable(cameras: Camera): void;
  137063. /**
  137064. * Enables the effect on given cameras
  137065. * @param cameras The camera to enable.
  137066. * @hidden
  137067. */
  137068. _enable(cameras: Nullable<Camera[]>): void;
  137069. /**
  137070. * Disables the effect on the given cameras
  137071. * @param cameras The camera to disable.
  137072. * @hidden
  137073. */
  137074. _disable(cameras: Camera): void;
  137075. /**
  137076. * Disables the effect on the given cameras
  137077. * @param cameras The camera to disable.
  137078. * @hidden
  137079. */
  137080. _disable(cameras: Nullable<Camera[]>): void;
  137081. /**
  137082. * Gets a list of the post processes contained in the effect.
  137083. * @param camera The camera to get the post processes on.
  137084. * @returns The list of the post processes in the effect.
  137085. */
  137086. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137087. }
  137088. }
  137089. declare module BABYLON {
  137090. /** @hidden */
  137091. export var extractHighlightsPixelShader: {
  137092. name: string;
  137093. shader: string;
  137094. };
  137095. }
  137096. declare module BABYLON {
  137097. /**
  137098. * 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.
  137099. */
  137100. export class ExtractHighlightsPostProcess extends PostProcess {
  137101. /**
  137102. * The luminance threshold, pixels below this value will be set to black.
  137103. */
  137104. threshold: number;
  137105. /** @hidden */
  137106. _exposure: number;
  137107. /**
  137108. * Post process which has the input texture to be used when performing highlight extraction
  137109. * @hidden
  137110. */
  137111. _inputPostProcess: Nullable<PostProcess>;
  137112. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137113. }
  137114. }
  137115. declare module BABYLON {
  137116. /** @hidden */
  137117. export var bloomMergePixelShader: {
  137118. name: string;
  137119. shader: string;
  137120. };
  137121. }
  137122. declare module BABYLON {
  137123. /**
  137124. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137125. */
  137126. export class BloomMergePostProcess extends PostProcess {
  137127. /** Weight of the bloom to be added to the original input. */
  137128. weight: number;
  137129. /**
  137130. * Creates a new instance of @see BloomMergePostProcess
  137131. * @param name The name of the effect.
  137132. * @param originalFromInput Post process which's input will be used for the merge.
  137133. * @param blurred Blurred highlights post process which's output will be used.
  137134. * @param weight Weight of the bloom to be added to the original input.
  137135. * @param options The required width/height ratio to downsize to before computing the render pass.
  137136. * @param camera The camera to apply the render pass to.
  137137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137138. * @param engine The engine which the post process will be applied. (default: current engine)
  137139. * @param reusable If the post process can be reused on the same frame. (default: false)
  137140. * @param textureType Type of textures used when performing the post process. (default: 0)
  137141. * @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)
  137142. */
  137143. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137144. /** Weight of the bloom to be added to the original input. */
  137145. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137146. }
  137147. }
  137148. declare module BABYLON {
  137149. /**
  137150. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137151. */
  137152. export class BloomEffect extends PostProcessRenderEffect {
  137153. private bloomScale;
  137154. /**
  137155. * @hidden Internal
  137156. */
  137157. _effects: Array<PostProcess>;
  137158. /**
  137159. * @hidden Internal
  137160. */
  137161. _downscale: ExtractHighlightsPostProcess;
  137162. private _blurX;
  137163. private _blurY;
  137164. private _merge;
  137165. /**
  137166. * The luminance threshold to find bright areas of the image to bloom.
  137167. */
  137168. get threshold(): number;
  137169. set threshold(value: number);
  137170. /**
  137171. * The strength of the bloom.
  137172. */
  137173. get weight(): number;
  137174. set weight(value: number);
  137175. /**
  137176. * Specifies the size of the bloom blur kernel, relative to the final output size
  137177. */
  137178. get kernel(): number;
  137179. set kernel(value: number);
  137180. /**
  137181. * Creates a new instance of @see BloomEffect
  137182. * @param scene The scene the effect belongs to.
  137183. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137184. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137185. * @param bloomWeight The the strength of bloom.
  137186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137187. * @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)
  137188. */
  137189. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137190. /**
  137191. * Disposes each of the internal effects for a given camera.
  137192. * @param camera The camera to dispose the effect on.
  137193. */
  137194. disposeEffects(camera: Camera): void;
  137195. /**
  137196. * @hidden Internal
  137197. */
  137198. _updateEffects(): void;
  137199. /**
  137200. * Internal
  137201. * @returns if all the contained post processes are ready.
  137202. * @hidden
  137203. */
  137204. _isReady(): boolean;
  137205. }
  137206. }
  137207. declare module BABYLON {
  137208. /** @hidden */
  137209. export var chromaticAberrationPixelShader: {
  137210. name: string;
  137211. shader: string;
  137212. };
  137213. }
  137214. declare module BABYLON {
  137215. /**
  137216. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137217. */
  137218. export class ChromaticAberrationPostProcess extends PostProcess {
  137219. /**
  137220. * The amount of seperation of rgb channels (default: 30)
  137221. */
  137222. aberrationAmount: number;
  137223. /**
  137224. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137225. */
  137226. radialIntensity: number;
  137227. /**
  137228. * 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))
  137229. */
  137230. direction: Vector2;
  137231. /**
  137232. * 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))
  137233. */
  137234. centerPosition: Vector2;
  137235. /**
  137236. * Creates a new instance ChromaticAberrationPostProcess
  137237. * @param name The name of the effect.
  137238. * @param screenWidth The width of the screen to apply the effect on.
  137239. * @param screenHeight The height of the screen to apply the effect on.
  137240. * @param options The required width/height ratio to downsize to before computing the render pass.
  137241. * @param camera The camera to apply the render pass to.
  137242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137243. * @param engine The engine which the post process will be applied. (default: current engine)
  137244. * @param reusable If the post process can be reused on the same frame. (default: false)
  137245. * @param textureType Type of textures used when performing the post process. (default: 0)
  137246. * @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)
  137247. */
  137248. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137249. }
  137250. }
  137251. declare module BABYLON {
  137252. /** @hidden */
  137253. export var circleOfConfusionPixelShader: {
  137254. name: string;
  137255. shader: string;
  137256. };
  137257. }
  137258. declare module BABYLON {
  137259. /**
  137260. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137261. */
  137262. export class CircleOfConfusionPostProcess extends PostProcess {
  137263. /**
  137264. * 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.
  137265. */
  137266. lensSize: number;
  137267. /**
  137268. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137269. */
  137270. fStop: number;
  137271. /**
  137272. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137273. */
  137274. focusDistance: number;
  137275. /**
  137276. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137277. */
  137278. focalLength: number;
  137279. private _depthTexture;
  137280. /**
  137281. * Creates a new instance CircleOfConfusionPostProcess
  137282. * @param name The name of the effect.
  137283. * @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.
  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, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137293. /**
  137294. * 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.
  137295. */
  137296. set depthTexture(value: RenderTargetTexture);
  137297. }
  137298. }
  137299. declare module BABYLON {
  137300. /** @hidden */
  137301. export var colorCorrectionPixelShader: {
  137302. name: string;
  137303. shader: string;
  137304. };
  137305. }
  137306. declare module BABYLON {
  137307. /**
  137308. *
  137309. * This post-process allows the modification of rendered colors by using
  137310. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137311. *
  137312. * The object needs to be provided an url to a texture containing the color
  137313. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137314. * Use an image editing software to tweak the LUT to match your needs.
  137315. *
  137316. * For an example of a color LUT, see here:
  137317. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137318. * For explanations on color grading, see here:
  137319. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137320. *
  137321. */
  137322. export class ColorCorrectionPostProcess extends PostProcess {
  137323. private _colorTableTexture;
  137324. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137325. }
  137326. }
  137327. declare module BABYLON {
  137328. /** @hidden */
  137329. export var convolutionPixelShader: {
  137330. name: string;
  137331. shader: string;
  137332. };
  137333. }
  137334. declare module BABYLON {
  137335. /**
  137336. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137337. * input texture to perform effects such as edge detection or sharpening
  137338. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137339. */
  137340. export class ConvolutionPostProcess extends PostProcess {
  137341. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137342. kernel: number[];
  137343. /**
  137344. * Creates a new instance ConvolutionPostProcess
  137345. * @param name The name of the effect.
  137346. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137347. * @param options The required width/height ratio to downsize to before computing the render pass.
  137348. * @param camera The camera to apply the render pass to.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  137353. */
  137354. constructor(name: string,
  137355. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137356. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137357. /**
  137358. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137359. */
  137360. static EdgeDetect0Kernel: number[];
  137361. /**
  137362. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137363. */
  137364. static EdgeDetect1Kernel: number[];
  137365. /**
  137366. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137367. */
  137368. static EdgeDetect2Kernel: number[];
  137369. /**
  137370. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137371. */
  137372. static SharpenKernel: number[];
  137373. /**
  137374. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137375. */
  137376. static EmbossKernel: number[];
  137377. /**
  137378. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137379. */
  137380. static GaussianKernel: number[];
  137381. }
  137382. }
  137383. declare module BABYLON {
  137384. /**
  137385. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137386. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137387. * based on samples that have a large difference in distance than the center pixel.
  137388. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137389. */
  137390. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137391. direction: Vector2;
  137392. /**
  137393. * Creates a new instance CircleOfConfusionPostProcess
  137394. * @param name The name of the effect.
  137395. * @param scene The scene the effect belongs to.
  137396. * @param direction The direction the blur should be applied.
  137397. * @param kernel The size of the kernel used to blur.
  137398. * @param options The required width/height ratio to downsize to before computing the render pass.
  137399. * @param camera The camera to apply the render pass to.
  137400. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137401. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137403. * @param engine The engine which the post process will be applied. (default: current engine)
  137404. * @param reusable If the post process can be reused on the same frame. (default: false)
  137405. * @param textureType Type of textures used when performing the post process. (default: 0)
  137406. * @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)
  137407. */
  137408. 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);
  137409. }
  137410. }
  137411. declare module BABYLON {
  137412. /** @hidden */
  137413. export var depthOfFieldMergePixelShader: {
  137414. name: string;
  137415. shader: string;
  137416. };
  137417. }
  137418. declare module BABYLON {
  137419. /**
  137420. * Options to be set when merging outputs from the default pipeline.
  137421. */
  137422. export class DepthOfFieldMergePostProcessOptions {
  137423. /**
  137424. * The original image to merge on top of
  137425. */
  137426. originalFromInput: PostProcess;
  137427. /**
  137428. * Parameters to perform the merge of the depth of field effect
  137429. */
  137430. depthOfField?: {
  137431. circleOfConfusion: PostProcess;
  137432. blurSteps: Array<PostProcess>;
  137433. };
  137434. /**
  137435. * Parameters to perform the merge of bloom effect
  137436. */
  137437. bloom?: {
  137438. blurred: PostProcess;
  137439. weight: number;
  137440. };
  137441. }
  137442. /**
  137443. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137444. */
  137445. export class DepthOfFieldMergePostProcess extends PostProcess {
  137446. private blurSteps;
  137447. /**
  137448. * Creates a new instance of DepthOfFieldMergePostProcess
  137449. * @param name The name of the effect.
  137450. * @param originalFromInput Post process which's input will be used for the merge.
  137451. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137452. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137453. * @param options The required width/height ratio to downsize to before computing the render pass.
  137454. * @param camera The camera to apply the render pass to.
  137455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137456. * @param engine The engine which the post process will be applied. (default: current engine)
  137457. * @param reusable If the post process can be reused on the same frame. (default: false)
  137458. * @param textureType Type of textures used when performing the post process. (default: 0)
  137459. * @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)
  137460. */
  137461. 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);
  137462. /**
  137463. * Updates the effect with the current post process compile time values and recompiles the shader.
  137464. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137465. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137466. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137467. * @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
  137468. * @param onCompiled Called when the shader has been compiled.
  137469. * @param onError Called if there is an error when compiling a shader.
  137470. */
  137471. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137472. }
  137473. }
  137474. declare module BABYLON {
  137475. /**
  137476. * Specifies the level of max blur that should be applied when using the depth of field effect
  137477. */
  137478. export enum DepthOfFieldEffectBlurLevel {
  137479. /**
  137480. * Subtle blur
  137481. */
  137482. Low = 0,
  137483. /**
  137484. * Medium blur
  137485. */
  137486. Medium = 1,
  137487. /**
  137488. * Large blur
  137489. */
  137490. High = 2
  137491. }
  137492. /**
  137493. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137494. */
  137495. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137496. private _circleOfConfusion;
  137497. /**
  137498. * @hidden Internal, blurs from high to low
  137499. */
  137500. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137501. private _depthOfFieldBlurY;
  137502. private _dofMerge;
  137503. /**
  137504. * @hidden Internal post processes in depth of field effect
  137505. */
  137506. _effects: Array<PostProcess>;
  137507. /**
  137508. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137509. */
  137510. set focalLength(value: number);
  137511. get focalLength(): number;
  137512. /**
  137513. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137514. */
  137515. set fStop(value: number);
  137516. get fStop(): number;
  137517. /**
  137518. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137519. */
  137520. set focusDistance(value: number);
  137521. get focusDistance(): number;
  137522. /**
  137523. * 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.
  137524. */
  137525. set lensSize(value: number);
  137526. get lensSize(): number;
  137527. /**
  137528. * Creates a new instance DepthOfFieldEffect
  137529. * @param scene The scene the effect belongs to.
  137530. * @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.
  137531. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137532. * @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)
  137533. */
  137534. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137535. /**
  137536. * Get the current class name of the current effet
  137537. * @returns "DepthOfFieldEffect"
  137538. */
  137539. getClassName(): string;
  137540. /**
  137541. * 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.
  137542. */
  137543. set depthTexture(value: RenderTargetTexture);
  137544. /**
  137545. * Disposes each of the internal effects for a given camera.
  137546. * @param camera The camera to dispose the effect on.
  137547. */
  137548. disposeEffects(camera: Camera): void;
  137549. /**
  137550. * @hidden Internal
  137551. */
  137552. _updateEffects(): void;
  137553. /**
  137554. * Internal
  137555. * @returns if all the contained post processes are ready.
  137556. * @hidden
  137557. */
  137558. _isReady(): boolean;
  137559. }
  137560. }
  137561. declare module BABYLON {
  137562. /** @hidden */
  137563. export var displayPassPixelShader: {
  137564. name: string;
  137565. shader: string;
  137566. };
  137567. }
  137568. declare module BABYLON {
  137569. /**
  137570. * DisplayPassPostProcess which produces an output the same as it's input
  137571. */
  137572. export class DisplayPassPostProcess extends PostProcess {
  137573. /**
  137574. * Creates the DisplayPassPostProcess
  137575. * @param name The name of the effect.
  137576. * @param options The required width/height ratio to downsize to before computing the render pass.
  137577. * @param camera The camera to apply the render pass to.
  137578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137579. * @param engine The engine which the post process will be applied. (default: current engine)
  137580. * @param reusable If the post process can be reused on the same frame. (default: false)
  137581. */
  137582. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137583. }
  137584. }
  137585. declare module BABYLON {
  137586. /** @hidden */
  137587. export var filterPixelShader: {
  137588. name: string;
  137589. shader: string;
  137590. };
  137591. }
  137592. declare module BABYLON {
  137593. /**
  137594. * Applies a kernel filter to the image
  137595. */
  137596. export class FilterPostProcess extends PostProcess {
  137597. /** The matrix to be applied to the image */
  137598. kernelMatrix: Matrix;
  137599. /**
  137600. *
  137601. * @param name The name of the effect.
  137602. * @param kernelMatrix The matrix to be applied to the image
  137603. * @param options The required width/height ratio to downsize to before computing the render pass.
  137604. * @param camera The camera to apply the render pass to.
  137605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137606. * @param engine The engine which the post process will be applied. (default: current engine)
  137607. * @param reusable If the post process can be reused on the same frame. (default: false)
  137608. */
  137609. constructor(name: string,
  137610. /** The matrix to be applied to the image */
  137611. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137612. }
  137613. }
  137614. declare module BABYLON {
  137615. /** @hidden */
  137616. export var fxaaPixelShader: {
  137617. name: string;
  137618. shader: string;
  137619. };
  137620. }
  137621. declare module BABYLON {
  137622. /** @hidden */
  137623. export var fxaaVertexShader: {
  137624. name: string;
  137625. shader: string;
  137626. };
  137627. }
  137628. declare module BABYLON {
  137629. /**
  137630. * Fxaa post process
  137631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137632. */
  137633. export class FxaaPostProcess extends PostProcess {
  137634. /** @hidden */
  137635. texelWidth: number;
  137636. /** @hidden */
  137637. texelHeight: number;
  137638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137639. private _getDefines;
  137640. }
  137641. }
  137642. declare module BABYLON {
  137643. /** @hidden */
  137644. export var grainPixelShader: {
  137645. name: string;
  137646. shader: string;
  137647. };
  137648. }
  137649. declare module BABYLON {
  137650. /**
  137651. * The GrainPostProcess adds noise to the image at mid luminance levels
  137652. */
  137653. export class GrainPostProcess extends PostProcess {
  137654. /**
  137655. * The intensity of the grain added (default: 30)
  137656. */
  137657. intensity: number;
  137658. /**
  137659. * If the grain should be randomized on every frame
  137660. */
  137661. animated: boolean;
  137662. /**
  137663. * Creates a new instance of @see GrainPostProcess
  137664. * @param name The name of the effect.
  137665. * @param options The required width/height ratio to downsize to before computing the render pass.
  137666. * @param camera The camera to apply the render pass to.
  137667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137668. * @param engine The engine which the post process will be applied. (default: current engine)
  137669. * @param reusable If the post process can be reused on the same frame. (default: false)
  137670. * @param textureType Type of textures used when performing the post process. (default: 0)
  137671. * @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)
  137672. */
  137673. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137674. }
  137675. }
  137676. declare module BABYLON {
  137677. /** @hidden */
  137678. export var highlightsPixelShader: {
  137679. name: string;
  137680. shader: string;
  137681. };
  137682. }
  137683. declare module BABYLON {
  137684. /**
  137685. * Extracts highlights from the image
  137686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137687. */
  137688. export class HighlightsPostProcess extends PostProcess {
  137689. /**
  137690. * Extracts highlights from the image
  137691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137692. * @param name The name of the effect.
  137693. * @param options The required width/height ratio to downsize to before computing the render pass.
  137694. * @param camera The camera to apply the render pass to.
  137695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137696. * @param engine The engine which the post process will be applied. (default: current engine)
  137697. * @param reusable If the post process can be reused on the same frame. (default: false)
  137698. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137699. */
  137700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137701. }
  137702. }
  137703. declare module BABYLON {
  137704. /** @hidden */
  137705. export var mrtFragmentDeclaration: {
  137706. name: string;
  137707. shader: string;
  137708. };
  137709. }
  137710. declare module BABYLON {
  137711. /** @hidden */
  137712. export var geometryPixelShader: {
  137713. name: string;
  137714. shader: string;
  137715. };
  137716. }
  137717. declare module BABYLON {
  137718. /** @hidden */
  137719. export var geometryVertexShader: {
  137720. name: string;
  137721. shader: string;
  137722. };
  137723. }
  137724. declare module BABYLON {
  137725. /** @hidden */
  137726. interface ISavedTransformationMatrix {
  137727. world: Matrix;
  137728. viewProjection: Matrix;
  137729. }
  137730. /**
  137731. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137732. */
  137733. export class GeometryBufferRenderer {
  137734. /**
  137735. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137736. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137737. */
  137738. static readonly POSITION_TEXTURE_TYPE: number;
  137739. /**
  137740. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137741. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137742. */
  137743. static readonly VELOCITY_TEXTURE_TYPE: number;
  137744. /**
  137745. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137746. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137747. */
  137748. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137749. /**
  137750. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137751. * in order to compute objects velocities when enableVelocity is set to "true"
  137752. * @hidden
  137753. */
  137754. _previousTransformationMatrices: {
  137755. [index: number]: ISavedTransformationMatrix;
  137756. };
  137757. /**
  137758. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137759. * in order to compute objects velocities when enableVelocity is set to "true"
  137760. * @hidden
  137761. */
  137762. _previousBonesTransformationMatrices: {
  137763. [index: number]: Float32Array;
  137764. };
  137765. /**
  137766. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137767. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137768. */
  137769. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137770. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137771. renderTransparentMeshes: boolean;
  137772. private _scene;
  137773. private _multiRenderTarget;
  137774. private _ratio;
  137775. private _enablePosition;
  137776. private _enableVelocity;
  137777. private _enableReflectivity;
  137778. private _positionIndex;
  137779. private _velocityIndex;
  137780. private _reflectivityIndex;
  137781. protected _effect: Effect;
  137782. protected _cachedDefines: string;
  137783. /**
  137784. * Set the render list (meshes to be rendered) used in the G buffer.
  137785. */
  137786. set renderList(meshes: Mesh[]);
  137787. /**
  137788. * Gets wether or not G buffer are supported by the running hardware.
  137789. * This requires draw buffer supports
  137790. */
  137791. get isSupported(): boolean;
  137792. /**
  137793. * Returns the index of the given texture type in the G-Buffer textures array
  137794. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137795. * @returns the index of the given texture type in the G-Buffer textures array
  137796. */
  137797. getTextureIndex(textureType: number): number;
  137798. /**
  137799. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137800. */
  137801. get enablePosition(): boolean;
  137802. /**
  137803. * Sets whether or not objects positions are enabled for the G buffer.
  137804. */
  137805. set enablePosition(enable: boolean);
  137806. /**
  137807. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137808. */
  137809. get enableVelocity(): boolean;
  137810. /**
  137811. * Sets wether or not objects velocities are enabled for the G buffer.
  137812. */
  137813. set enableVelocity(enable: boolean);
  137814. /**
  137815. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137816. */
  137817. get enableReflectivity(): boolean;
  137818. /**
  137819. * Sets wether or not objects roughness are enabled for the G buffer.
  137820. */
  137821. set enableReflectivity(enable: boolean);
  137822. /**
  137823. * Gets the scene associated with the buffer.
  137824. */
  137825. get scene(): Scene;
  137826. /**
  137827. * Gets the ratio used by the buffer during its creation.
  137828. * How big is the buffer related to the main canvas.
  137829. */
  137830. get ratio(): number;
  137831. /** @hidden */
  137832. static _SceneComponentInitialization: (scene: Scene) => void;
  137833. /**
  137834. * Creates a new G Buffer for the scene
  137835. * @param scene The scene the buffer belongs to
  137836. * @param ratio How big is the buffer related to the main canvas.
  137837. */
  137838. constructor(scene: Scene, ratio?: number);
  137839. /**
  137840. * Checks wether everything is ready to render a submesh to the G buffer.
  137841. * @param subMesh the submesh to check readiness for
  137842. * @param useInstances is the mesh drawn using instance or not
  137843. * @returns true if ready otherwise false
  137844. */
  137845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137846. /**
  137847. * Gets the current underlying G Buffer.
  137848. * @returns the buffer
  137849. */
  137850. getGBuffer(): MultiRenderTarget;
  137851. /**
  137852. * Gets the number of samples used to render the buffer (anti aliasing).
  137853. */
  137854. get samples(): number;
  137855. /**
  137856. * Sets the number of samples used to render the buffer (anti aliasing).
  137857. */
  137858. set samples(value: number);
  137859. /**
  137860. * Disposes the renderer and frees up associated resources.
  137861. */
  137862. dispose(): void;
  137863. protected _createRenderTargets(): void;
  137864. private _copyBonesTransformationMatrices;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. interface Scene {
  137869. /** @hidden (Backing field) */
  137870. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137871. /**
  137872. * Gets or Sets the current geometry buffer associated to the scene.
  137873. */
  137874. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137875. /**
  137876. * Enables a GeometryBufferRender and associates it with the scene
  137877. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137878. * @returns the GeometryBufferRenderer
  137879. */
  137880. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137881. /**
  137882. * Disables the GeometryBufferRender associated with the scene
  137883. */
  137884. disableGeometryBufferRenderer(): void;
  137885. }
  137886. /**
  137887. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137888. * in several rendering techniques.
  137889. */
  137890. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137891. /**
  137892. * The component name helpful to identify the component in the list of scene components.
  137893. */
  137894. readonly name: string;
  137895. /**
  137896. * The scene the component belongs to.
  137897. */
  137898. scene: Scene;
  137899. /**
  137900. * Creates a new instance of the component for the given scene
  137901. * @param scene Defines the scene to register the component in
  137902. */
  137903. constructor(scene: Scene);
  137904. /**
  137905. * Registers the component in a given scene
  137906. */
  137907. register(): void;
  137908. /**
  137909. * Rebuilds the elements related to this component in case of
  137910. * context lost for instance.
  137911. */
  137912. rebuild(): void;
  137913. /**
  137914. * Disposes the component and the associated ressources
  137915. */
  137916. dispose(): void;
  137917. private _gatherRenderTargets;
  137918. }
  137919. }
  137920. declare module BABYLON {
  137921. /** @hidden */
  137922. export var motionBlurPixelShader: {
  137923. name: string;
  137924. shader: string;
  137925. };
  137926. }
  137927. declare module BABYLON {
  137928. /**
  137929. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137930. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137931. * As an example, all you have to do is to create the post-process:
  137932. * var mb = new BABYLON.MotionBlurPostProcess(
  137933. * 'mb', // The name of the effect.
  137934. * scene, // The scene containing the objects to blur according to their velocity.
  137935. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137936. * camera // The camera to apply the render pass to.
  137937. * );
  137938. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137939. */
  137940. export class MotionBlurPostProcess extends PostProcess {
  137941. /**
  137942. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137943. */
  137944. motionStrength: number;
  137945. /**
  137946. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137947. */
  137948. get motionBlurSamples(): number;
  137949. /**
  137950. * Sets the number of iterations to be used for motion blur quality
  137951. */
  137952. set motionBlurSamples(samples: number);
  137953. private _motionBlurSamples;
  137954. private _geometryBufferRenderer;
  137955. /**
  137956. * Creates a new instance MotionBlurPostProcess
  137957. * @param name The name of the effect.
  137958. * @param scene The scene containing the objects to blur according to their velocity.
  137959. * @param options The required width/height ratio to downsize to before computing the render pass.
  137960. * @param camera The camera to apply the render pass to.
  137961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137962. * @param engine The engine which the post process will be applied. (default: current engine)
  137963. * @param reusable If the post process can be reused on the same frame. (default: false)
  137964. * @param textureType Type of textures used when performing the post process. (default: 0)
  137965. * @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)
  137966. */
  137967. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137968. /**
  137969. * Excludes the given skinned mesh from computing bones velocities.
  137970. * 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.
  137971. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137972. */
  137973. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137974. /**
  137975. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137976. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137977. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137978. */
  137979. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137980. /**
  137981. * Disposes the post process.
  137982. * @param camera The camera to dispose the post process on.
  137983. */
  137984. dispose(camera?: Camera): void;
  137985. }
  137986. }
  137987. declare module BABYLON {
  137988. /** @hidden */
  137989. export var refractionPixelShader: {
  137990. name: string;
  137991. shader: string;
  137992. };
  137993. }
  137994. declare module BABYLON {
  137995. /**
  137996. * Post process which applies a refractin texture
  137997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137998. */
  137999. export class RefractionPostProcess extends PostProcess {
  138000. /** the base color of the refraction (used to taint the rendering) */
  138001. color: Color3;
  138002. /** simulated refraction depth */
  138003. depth: number;
  138004. /** the coefficient of the base color (0 to remove base color tainting) */
  138005. colorLevel: number;
  138006. private _refTexture;
  138007. private _ownRefractionTexture;
  138008. /**
  138009. * Gets or sets the refraction texture
  138010. * Please note that you are responsible for disposing the texture if you set it manually
  138011. */
  138012. get refractionTexture(): Texture;
  138013. set refractionTexture(value: Texture);
  138014. /**
  138015. * Initializes the RefractionPostProcess
  138016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138017. * @param name The name of the effect.
  138018. * @param refractionTextureUrl Url of the refraction texture to use
  138019. * @param color the base color of the refraction (used to taint the rendering)
  138020. * @param depth simulated refraction depth
  138021. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138022. * @param camera The camera to apply the render pass to.
  138023. * @param options The required width/height ratio to downsize to before computing the render pass.
  138024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138025. * @param engine The engine which the post process will be applied. (default: current engine)
  138026. * @param reusable If the post process can be reused on the same frame. (default: false)
  138027. */
  138028. constructor(name: string, refractionTextureUrl: string,
  138029. /** the base color of the refraction (used to taint the rendering) */
  138030. color: Color3,
  138031. /** simulated refraction depth */
  138032. depth: number,
  138033. /** the coefficient of the base color (0 to remove base color tainting) */
  138034. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138035. /**
  138036. * Disposes of the post process
  138037. * @param camera Camera to dispose post process on
  138038. */
  138039. dispose(camera: Camera): void;
  138040. }
  138041. }
  138042. declare module BABYLON {
  138043. /** @hidden */
  138044. export var sharpenPixelShader: {
  138045. name: string;
  138046. shader: string;
  138047. };
  138048. }
  138049. declare module BABYLON {
  138050. /**
  138051. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138052. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138053. */
  138054. export class SharpenPostProcess extends PostProcess {
  138055. /**
  138056. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138057. */
  138058. colorAmount: number;
  138059. /**
  138060. * How much sharpness should be applied (default: 0.3)
  138061. */
  138062. edgeAmount: number;
  138063. /**
  138064. * Creates a new instance ConvolutionPostProcess
  138065. * @param name The name of the effect.
  138066. * @param options The required width/height ratio to downsize to before computing the render pass.
  138067. * @param camera The camera to apply the render pass to.
  138068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138069. * @param engine The engine which the post process will be applied. (default: current engine)
  138070. * @param reusable If the post process can be reused on the same frame. (default: false)
  138071. * @param textureType Type of textures used when performing the post process. (default: 0)
  138072. * @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)
  138073. */
  138074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138075. }
  138076. }
  138077. declare module BABYLON {
  138078. /**
  138079. * PostProcessRenderPipeline
  138080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138081. */
  138082. export class PostProcessRenderPipeline {
  138083. private engine;
  138084. private _renderEffects;
  138085. private _renderEffectsForIsolatedPass;
  138086. /**
  138087. * List of inspectable custom properties (used by the Inspector)
  138088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138089. */
  138090. inspectableCustomProperties: IInspectable[];
  138091. /**
  138092. * @hidden
  138093. */
  138094. protected _cameras: Camera[];
  138095. /** @hidden */
  138096. _name: string;
  138097. /**
  138098. * Gets pipeline name
  138099. */
  138100. get name(): string;
  138101. /** Gets the list of attached cameras */
  138102. get cameras(): Camera[];
  138103. /**
  138104. * Initializes a PostProcessRenderPipeline
  138105. * @param engine engine to add the pipeline to
  138106. * @param name name of the pipeline
  138107. */
  138108. constructor(engine: Engine, name: string);
  138109. /**
  138110. * Gets the class name
  138111. * @returns "PostProcessRenderPipeline"
  138112. */
  138113. getClassName(): string;
  138114. /**
  138115. * If all the render effects in the pipeline are supported
  138116. */
  138117. get isSupported(): boolean;
  138118. /**
  138119. * Adds an effect to the pipeline
  138120. * @param renderEffect the effect to add
  138121. */
  138122. addEffect(renderEffect: PostProcessRenderEffect): void;
  138123. /** @hidden */
  138124. _rebuild(): void;
  138125. /** @hidden */
  138126. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138127. /** @hidden */
  138128. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138129. /** @hidden */
  138130. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138131. /** @hidden */
  138132. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138133. /** @hidden */
  138134. _attachCameras(cameras: Camera, unique: boolean): void;
  138135. /** @hidden */
  138136. _attachCameras(cameras: Camera[], unique: boolean): void;
  138137. /** @hidden */
  138138. _detachCameras(cameras: Camera): void;
  138139. /** @hidden */
  138140. _detachCameras(cameras: Nullable<Camera[]>): void;
  138141. /** @hidden */
  138142. _update(): void;
  138143. /** @hidden */
  138144. _reset(): void;
  138145. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138146. /**
  138147. * Disposes of the pipeline
  138148. */
  138149. dispose(): void;
  138150. }
  138151. }
  138152. declare module BABYLON {
  138153. /**
  138154. * PostProcessRenderPipelineManager class
  138155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138156. */
  138157. export class PostProcessRenderPipelineManager {
  138158. private _renderPipelines;
  138159. /**
  138160. * Initializes a PostProcessRenderPipelineManager
  138161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138162. */
  138163. constructor();
  138164. /**
  138165. * Gets the list of supported render pipelines
  138166. */
  138167. get supportedPipelines(): PostProcessRenderPipeline[];
  138168. /**
  138169. * Adds a pipeline to the manager
  138170. * @param renderPipeline The pipeline to add
  138171. */
  138172. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138173. /**
  138174. * Attaches a camera to the pipeline
  138175. * @param renderPipelineName The name of the pipeline to attach to
  138176. * @param cameras the camera to attach
  138177. * @param unique if the camera can be attached multiple times to the pipeline
  138178. */
  138179. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138180. /**
  138181. * Detaches a camera from the pipeline
  138182. * @param renderPipelineName The name of the pipeline to detach from
  138183. * @param cameras the camera to detach
  138184. */
  138185. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138186. /**
  138187. * Enables an effect by name on a pipeline
  138188. * @param renderPipelineName the name of the pipeline to enable the effect in
  138189. * @param renderEffectName the name of the effect to enable
  138190. * @param cameras the cameras that the effect should be enabled on
  138191. */
  138192. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138193. /**
  138194. * Disables an effect by name on a pipeline
  138195. * @param renderPipelineName the name of the pipeline to disable the effect in
  138196. * @param renderEffectName the name of the effect to disable
  138197. * @param cameras the cameras that the effect should be disabled on
  138198. */
  138199. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138200. /**
  138201. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138202. */
  138203. update(): void;
  138204. /** @hidden */
  138205. _rebuild(): void;
  138206. /**
  138207. * Disposes of the manager and pipelines
  138208. */
  138209. dispose(): void;
  138210. }
  138211. }
  138212. declare module BABYLON {
  138213. interface Scene {
  138214. /** @hidden (Backing field) */
  138215. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138216. /**
  138217. * Gets the postprocess render pipeline manager
  138218. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138219. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138220. */
  138221. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138222. }
  138223. /**
  138224. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138225. */
  138226. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138227. /**
  138228. * The component name helpfull to identify the component in the list of scene components.
  138229. */
  138230. readonly name: string;
  138231. /**
  138232. * The scene the component belongs to.
  138233. */
  138234. scene: Scene;
  138235. /**
  138236. * Creates a new instance of the component for the given scene
  138237. * @param scene Defines the scene to register the component in
  138238. */
  138239. constructor(scene: Scene);
  138240. /**
  138241. * Registers the component in a given scene
  138242. */
  138243. register(): void;
  138244. /**
  138245. * Rebuilds the elements related to this component in case of
  138246. * context lost for instance.
  138247. */
  138248. rebuild(): void;
  138249. /**
  138250. * Disposes the component and the associated ressources
  138251. */
  138252. dispose(): void;
  138253. private _gatherRenderTargets;
  138254. }
  138255. }
  138256. declare module BABYLON {
  138257. /**
  138258. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138259. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138260. */
  138261. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138262. private _scene;
  138263. private _camerasToBeAttached;
  138264. /**
  138265. * ID of the sharpen post process,
  138266. */
  138267. private readonly SharpenPostProcessId;
  138268. /**
  138269. * @ignore
  138270. * ID of the image processing post process;
  138271. */
  138272. readonly ImageProcessingPostProcessId: string;
  138273. /**
  138274. * @ignore
  138275. * ID of the Fast Approximate Anti-Aliasing post process;
  138276. */
  138277. readonly FxaaPostProcessId: string;
  138278. /**
  138279. * ID of the chromatic aberration post process,
  138280. */
  138281. private readonly ChromaticAberrationPostProcessId;
  138282. /**
  138283. * ID of the grain post process
  138284. */
  138285. private readonly GrainPostProcessId;
  138286. /**
  138287. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138288. */
  138289. sharpen: SharpenPostProcess;
  138290. private _sharpenEffect;
  138291. private bloom;
  138292. /**
  138293. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138294. */
  138295. depthOfField: DepthOfFieldEffect;
  138296. /**
  138297. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138298. */
  138299. fxaa: FxaaPostProcess;
  138300. /**
  138301. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138302. */
  138303. imageProcessing: ImageProcessingPostProcess;
  138304. /**
  138305. * Chromatic aberration post process which will shift rgb colors in the image
  138306. */
  138307. chromaticAberration: ChromaticAberrationPostProcess;
  138308. private _chromaticAberrationEffect;
  138309. /**
  138310. * Grain post process which add noise to the image
  138311. */
  138312. grain: GrainPostProcess;
  138313. private _grainEffect;
  138314. /**
  138315. * Glow post process which adds a glow to emissive areas of the image
  138316. */
  138317. private _glowLayer;
  138318. /**
  138319. * Animations which can be used to tweak settings over a period of time
  138320. */
  138321. animations: Animation[];
  138322. private _imageProcessingConfigurationObserver;
  138323. private _sharpenEnabled;
  138324. private _bloomEnabled;
  138325. private _depthOfFieldEnabled;
  138326. private _depthOfFieldBlurLevel;
  138327. private _fxaaEnabled;
  138328. private _imageProcessingEnabled;
  138329. private _defaultPipelineTextureType;
  138330. private _bloomScale;
  138331. private _chromaticAberrationEnabled;
  138332. private _grainEnabled;
  138333. private _buildAllowed;
  138334. /**
  138335. * Gets active scene
  138336. */
  138337. get scene(): Scene;
  138338. /**
  138339. * Enable or disable the sharpen process from the pipeline
  138340. */
  138341. set sharpenEnabled(enabled: boolean);
  138342. get sharpenEnabled(): boolean;
  138343. private _resizeObserver;
  138344. private _hardwareScaleLevel;
  138345. private _bloomKernel;
  138346. /**
  138347. * Specifies the size of the bloom blur kernel, relative to the final output size
  138348. */
  138349. get bloomKernel(): number;
  138350. set bloomKernel(value: number);
  138351. /**
  138352. * Specifies the weight of the bloom in the final rendering
  138353. */
  138354. private _bloomWeight;
  138355. /**
  138356. * Specifies the luma threshold for the area that will be blurred by the bloom
  138357. */
  138358. private _bloomThreshold;
  138359. private _hdr;
  138360. /**
  138361. * The strength of the bloom.
  138362. */
  138363. set bloomWeight(value: number);
  138364. get bloomWeight(): number;
  138365. /**
  138366. * The strength of the bloom.
  138367. */
  138368. set bloomThreshold(value: number);
  138369. get bloomThreshold(): number;
  138370. /**
  138371. * The scale of the bloom, lower value will provide better performance.
  138372. */
  138373. set bloomScale(value: number);
  138374. get bloomScale(): number;
  138375. /**
  138376. * Enable or disable the bloom from the pipeline
  138377. */
  138378. set bloomEnabled(enabled: boolean);
  138379. get bloomEnabled(): boolean;
  138380. private _rebuildBloom;
  138381. /**
  138382. * If the depth of field is enabled.
  138383. */
  138384. get depthOfFieldEnabled(): boolean;
  138385. set depthOfFieldEnabled(enabled: boolean);
  138386. /**
  138387. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138388. */
  138389. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138390. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138391. /**
  138392. * If the anti aliasing is enabled.
  138393. */
  138394. set fxaaEnabled(enabled: boolean);
  138395. get fxaaEnabled(): boolean;
  138396. private _samples;
  138397. /**
  138398. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138399. */
  138400. set samples(sampleCount: number);
  138401. get samples(): number;
  138402. /**
  138403. * If image processing is enabled.
  138404. */
  138405. set imageProcessingEnabled(enabled: boolean);
  138406. get imageProcessingEnabled(): boolean;
  138407. /**
  138408. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138409. */
  138410. set glowLayerEnabled(enabled: boolean);
  138411. get glowLayerEnabled(): boolean;
  138412. /**
  138413. * Gets the glow layer (or null if not defined)
  138414. */
  138415. get glowLayer(): Nullable<GlowLayer>;
  138416. /**
  138417. * Enable or disable the chromaticAberration process from the pipeline
  138418. */
  138419. set chromaticAberrationEnabled(enabled: boolean);
  138420. get chromaticAberrationEnabled(): boolean;
  138421. /**
  138422. * Enable or disable the grain process from the pipeline
  138423. */
  138424. set grainEnabled(enabled: boolean);
  138425. get grainEnabled(): boolean;
  138426. /**
  138427. * @constructor
  138428. * @param name - The rendering pipeline name (default: "")
  138429. * @param hdr - If high dynamic range textures should be used (default: true)
  138430. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138431. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138432. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138433. */
  138434. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138435. /**
  138436. * Get the class name
  138437. * @returns "DefaultRenderingPipeline"
  138438. */
  138439. getClassName(): string;
  138440. /**
  138441. * Force the compilation of the entire pipeline.
  138442. */
  138443. prepare(): void;
  138444. private _hasCleared;
  138445. private _prevPostProcess;
  138446. private _prevPrevPostProcess;
  138447. private _setAutoClearAndTextureSharing;
  138448. private _depthOfFieldSceneObserver;
  138449. private _buildPipeline;
  138450. private _disposePostProcesses;
  138451. /**
  138452. * Adds a camera to the pipeline
  138453. * @param camera the camera to be added
  138454. */
  138455. addCamera(camera: Camera): void;
  138456. /**
  138457. * Removes a camera from the pipeline
  138458. * @param camera the camera to remove
  138459. */
  138460. removeCamera(camera: Camera): void;
  138461. /**
  138462. * Dispose of the pipeline and stop all post processes
  138463. */
  138464. dispose(): void;
  138465. /**
  138466. * Serialize the rendering pipeline (Used when exporting)
  138467. * @returns the serialized object
  138468. */
  138469. serialize(): any;
  138470. /**
  138471. * Parse the serialized pipeline
  138472. * @param source Source pipeline.
  138473. * @param scene The scene to load the pipeline to.
  138474. * @param rootUrl The URL of the serialized pipeline.
  138475. * @returns An instantiated pipeline from the serialized object.
  138476. */
  138477. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138478. }
  138479. }
  138480. declare module BABYLON {
  138481. /** @hidden */
  138482. export var lensHighlightsPixelShader: {
  138483. name: string;
  138484. shader: string;
  138485. };
  138486. }
  138487. declare module BABYLON {
  138488. /** @hidden */
  138489. export var depthOfFieldPixelShader: {
  138490. name: string;
  138491. shader: string;
  138492. };
  138493. }
  138494. declare module BABYLON {
  138495. /**
  138496. * BABYLON.JS Chromatic Aberration GLSL Shader
  138497. * Author: Olivier Guyot
  138498. * Separates very slightly R, G and B colors on the edges of the screen
  138499. * Inspired by Francois Tarlier & Martins Upitis
  138500. */
  138501. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138502. /**
  138503. * @ignore
  138504. * The chromatic aberration PostProcess id in the pipeline
  138505. */
  138506. LensChromaticAberrationEffect: string;
  138507. /**
  138508. * @ignore
  138509. * The highlights enhancing PostProcess id in the pipeline
  138510. */
  138511. HighlightsEnhancingEffect: string;
  138512. /**
  138513. * @ignore
  138514. * The depth-of-field PostProcess id in the pipeline
  138515. */
  138516. LensDepthOfFieldEffect: string;
  138517. private _scene;
  138518. private _depthTexture;
  138519. private _grainTexture;
  138520. private _chromaticAberrationPostProcess;
  138521. private _highlightsPostProcess;
  138522. private _depthOfFieldPostProcess;
  138523. private _edgeBlur;
  138524. private _grainAmount;
  138525. private _chromaticAberration;
  138526. private _distortion;
  138527. private _highlightsGain;
  138528. private _highlightsThreshold;
  138529. private _dofDistance;
  138530. private _dofAperture;
  138531. private _dofDarken;
  138532. private _dofPentagon;
  138533. private _blurNoise;
  138534. /**
  138535. * @constructor
  138536. *
  138537. * Effect parameters are as follow:
  138538. * {
  138539. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138540. * edge_blur: number; // from 0 to x (1 for realism)
  138541. * distortion: number; // from 0 to x (1 for realism)
  138542. * grain_amount: number; // from 0 to 1
  138543. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138544. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138545. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138546. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138547. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138548. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138549. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138550. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138551. * }
  138552. * Note: if an effect parameter is unset, effect is disabled
  138553. *
  138554. * @param name The rendering pipeline name
  138555. * @param parameters - An object containing all parameters (see above)
  138556. * @param scene The scene linked to this pipeline
  138557. * @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)
  138558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138559. */
  138560. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138561. /**
  138562. * Get the class name
  138563. * @returns "LensRenderingPipeline"
  138564. */
  138565. getClassName(): string;
  138566. /**
  138567. * Gets associated scene
  138568. */
  138569. get scene(): Scene;
  138570. /**
  138571. * Gets or sets the edge blur
  138572. */
  138573. get edgeBlur(): number;
  138574. set edgeBlur(value: number);
  138575. /**
  138576. * Gets or sets the grain amount
  138577. */
  138578. get grainAmount(): number;
  138579. set grainAmount(value: number);
  138580. /**
  138581. * Gets or sets the chromatic aberration amount
  138582. */
  138583. get chromaticAberration(): number;
  138584. set chromaticAberration(value: number);
  138585. /**
  138586. * Gets or sets the depth of field aperture
  138587. */
  138588. get dofAperture(): number;
  138589. set dofAperture(value: number);
  138590. /**
  138591. * Gets or sets the edge distortion
  138592. */
  138593. get edgeDistortion(): number;
  138594. set edgeDistortion(value: number);
  138595. /**
  138596. * Gets or sets the depth of field distortion
  138597. */
  138598. get dofDistortion(): number;
  138599. set dofDistortion(value: number);
  138600. /**
  138601. * Gets or sets the darken out of focus amount
  138602. */
  138603. get darkenOutOfFocus(): number;
  138604. set darkenOutOfFocus(value: number);
  138605. /**
  138606. * Gets or sets a boolean indicating if blur noise is enabled
  138607. */
  138608. get blurNoise(): boolean;
  138609. set blurNoise(value: boolean);
  138610. /**
  138611. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138612. */
  138613. get pentagonBokeh(): boolean;
  138614. set pentagonBokeh(value: boolean);
  138615. /**
  138616. * Gets or sets the highlight grain amount
  138617. */
  138618. get highlightsGain(): number;
  138619. set highlightsGain(value: number);
  138620. /**
  138621. * Gets or sets the highlight threshold
  138622. */
  138623. get highlightsThreshold(): number;
  138624. set highlightsThreshold(value: number);
  138625. /**
  138626. * Sets the amount of blur at the edges
  138627. * @param amount blur amount
  138628. */
  138629. setEdgeBlur(amount: number): void;
  138630. /**
  138631. * Sets edge blur to 0
  138632. */
  138633. disableEdgeBlur(): void;
  138634. /**
  138635. * Sets the amout of grain
  138636. * @param amount Amount of grain
  138637. */
  138638. setGrainAmount(amount: number): void;
  138639. /**
  138640. * Set grain amount to 0
  138641. */
  138642. disableGrain(): void;
  138643. /**
  138644. * Sets the chromatic aberration amount
  138645. * @param amount amount of chromatic aberration
  138646. */
  138647. setChromaticAberration(amount: number): void;
  138648. /**
  138649. * Sets chromatic aberration amount to 0
  138650. */
  138651. disableChromaticAberration(): void;
  138652. /**
  138653. * Sets the EdgeDistortion amount
  138654. * @param amount amount of EdgeDistortion
  138655. */
  138656. setEdgeDistortion(amount: number): void;
  138657. /**
  138658. * Sets edge distortion to 0
  138659. */
  138660. disableEdgeDistortion(): void;
  138661. /**
  138662. * Sets the FocusDistance amount
  138663. * @param amount amount of FocusDistance
  138664. */
  138665. setFocusDistance(amount: number): void;
  138666. /**
  138667. * Disables depth of field
  138668. */
  138669. disableDepthOfField(): void;
  138670. /**
  138671. * Sets the Aperture amount
  138672. * @param amount amount of Aperture
  138673. */
  138674. setAperture(amount: number): void;
  138675. /**
  138676. * Sets the DarkenOutOfFocus amount
  138677. * @param amount amount of DarkenOutOfFocus
  138678. */
  138679. setDarkenOutOfFocus(amount: number): void;
  138680. private _pentagonBokehIsEnabled;
  138681. /**
  138682. * Creates a pentagon bokeh effect
  138683. */
  138684. enablePentagonBokeh(): void;
  138685. /**
  138686. * Disables the pentagon bokeh effect
  138687. */
  138688. disablePentagonBokeh(): void;
  138689. /**
  138690. * Enables noise blur
  138691. */
  138692. enableNoiseBlur(): void;
  138693. /**
  138694. * Disables noise blur
  138695. */
  138696. disableNoiseBlur(): void;
  138697. /**
  138698. * Sets the HighlightsGain amount
  138699. * @param amount amount of HighlightsGain
  138700. */
  138701. setHighlightsGain(amount: number): void;
  138702. /**
  138703. * Sets the HighlightsThreshold amount
  138704. * @param amount amount of HighlightsThreshold
  138705. */
  138706. setHighlightsThreshold(amount: number): void;
  138707. /**
  138708. * Disables highlights
  138709. */
  138710. disableHighlights(): void;
  138711. /**
  138712. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138713. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138714. */
  138715. dispose(disableDepthRender?: boolean): void;
  138716. private _createChromaticAberrationPostProcess;
  138717. private _createHighlightsPostProcess;
  138718. private _createDepthOfFieldPostProcess;
  138719. private _createGrainTexture;
  138720. }
  138721. }
  138722. declare module BABYLON {
  138723. /** @hidden */
  138724. export var ssao2PixelShader: {
  138725. name: string;
  138726. shader: string;
  138727. };
  138728. }
  138729. declare module BABYLON {
  138730. /** @hidden */
  138731. export var ssaoCombinePixelShader: {
  138732. name: string;
  138733. shader: string;
  138734. };
  138735. }
  138736. declare module BABYLON {
  138737. /**
  138738. * Render pipeline to produce ssao effect
  138739. */
  138740. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138741. /**
  138742. * @ignore
  138743. * The PassPostProcess id in the pipeline that contains the original scene color
  138744. */
  138745. SSAOOriginalSceneColorEffect: string;
  138746. /**
  138747. * @ignore
  138748. * The SSAO PostProcess id in the pipeline
  138749. */
  138750. SSAORenderEffect: string;
  138751. /**
  138752. * @ignore
  138753. * The horizontal blur PostProcess id in the pipeline
  138754. */
  138755. SSAOBlurHRenderEffect: string;
  138756. /**
  138757. * @ignore
  138758. * The vertical blur PostProcess id in the pipeline
  138759. */
  138760. SSAOBlurVRenderEffect: string;
  138761. /**
  138762. * @ignore
  138763. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138764. */
  138765. SSAOCombineRenderEffect: string;
  138766. /**
  138767. * The output strength of the SSAO post-process. Default value is 1.0.
  138768. */
  138769. totalStrength: number;
  138770. /**
  138771. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138772. */
  138773. maxZ: number;
  138774. /**
  138775. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138776. */
  138777. minZAspect: number;
  138778. private _samples;
  138779. /**
  138780. * Number of samples used for the SSAO calculations. Default value is 8
  138781. */
  138782. set samples(n: number);
  138783. get samples(): number;
  138784. private _textureSamples;
  138785. /**
  138786. * Number of samples to use for antialiasing
  138787. */
  138788. set textureSamples(n: number);
  138789. get textureSamples(): number;
  138790. /**
  138791. * Ratio object used for SSAO ratio and blur ratio
  138792. */
  138793. private _ratio;
  138794. /**
  138795. * Dynamically generated sphere sampler.
  138796. */
  138797. private _sampleSphere;
  138798. /**
  138799. * Blur filter offsets
  138800. */
  138801. private _samplerOffsets;
  138802. private _expensiveBlur;
  138803. /**
  138804. * If bilateral blur should be used
  138805. */
  138806. set expensiveBlur(b: boolean);
  138807. get expensiveBlur(): boolean;
  138808. /**
  138809. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138810. */
  138811. radius: number;
  138812. /**
  138813. * The base color of the SSAO post-process
  138814. * The final result is "base + ssao" between [0, 1]
  138815. */
  138816. base: number;
  138817. /**
  138818. * Support test.
  138819. */
  138820. static get IsSupported(): boolean;
  138821. private _scene;
  138822. private _depthTexture;
  138823. private _normalTexture;
  138824. private _randomTexture;
  138825. private _originalColorPostProcess;
  138826. private _ssaoPostProcess;
  138827. private _blurHPostProcess;
  138828. private _blurVPostProcess;
  138829. private _ssaoCombinePostProcess;
  138830. /**
  138831. * Gets active scene
  138832. */
  138833. get scene(): Scene;
  138834. /**
  138835. * @constructor
  138836. * @param name The rendering pipeline name
  138837. * @param scene The scene linked to this pipeline
  138838. * @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 }
  138839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138840. */
  138841. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138842. /**
  138843. * Get the class name
  138844. * @returns "SSAO2RenderingPipeline"
  138845. */
  138846. getClassName(): string;
  138847. /**
  138848. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138849. */
  138850. dispose(disableGeometryBufferRenderer?: boolean): void;
  138851. private _createBlurPostProcess;
  138852. /** @hidden */
  138853. _rebuild(): void;
  138854. private _bits;
  138855. private _radicalInverse_VdC;
  138856. private _hammersley;
  138857. private _hemisphereSample_uniform;
  138858. private _generateHemisphere;
  138859. private _createSSAOPostProcess;
  138860. private _createSSAOCombinePostProcess;
  138861. private _createRandomTexture;
  138862. /**
  138863. * Serialize the rendering pipeline (Used when exporting)
  138864. * @returns the serialized object
  138865. */
  138866. serialize(): any;
  138867. /**
  138868. * Parse the serialized pipeline
  138869. * @param source Source pipeline.
  138870. * @param scene The scene to load the pipeline to.
  138871. * @param rootUrl The URL of the serialized pipeline.
  138872. * @returns An instantiated pipeline from the serialized object.
  138873. */
  138874. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138875. }
  138876. }
  138877. declare module BABYLON {
  138878. /** @hidden */
  138879. export var ssaoPixelShader: {
  138880. name: string;
  138881. shader: string;
  138882. };
  138883. }
  138884. declare module BABYLON {
  138885. /**
  138886. * Render pipeline to produce ssao effect
  138887. */
  138888. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138889. /**
  138890. * @ignore
  138891. * The PassPostProcess id in the pipeline that contains the original scene color
  138892. */
  138893. SSAOOriginalSceneColorEffect: string;
  138894. /**
  138895. * @ignore
  138896. * The SSAO PostProcess id in the pipeline
  138897. */
  138898. SSAORenderEffect: string;
  138899. /**
  138900. * @ignore
  138901. * The horizontal blur PostProcess id in the pipeline
  138902. */
  138903. SSAOBlurHRenderEffect: string;
  138904. /**
  138905. * @ignore
  138906. * The vertical blur PostProcess id in the pipeline
  138907. */
  138908. SSAOBlurVRenderEffect: string;
  138909. /**
  138910. * @ignore
  138911. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138912. */
  138913. SSAOCombineRenderEffect: string;
  138914. /**
  138915. * The output strength of the SSAO post-process. Default value is 1.0.
  138916. */
  138917. totalStrength: number;
  138918. /**
  138919. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138920. */
  138921. radius: number;
  138922. /**
  138923. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138924. * Must not be equal to fallOff and superior to fallOff.
  138925. * Default value is 0.0075
  138926. */
  138927. area: number;
  138928. /**
  138929. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138930. * Must not be equal to area and inferior to area.
  138931. * Default value is 0.000001
  138932. */
  138933. fallOff: number;
  138934. /**
  138935. * The base color of the SSAO post-process
  138936. * The final result is "base + ssao" between [0, 1]
  138937. */
  138938. base: number;
  138939. private _scene;
  138940. private _depthTexture;
  138941. private _randomTexture;
  138942. private _originalColorPostProcess;
  138943. private _ssaoPostProcess;
  138944. private _blurHPostProcess;
  138945. private _blurVPostProcess;
  138946. private _ssaoCombinePostProcess;
  138947. private _firstUpdate;
  138948. /**
  138949. * Gets active scene
  138950. */
  138951. get scene(): Scene;
  138952. /**
  138953. * @constructor
  138954. * @param name - The rendering pipeline name
  138955. * @param scene - The scene linked to this pipeline
  138956. * @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 }
  138957. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138958. */
  138959. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138960. /**
  138961. * Get the class name
  138962. * @returns "SSAORenderingPipeline"
  138963. */
  138964. getClassName(): string;
  138965. /**
  138966. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138967. */
  138968. dispose(disableDepthRender?: boolean): void;
  138969. private _createBlurPostProcess;
  138970. /** @hidden */
  138971. _rebuild(): void;
  138972. private _createSSAOPostProcess;
  138973. private _createSSAOCombinePostProcess;
  138974. private _createRandomTexture;
  138975. }
  138976. }
  138977. declare module BABYLON {
  138978. /** @hidden */
  138979. export var screenSpaceReflectionPixelShader: {
  138980. name: string;
  138981. shader: string;
  138982. };
  138983. }
  138984. declare module BABYLON {
  138985. /**
  138986. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138987. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138988. */
  138989. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138990. /**
  138991. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138992. */
  138993. threshold: number;
  138994. /**
  138995. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138996. */
  138997. strength: number;
  138998. /**
  138999. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139000. */
  139001. reflectionSpecularFalloffExponent: number;
  139002. /**
  139003. * 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]
  139004. */
  139005. step: number;
  139006. /**
  139007. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139008. */
  139009. roughnessFactor: number;
  139010. private _geometryBufferRenderer;
  139011. private _enableSmoothReflections;
  139012. private _reflectionSamples;
  139013. private _smoothSteps;
  139014. /**
  139015. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139016. * @param name The name of the effect.
  139017. * @param scene The scene containing the objects to calculate reflections.
  139018. * @param options The required width/height ratio to downsize to before computing the render pass.
  139019. * @param camera The camera to apply the render pass to.
  139020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139021. * @param engine The engine which the post process will be applied. (default: current engine)
  139022. * @param reusable If the post process can be reused on the same frame. (default: false)
  139023. * @param textureType Type of textures used when performing the post process. (default: 0)
  139024. * @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)
  139025. */
  139026. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139027. /**
  139028. * Gets wether or not smoothing reflections is enabled.
  139029. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139030. */
  139031. get enableSmoothReflections(): boolean;
  139032. /**
  139033. * Sets wether or not smoothing reflections is enabled.
  139034. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139035. */
  139036. set enableSmoothReflections(enabled: boolean);
  139037. /**
  139038. * Gets the number of samples taken while computing reflections. More samples count is high,
  139039. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139040. */
  139041. get reflectionSamples(): number;
  139042. /**
  139043. * Sets the number of samples taken while computing reflections. More samples count is high,
  139044. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139045. */
  139046. set reflectionSamples(samples: number);
  139047. /**
  139048. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139049. * more the post-process will require GPU power and can generate a drop in FPS.
  139050. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139051. */
  139052. get smoothSteps(): number;
  139053. set smoothSteps(steps: number);
  139054. private _updateEffectDefines;
  139055. }
  139056. }
  139057. declare module BABYLON {
  139058. /** @hidden */
  139059. export var standardPixelShader: {
  139060. name: string;
  139061. shader: string;
  139062. };
  139063. }
  139064. declare module BABYLON {
  139065. /**
  139066. * Standard rendering pipeline
  139067. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139068. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139069. */
  139070. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139071. /**
  139072. * Public members
  139073. */
  139074. /**
  139075. * Post-process which contains the original scene color before the pipeline applies all the effects
  139076. */
  139077. originalPostProcess: Nullable<PostProcess>;
  139078. /**
  139079. * Post-process used to down scale an image x4
  139080. */
  139081. downSampleX4PostProcess: Nullable<PostProcess>;
  139082. /**
  139083. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139084. */
  139085. brightPassPostProcess: Nullable<PostProcess>;
  139086. /**
  139087. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139088. */
  139089. blurHPostProcesses: PostProcess[];
  139090. /**
  139091. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139092. */
  139093. blurVPostProcesses: PostProcess[];
  139094. /**
  139095. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139096. */
  139097. textureAdderPostProcess: Nullable<PostProcess>;
  139098. /**
  139099. * Post-process used to create volumetric lighting effect
  139100. */
  139101. volumetricLightPostProcess: Nullable<PostProcess>;
  139102. /**
  139103. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139104. */
  139105. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139106. /**
  139107. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139108. */
  139109. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139110. /**
  139111. * Post-process used to merge the volumetric light effect and the real scene color
  139112. */
  139113. volumetricLightMergePostProces: Nullable<PostProcess>;
  139114. /**
  139115. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139116. */
  139117. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139118. /**
  139119. * Base post-process used to calculate the average luminance of the final image for HDR
  139120. */
  139121. luminancePostProcess: Nullable<PostProcess>;
  139122. /**
  139123. * Post-processes used to create down sample post-processes in order to get
  139124. * the average luminance of the final image for HDR
  139125. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139126. */
  139127. luminanceDownSamplePostProcesses: PostProcess[];
  139128. /**
  139129. * Post-process used to create a HDR effect (light adaptation)
  139130. */
  139131. hdrPostProcess: Nullable<PostProcess>;
  139132. /**
  139133. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139134. */
  139135. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139136. /**
  139137. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139138. */
  139139. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139140. /**
  139141. * Post-process used to merge the final HDR post-process and the real scene color
  139142. */
  139143. hdrFinalPostProcess: Nullable<PostProcess>;
  139144. /**
  139145. * Post-process used to create a lens flare effect
  139146. */
  139147. lensFlarePostProcess: Nullable<PostProcess>;
  139148. /**
  139149. * Post-process that merges the result of the lens flare post-process and the real scene color
  139150. */
  139151. lensFlareComposePostProcess: Nullable<PostProcess>;
  139152. /**
  139153. * Post-process used to create a motion blur effect
  139154. */
  139155. motionBlurPostProcess: Nullable<PostProcess>;
  139156. /**
  139157. * Post-process used to create a depth of field effect
  139158. */
  139159. depthOfFieldPostProcess: Nullable<PostProcess>;
  139160. /**
  139161. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139162. */
  139163. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139164. /**
  139165. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139166. */
  139167. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139168. /**
  139169. * Represents the brightness threshold in order to configure the illuminated surfaces
  139170. */
  139171. brightThreshold: number;
  139172. /**
  139173. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139174. */
  139175. blurWidth: number;
  139176. /**
  139177. * Sets if the blur for highlighted surfaces must be only horizontal
  139178. */
  139179. horizontalBlur: boolean;
  139180. /**
  139181. * Gets the overall exposure used by the pipeline
  139182. */
  139183. get exposure(): number;
  139184. /**
  139185. * Sets the overall exposure used by the pipeline
  139186. */
  139187. set exposure(value: number);
  139188. /**
  139189. * Texture used typically to simulate "dirty" on camera lens
  139190. */
  139191. lensTexture: Nullable<Texture>;
  139192. /**
  139193. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139194. */
  139195. volumetricLightCoefficient: number;
  139196. /**
  139197. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139198. */
  139199. volumetricLightPower: number;
  139200. /**
  139201. * Used the set the blur intensity to smooth the volumetric lights
  139202. */
  139203. volumetricLightBlurScale: number;
  139204. /**
  139205. * Light (spot or directional) used to generate the volumetric lights rays
  139206. * The source light must have a shadow generate so the pipeline can get its
  139207. * depth map
  139208. */
  139209. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139210. /**
  139211. * For eye adaptation, represents the minimum luminance the eye can see
  139212. */
  139213. hdrMinimumLuminance: number;
  139214. /**
  139215. * For eye adaptation, represents the decrease luminance speed
  139216. */
  139217. hdrDecreaseRate: number;
  139218. /**
  139219. * For eye adaptation, represents the increase luminance speed
  139220. */
  139221. hdrIncreaseRate: number;
  139222. /**
  139223. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139224. */
  139225. get hdrAutoExposure(): boolean;
  139226. /**
  139227. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139228. */
  139229. set hdrAutoExposure(value: boolean);
  139230. /**
  139231. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139232. */
  139233. lensColorTexture: Nullable<Texture>;
  139234. /**
  139235. * The overall strengh for the lens flare effect
  139236. */
  139237. lensFlareStrength: number;
  139238. /**
  139239. * Dispersion coefficient for lens flare ghosts
  139240. */
  139241. lensFlareGhostDispersal: number;
  139242. /**
  139243. * Main lens flare halo width
  139244. */
  139245. lensFlareHaloWidth: number;
  139246. /**
  139247. * Based on the lens distortion effect, defines how much the lens flare result
  139248. * is distorted
  139249. */
  139250. lensFlareDistortionStrength: number;
  139251. /**
  139252. * Configures the blur intensity used for for lens flare (halo)
  139253. */
  139254. lensFlareBlurWidth: number;
  139255. /**
  139256. * Lens star texture must be used to simulate rays on the flares and is available
  139257. * in the documentation
  139258. */
  139259. lensStarTexture: Nullable<Texture>;
  139260. /**
  139261. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139262. * flare effect by taking account of the dirt texture
  139263. */
  139264. lensFlareDirtTexture: Nullable<Texture>;
  139265. /**
  139266. * Represents the focal length for the depth of field effect
  139267. */
  139268. depthOfFieldDistance: number;
  139269. /**
  139270. * Represents the blur intensity for the blurred part of the depth of field effect
  139271. */
  139272. depthOfFieldBlurWidth: number;
  139273. /**
  139274. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139275. */
  139276. get motionStrength(): number;
  139277. /**
  139278. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139279. */
  139280. set motionStrength(strength: number);
  139281. /**
  139282. * Gets wether or not the motion blur post-process is object based or screen based.
  139283. */
  139284. get objectBasedMotionBlur(): boolean;
  139285. /**
  139286. * Sets wether or not the motion blur post-process should be object based or screen based
  139287. */
  139288. set objectBasedMotionBlur(value: boolean);
  139289. /**
  139290. * List of animations for the pipeline (IAnimatable implementation)
  139291. */
  139292. animations: Animation[];
  139293. /**
  139294. * Private members
  139295. */
  139296. private _scene;
  139297. private _currentDepthOfFieldSource;
  139298. private _basePostProcess;
  139299. private _fixedExposure;
  139300. private _currentExposure;
  139301. private _hdrAutoExposure;
  139302. private _hdrCurrentLuminance;
  139303. private _motionStrength;
  139304. private _isObjectBasedMotionBlur;
  139305. private _floatTextureType;
  139306. private _camerasToBeAttached;
  139307. private _ratio;
  139308. private _bloomEnabled;
  139309. private _depthOfFieldEnabled;
  139310. private _vlsEnabled;
  139311. private _lensFlareEnabled;
  139312. private _hdrEnabled;
  139313. private _motionBlurEnabled;
  139314. private _fxaaEnabled;
  139315. private _screenSpaceReflectionsEnabled;
  139316. private _motionBlurSamples;
  139317. private _volumetricLightStepsCount;
  139318. private _samples;
  139319. /**
  139320. * @ignore
  139321. * Specifies if the bloom pipeline is enabled
  139322. */
  139323. get BloomEnabled(): boolean;
  139324. set BloomEnabled(enabled: boolean);
  139325. /**
  139326. * @ignore
  139327. * Specifies if the depth of field pipeline is enabed
  139328. */
  139329. get DepthOfFieldEnabled(): boolean;
  139330. set DepthOfFieldEnabled(enabled: boolean);
  139331. /**
  139332. * @ignore
  139333. * Specifies if the lens flare pipeline is enabed
  139334. */
  139335. get LensFlareEnabled(): boolean;
  139336. set LensFlareEnabled(enabled: boolean);
  139337. /**
  139338. * @ignore
  139339. * Specifies if the HDR pipeline is enabled
  139340. */
  139341. get HDREnabled(): boolean;
  139342. set HDREnabled(enabled: boolean);
  139343. /**
  139344. * @ignore
  139345. * Specifies if the volumetric lights scattering effect is enabled
  139346. */
  139347. get VLSEnabled(): boolean;
  139348. set VLSEnabled(enabled: boolean);
  139349. /**
  139350. * @ignore
  139351. * Specifies if the motion blur effect is enabled
  139352. */
  139353. get MotionBlurEnabled(): boolean;
  139354. set MotionBlurEnabled(enabled: boolean);
  139355. /**
  139356. * Specifies if anti-aliasing is enabled
  139357. */
  139358. get fxaaEnabled(): boolean;
  139359. set fxaaEnabled(enabled: boolean);
  139360. /**
  139361. * Specifies if screen space reflections are enabled.
  139362. */
  139363. get screenSpaceReflectionsEnabled(): boolean;
  139364. set screenSpaceReflectionsEnabled(enabled: boolean);
  139365. /**
  139366. * Specifies the number of steps used to calculate the volumetric lights
  139367. * Typically in interval [50, 200]
  139368. */
  139369. get volumetricLightStepsCount(): number;
  139370. set volumetricLightStepsCount(count: number);
  139371. /**
  139372. * Specifies the number of samples used for the motion blur effect
  139373. * Typically in interval [16, 64]
  139374. */
  139375. get motionBlurSamples(): number;
  139376. set motionBlurSamples(samples: number);
  139377. /**
  139378. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139379. */
  139380. get samples(): number;
  139381. set samples(sampleCount: number);
  139382. /**
  139383. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139384. * @constructor
  139385. * @param name The rendering pipeline name
  139386. * @param scene The scene linked to this pipeline
  139387. * @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)
  139388. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139389. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139390. */
  139391. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139392. private _buildPipeline;
  139393. private _createDownSampleX4PostProcess;
  139394. private _createBrightPassPostProcess;
  139395. private _createBlurPostProcesses;
  139396. private _createTextureAdderPostProcess;
  139397. private _createVolumetricLightPostProcess;
  139398. private _createLuminancePostProcesses;
  139399. private _createHdrPostProcess;
  139400. private _createLensFlarePostProcess;
  139401. private _createDepthOfFieldPostProcess;
  139402. private _createMotionBlurPostProcess;
  139403. private _getDepthTexture;
  139404. private _disposePostProcesses;
  139405. /**
  139406. * Dispose of the pipeline and stop all post processes
  139407. */
  139408. dispose(): void;
  139409. /**
  139410. * Serialize the rendering pipeline (Used when exporting)
  139411. * @returns the serialized object
  139412. */
  139413. serialize(): any;
  139414. /**
  139415. * Parse the serialized pipeline
  139416. * @param source Source pipeline.
  139417. * @param scene The scene to load the pipeline to.
  139418. * @param rootUrl The URL of the serialized pipeline.
  139419. * @returns An instantiated pipeline from the serialized object.
  139420. */
  139421. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139422. /**
  139423. * Luminance steps
  139424. */
  139425. static LuminanceSteps: number;
  139426. }
  139427. }
  139428. declare module BABYLON {
  139429. /** @hidden */
  139430. export var tonemapPixelShader: {
  139431. name: string;
  139432. shader: string;
  139433. };
  139434. }
  139435. declare module BABYLON {
  139436. /** Defines operator used for tonemapping */
  139437. export enum TonemappingOperator {
  139438. /** Hable */
  139439. Hable = 0,
  139440. /** Reinhard */
  139441. Reinhard = 1,
  139442. /** HejiDawson */
  139443. HejiDawson = 2,
  139444. /** Photographic */
  139445. Photographic = 3
  139446. }
  139447. /**
  139448. * Defines a post process to apply tone mapping
  139449. */
  139450. export class TonemapPostProcess extends PostProcess {
  139451. private _operator;
  139452. /** Defines the required exposure adjustement */
  139453. exposureAdjustment: number;
  139454. /**
  139455. * Creates a new TonemapPostProcess
  139456. * @param name defines the name of the postprocess
  139457. * @param _operator defines the operator to use
  139458. * @param exposureAdjustment defines the required exposure adjustement
  139459. * @param camera defines the camera to use (can be null)
  139460. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139461. * @param engine defines the hosting engine (can be ignore if camera is set)
  139462. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139463. */
  139464. constructor(name: string, _operator: TonemappingOperator,
  139465. /** Defines the required exposure adjustement */
  139466. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139467. }
  139468. }
  139469. declare module BABYLON {
  139470. /** @hidden */
  139471. export var volumetricLightScatteringPixelShader: {
  139472. name: string;
  139473. shader: string;
  139474. };
  139475. }
  139476. declare module BABYLON {
  139477. /** @hidden */
  139478. export var volumetricLightScatteringPassVertexShader: {
  139479. name: string;
  139480. shader: string;
  139481. };
  139482. }
  139483. declare module BABYLON {
  139484. /** @hidden */
  139485. export var volumetricLightScatteringPassPixelShader: {
  139486. name: string;
  139487. shader: string;
  139488. };
  139489. }
  139490. declare module BABYLON {
  139491. /**
  139492. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139493. */
  139494. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139495. private _volumetricLightScatteringPass;
  139496. private _volumetricLightScatteringRTT;
  139497. private _viewPort;
  139498. private _screenCoordinates;
  139499. private _cachedDefines;
  139500. /**
  139501. * If not undefined, the mesh position is computed from the attached node position
  139502. */
  139503. attachedNode: {
  139504. position: Vector3;
  139505. };
  139506. /**
  139507. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139508. */
  139509. customMeshPosition: Vector3;
  139510. /**
  139511. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139512. */
  139513. useCustomMeshPosition: boolean;
  139514. /**
  139515. * If the post-process should inverse the light scattering direction
  139516. */
  139517. invert: boolean;
  139518. /**
  139519. * The internal mesh used by the post-process
  139520. */
  139521. mesh: Mesh;
  139522. /**
  139523. * @hidden
  139524. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139525. */
  139526. get useDiffuseColor(): boolean;
  139527. set useDiffuseColor(useDiffuseColor: boolean);
  139528. /**
  139529. * Array containing the excluded meshes not rendered in the internal pass
  139530. */
  139531. excludedMeshes: AbstractMesh[];
  139532. /**
  139533. * Controls the overall intensity of the post-process
  139534. */
  139535. exposure: number;
  139536. /**
  139537. * Dissipates each sample's contribution in range [0, 1]
  139538. */
  139539. decay: number;
  139540. /**
  139541. * Controls the overall intensity of each sample
  139542. */
  139543. weight: number;
  139544. /**
  139545. * Controls the density of each sample
  139546. */
  139547. density: number;
  139548. /**
  139549. * @constructor
  139550. * @param name The post-process name
  139551. * @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)
  139552. * @param camera The camera that the post-process will be attached to
  139553. * @param mesh The mesh used to create the light scattering
  139554. * @param samples The post-process quality, default 100
  139555. * @param samplingModeThe post-process filtering mode
  139556. * @param engine The babylon engine
  139557. * @param reusable If the post-process is reusable
  139558. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139559. */
  139560. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139561. /**
  139562. * Returns the string "VolumetricLightScatteringPostProcess"
  139563. * @returns "VolumetricLightScatteringPostProcess"
  139564. */
  139565. getClassName(): string;
  139566. private _isReady;
  139567. /**
  139568. * Sets the new light position for light scattering effect
  139569. * @param position The new custom light position
  139570. */
  139571. setCustomMeshPosition(position: Vector3): void;
  139572. /**
  139573. * Returns the light position for light scattering effect
  139574. * @return Vector3 The custom light position
  139575. */
  139576. getCustomMeshPosition(): Vector3;
  139577. /**
  139578. * Disposes the internal assets and detaches the post-process from the camera
  139579. */
  139580. dispose(camera: Camera): void;
  139581. /**
  139582. * Returns the render target texture used by the post-process
  139583. * @return the render target texture used by the post-process
  139584. */
  139585. getPass(): RenderTargetTexture;
  139586. private _meshExcluded;
  139587. private _createPass;
  139588. private _updateMeshScreenCoordinates;
  139589. /**
  139590. * Creates a default mesh for the Volumeric Light Scattering post-process
  139591. * @param name The mesh name
  139592. * @param scene The scene where to create the mesh
  139593. * @return the default mesh
  139594. */
  139595. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139596. }
  139597. }
  139598. declare module BABYLON {
  139599. interface Scene {
  139600. /** @hidden (Backing field) */
  139601. _boundingBoxRenderer: BoundingBoxRenderer;
  139602. /** @hidden (Backing field) */
  139603. _forceShowBoundingBoxes: boolean;
  139604. /**
  139605. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139606. */
  139607. forceShowBoundingBoxes: boolean;
  139608. /**
  139609. * Gets the bounding box renderer associated with the scene
  139610. * @returns a BoundingBoxRenderer
  139611. */
  139612. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139613. }
  139614. interface AbstractMesh {
  139615. /** @hidden (Backing field) */
  139616. _showBoundingBox: boolean;
  139617. /**
  139618. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139619. */
  139620. showBoundingBox: boolean;
  139621. }
  139622. /**
  139623. * Component responsible of rendering the bounding box of the meshes in a scene.
  139624. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139625. */
  139626. export class BoundingBoxRenderer implements ISceneComponent {
  139627. /**
  139628. * The component name helpfull to identify the component in the list of scene components.
  139629. */
  139630. readonly name: string;
  139631. /**
  139632. * The scene the component belongs to.
  139633. */
  139634. scene: Scene;
  139635. /**
  139636. * Color of the bounding box lines placed in front of an object
  139637. */
  139638. frontColor: Color3;
  139639. /**
  139640. * Color of the bounding box lines placed behind an object
  139641. */
  139642. backColor: Color3;
  139643. /**
  139644. * Defines if the renderer should show the back lines or not
  139645. */
  139646. showBackLines: boolean;
  139647. /**
  139648. * @hidden
  139649. */
  139650. renderList: SmartArray<BoundingBox>;
  139651. private _colorShader;
  139652. private _vertexBuffers;
  139653. private _indexBuffer;
  139654. private _fillIndexBuffer;
  139655. private _fillIndexData;
  139656. /**
  139657. * Instantiates a new bounding box renderer in a scene.
  139658. * @param scene the scene the renderer renders in
  139659. */
  139660. constructor(scene: Scene);
  139661. /**
  139662. * Registers the component in a given scene
  139663. */
  139664. register(): void;
  139665. private _evaluateSubMesh;
  139666. private _activeMesh;
  139667. private _prepareRessources;
  139668. private _createIndexBuffer;
  139669. /**
  139670. * Rebuilds the elements related to this component in case of
  139671. * context lost for instance.
  139672. */
  139673. rebuild(): void;
  139674. /**
  139675. * @hidden
  139676. */
  139677. reset(): void;
  139678. /**
  139679. * Render the bounding boxes of a specific rendering group
  139680. * @param renderingGroupId defines the rendering group to render
  139681. */
  139682. render(renderingGroupId: number): void;
  139683. /**
  139684. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139685. * @param mesh Define the mesh to render the occlusion bounding box for
  139686. */
  139687. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139688. /**
  139689. * Dispose and release the resources attached to this renderer.
  139690. */
  139691. dispose(): void;
  139692. }
  139693. }
  139694. declare module BABYLON {
  139695. interface Scene {
  139696. /** @hidden (Backing field) */
  139697. _depthRenderer: {
  139698. [id: string]: DepthRenderer;
  139699. };
  139700. /**
  139701. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139702. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139703. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139704. * @returns the created depth renderer
  139705. */
  139706. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139707. /**
  139708. * Disables a depth renderer for a given camera
  139709. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139710. */
  139711. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139712. }
  139713. /**
  139714. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139715. * in several rendering techniques.
  139716. */
  139717. export class DepthRendererSceneComponent implements ISceneComponent {
  139718. /**
  139719. * The component name helpfull to identify the component in the list of scene components.
  139720. */
  139721. readonly name: string;
  139722. /**
  139723. * The scene the component belongs to.
  139724. */
  139725. scene: Scene;
  139726. /**
  139727. * Creates a new instance of the component for the given scene
  139728. * @param scene Defines the scene to register the component in
  139729. */
  139730. constructor(scene: Scene);
  139731. /**
  139732. * Registers the component in a given scene
  139733. */
  139734. register(): void;
  139735. /**
  139736. * Rebuilds the elements related to this component in case of
  139737. * context lost for instance.
  139738. */
  139739. rebuild(): void;
  139740. /**
  139741. * Disposes the component and the associated ressources
  139742. */
  139743. dispose(): void;
  139744. private _gatherRenderTargets;
  139745. private _gatherActiveCameraRenderTargets;
  139746. }
  139747. }
  139748. declare module BABYLON {
  139749. /** @hidden */
  139750. export var outlinePixelShader: {
  139751. name: string;
  139752. shader: string;
  139753. };
  139754. }
  139755. declare module BABYLON {
  139756. /** @hidden */
  139757. export var outlineVertexShader: {
  139758. name: string;
  139759. shader: string;
  139760. };
  139761. }
  139762. declare module BABYLON {
  139763. interface Scene {
  139764. /** @hidden */
  139765. _outlineRenderer: OutlineRenderer;
  139766. /**
  139767. * Gets the outline renderer associated with the scene
  139768. * @returns a OutlineRenderer
  139769. */
  139770. getOutlineRenderer(): OutlineRenderer;
  139771. }
  139772. interface AbstractMesh {
  139773. /** @hidden (Backing field) */
  139774. _renderOutline: boolean;
  139775. /**
  139776. * Gets or sets a boolean indicating if the outline must be rendered as well
  139777. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139778. */
  139779. renderOutline: boolean;
  139780. /** @hidden (Backing field) */
  139781. _renderOverlay: boolean;
  139782. /**
  139783. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139784. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139785. */
  139786. renderOverlay: boolean;
  139787. }
  139788. /**
  139789. * This class is responsible to draw bothe outline/overlay of meshes.
  139790. * It should not be used directly but through the available method on mesh.
  139791. */
  139792. export class OutlineRenderer implements ISceneComponent {
  139793. /**
  139794. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139795. */
  139796. private static _StencilReference;
  139797. /**
  139798. * The name of the component. Each component must have a unique name.
  139799. */
  139800. name: string;
  139801. /**
  139802. * The scene the component belongs to.
  139803. */
  139804. scene: Scene;
  139805. /**
  139806. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139807. */
  139808. zOffset: number;
  139809. private _engine;
  139810. private _effect;
  139811. private _cachedDefines;
  139812. private _savedDepthWrite;
  139813. /**
  139814. * Instantiates a new outline renderer. (There could be only one per scene).
  139815. * @param scene Defines the scene it belongs to
  139816. */
  139817. constructor(scene: Scene);
  139818. /**
  139819. * Register the component to one instance of a scene.
  139820. */
  139821. register(): void;
  139822. /**
  139823. * Rebuilds the elements related to this component in case of
  139824. * context lost for instance.
  139825. */
  139826. rebuild(): void;
  139827. /**
  139828. * Disposes the component and the associated ressources.
  139829. */
  139830. dispose(): void;
  139831. /**
  139832. * Renders the outline in the canvas.
  139833. * @param subMesh Defines the sumesh to render
  139834. * @param batch Defines the batch of meshes in case of instances
  139835. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139836. */
  139837. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139838. /**
  139839. * Returns whether or not the outline renderer is ready for a given submesh.
  139840. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139841. * @param subMesh Defines the submesh to check readyness for
  139842. * @param useInstances Defines wheter wee are trying to render instances or not
  139843. * @returns true if ready otherwise false
  139844. */
  139845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139846. private _beforeRenderingMesh;
  139847. private _afterRenderingMesh;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. /**
  139852. * Defines the basic options interface of a Sprite Frame Source Size.
  139853. */
  139854. export interface ISpriteJSONSpriteSourceSize {
  139855. /**
  139856. * number of the original width of the Frame
  139857. */
  139858. w: number;
  139859. /**
  139860. * number of the original height of the Frame
  139861. */
  139862. h: number;
  139863. }
  139864. /**
  139865. * Defines the basic options interface of a Sprite Frame Data.
  139866. */
  139867. export interface ISpriteJSONSpriteFrameData {
  139868. /**
  139869. * number of the x offset of the Frame
  139870. */
  139871. x: number;
  139872. /**
  139873. * number of the y offset of the Frame
  139874. */
  139875. y: number;
  139876. /**
  139877. * number of the width of the Frame
  139878. */
  139879. w: number;
  139880. /**
  139881. * number of the height of the Frame
  139882. */
  139883. h: number;
  139884. }
  139885. /**
  139886. * Defines the basic options interface of a JSON Sprite.
  139887. */
  139888. export interface ISpriteJSONSprite {
  139889. /**
  139890. * string name of the Frame
  139891. */
  139892. filename: string;
  139893. /**
  139894. * ISpriteJSONSpriteFrame basic object of the frame data
  139895. */
  139896. frame: ISpriteJSONSpriteFrameData;
  139897. /**
  139898. * boolean to flag is the frame was rotated.
  139899. */
  139900. rotated: boolean;
  139901. /**
  139902. * boolean to flag is the frame was trimmed.
  139903. */
  139904. trimmed: boolean;
  139905. /**
  139906. * ISpriteJSONSpriteFrame basic object of the source data
  139907. */
  139908. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139909. /**
  139910. * ISpriteJSONSpriteFrame basic object of the source data
  139911. */
  139912. sourceSize: ISpriteJSONSpriteSourceSize;
  139913. }
  139914. /**
  139915. * Defines the basic options interface of a JSON atlas.
  139916. */
  139917. export interface ISpriteJSONAtlas {
  139918. /**
  139919. * Array of objects that contain the frame data.
  139920. */
  139921. frames: Array<ISpriteJSONSprite>;
  139922. /**
  139923. * object basic object containing the sprite meta data.
  139924. */
  139925. meta?: object;
  139926. }
  139927. }
  139928. declare module BABYLON {
  139929. /** @hidden */
  139930. export var spriteMapPixelShader: {
  139931. name: string;
  139932. shader: string;
  139933. };
  139934. }
  139935. declare module BABYLON {
  139936. /** @hidden */
  139937. export var spriteMapVertexShader: {
  139938. name: string;
  139939. shader: string;
  139940. };
  139941. }
  139942. declare module BABYLON {
  139943. /**
  139944. * Defines the basic options interface of a SpriteMap
  139945. */
  139946. export interface ISpriteMapOptions {
  139947. /**
  139948. * Vector2 of the number of cells in the grid.
  139949. */
  139950. stageSize?: Vector2;
  139951. /**
  139952. * Vector2 of the size of the output plane in World Units.
  139953. */
  139954. outputSize?: Vector2;
  139955. /**
  139956. * Vector3 of the position of the output plane in World Units.
  139957. */
  139958. outputPosition?: Vector3;
  139959. /**
  139960. * Vector3 of the rotation of the output plane.
  139961. */
  139962. outputRotation?: Vector3;
  139963. /**
  139964. * number of layers that the system will reserve in resources.
  139965. */
  139966. layerCount?: number;
  139967. /**
  139968. * number of max animation frames a single cell will reserve in resources.
  139969. */
  139970. maxAnimationFrames?: number;
  139971. /**
  139972. * number cell index of the base tile when the system compiles.
  139973. */
  139974. baseTile?: number;
  139975. /**
  139976. * boolean flip the sprite after its been repositioned by the framing data.
  139977. */
  139978. flipU?: boolean;
  139979. /**
  139980. * Vector3 scalar of the global RGB values of the SpriteMap.
  139981. */
  139982. colorMultiply?: Vector3;
  139983. }
  139984. /**
  139985. * Defines the IDisposable interface in order to be cleanable from resources.
  139986. */
  139987. export interface ISpriteMap extends IDisposable {
  139988. /**
  139989. * String name of the SpriteMap.
  139990. */
  139991. name: string;
  139992. /**
  139993. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139994. */
  139995. atlasJSON: ISpriteJSONAtlas;
  139996. /**
  139997. * Texture of the SpriteMap.
  139998. */
  139999. spriteSheet: Texture;
  140000. /**
  140001. * The parameters to initialize the SpriteMap with.
  140002. */
  140003. options: ISpriteMapOptions;
  140004. }
  140005. /**
  140006. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140007. */
  140008. export class SpriteMap implements ISpriteMap {
  140009. /** The Name of the spriteMap */
  140010. name: string;
  140011. /** The JSON file with the frame and meta data */
  140012. atlasJSON: ISpriteJSONAtlas;
  140013. /** The systems Sprite Sheet Texture */
  140014. spriteSheet: Texture;
  140015. /** Arguments passed with the Constructor */
  140016. options: ISpriteMapOptions;
  140017. /** Public Sprite Storage array, parsed from atlasJSON */
  140018. sprites: Array<ISpriteJSONSprite>;
  140019. /** Returns the Number of Sprites in the System */
  140020. get spriteCount(): number;
  140021. /** Returns the Position of Output Plane*/
  140022. get position(): Vector3;
  140023. /** Returns the Position of Output Plane*/
  140024. set position(v: Vector3);
  140025. /** Returns the Rotation of Output Plane*/
  140026. get rotation(): Vector3;
  140027. /** Returns the Rotation of Output Plane*/
  140028. set rotation(v: Vector3);
  140029. /** Sets the AnimationMap*/
  140030. get animationMap(): RawTexture;
  140031. /** Sets the AnimationMap*/
  140032. set animationMap(v: RawTexture);
  140033. /** Scene that the SpriteMap was created in */
  140034. private _scene;
  140035. /** Texture Buffer of Float32 that holds tile frame data*/
  140036. private _frameMap;
  140037. /** Texture Buffers of Float32 that holds tileMap data*/
  140038. private _tileMaps;
  140039. /** Texture Buffer of Float32 that holds Animation Data*/
  140040. private _animationMap;
  140041. /** Custom ShaderMaterial Central to the System*/
  140042. private _material;
  140043. /** Custom ShaderMaterial Central to the System*/
  140044. private _output;
  140045. /** Systems Time Ticker*/
  140046. private _time;
  140047. /**
  140048. * Creates a new SpriteMap
  140049. * @param name defines the SpriteMaps Name
  140050. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140051. * @param spriteSheet is the Texture that the Sprites are on.
  140052. * @param options a basic deployment configuration
  140053. * @param scene The Scene that the map is deployed on
  140054. */
  140055. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140056. /**
  140057. * Returns tileID location
  140058. * @returns Vector2 the cell position ID
  140059. */
  140060. getTileID(): Vector2;
  140061. /**
  140062. * Gets the UV location of the mouse over the SpriteMap.
  140063. * @returns Vector2 the UV position of the mouse interaction
  140064. */
  140065. getMousePosition(): Vector2;
  140066. /**
  140067. * Creates the "frame" texture Buffer
  140068. * -------------------------------------
  140069. * Structure of frames
  140070. * "filename": "Falling-Water-2.png",
  140071. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140072. * "rotated": true,
  140073. * "trimmed": true,
  140074. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140075. * "sourceSize": {"w":32,"h":32}
  140076. * @returns RawTexture of the frameMap
  140077. */
  140078. private _createFrameBuffer;
  140079. /**
  140080. * Creates the tileMap texture Buffer
  140081. * @param buffer normally and array of numbers, or a false to generate from scratch
  140082. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140083. * @returns RawTexture of the tileMap
  140084. */
  140085. private _createTileBuffer;
  140086. /**
  140087. * Modifies the data of the tileMaps
  140088. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140089. * @param pos is the iVector2 Coordinates of the Tile
  140090. * @param tile The SpriteIndex of the new Tile
  140091. */
  140092. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140093. /**
  140094. * Creates the animationMap texture Buffer
  140095. * @param buffer normally and array of numbers, or a false to generate from scratch
  140096. * @returns RawTexture of the animationMap
  140097. */
  140098. private _createTileAnimationBuffer;
  140099. /**
  140100. * Modifies the data of the animationMap
  140101. * @param cellID is the Index of the Sprite
  140102. * @param _frame is the target Animation frame
  140103. * @param toCell is the Target Index of the next frame of the animation
  140104. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140105. * @param speed is a global scalar of the time variable on the map.
  140106. */
  140107. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140108. /**
  140109. * Exports the .tilemaps file
  140110. */
  140111. saveTileMaps(): void;
  140112. /**
  140113. * Imports the .tilemaps file
  140114. * @param url of the .tilemaps file
  140115. */
  140116. loadTileMaps(url: string): void;
  140117. /**
  140118. * Release associated resources
  140119. */
  140120. dispose(): void;
  140121. }
  140122. }
  140123. declare module BABYLON {
  140124. /**
  140125. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140126. * @see http://doc.babylonjs.com/babylon101/sprites
  140127. */
  140128. export class SpritePackedManager extends SpriteManager {
  140129. /** defines the packed manager's name */
  140130. name: string;
  140131. /**
  140132. * Creates a new sprite manager from a packed sprite sheet
  140133. * @param name defines the manager's name
  140134. * @param imgUrl defines the sprite sheet url
  140135. * @param capacity defines the maximum allowed number of sprites
  140136. * @param scene defines the hosting scene
  140137. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140138. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140139. * @param samplingMode defines the smapling mode to use with spritesheet
  140140. * @param fromPacked set to true; do not alter
  140141. */
  140142. constructor(
  140143. /** defines the packed manager's name */
  140144. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140145. }
  140146. }
  140147. declare module BABYLON {
  140148. /**
  140149. * Defines the list of states available for a task inside a AssetsManager
  140150. */
  140151. export enum AssetTaskState {
  140152. /**
  140153. * Initialization
  140154. */
  140155. INIT = 0,
  140156. /**
  140157. * Running
  140158. */
  140159. RUNNING = 1,
  140160. /**
  140161. * Done
  140162. */
  140163. DONE = 2,
  140164. /**
  140165. * Error
  140166. */
  140167. ERROR = 3
  140168. }
  140169. /**
  140170. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140171. */
  140172. export abstract class AbstractAssetTask {
  140173. /**
  140174. * Task name
  140175. */ name: string;
  140176. /**
  140177. * Callback called when the task is successful
  140178. */
  140179. onSuccess: (task: any) => void;
  140180. /**
  140181. * Callback called when the task is not successful
  140182. */
  140183. onError: (task: any, message?: string, exception?: any) => void;
  140184. /**
  140185. * Creates a new AssetsManager
  140186. * @param name defines the name of the task
  140187. */
  140188. constructor(
  140189. /**
  140190. * Task name
  140191. */ name: string);
  140192. private _isCompleted;
  140193. private _taskState;
  140194. private _errorObject;
  140195. /**
  140196. * Get if the task is completed
  140197. */
  140198. get isCompleted(): boolean;
  140199. /**
  140200. * Gets the current state of the task
  140201. */
  140202. get taskState(): AssetTaskState;
  140203. /**
  140204. * Gets the current error object (if task is in error)
  140205. */
  140206. get errorObject(): {
  140207. message?: string;
  140208. exception?: any;
  140209. };
  140210. /**
  140211. * Internal only
  140212. * @hidden
  140213. */
  140214. _setErrorObject(message?: string, exception?: any): void;
  140215. /**
  140216. * Execute the current task
  140217. * @param scene defines the scene where you want your assets to be loaded
  140218. * @param onSuccess is a callback called when the task is successfully executed
  140219. * @param onError is a callback called if an error occurs
  140220. */
  140221. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140222. /**
  140223. * Execute the current task
  140224. * @param scene defines the scene where you want your assets to be loaded
  140225. * @param onSuccess is a callback called when the task is successfully executed
  140226. * @param onError is a callback called if an error occurs
  140227. */
  140228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140229. /**
  140230. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140231. * This can be used with failed tasks that have the reason for failure fixed.
  140232. */
  140233. reset(): void;
  140234. private onErrorCallback;
  140235. private onDoneCallback;
  140236. }
  140237. /**
  140238. * Define the interface used by progress events raised during assets loading
  140239. */
  140240. export interface IAssetsProgressEvent {
  140241. /**
  140242. * Defines the number of remaining tasks to process
  140243. */
  140244. remainingCount: number;
  140245. /**
  140246. * Defines the total number of tasks
  140247. */
  140248. totalCount: number;
  140249. /**
  140250. * Defines the task that was just processed
  140251. */
  140252. task: AbstractAssetTask;
  140253. }
  140254. /**
  140255. * Class used to share progress information about assets loading
  140256. */
  140257. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140258. /**
  140259. * Defines the number of remaining tasks to process
  140260. */
  140261. remainingCount: number;
  140262. /**
  140263. * Defines the total number of tasks
  140264. */
  140265. totalCount: number;
  140266. /**
  140267. * Defines the task that was just processed
  140268. */
  140269. task: AbstractAssetTask;
  140270. /**
  140271. * Creates a AssetsProgressEvent
  140272. * @param remainingCount defines the number of remaining tasks to process
  140273. * @param totalCount defines the total number of tasks
  140274. * @param task defines the task that was just processed
  140275. */
  140276. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140277. }
  140278. /**
  140279. * Define a task used by AssetsManager to load meshes
  140280. */
  140281. export class MeshAssetTask extends AbstractAssetTask {
  140282. /**
  140283. * Defines the name of the task
  140284. */
  140285. name: string;
  140286. /**
  140287. * Defines the list of mesh's names you want to load
  140288. */
  140289. meshesNames: any;
  140290. /**
  140291. * Defines the root url to use as a base to load your meshes and associated resources
  140292. */
  140293. rootUrl: string;
  140294. /**
  140295. * Defines the filename of the scene to load from
  140296. */
  140297. sceneFilename: string;
  140298. /**
  140299. * Gets the list of loaded meshes
  140300. */
  140301. loadedMeshes: Array<AbstractMesh>;
  140302. /**
  140303. * Gets the list of loaded particle systems
  140304. */
  140305. loadedParticleSystems: Array<IParticleSystem>;
  140306. /**
  140307. * Gets the list of loaded skeletons
  140308. */
  140309. loadedSkeletons: Array<Skeleton>;
  140310. /**
  140311. * Gets the list of loaded animation groups
  140312. */
  140313. loadedAnimationGroups: Array<AnimationGroup>;
  140314. /**
  140315. * Callback called when the task is successful
  140316. */
  140317. onSuccess: (task: MeshAssetTask) => void;
  140318. /**
  140319. * Callback called when the task is successful
  140320. */
  140321. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140322. /**
  140323. * Creates a new MeshAssetTask
  140324. * @param name defines the name of the task
  140325. * @param meshesNames defines the list of mesh's names you want to load
  140326. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140327. * @param sceneFilename defines the filename of the scene to load from
  140328. */
  140329. constructor(
  140330. /**
  140331. * Defines the name of the task
  140332. */
  140333. name: string,
  140334. /**
  140335. * Defines the list of mesh's names you want to load
  140336. */
  140337. meshesNames: any,
  140338. /**
  140339. * Defines the root url to use as a base to load your meshes and associated resources
  140340. */
  140341. rootUrl: string,
  140342. /**
  140343. * Defines the filename of the scene to load from
  140344. */
  140345. sceneFilename: string);
  140346. /**
  140347. * Execute the current task
  140348. * @param scene defines the scene where you want your assets to be loaded
  140349. * @param onSuccess is a callback called when the task is successfully executed
  140350. * @param onError is a callback called if an error occurs
  140351. */
  140352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140353. }
  140354. /**
  140355. * Define a task used by AssetsManager to load text content
  140356. */
  140357. export class TextFileAssetTask extends AbstractAssetTask {
  140358. /**
  140359. * Defines the name of the task
  140360. */
  140361. name: string;
  140362. /**
  140363. * Defines the location of the file to load
  140364. */
  140365. url: string;
  140366. /**
  140367. * Gets the loaded text string
  140368. */
  140369. text: string;
  140370. /**
  140371. * Callback called when the task is successful
  140372. */
  140373. onSuccess: (task: TextFileAssetTask) => void;
  140374. /**
  140375. * Callback called when the task is successful
  140376. */
  140377. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140378. /**
  140379. * Creates a new TextFileAssetTask object
  140380. * @param name defines the name of the task
  140381. * @param url defines the location of the file to load
  140382. */
  140383. constructor(
  140384. /**
  140385. * Defines the name of the task
  140386. */
  140387. name: string,
  140388. /**
  140389. * Defines the location of the file to load
  140390. */
  140391. url: string);
  140392. /**
  140393. * Execute the current task
  140394. * @param scene defines the scene where you want your assets to be loaded
  140395. * @param onSuccess is a callback called when the task is successfully executed
  140396. * @param onError is a callback called if an error occurs
  140397. */
  140398. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140399. }
  140400. /**
  140401. * Define a task used by AssetsManager to load binary data
  140402. */
  140403. export class BinaryFileAssetTask extends AbstractAssetTask {
  140404. /**
  140405. * Defines the name of the task
  140406. */
  140407. name: string;
  140408. /**
  140409. * Defines the location of the file to load
  140410. */
  140411. url: string;
  140412. /**
  140413. * Gets the lodaded data (as an array buffer)
  140414. */
  140415. data: ArrayBuffer;
  140416. /**
  140417. * Callback called when the task is successful
  140418. */
  140419. onSuccess: (task: BinaryFileAssetTask) => void;
  140420. /**
  140421. * Callback called when the task is successful
  140422. */
  140423. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140424. /**
  140425. * Creates a new BinaryFileAssetTask object
  140426. * @param name defines the name of the new task
  140427. * @param url defines the location of the file to load
  140428. */
  140429. constructor(
  140430. /**
  140431. * Defines the name of the task
  140432. */
  140433. name: string,
  140434. /**
  140435. * Defines the location of the file to load
  140436. */
  140437. url: string);
  140438. /**
  140439. * Execute the current task
  140440. * @param scene defines the scene where you want your assets to be loaded
  140441. * @param onSuccess is a callback called when the task is successfully executed
  140442. * @param onError is a callback called if an error occurs
  140443. */
  140444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140445. }
  140446. /**
  140447. * Define a task used by AssetsManager to load images
  140448. */
  140449. export class ImageAssetTask extends AbstractAssetTask {
  140450. /**
  140451. * Defines the name of the task
  140452. */
  140453. name: string;
  140454. /**
  140455. * Defines the location of the image to load
  140456. */
  140457. url: string;
  140458. /**
  140459. * Gets the loaded images
  140460. */
  140461. image: HTMLImageElement;
  140462. /**
  140463. * Callback called when the task is successful
  140464. */
  140465. onSuccess: (task: ImageAssetTask) => void;
  140466. /**
  140467. * Callback called when the task is successful
  140468. */
  140469. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140470. /**
  140471. * Creates a new ImageAssetTask
  140472. * @param name defines the name of the task
  140473. * @param url defines the location of the image to load
  140474. */
  140475. constructor(
  140476. /**
  140477. * Defines the name of the task
  140478. */
  140479. name: string,
  140480. /**
  140481. * Defines the location of the image to load
  140482. */
  140483. url: string);
  140484. /**
  140485. * Execute the current task
  140486. * @param scene defines the scene where you want your assets to be loaded
  140487. * @param onSuccess is a callback called when the task is successfully executed
  140488. * @param onError is a callback called if an error occurs
  140489. */
  140490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140491. }
  140492. /**
  140493. * Defines the interface used by texture loading tasks
  140494. */
  140495. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140496. /**
  140497. * Gets the loaded texture
  140498. */
  140499. texture: TEX;
  140500. }
  140501. /**
  140502. * Define a task used by AssetsManager to load 2D textures
  140503. */
  140504. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140505. /**
  140506. * Defines the name of the task
  140507. */
  140508. name: string;
  140509. /**
  140510. * Defines the location of the file to load
  140511. */
  140512. url: string;
  140513. /**
  140514. * Defines if mipmap should not be generated (default is false)
  140515. */
  140516. noMipmap?: boolean | undefined;
  140517. /**
  140518. * Defines if texture must be inverted on Y axis (default is false)
  140519. */
  140520. invertY?: boolean | undefined;
  140521. /**
  140522. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140523. */
  140524. samplingMode: number;
  140525. /**
  140526. * Gets the loaded texture
  140527. */
  140528. texture: Texture;
  140529. /**
  140530. * Callback called when the task is successful
  140531. */
  140532. onSuccess: (task: TextureAssetTask) => void;
  140533. /**
  140534. * Callback called when the task is successful
  140535. */
  140536. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140537. /**
  140538. * Creates a new TextureAssetTask object
  140539. * @param name defines the name of the task
  140540. * @param url defines the location of the file to load
  140541. * @param noMipmap defines if mipmap should not be generated (default is false)
  140542. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140543. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140544. */
  140545. constructor(
  140546. /**
  140547. * Defines the name of the task
  140548. */
  140549. name: string,
  140550. /**
  140551. * Defines the location of the file to load
  140552. */
  140553. url: string,
  140554. /**
  140555. * Defines if mipmap should not be generated (default is false)
  140556. */
  140557. noMipmap?: boolean | undefined,
  140558. /**
  140559. * Defines if texture must be inverted on Y axis (default is false)
  140560. */
  140561. invertY?: boolean | undefined,
  140562. /**
  140563. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140564. */
  140565. samplingMode?: number);
  140566. /**
  140567. * Execute the current task
  140568. * @param scene defines the scene where you want your assets to be loaded
  140569. * @param onSuccess is a callback called when the task is successfully executed
  140570. * @param onError is a callback called if an error occurs
  140571. */
  140572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140573. }
  140574. /**
  140575. * Define a task used by AssetsManager to load cube textures
  140576. */
  140577. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140578. /**
  140579. * Defines the name of the task
  140580. */
  140581. name: string;
  140582. /**
  140583. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140584. */
  140585. url: string;
  140586. /**
  140587. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140588. */
  140589. extensions?: string[] | undefined;
  140590. /**
  140591. * Defines if mipmaps should not be generated (default is false)
  140592. */
  140593. noMipmap?: boolean | undefined;
  140594. /**
  140595. * Defines the explicit list of files (undefined by default)
  140596. */
  140597. files?: string[] | undefined;
  140598. /**
  140599. * Gets the loaded texture
  140600. */
  140601. texture: CubeTexture;
  140602. /**
  140603. * Callback called when the task is successful
  140604. */
  140605. onSuccess: (task: CubeTextureAssetTask) => void;
  140606. /**
  140607. * Callback called when the task is successful
  140608. */
  140609. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140610. /**
  140611. * Creates a new CubeTextureAssetTask
  140612. * @param name defines the name of the task
  140613. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140614. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140616. * @param files defines the explicit list of files (undefined by default)
  140617. */
  140618. constructor(
  140619. /**
  140620. * Defines the name of the task
  140621. */
  140622. name: string,
  140623. /**
  140624. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140625. */
  140626. url: string,
  140627. /**
  140628. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140629. */
  140630. extensions?: string[] | undefined,
  140631. /**
  140632. * Defines if mipmaps should not be generated (default is false)
  140633. */
  140634. noMipmap?: boolean | undefined,
  140635. /**
  140636. * Defines the explicit list of files (undefined by default)
  140637. */
  140638. files?: string[] | undefined);
  140639. /**
  140640. * Execute the current task
  140641. * @param scene defines the scene where you want your assets to be loaded
  140642. * @param onSuccess is a callback called when the task is successfully executed
  140643. * @param onError is a callback called if an error occurs
  140644. */
  140645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140646. }
  140647. /**
  140648. * Define a task used by AssetsManager to load HDR cube textures
  140649. */
  140650. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140651. /**
  140652. * Defines the name of the task
  140653. */
  140654. name: string;
  140655. /**
  140656. * Defines the location of the file to load
  140657. */
  140658. url: string;
  140659. /**
  140660. * Defines the desired size (the more it increases the longer the generation will be)
  140661. */
  140662. size: number;
  140663. /**
  140664. * Defines if mipmaps should not be generated (default is false)
  140665. */
  140666. noMipmap: boolean;
  140667. /**
  140668. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140669. */
  140670. generateHarmonics: boolean;
  140671. /**
  140672. * 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)
  140673. */
  140674. gammaSpace: boolean;
  140675. /**
  140676. * Internal Use Only
  140677. */
  140678. reserved: boolean;
  140679. /**
  140680. * Gets the loaded texture
  140681. */
  140682. texture: HDRCubeTexture;
  140683. /**
  140684. * Callback called when the task is successful
  140685. */
  140686. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140687. /**
  140688. * Callback called when the task is successful
  140689. */
  140690. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140691. /**
  140692. * Creates a new HDRCubeTextureAssetTask object
  140693. * @param name defines the name of the task
  140694. * @param url defines the location of the file to load
  140695. * @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.
  140696. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140697. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140698. * @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)
  140699. * @param reserved Internal use only
  140700. */
  140701. constructor(
  140702. /**
  140703. * Defines the name of the task
  140704. */
  140705. name: string,
  140706. /**
  140707. * Defines the location of the file to load
  140708. */
  140709. url: string,
  140710. /**
  140711. * Defines the desired size (the more it increases the longer the generation will be)
  140712. */
  140713. size: number,
  140714. /**
  140715. * Defines if mipmaps should not be generated (default is false)
  140716. */
  140717. noMipmap?: boolean,
  140718. /**
  140719. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140720. */
  140721. generateHarmonics?: boolean,
  140722. /**
  140723. * 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)
  140724. */
  140725. gammaSpace?: boolean,
  140726. /**
  140727. * Internal Use Only
  140728. */
  140729. reserved?: boolean);
  140730. /**
  140731. * Execute the current task
  140732. * @param scene defines the scene where you want your assets to be loaded
  140733. * @param onSuccess is a callback called when the task is successfully executed
  140734. * @param onError is a callback called if an error occurs
  140735. */
  140736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140737. }
  140738. /**
  140739. * Define a task used by AssetsManager to load Equirectangular cube textures
  140740. */
  140741. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140742. /**
  140743. * Defines the name of the task
  140744. */
  140745. name: string;
  140746. /**
  140747. * Defines the location of the file to load
  140748. */
  140749. url: string;
  140750. /**
  140751. * Defines the desired size (the more it increases the longer the generation will be)
  140752. */
  140753. size: number;
  140754. /**
  140755. * Defines if mipmaps should not be generated (default is false)
  140756. */
  140757. noMipmap: boolean;
  140758. /**
  140759. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140760. * but the standard material would require them in Gamma space) (default is true)
  140761. */
  140762. gammaSpace: boolean;
  140763. /**
  140764. * Gets the loaded texture
  140765. */
  140766. texture: EquiRectangularCubeTexture;
  140767. /**
  140768. * Callback called when the task is successful
  140769. */
  140770. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140771. /**
  140772. * Callback called when the task is successful
  140773. */
  140774. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140775. /**
  140776. * Creates a new EquiRectangularCubeTextureAssetTask object
  140777. * @param name defines the name of the task
  140778. * @param url defines the location of the file to load
  140779. * @param size defines the desired size (the more it increases the longer the generation will be)
  140780. * If the size is omitted this implies you are using a preprocessed cubemap.
  140781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140782. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140783. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140784. * (default is true)
  140785. */
  140786. constructor(
  140787. /**
  140788. * Defines the name of the task
  140789. */
  140790. name: string,
  140791. /**
  140792. * Defines the location of the file to load
  140793. */
  140794. url: string,
  140795. /**
  140796. * Defines the desired size (the more it increases the longer the generation will be)
  140797. */
  140798. size: number,
  140799. /**
  140800. * Defines if mipmaps should not be generated (default is false)
  140801. */
  140802. noMipmap?: boolean,
  140803. /**
  140804. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140805. * but the standard material would require them in Gamma space) (default is true)
  140806. */
  140807. gammaSpace?: boolean);
  140808. /**
  140809. * Execute the current task
  140810. * @param scene defines the scene where you want your assets to be loaded
  140811. * @param onSuccess is a callback called when the task is successfully executed
  140812. * @param onError is a callback called if an error occurs
  140813. */
  140814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140815. }
  140816. /**
  140817. * This class can be used to easily import assets into a scene
  140818. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140819. */
  140820. export class AssetsManager {
  140821. private _scene;
  140822. private _isLoading;
  140823. protected _tasks: AbstractAssetTask[];
  140824. protected _waitingTasksCount: number;
  140825. protected _totalTasksCount: number;
  140826. /**
  140827. * Callback called when all tasks are processed
  140828. */
  140829. onFinish: (tasks: AbstractAssetTask[]) => void;
  140830. /**
  140831. * Callback called when a task is successful
  140832. */
  140833. onTaskSuccess: (task: AbstractAssetTask) => void;
  140834. /**
  140835. * Callback called when a task had an error
  140836. */
  140837. onTaskError: (task: AbstractAssetTask) => void;
  140838. /**
  140839. * Callback called when a task is done (whatever the result is)
  140840. */
  140841. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140842. /**
  140843. * Observable called when all tasks are processed
  140844. */
  140845. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140846. /**
  140847. * Observable called when a task had an error
  140848. */
  140849. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140850. /**
  140851. * Observable called when all tasks were executed
  140852. */
  140853. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140854. /**
  140855. * Observable called when a task is done (whatever the result is)
  140856. */
  140857. onProgressObservable: Observable<IAssetsProgressEvent>;
  140858. /**
  140859. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140861. */
  140862. useDefaultLoadingScreen: boolean;
  140863. /**
  140864. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140865. * when all assets have been downloaded.
  140866. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140867. */
  140868. autoHideLoadingUI: boolean;
  140869. /**
  140870. * Creates a new AssetsManager
  140871. * @param scene defines the scene to work on
  140872. */
  140873. constructor(scene: Scene);
  140874. /**
  140875. * Add a MeshAssetTask to the list of active tasks
  140876. * @param taskName defines the name of the new task
  140877. * @param meshesNames defines the name of meshes to load
  140878. * @param rootUrl defines the root url to use to locate files
  140879. * @param sceneFilename defines the filename of the scene file
  140880. * @returns a new MeshAssetTask object
  140881. */
  140882. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140883. /**
  140884. * Add a TextFileAssetTask to the list of active tasks
  140885. * @param taskName defines the name of the new task
  140886. * @param url defines the url of the file to load
  140887. * @returns a new TextFileAssetTask object
  140888. */
  140889. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140890. /**
  140891. * Add a BinaryFileAssetTask to the list of active tasks
  140892. * @param taskName defines the name of the new task
  140893. * @param url defines the url of the file to load
  140894. * @returns a new BinaryFileAssetTask object
  140895. */
  140896. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140897. /**
  140898. * Add a ImageAssetTask to the list of active tasks
  140899. * @param taskName defines the name of the new task
  140900. * @param url defines the url of the file to load
  140901. * @returns a new ImageAssetTask object
  140902. */
  140903. addImageTask(taskName: string, url: string): ImageAssetTask;
  140904. /**
  140905. * Add a TextureAssetTask to the list of active tasks
  140906. * @param taskName defines the name of the new task
  140907. * @param url defines the url of the file to load
  140908. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140909. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140911. * @returns a new TextureAssetTask object
  140912. */
  140913. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140914. /**
  140915. * Add a CubeTextureAssetTask to the list of active tasks
  140916. * @param taskName defines the name of the new task
  140917. * @param url defines the url of the file to load
  140918. * @param extensions defines the extension to use to load the cube map (can be null)
  140919. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140920. * @param files defines the list of files to load (can be null)
  140921. * @returns a new CubeTextureAssetTask object
  140922. */
  140923. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140924. /**
  140925. *
  140926. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140927. * @param taskName defines the name of the new task
  140928. * @param url defines the url of the file to load
  140929. * @param size defines the size you want for the cubemap (can be null)
  140930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140931. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140932. * @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)
  140933. * @param reserved Internal use only
  140934. * @returns a new HDRCubeTextureAssetTask object
  140935. */
  140936. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140937. /**
  140938. *
  140939. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140940. * @param taskName defines the name of the new task
  140941. * @param url defines the url of the file to load
  140942. * @param size defines the size you want for the cubemap (can be null)
  140943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140944. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140945. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140946. * @returns a new EquiRectangularCubeTextureAssetTask object
  140947. */
  140948. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140949. /**
  140950. * Remove a task from the assets manager.
  140951. * @param task the task to remove
  140952. */
  140953. removeTask(task: AbstractAssetTask): void;
  140954. private _decreaseWaitingTasksCount;
  140955. private _runTask;
  140956. /**
  140957. * Reset the AssetsManager and remove all tasks
  140958. * @return the current instance of the AssetsManager
  140959. */
  140960. reset(): AssetsManager;
  140961. /**
  140962. * Start the loading process
  140963. * @return the current instance of the AssetsManager
  140964. */
  140965. load(): AssetsManager;
  140966. /**
  140967. * Start the loading process as an async operation
  140968. * @return a promise returning the list of failed tasks
  140969. */
  140970. loadAsync(): Promise<void>;
  140971. }
  140972. }
  140973. declare module BABYLON {
  140974. /**
  140975. * Wrapper class for promise with external resolve and reject.
  140976. */
  140977. export class Deferred<T> {
  140978. /**
  140979. * The promise associated with this deferred object.
  140980. */
  140981. readonly promise: Promise<T>;
  140982. private _resolve;
  140983. private _reject;
  140984. /**
  140985. * The resolve method of the promise associated with this deferred object.
  140986. */
  140987. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140988. /**
  140989. * The reject method of the promise associated with this deferred object.
  140990. */
  140991. get reject(): (reason?: any) => void;
  140992. /**
  140993. * Constructor for this deferred object.
  140994. */
  140995. constructor();
  140996. }
  140997. }
  140998. declare module BABYLON {
  140999. /**
  141000. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141001. */
  141002. export class MeshExploder {
  141003. private _centerMesh;
  141004. private _meshes;
  141005. private _meshesOrigins;
  141006. private _toCenterVectors;
  141007. private _scaledDirection;
  141008. private _newPosition;
  141009. private _centerPosition;
  141010. /**
  141011. * Explodes meshes from a center mesh.
  141012. * @param meshes The meshes to explode.
  141013. * @param centerMesh The mesh to be center of explosion.
  141014. */
  141015. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141016. private _setCenterMesh;
  141017. /**
  141018. * Get class name
  141019. * @returns "MeshExploder"
  141020. */
  141021. getClassName(): string;
  141022. /**
  141023. * "Exploded meshes"
  141024. * @returns Array of meshes with the centerMesh at index 0.
  141025. */
  141026. getMeshes(): Array<Mesh>;
  141027. /**
  141028. * Explodes meshes giving a specific direction
  141029. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141030. */
  141031. explode(direction?: number): void;
  141032. }
  141033. }
  141034. declare module BABYLON {
  141035. /**
  141036. * Class used to help managing file picking and drag'n'drop
  141037. */
  141038. export class FilesInput {
  141039. /**
  141040. * List of files ready to be loaded
  141041. */
  141042. static get FilesToLoad(): {
  141043. [key: string]: File;
  141044. };
  141045. /**
  141046. * Callback called when a file is processed
  141047. */
  141048. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141049. private _engine;
  141050. private _currentScene;
  141051. private _sceneLoadedCallback;
  141052. private _progressCallback;
  141053. private _additionalRenderLoopLogicCallback;
  141054. private _textureLoadingCallback;
  141055. private _startingProcessingFilesCallback;
  141056. private _onReloadCallback;
  141057. private _errorCallback;
  141058. private _elementToMonitor;
  141059. private _sceneFileToLoad;
  141060. private _filesToLoad;
  141061. /**
  141062. * Creates a new FilesInput
  141063. * @param engine defines the rendering engine
  141064. * @param scene defines the hosting scene
  141065. * @param sceneLoadedCallback callback called when scene is loaded
  141066. * @param progressCallback callback called to track progress
  141067. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141068. * @param textureLoadingCallback callback called when a texture is loading
  141069. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141070. * @param onReloadCallback callback called when a reload is requested
  141071. * @param errorCallback callback call if an error occurs
  141072. */
  141073. 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);
  141074. private _dragEnterHandler;
  141075. private _dragOverHandler;
  141076. private _dropHandler;
  141077. /**
  141078. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141079. * @param elementToMonitor defines the DOM element to track
  141080. */
  141081. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141082. /**
  141083. * Release all associated resources
  141084. */
  141085. dispose(): void;
  141086. private renderFunction;
  141087. private drag;
  141088. private drop;
  141089. private _traverseFolder;
  141090. private _processFiles;
  141091. /**
  141092. * Load files from a drop event
  141093. * @param event defines the drop event to use as source
  141094. */
  141095. loadFiles(event: any): void;
  141096. private _processReload;
  141097. /**
  141098. * Reload the current scene from the loaded files
  141099. */
  141100. reload(): void;
  141101. }
  141102. }
  141103. declare module BABYLON {
  141104. /**
  141105. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141107. */
  141108. export class SceneOptimization {
  141109. /**
  141110. * Defines the priority of this optimization (0 by default which means first in the list)
  141111. */
  141112. priority: number;
  141113. /**
  141114. * Gets a string describing the action executed by the current optimization
  141115. * @returns description string
  141116. */
  141117. getDescription(): string;
  141118. /**
  141119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141120. * @param scene defines the current scene where to apply this optimization
  141121. * @param optimizer defines the current optimizer
  141122. * @returns true if everything that can be done was applied
  141123. */
  141124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141125. /**
  141126. * Creates the SceneOptimization object
  141127. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141128. * @param desc defines the description associated with the optimization
  141129. */
  141130. constructor(
  141131. /**
  141132. * Defines the priority of this optimization (0 by default which means first in the list)
  141133. */
  141134. priority?: number);
  141135. }
  141136. /**
  141137. * Defines an optimization used to reduce the size of render target textures
  141138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141139. */
  141140. export class TextureOptimization extends SceneOptimization {
  141141. /**
  141142. * Defines the priority of this optimization (0 by default which means first in the list)
  141143. */
  141144. priority: number;
  141145. /**
  141146. * 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
  141147. */
  141148. maximumSize: number;
  141149. /**
  141150. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141151. */
  141152. step: number;
  141153. /**
  141154. * Gets a string describing the action executed by the current optimization
  141155. * @returns description string
  141156. */
  141157. getDescription(): string;
  141158. /**
  141159. * Creates the TextureOptimization object
  141160. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141161. * @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
  141162. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141163. */
  141164. constructor(
  141165. /**
  141166. * Defines the priority of this optimization (0 by default which means first in the list)
  141167. */
  141168. priority?: number,
  141169. /**
  141170. * 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
  141171. */
  141172. maximumSize?: number,
  141173. /**
  141174. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141175. */
  141176. step?: number);
  141177. /**
  141178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141179. * @param scene defines the current scene where to apply this optimization
  141180. * @param optimizer defines the current optimizer
  141181. * @returns true if everything that can be done was applied
  141182. */
  141183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141184. }
  141185. /**
  141186. * Defines an optimization used to increase or decrease the rendering resolution
  141187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141188. */
  141189. export class HardwareScalingOptimization extends SceneOptimization {
  141190. /**
  141191. * Defines the priority of this optimization (0 by default which means first in the list)
  141192. */
  141193. priority: number;
  141194. /**
  141195. * Defines the maximum scale to use (2 by default)
  141196. */
  141197. maximumScale: number;
  141198. /**
  141199. * Defines the step to use between two passes (0.5 by default)
  141200. */
  141201. step: number;
  141202. private _currentScale;
  141203. private _directionOffset;
  141204. /**
  141205. * Gets a string describing the action executed by the current optimization
  141206. * @return description string
  141207. */
  141208. getDescription(): string;
  141209. /**
  141210. * Creates the HardwareScalingOptimization object
  141211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141212. * @param maximumScale defines the maximum scale to use (2 by default)
  141213. * @param step defines the step to use between two passes (0.5 by default)
  141214. */
  141215. constructor(
  141216. /**
  141217. * Defines the priority of this optimization (0 by default which means first in the list)
  141218. */
  141219. priority?: number,
  141220. /**
  141221. * Defines the maximum scale to use (2 by default)
  141222. */
  141223. maximumScale?: number,
  141224. /**
  141225. * Defines the step to use between two passes (0.5 by default)
  141226. */
  141227. step?: number);
  141228. /**
  141229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141230. * @param scene defines the current scene where to apply this optimization
  141231. * @param optimizer defines the current optimizer
  141232. * @returns true if everything that can be done was applied
  141233. */
  141234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141235. }
  141236. /**
  141237. * Defines an optimization used to remove shadows
  141238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141239. */
  141240. export class ShadowsOptimization extends SceneOptimization {
  141241. /**
  141242. * Gets a string describing the action executed by the current optimization
  141243. * @return description string
  141244. */
  141245. getDescription(): string;
  141246. /**
  141247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141248. * @param scene defines the current scene where to apply this optimization
  141249. * @param optimizer defines the current optimizer
  141250. * @returns true if everything that can be done was applied
  141251. */
  141252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141253. }
  141254. /**
  141255. * Defines an optimization used to turn post-processes off
  141256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141257. */
  141258. export class PostProcessesOptimization extends SceneOptimization {
  141259. /**
  141260. * Gets a string describing the action executed by the current optimization
  141261. * @return description string
  141262. */
  141263. getDescription(): string;
  141264. /**
  141265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141266. * @param scene defines the current scene where to apply this optimization
  141267. * @param optimizer defines the current optimizer
  141268. * @returns true if everything that can be done was applied
  141269. */
  141270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141271. }
  141272. /**
  141273. * Defines an optimization used to turn lens flares off
  141274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141275. */
  141276. export class LensFlaresOptimization extends SceneOptimization {
  141277. /**
  141278. * Gets a string describing the action executed by the current optimization
  141279. * @return description string
  141280. */
  141281. getDescription(): string;
  141282. /**
  141283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141284. * @param scene defines the current scene where to apply this optimization
  141285. * @param optimizer defines the current optimizer
  141286. * @returns true if everything that can be done was applied
  141287. */
  141288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141289. }
  141290. /**
  141291. * Defines an optimization based on user defined callback.
  141292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141293. */
  141294. export class CustomOptimization extends SceneOptimization {
  141295. /**
  141296. * Callback called to apply the custom optimization.
  141297. */
  141298. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141299. /**
  141300. * Callback called to get custom description
  141301. */
  141302. onGetDescription: () => string;
  141303. /**
  141304. * Gets a string describing the action executed by the current optimization
  141305. * @returns description string
  141306. */
  141307. getDescription(): string;
  141308. /**
  141309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141310. * @param scene defines the current scene where to apply this optimization
  141311. * @param optimizer defines the current optimizer
  141312. * @returns true if everything that can be done was applied
  141313. */
  141314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141315. }
  141316. /**
  141317. * Defines an optimization used to turn particles off
  141318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141319. */
  141320. export class ParticlesOptimization extends SceneOptimization {
  141321. /**
  141322. * Gets a string describing the action executed by the current optimization
  141323. * @return description string
  141324. */
  141325. getDescription(): string;
  141326. /**
  141327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141328. * @param scene defines the current scene where to apply this optimization
  141329. * @param optimizer defines the current optimizer
  141330. * @returns true if everything that can be done was applied
  141331. */
  141332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141333. }
  141334. /**
  141335. * Defines an optimization used to turn render targets off
  141336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141337. */
  141338. export class RenderTargetsOptimization extends SceneOptimization {
  141339. /**
  141340. * Gets a string describing the action executed by the current optimization
  141341. * @return description string
  141342. */
  141343. getDescription(): string;
  141344. /**
  141345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141346. * @param scene defines the current scene where to apply this optimization
  141347. * @param optimizer defines the current optimizer
  141348. * @returns true if everything that can be done was applied
  141349. */
  141350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141351. }
  141352. /**
  141353. * Defines an optimization used to merge meshes with compatible materials
  141354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141355. */
  141356. export class MergeMeshesOptimization extends SceneOptimization {
  141357. private static _UpdateSelectionTree;
  141358. /**
  141359. * Gets or sets a boolean which defines if optimization octree has to be updated
  141360. */
  141361. static get UpdateSelectionTree(): boolean;
  141362. /**
  141363. * Gets or sets a boolean which defines if optimization octree has to be updated
  141364. */
  141365. static set UpdateSelectionTree(value: boolean);
  141366. /**
  141367. * Gets a string describing the action executed by the current optimization
  141368. * @return description string
  141369. */
  141370. getDescription(): string;
  141371. private _canBeMerged;
  141372. /**
  141373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141374. * @param scene defines the current scene where to apply this optimization
  141375. * @param optimizer defines the current optimizer
  141376. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141377. * @returns true if everything that can be done was applied
  141378. */
  141379. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141380. }
  141381. /**
  141382. * Defines a list of options used by SceneOptimizer
  141383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141384. */
  141385. export class SceneOptimizerOptions {
  141386. /**
  141387. * Defines the target frame rate to reach (60 by default)
  141388. */
  141389. targetFrameRate: number;
  141390. /**
  141391. * Defines the interval between two checkes (2000ms by default)
  141392. */
  141393. trackerDuration: number;
  141394. /**
  141395. * Gets the list of optimizations to apply
  141396. */
  141397. optimizations: SceneOptimization[];
  141398. /**
  141399. * Creates a new list of options used by SceneOptimizer
  141400. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141401. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141402. */
  141403. constructor(
  141404. /**
  141405. * Defines the target frame rate to reach (60 by default)
  141406. */
  141407. targetFrameRate?: number,
  141408. /**
  141409. * Defines the interval between two checkes (2000ms by default)
  141410. */
  141411. trackerDuration?: number);
  141412. /**
  141413. * Add a new optimization
  141414. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141415. * @returns the current SceneOptimizerOptions
  141416. */
  141417. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141418. /**
  141419. * Add a new custom optimization
  141420. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141421. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141423. * @returns the current SceneOptimizerOptions
  141424. */
  141425. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141426. /**
  141427. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141428. * @param targetFrameRate defines the target frame rate (60 by default)
  141429. * @returns a SceneOptimizerOptions object
  141430. */
  141431. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141432. /**
  141433. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141434. * @param targetFrameRate defines the target frame rate (60 by default)
  141435. * @returns a SceneOptimizerOptions object
  141436. */
  141437. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141438. /**
  141439. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141440. * @param targetFrameRate defines the target frame rate (60 by default)
  141441. * @returns a SceneOptimizerOptions object
  141442. */
  141443. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141444. }
  141445. /**
  141446. * Class used to run optimizations in order to reach a target frame rate
  141447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141448. */
  141449. export class SceneOptimizer implements IDisposable {
  141450. private _isRunning;
  141451. private _options;
  141452. private _scene;
  141453. private _currentPriorityLevel;
  141454. private _targetFrameRate;
  141455. private _trackerDuration;
  141456. private _currentFrameRate;
  141457. private _sceneDisposeObserver;
  141458. private _improvementMode;
  141459. /**
  141460. * Defines an observable called when the optimizer reaches the target frame rate
  141461. */
  141462. onSuccessObservable: Observable<SceneOptimizer>;
  141463. /**
  141464. * Defines an observable called when the optimizer enables an optimization
  141465. */
  141466. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141467. /**
  141468. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141469. */
  141470. onFailureObservable: Observable<SceneOptimizer>;
  141471. /**
  141472. * Gets a boolean indicating if the optimizer is in improvement mode
  141473. */
  141474. get isInImprovementMode(): boolean;
  141475. /**
  141476. * Gets the current priority level (0 at start)
  141477. */
  141478. get currentPriorityLevel(): number;
  141479. /**
  141480. * Gets the current frame rate checked by the SceneOptimizer
  141481. */
  141482. get currentFrameRate(): number;
  141483. /**
  141484. * Gets or sets the current target frame rate (60 by default)
  141485. */
  141486. get targetFrameRate(): number;
  141487. /**
  141488. * Gets or sets the current target frame rate (60 by default)
  141489. */
  141490. set targetFrameRate(value: number);
  141491. /**
  141492. * Gets or sets the current interval between two checks (every 2000ms by default)
  141493. */
  141494. get trackerDuration(): number;
  141495. /**
  141496. * Gets or sets the current interval between two checks (every 2000ms by default)
  141497. */
  141498. set trackerDuration(value: number);
  141499. /**
  141500. * Gets the list of active optimizations
  141501. */
  141502. get optimizations(): SceneOptimization[];
  141503. /**
  141504. * Creates a new SceneOptimizer
  141505. * @param scene defines the scene to work on
  141506. * @param options defines the options to use with the SceneOptimizer
  141507. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141508. * @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)
  141509. */
  141510. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141511. /**
  141512. * Stops the current optimizer
  141513. */
  141514. stop(): void;
  141515. /**
  141516. * Reset the optimizer to initial step (current priority level = 0)
  141517. */
  141518. reset(): void;
  141519. /**
  141520. * Start the optimizer. By default it will try to reach a specific framerate
  141521. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141522. */
  141523. start(): void;
  141524. private _checkCurrentState;
  141525. /**
  141526. * Release all resources
  141527. */
  141528. dispose(): void;
  141529. /**
  141530. * Helper function to create a SceneOptimizer with one single line of code
  141531. * @param scene defines the scene to work on
  141532. * @param options defines the options to use with the SceneOptimizer
  141533. * @param onSuccess defines a callback to call on success
  141534. * @param onFailure defines a callback to call on failure
  141535. * @returns the new SceneOptimizer object
  141536. */
  141537. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141538. }
  141539. }
  141540. declare module BABYLON {
  141541. /**
  141542. * Class used to serialize a scene into a string
  141543. */
  141544. export class SceneSerializer {
  141545. /**
  141546. * Clear cache used by a previous serialization
  141547. */
  141548. static ClearCache(): void;
  141549. /**
  141550. * Serialize a scene into a JSON compatible object
  141551. * @param scene defines the scene to serialize
  141552. * @returns a JSON compatible object
  141553. */
  141554. static Serialize(scene: Scene): any;
  141555. /**
  141556. * Serialize a mesh into a JSON compatible object
  141557. * @param toSerialize defines the mesh to serialize
  141558. * @param withParents defines if parents must be serialized as well
  141559. * @param withChildren defines if children must be serialized as well
  141560. * @returns a JSON compatible object
  141561. */
  141562. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141563. }
  141564. }
  141565. declare module BABYLON {
  141566. /**
  141567. * Class used to host texture specific utilities
  141568. */
  141569. export class TextureTools {
  141570. /**
  141571. * Uses the GPU to create a copy texture rescaled at a given size
  141572. * @param texture Texture to copy from
  141573. * @param width defines the desired width
  141574. * @param height defines the desired height
  141575. * @param useBilinearMode defines if bilinear mode has to be used
  141576. * @return the generated texture
  141577. */
  141578. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141579. }
  141580. }
  141581. declare module BABYLON {
  141582. /**
  141583. * This represents the different options available for the video capture.
  141584. */
  141585. export interface VideoRecorderOptions {
  141586. /** Defines the mime type of the video. */
  141587. mimeType: string;
  141588. /** Defines the FPS the video should be recorded at. */
  141589. fps: number;
  141590. /** Defines the chunk size for the recording data. */
  141591. recordChunckSize: number;
  141592. /** The audio tracks to attach to the recording. */
  141593. audioTracks?: MediaStreamTrack[];
  141594. }
  141595. /**
  141596. * This can help with recording videos from BabylonJS.
  141597. * This is based on the available WebRTC functionalities of the browser.
  141598. *
  141599. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141600. */
  141601. export class VideoRecorder {
  141602. private static readonly _defaultOptions;
  141603. /**
  141604. * Returns whether or not the VideoRecorder is available in your browser.
  141605. * @param engine Defines the Babylon Engine.
  141606. * @returns true if supported otherwise false.
  141607. */
  141608. static IsSupported(engine: Engine): boolean;
  141609. private readonly _options;
  141610. private _canvas;
  141611. private _mediaRecorder;
  141612. private _recordedChunks;
  141613. private _fileName;
  141614. private _resolve;
  141615. private _reject;
  141616. /**
  141617. * True when a recording is already in progress.
  141618. */
  141619. get isRecording(): boolean;
  141620. /**
  141621. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141622. * @param engine Defines the BabylonJS Engine you wish to record.
  141623. * @param options Defines options that can be used to customize the capture.
  141624. */
  141625. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141626. /**
  141627. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141628. */
  141629. stopRecording(): void;
  141630. /**
  141631. * Starts recording the canvas for a max duration specified in parameters.
  141632. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141633. * If null no automatic download will start and you can rely on the promise to get the data back.
  141634. * @param maxDuration Defines the maximum recording time in seconds.
  141635. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141636. * @return A promise callback at the end of the recording with the video data in Blob.
  141637. */
  141638. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141639. /**
  141640. * Releases internal resources used during the recording.
  141641. */
  141642. dispose(): void;
  141643. private _handleDataAvailable;
  141644. private _handleError;
  141645. private _handleStop;
  141646. }
  141647. }
  141648. declare module BABYLON {
  141649. /**
  141650. * Class containing a set of static utilities functions for screenshots
  141651. */
  141652. export class ScreenshotTools {
  141653. /**
  141654. * Captures a screenshot of the current rendering
  141655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141656. * @param engine defines the rendering engine
  141657. * @param camera defines the source camera
  141658. * @param size This parameter can be set to a single number or to an object with the
  141659. * following (optional) properties: precision, width, height. If a single number is passed,
  141660. * it will be used for both width and height. If an object is passed, the screenshot size
  141661. * will be derived from the parameters. The precision property is a multiplier allowing
  141662. * rendering at a higher or lower resolution
  141663. * @param successCallback defines the callback receives a single parameter which contains the
  141664. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141665. * src parameter of an <img> to display it
  141666. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141667. * Check your browser for supported MIME types
  141668. */
  141669. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141670. /**
  141671. * Captures a screenshot of the current rendering
  141672. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141673. * @param engine defines the rendering engine
  141674. * @param camera defines the source camera
  141675. * @param size This parameter can be set to a single number or to an object with the
  141676. * following (optional) properties: precision, width, height. If a single number is passed,
  141677. * it will be used for both width and height. If an object is passed, the screenshot size
  141678. * will be derived from the parameters. The precision property is a multiplier allowing
  141679. * rendering at a higher or lower resolution
  141680. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141681. * Check your browser for supported MIME types
  141682. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141683. * to the src parameter of an <img> to display it
  141684. */
  141685. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141686. /**
  141687. * Generates an image screenshot from the specified camera.
  141688. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141689. * @param engine The engine to use for rendering
  141690. * @param camera The camera to use for rendering
  141691. * @param size This parameter can be set to a single number or to an object with the
  141692. * following (optional) properties: precision, width, height. If a single number is passed,
  141693. * it will be used for both width and height. If an object is passed, the screenshot size
  141694. * will be derived from the parameters. The precision property is a multiplier allowing
  141695. * rendering at a higher or lower resolution
  141696. * @param successCallback The callback receives a single parameter which contains the
  141697. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141698. * src parameter of an <img> to display it
  141699. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141700. * Check your browser for supported MIME types
  141701. * @param samples Texture samples (default: 1)
  141702. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141703. * @param fileName A name for for the downloaded file.
  141704. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141705. */
  141706. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141707. /**
  141708. * Generates an image screenshot from the specified camera.
  141709. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141710. * @param engine The engine to use for rendering
  141711. * @param camera The camera to use for rendering
  141712. * @param size This parameter can be set to a single number or to an object with the
  141713. * following (optional) properties: precision, width, height. If a single number is passed,
  141714. * it will be used for both width and height. If an object is passed, the screenshot size
  141715. * will be derived from the parameters. The precision property is a multiplier allowing
  141716. * rendering at a higher or lower resolution
  141717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141718. * Check your browser for supported MIME types
  141719. * @param samples Texture samples (default: 1)
  141720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141721. * @param fileName A name for for the downloaded file.
  141722. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141724. * to the src parameter of an <img> to display it
  141725. */
  141726. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141727. /**
  141728. * Gets height and width for screenshot size
  141729. * @private
  141730. */
  141731. private static _getScreenshotSize;
  141732. }
  141733. }
  141734. declare module BABYLON {
  141735. /**
  141736. * Interface for a data buffer
  141737. */
  141738. export interface IDataBuffer {
  141739. /**
  141740. * Reads bytes from the data buffer.
  141741. * @param byteOffset The byte offset to read
  141742. * @param byteLength The byte length to read
  141743. * @returns A promise that resolves when the bytes are read
  141744. */
  141745. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141746. /**
  141747. * The byte length of the buffer.
  141748. */
  141749. readonly byteLength: number;
  141750. }
  141751. /**
  141752. * Utility class for reading from a data buffer
  141753. */
  141754. export class DataReader {
  141755. /**
  141756. * The data buffer associated with this data reader.
  141757. */
  141758. readonly buffer: IDataBuffer;
  141759. /**
  141760. * The current byte offset from the beginning of the data buffer.
  141761. */
  141762. byteOffset: number;
  141763. private _dataView;
  141764. private _dataByteOffset;
  141765. /**
  141766. * Constructor
  141767. * @param buffer The buffer to read
  141768. */
  141769. constructor(buffer: IDataBuffer);
  141770. /**
  141771. * Loads the given byte length.
  141772. * @param byteLength The byte length to load
  141773. * @returns A promise that resolves when the load is complete
  141774. */
  141775. loadAsync(byteLength: number): Promise<void>;
  141776. /**
  141777. * Read a unsigned 32-bit integer from the currently loaded data range.
  141778. * @returns The 32-bit integer read
  141779. */
  141780. readUint32(): number;
  141781. /**
  141782. * Read a byte array from the currently loaded data range.
  141783. * @param byteLength The byte length to read
  141784. * @returns The byte array read
  141785. */
  141786. readUint8Array(byteLength: number): Uint8Array;
  141787. /**
  141788. * Read a string from the currently loaded data range.
  141789. * @param byteLength The byte length to read
  141790. * @returns The string read
  141791. */
  141792. readString(byteLength: number): string;
  141793. /**
  141794. * Skips the given byte length the currently loaded data range.
  141795. * @param byteLength The byte length to skip
  141796. */
  141797. skipBytes(byteLength: number): void;
  141798. }
  141799. }
  141800. declare module BABYLON {
  141801. /**
  141802. * Options used for hit testing
  141803. */
  141804. export interface IWebXRHitTestOptions {
  141805. /**
  141806. * Only test when user interacted with the scene. Default - hit test every frame
  141807. */
  141808. testOnPointerDownOnly?: boolean;
  141809. /**
  141810. * The node to use to transform the local results to world coordinates
  141811. */
  141812. worldParentNode?: TransformNode;
  141813. }
  141814. /**
  141815. * Interface defining the babylon result of raycasting/hit-test
  141816. */
  141817. export interface IWebXRHitResult {
  141818. /**
  141819. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141820. */
  141821. transformationMatrix: Matrix;
  141822. /**
  141823. * The native hit test result
  141824. */
  141825. xrHitResult: XRHitResult;
  141826. }
  141827. /**
  141828. * The currently-working hit-test module.
  141829. * Hit test (or Ray-casting) is used to interact with the real world.
  141830. * For further information read here - https://github.com/immersive-web/hit-test
  141831. */
  141832. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141833. /**
  141834. * options to use when constructing this feature
  141835. */
  141836. readonly options: IWebXRHitTestOptions;
  141837. private _direction;
  141838. private _mat;
  141839. private _onSelectEnabled;
  141840. private _origin;
  141841. /**
  141842. * The module's name
  141843. */
  141844. static readonly Name: string;
  141845. /**
  141846. * The (Babylon) version of this module.
  141847. * This is an integer representing the implementation version.
  141848. * This number does not correspond to the WebXR specs version
  141849. */
  141850. static readonly Version: number;
  141851. /**
  141852. * Populated with the last native XR Hit Results
  141853. */
  141854. lastNativeXRHitResults: XRHitResult[];
  141855. /**
  141856. * Triggered when new babylon (transformed) hit test results are available
  141857. */
  141858. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141859. /**
  141860. * Creates a new instance of the (legacy version) hit test feature
  141861. * @param _xrSessionManager an instance of WebXRSessionManager
  141862. * @param options options to use when constructing this feature
  141863. */
  141864. constructor(_xrSessionManager: WebXRSessionManager,
  141865. /**
  141866. * options to use when constructing this feature
  141867. */
  141868. options?: IWebXRHitTestOptions);
  141869. /**
  141870. * execute a hit test with an XR Ray
  141871. *
  141872. * @param xrSession a native xrSession that will execute this hit test
  141873. * @param xrRay the ray (position and direction) to use for ray-casting
  141874. * @param referenceSpace native XR reference space to use for the hit-test
  141875. * @param filter filter function that will filter the results
  141876. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141877. */
  141878. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141879. /**
  141880. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141881. * @param event the (select) event to use to select with
  141882. * @param referenceSpace the reference space to use for this hit test
  141883. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141884. */
  141885. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141886. /**
  141887. * attach this feature
  141888. * Will usually be called by the features manager
  141889. *
  141890. * @returns true if successful.
  141891. */
  141892. attach(): boolean;
  141893. /**
  141894. * detach this feature.
  141895. * Will usually be called by the features manager
  141896. *
  141897. * @returns true if successful.
  141898. */
  141899. detach(): boolean;
  141900. /**
  141901. * Dispose this feature and all of the resources attached
  141902. */
  141903. dispose(): void;
  141904. protected _onXRFrame(frame: XRFrame): void;
  141905. private _onHitTestResults;
  141906. private _onSelect;
  141907. }
  141908. }
  141909. declare module BABYLON {
  141910. /**
  141911. * Options used in the plane detector module
  141912. */
  141913. export interface IWebXRPlaneDetectorOptions {
  141914. /**
  141915. * The node to use to transform the local results to world coordinates
  141916. */
  141917. worldParentNode?: TransformNode;
  141918. }
  141919. /**
  141920. * A babylon interface for a WebXR plane.
  141921. * A Plane is actually a polygon, built from N points in space
  141922. *
  141923. * Supported in chrome 79, not supported in canary 81 ATM
  141924. */
  141925. export interface IWebXRPlane {
  141926. /**
  141927. * a babylon-assigned ID for this polygon
  141928. */
  141929. id: number;
  141930. /**
  141931. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141932. */
  141933. polygonDefinition: Array<Vector3>;
  141934. /**
  141935. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141936. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141937. */
  141938. transformationMatrix: Matrix;
  141939. /**
  141940. * the native xr-plane object
  141941. */
  141942. xrPlane: XRPlane;
  141943. }
  141944. /**
  141945. * The plane detector is used to detect planes in the real world when in AR
  141946. * For more information see https://github.com/immersive-web/real-world-geometry/
  141947. */
  141948. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141949. private _options;
  141950. private _detectedPlanes;
  141951. private _enabled;
  141952. private _lastFrameDetected;
  141953. /**
  141954. * The module's name
  141955. */
  141956. static readonly Name: string;
  141957. /**
  141958. * The (Babylon) version of this module.
  141959. * This is an integer representing the implementation version.
  141960. * This number does not correspond to the WebXR specs version
  141961. */
  141962. static readonly Version: number;
  141963. /**
  141964. * Observers registered here will be executed when a new plane was added to the session
  141965. */
  141966. onPlaneAddedObservable: Observable<IWebXRPlane>;
  141967. /**
  141968. * Observers registered here will be executed when a plane is no longer detected in the session
  141969. */
  141970. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  141971. /**
  141972. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  141973. * This can execute N times every frame
  141974. */
  141975. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  141976. /**
  141977. * construct a new Plane Detector
  141978. * @param _xrSessionManager an instance of xr Session manager
  141979. * @param _options configuration to use when constructing this feature
  141980. */
  141981. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  141982. /**
  141983. * Dispose this feature and all of the resources attached
  141984. */
  141985. dispose(): void;
  141986. protected _onXRFrame(frame: XRFrame): void;
  141987. private _init;
  141988. private _updatePlaneWithXRPlane;
  141989. /**
  141990. * avoiding using Array.find for global support.
  141991. * @param xrPlane the plane to find in the array
  141992. */
  141993. private findIndexInPlaneArray;
  141994. }
  141995. }
  141996. declare module BABYLON {
  141997. /**
  141998. * Configuration options of the anchor system
  141999. */
  142000. export interface IWebXRAnchorSystemOptions {
  142001. /**
  142002. * Should a new anchor be added every time a select event is triggered
  142003. */
  142004. addAnchorOnSelect?: boolean;
  142005. /**
  142006. * should the anchor system use plane detection.
  142007. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142008. */
  142009. usePlaneDetection?: boolean;
  142010. /**
  142011. * a node that will be used to convert local to world coordinates
  142012. */
  142013. worldParentNode?: TransformNode;
  142014. }
  142015. /**
  142016. * A babylon container for an XR Anchor
  142017. */
  142018. export interface IWebXRAnchor {
  142019. /**
  142020. * A babylon-assigned ID for this anchor
  142021. */
  142022. id: number;
  142023. /**
  142024. * Transformation matrix to apply to an object attached to this anchor
  142025. */
  142026. transformationMatrix: Matrix;
  142027. /**
  142028. * The native anchor object
  142029. */
  142030. xrAnchor: XRAnchor;
  142031. }
  142032. /**
  142033. * An implementation of the anchor system of WebXR.
  142034. * Note that the current documented implementation is not available in any browser. Future implementations
  142035. * will use the frame to create an anchor and not the session or a detected plane
  142036. * For further information see https://github.com/immersive-web/anchors/
  142037. */
  142038. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142039. private _options;
  142040. private _enabled;
  142041. private _hitTestModule;
  142042. private _lastFrameDetected;
  142043. private _onSelect;
  142044. private _planeDetector;
  142045. private _trackedAnchors;
  142046. /**
  142047. * The module's name
  142048. */
  142049. static readonly Name: string;
  142050. /**
  142051. * The (Babylon) version of this module.
  142052. * This is an integer representing the implementation version.
  142053. * This number does not correspond to the WebXR specs version
  142054. */
  142055. static readonly Version: number;
  142056. /**
  142057. * Observers registered here will be executed when a new anchor was added to the session
  142058. */
  142059. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142060. /**
  142061. * Observers registered here will be executed when an anchor was removed from the session
  142062. */
  142063. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142064. /**
  142065. * Observers registered here will be executed when an existing anchor updates
  142066. * This can execute N times every frame
  142067. */
  142068. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142069. /**
  142070. * constructs a new anchor system
  142071. * @param _xrSessionManager an instance of WebXRSessionManager
  142072. * @param _options configuration object for this feature
  142073. */
  142074. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142075. /**
  142076. * Add anchor at a specific XR point.
  142077. *
  142078. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142079. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142080. * @returns a promise the fulfills when the anchor was created
  142081. */
  142082. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142083. /**
  142084. * attach this feature
  142085. * Will usually be called by the features manager
  142086. *
  142087. * @returns true if successful.
  142088. */
  142089. attach(): boolean;
  142090. /**
  142091. * detach this feature.
  142092. * Will usually be called by the features manager
  142093. *
  142094. * @returns true if successful.
  142095. */
  142096. detach(): boolean;
  142097. /**
  142098. * Dispose this feature and all of the resources attached
  142099. */
  142100. dispose(): void;
  142101. /**
  142102. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142103. * @param hitTestModule the hit-test module to use.
  142104. */
  142105. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142106. /**
  142107. * set the plane detector to use in order to create anchors from frames
  142108. * @param planeDetector the plane-detector module to use
  142109. * @param enable enable plane-anchors. default is true
  142110. */
  142111. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142112. protected _onXRFrame(frame: XRFrame): void;
  142113. /**
  142114. * avoiding using Array.find for global support.
  142115. * @param xrAnchor the plane to find in the array
  142116. */
  142117. private _findIndexInAnchorArray;
  142118. private _updateAnchorWithXRFrame;
  142119. }
  142120. }
  142121. declare module BABYLON {
  142122. /**
  142123. * Options interface for the background remover plugin
  142124. */
  142125. export interface IWebXRBackgroundRemoverOptions {
  142126. /**
  142127. * Further background meshes to disable when entering AR
  142128. */
  142129. backgroundMeshes?: AbstractMesh[];
  142130. /**
  142131. * flags to configure the removal of the environment helper.
  142132. * If not set, the entire background will be removed. If set, flags should be set as well.
  142133. */
  142134. environmentHelperRemovalFlags?: {
  142135. /**
  142136. * Should the skybox be removed (default false)
  142137. */
  142138. skyBox?: boolean;
  142139. /**
  142140. * Should the ground be removed (default false)
  142141. */
  142142. ground?: boolean;
  142143. };
  142144. /**
  142145. * don't disable the environment helper
  142146. */
  142147. ignoreEnvironmentHelper?: boolean;
  142148. }
  142149. /**
  142150. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142151. */
  142152. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142153. /**
  142154. * read-only options to be used in this module
  142155. */
  142156. readonly options: IWebXRBackgroundRemoverOptions;
  142157. /**
  142158. * The module's name
  142159. */
  142160. static readonly Name: string;
  142161. /**
  142162. * The (Babylon) version of this module.
  142163. * This is an integer representing the implementation version.
  142164. * This number does not correspond to the WebXR specs version
  142165. */
  142166. static readonly Version: number;
  142167. /**
  142168. * registered observers will be triggered when the background state changes
  142169. */
  142170. onBackgroundStateChangedObservable: Observable<boolean>;
  142171. /**
  142172. * constructs a new background remover module
  142173. * @param _xrSessionManager the session manager for this module
  142174. * @param options read-only options to be used in this module
  142175. */
  142176. constructor(_xrSessionManager: WebXRSessionManager,
  142177. /**
  142178. * read-only options to be used in this module
  142179. */
  142180. options?: IWebXRBackgroundRemoverOptions);
  142181. /**
  142182. * attach this feature
  142183. * Will usually be called by the features manager
  142184. *
  142185. * @returns true if successful.
  142186. */
  142187. attach(): boolean;
  142188. /**
  142189. * detach this feature.
  142190. * Will usually be called by the features manager
  142191. *
  142192. * @returns true if successful.
  142193. */
  142194. detach(): boolean;
  142195. /**
  142196. * Dispose this feature and all of the resources attached
  142197. */
  142198. dispose(): void;
  142199. protected _onXRFrame(_xrFrame: XRFrame): void;
  142200. private _setBackgroundState;
  142201. }
  142202. }
  142203. declare module BABYLON {
  142204. /**
  142205. * Options for the controller physics feature
  142206. */
  142207. export class IWebXRControllerPhysicsOptions {
  142208. /**
  142209. * Should the headset get its own impostor
  142210. */
  142211. enableHeadsetImpostor?: boolean;
  142212. /**
  142213. * Optional parameters for the headset impostor
  142214. */
  142215. headsetImpostorParams?: {
  142216. /**
  142217. * The type of impostor to create. Default is sphere
  142218. */
  142219. impostorType: number;
  142220. /**
  142221. * the size of the impostor. Defaults to 10cm
  142222. */
  142223. impostorSize?: number | {
  142224. width: number;
  142225. height: number;
  142226. depth: number;
  142227. };
  142228. /**
  142229. * Friction definitions
  142230. */
  142231. friction?: number;
  142232. /**
  142233. * Restitution
  142234. */
  142235. restitution?: number;
  142236. };
  142237. /**
  142238. * The physics properties of the future impostors
  142239. */
  142240. physicsProperties?: {
  142241. /**
  142242. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142243. * Note that this requires a physics engine that supports mesh impostors!
  142244. */
  142245. useControllerMesh?: boolean;
  142246. /**
  142247. * The type of impostor to create. Default is sphere
  142248. */
  142249. impostorType?: number;
  142250. /**
  142251. * the size of the impostor. Defaults to 10cm
  142252. */
  142253. impostorSize?: number | {
  142254. width: number;
  142255. height: number;
  142256. depth: number;
  142257. };
  142258. /**
  142259. * Friction definitions
  142260. */
  142261. friction?: number;
  142262. /**
  142263. * Restitution
  142264. */
  142265. restitution?: number;
  142266. };
  142267. /**
  142268. * the xr input to use with this pointer selection
  142269. */
  142270. xrInput: WebXRInput;
  142271. }
  142272. /**
  142273. * Add physics impostor to your webxr controllers,
  142274. * including naive calculation of their linear and angular velocity
  142275. */
  142276. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142277. private readonly _options;
  142278. private _attachController;
  142279. private _controllers;
  142280. private _debugMode;
  142281. private _delta;
  142282. private _headsetImpostor?;
  142283. private _headsetMesh?;
  142284. private _lastTimestamp;
  142285. private _tmpQuaternion;
  142286. private _tmpVector;
  142287. /**
  142288. * The module's name
  142289. */
  142290. static readonly Name: string;
  142291. /**
  142292. * The (Babylon) version of this module.
  142293. * This is an integer representing the implementation version.
  142294. * This number does not correspond to the webxr specs version
  142295. */
  142296. static readonly Version: number;
  142297. /**
  142298. * Construct a new Controller Physics Feature
  142299. * @param _xrSessionManager the corresponding xr session manager
  142300. * @param _options options to create this feature with
  142301. */
  142302. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142303. /**
  142304. * @hidden
  142305. * enable debugging - will show console outputs and the impostor mesh
  142306. */
  142307. _enablePhysicsDebug(): void;
  142308. /**
  142309. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142310. * @param xrController the controller to add
  142311. */
  142312. addController(xrController: WebXRInputSource): void;
  142313. /**
  142314. * attach this feature
  142315. * Will usually be called by the features manager
  142316. *
  142317. * @returns true if successful.
  142318. */
  142319. attach(): boolean;
  142320. /**
  142321. * detach this feature.
  142322. * Will usually be called by the features manager
  142323. *
  142324. * @returns true if successful.
  142325. */
  142326. detach(): boolean;
  142327. /**
  142328. * Get the headset impostor, if enabled
  142329. * @returns the impostor
  142330. */
  142331. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142332. /**
  142333. * Get the physics impostor of a specific controller.
  142334. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142335. * @param controller the controller or the controller id of which to get the impostor
  142336. * @returns the impostor or null
  142337. */
  142338. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142339. /**
  142340. * Update the physics properties provided in the constructor
  142341. * @param newProperties the new properties object
  142342. */
  142343. setPhysicsProperties(newProperties: {
  142344. impostorType?: number;
  142345. impostorSize?: number | {
  142346. width: number;
  142347. height: number;
  142348. depth: number;
  142349. };
  142350. friction?: number;
  142351. restitution?: number;
  142352. }): void;
  142353. protected _onXRFrame(_xrFrame: any): void;
  142354. private _detachController;
  142355. }
  142356. }
  142357. declare module BABYLON {
  142358. /**
  142359. * The motion controller class for all microsoft mixed reality controllers
  142360. */
  142361. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142362. protected readonly _mapping: {
  142363. defaultButton: {
  142364. "valueNodeName": string;
  142365. "unpressedNodeName": string;
  142366. "pressedNodeName": string;
  142367. };
  142368. defaultAxis: {
  142369. "valueNodeName": string;
  142370. "minNodeName": string;
  142371. "maxNodeName": string;
  142372. };
  142373. buttons: {
  142374. "xr-standard-trigger": {
  142375. "rootNodeName": string;
  142376. "componentProperty": string;
  142377. "states": string[];
  142378. };
  142379. "xr-standard-squeeze": {
  142380. "rootNodeName": string;
  142381. "componentProperty": string;
  142382. "states": string[];
  142383. };
  142384. "xr-standard-touchpad": {
  142385. "rootNodeName": string;
  142386. "labelAnchorNodeName": string;
  142387. "touchPointNodeName": string;
  142388. };
  142389. "xr-standard-thumbstick": {
  142390. "rootNodeName": string;
  142391. "componentProperty": string;
  142392. "states": string[];
  142393. };
  142394. };
  142395. axes: {
  142396. "xr-standard-touchpad": {
  142397. "x-axis": {
  142398. "rootNodeName": string;
  142399. };
  142400. "y-axis": {
  142401. "rootNodeName": string;
  142402. };
  142403. };
  142404. "xr-standard-thumbstick": {
  142405. "x-axis": {
  142406. "rootNodeName": string;
  142407. };
  142408. "y-axis": {
  142409. "rootNodeName": string;
  142410. };
  142411. };
  142412. };
  142413. };
  142414. /**
  142415. * The base url used to load the left and right controller models
  142416. */
  142417. static MODEL_BASE_URL: string;
  142418. /**
  142419. * The name of the left controller model file
  142420. */
  142421. static MODEL_LEFT_FILENAME: string;
  142422. /**
  142423. * The name of the right controller model file
  142424. */
  142425. static MODEL_RIGHT_FILENAME: string;
  142426. profileId: string;
  142427. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142428. protected _getFilenameAndPath(): {
  142429. filename: string;
  142430. path: string;
  142431. };
  142432. protected _getModelLoadingConstraints(): boolean;
  142433. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142434. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142435. protected _updateModel(): void;
  142436. }
  142437. }
  142438. declare module BABYLON {
  142439. /**
  142440. * The motion controller class for oculus touch (quest, rift).
  142441. * This class supports legacy mapping as well the standard xr mapping
  142442. */
  142443. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142444. private _forceLegacyControllers;
  142445. private _modelRootNode;
  142446. /**
  142447. * The base url used to load the left and right controller models
  142448. */
  142449. static MODEL_BASE_URL: string;
  142450. /**
  142451. * The name of the left controller model file
  142452. */
  142453. static MODEL_LEFT_FILENAME: string;
  142454. /**
  142455. * The name of the right controller model file
  142456. */
  142457. static MODEL_RIGHT_FILENAME: string;
  142458. /**
  142459. * Base Url for the Quest controller model.
  142460. */
  142461. static QUEST_MODEL_BASE_URL: string;
  142462. profileId: string;
  142463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142464. protected _getFilenameAndPath(): {
  142465. filename: string;
  142466. path: string;
  142467. };
  142468. protected _getModelLoadingConstraints(): boolean;
  142469. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142471. protected _updateModel(): void;
  142472. /**
  142473. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142474. * between the touch and touch 2.
  142475. */
  142476. private _isQuest;
  142477. }
  142478. }
  142479. declare module BABYLON {
  142480. /**
  142481. * The motion controller class for the standard HTC-Vive controllers
  142482. */
  142483. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142484. private _modelRootNode;
  142485. /**
  142486. * The base url used to load the left and right controller models
  142487. */
  142488. static MODEL_BASE_URL: string;
  142489. /**
  142490. * File name for the controller model.
  142491. */
  142492. static MODEL_FILENAME: string;
  142493. profileId: string;
  142494. /**
  142495. * Create a new Vive motion controller object
  142496. * @param scene the scene to use to create this controller
  142497. * @param gamepadObject the corresponding gamepad object
  142498. * @param handness the handness of the controller
  142499. */
  142500. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142501. protected _getFilenameAndPath(): {
  142502. filename: string;
  142503. path: string;
  142504. };
  142505. protected _getModelLoadingConstraints(): boolean;
  142506. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142507. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142508. protected _updateModel(): void;
  142509. }
  142510. }
  142511. declare module BABYLON {
  142512. /**
  142513. * A cursor which tracks a point on a path
  142514. */
  142515. export class PathCursor {
  142516. private path;
  142517. /**
  142518. * Stores path cursor callbacks for when an onchange event is triggered
  142519. */
  142520. private _onchange;
  142521. /**
  142522. * The value of the path cursor
  142523. */
  142524. value: number;
  142525. /**
  142526. * The animation array of the path cursor
  142527. */
  142528. animations: Animation[];
  142529. /**
  142530. * Initializes the path cursor
  142531. * @param path The path to track
  142532. */
  142533. constructor(path: Path2);
  142534. /**
  142535. * Gets the cursor point on the path
  142536. * @returns A point on the path cursor at the cursor location
  142537. */
  142538. getPoint(): Vector3;
  142539. /**
  142540. * Moves the cursor ahead by the step amount
  142541. * @param step The amount to move the cursor forward
  142542. * @returns This path cursor
  142543. */
  142544. moveAhead(step?: number): PathCursor;
  142545. /**
  142546. * Moves the cursor behind by the step amount
  142547. * @param step The amount to move the cursor back
  142548. * @returns This path cursor
  142549. */
  142550. moveBack(step?: number): PathCursor;
  142551. /**
  142552. * Moves the cursor by the step amount
  142553. * If the step amount is greater than one, an exception is thrown
  142554. * @param step The amount to move the cursor
  142555. * @returns This path cursor
  142556. */
  142557. move(step: number): PathCursor;
  142558. /**
  142559. * Ensures that the value is limited between zero and one
  142560. * @returns This path cursor
  142561. */
  142562. private ensureLimits;
  142563. /**
  142564. * Runs onchange callbacks on change (used by the animation engine)
  142565. * @returns This path cursor
  142566. */
  142567. private raiseOnChange;
  142568. /**
  142569. * Executes a function on change
  142570. * @param f A path cursor onchange callback
  142571. * @returns This path cursor
  142572. */
  142573. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142574. }
  142575. }
  142576. declare module BABYLON {
  142577. /** @hidden */
  142578. export var blurPixelShader: {
  142579. name: string;
  142580. shader: string;
  142581. };
  142582. }
  142583. declare module BABYLON {
  142584. /** @hidden */
  142585. export var pointCloudVertexDeclaration: {
  142586. name: string;
  142587. shader: string;
  142588. };
  142589. }
  142590. // Mixins
  142591. interface Window {
  142592. mozIndexedDB: IDBFactory;
  142593. webkitIndexedDB: IDBFactory;
  142594. msIndexedDB: IDBFactory;
  142595. webkitURL: typeof URL;
  142596. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142597. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142598. WebGLRenderingContext: WebGLRenderingContext;
  142599. MSGesture: MSGesture;
  142600. CANNON: any;
  142601. AudioContext: AudioContext;
  142602. webkitAudioContext: AudioContext;
  142603. PointerEvent: any;
  142604. Math: Math;
  142605. Uint8Array: Uint8ArrayConstructor;
  142606. Float32Array: Float32ArrayConstructor;
  142607. mozURL: typeof URL;
  142608. msURL: typeof URL;
  142609. VRFrameData: any; // WebVR, from specs 1.1
  142610. DracoDecoderModule: any;
  142611. setImmediate(handler: (...args: any[]) => void): number;
  142612. }
  142613. interface HTMLCanvasElement {
  142614. requestPointerLock(): void;
  142615. msRequestPointerLock?(): void;
  142616. mozRequestPointerLock?(): void;
  142617. webkitRequestPointerLock?(): void;
  142618. /** Track wether a record is in progress */
  142619. isRecording: boolean;
  142620. /** Capture Stream method defined by some browsers */
  142621. captureStream(fps?: number): MediaStream;
  142622. }
  142623. interface CanvasRenderingContext2D {
  142624. msImageSmoothingEnabled: boolean;
  142625. }
  142626. interface MouseEvent {
  142627. mozMovementX: number;
  142628. mozMovementY: number;
  142629. webkitMovementX: number;
  142630. webkitMovementY: number;
  142631. msMovementX: number;
  142632. msMovementY: number;
  142633. }
  142634. interface Navigator {
  142635. mozGetVRDevices: (any: any) => any;
  142636. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142637. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142638. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142639. webkitGetGamepads(): Gamepad[];
  142640. msGetGamepads(): Gamepad[];
  142641. webkitGamepads(): Gamepad[];
  142642. }
  142643. interface HTMLVideoElement {
  142644. mozSrcObject: any;
  142645. }
  142646. interface Math {
  142647. fround(x: number): number;
  142648. imul(a: number, b: number): number;
  142649. }
  142650. interface WebGLRenderingContext {
  142651. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142652. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142653. vertexAttribDivisor(index: number, divisor: number): void;
  142654. createVertexArray(): any;
  142655. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142656. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142657. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142658. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142659. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142660. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142661. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142662. // Queries
  142663. createQuery(): WebGLQuery;
  142664. deleteQuery(query: WebGLQuery): void;
  142665. beginQuery(target: number, query: WebGLQuery): void;
  142666. endQuery(target: number): void;
  142667. getQueryParameter(query: WebGLQuery, pname: number): any;
  142668. getQuery(target: number, pname: number): any;
  142669. MAX_SAMPLES: number;
  142670. RGBA8: number;
  142671. READ_FRAMEBUFFER: number;
  142672. DRAW_FRAMEBUFFER: number;
  142673. UNIFORM_BUFFER: number;
  142674. HALF_FLOAT_OES: number;
  142675. RGBA16F: number;
  142676. RGBA32F: number;
  142677. R32F: number;
  142678. RG32F: number;
  142679. RGB32F: number;
  142680. R16F: number;
  142681. RG16F: number;
  142682. RGB16F: number;
  142683. RED: number;
  142684. RG: number;
  142685. R8: number;
  142686. RG8: number;
  142687. UNSIGNED_INT_24_8: number;
  142688. DEPTH24_STENCIL8: number;
  142689. MIN: number;
  142690. MAX: number;
  142691. /* Multiple Render Targets */
  142692. drawBuffers(buffers: number[]): void;
  142693. readBuffer(src: number): void;
  142694. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142695. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142696. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142697. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142698. // Occlusion Query
  142699. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142700. ANY_SAMPLES_PASSED: number;
  142701. QUERY_RESULT_AVAILABLE: number;
  142702. QUERY_RESULT: number;
  142703. }
  142704. interface WebGLProgram {
  142705. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142706. }
  142707. interface EXT_disjoint_timer_query {
  142708. QUERY_COUNTER_BITS_EXT: number;
  142709. TIME_ELAPSED_EXT: number;
  142710. TIMESTAMP_EXT: number;
  142711. GPU_DISJOINT_EXT: number;
  142712. QUERY_RESULT_EXT: number;
  142713. QUERY_RESULT_AVAILABLE_EXT: number;
  142714. queryCounterEXT(query: WebGLQuery, target: number): void;
  142715. createQueryEXT(): WebGLQuery;
  142716. beginQueryEXT(target: number, query: WebGLQuery): void;
  142717. endQueryEXT(target: number): void;
  142718. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142719. deleteQueryEXT(query: WebGLQuery): void;
  142720. }
  142721. interface WebGLUniformLocation {
  142722. _currentState: any;
  142723. }
  142724. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142725. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142726. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142727. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142728. interface WebGLRenderingContext {
  142729. readonly RASTERIZER_DISCARD: number;
  142730. readonly DEPTH_COMPONENT24: number;
  142731. readonly TEXTURE_3D: number;
  142732. readonly TEXTURE_2D_ARRAY: number;
  142733. readonly TEXTURE_COMPARE_FUNC: number;
  142734. readonly TEXTURE_COMPARE_MODE: number;
  142735. readonly COMPARE_REF_TO_TEXTURE: number;
  142736. readonly TEXTURE_WRAP_R: number;
  142737. readonly HALF_FLOAT: number;
  142738. readonly RGB8: number;
  142739. readonly RED_INTEGER: number;
  142740. readonly RG_INTEGER: number;
  142741. readonly RGB_INTEGER: number;
  142742. readonly RGBA_INTEGER: number;
  142743. readonly R8_SNORM: number;
  142744. readonly RG8_SNORM: number;
  142745. readonly RGB8_SNORM: number;
  142746. readonly RGBA8_SNORM: number;
  142747. readonly R8I: number;
  142748. readonly RG8I: number;
  142749. readonly RGB8I: number;
  142750. readonly RGBA8I: number;
  142751. readonly R8UI: number;
  142752. readonly RG8UI: number;
  142753. readonly RGB8UI: number;
  142754. readonly RGBA8UI: number;
  142755. readonly R16I: number;
  142756. readonly RG16I: number;
  142757. readonly RGB16I: number;
  142758. readonly RGBA16I: number;
  142759. readonly R16UI: number;
  142760. readonly RG16UI: number;
  142761. readonly RGB16UI: number;
  142762. readonly RGBA16UI: number;
  142763. readonly R32I: number;
  142764. readonly RG32I: number;
  142765. readonly RGB32I: number;
  142766. readonly RGBA32I: number;
  142767. readonly R32UI: number;
  142768. readonly RG32UI: number;
  142769. readonly RGB32UI: number;
  142770. readonly RGBA32UI: number;
  142771. readonly RGB10_A2UI: number;
  142772. readonly R11F_G11F_B10F: number;
  142773. readonly RGB9_E5: number;
  142774. readonly RGB10_A2: number;
  142775. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142776. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142777. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142778. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142779. readonly DEPTH_COMPONENT32F: number;
  142780. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142781. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142782. 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;
  142783. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142784. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142785. readonly TRANSFORM_FEEDBACK: number;
  142786. readonly INTERLEAVED_ATTRIBS: number;
  142787. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142788. createTransformFeedback(): WebGLTransformFeedback;
  142789. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142790. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142791. beginTransformFeedback(primitiveMode: number): void;
  142792. endTransformFeedback(): void;
  142793. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142794. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142795. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142796. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142797. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142798. }
  142799. interface ImageBitmap {
  142800. readonly width: number;
  142801. readonly height: number;
  142802. close(): void;
  142803. }
  142804. interface WebGLQuery extends WebGLObject {
  142805. }
  142806. declare var WebGLQuery: {
  142807. prototype: WebGLQuery;
  142808. new(): WebGLQuery;
  142809. };
  142810. interface WebGLSampler extends WebGLObject {
  142811. }
  142812. declare var WebGLSampler: {
  142813. prototype: WebGLSampler;
  142814. new(): WebGLSampler;
  142815. };
  142816. interface WebGLSync extends WebGLObject {
  142817. }
  142818. declare var WebGLSync: {
  142819. prototype: WebGLSync;
  142820. new(): WebGLSync;
  142821. };
  142822. interface WebGLTransformFeedback extends WebGLObject {
  142823. }
  142824. declare var WebGLTransformFeedback: {
  142825. prototype: WebGLTransformFeedback;
  142826. new(): WebGLTransformFeedback;
  142827. };
  142828. interface WebGLVertexArrayObject extends WebGLObject {
  142829. }
  142830. declare var WebGLVertexArrayObject: {
  142831. prototype: WebGLVertexArrayObject;
  142832. new(): WebGLVertexArrayObject;
  142833. };
  142834. // Type definitions for WebVR API
  142835. // Project: https://w3c.github.io/webvr/
  142836. // Definitions by: six a <https://github.com/lostfictions>
  142837. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142838. interface VRDisplay extends EventTarget {
  142839. /**
  142840. * Dictionary of capabilities describing the VRDisplay.
  142841. */
  142842. readonly capabilities: VRDisplayCapabilities;
  142843. /**
  142844. * z-depth defining the far plane of the eye view frustum
  142845. * enables mapping of values in the render target depth
  142846. * attachment to scene coordinates. Initially set to 10000.0.
  142847. */
  142848. depthFar: number;
  142849. /**
  142850. * z-depth defining the near plane of the eye view frustum
  142851. * enables mapping of values in the render target depth
  142852. * attachment to scene coordinates. Initially set to 0.01.
  142853. */
  142854. depthNear: number;
  142855. /**
  142856. * An identifier for this distinct VRDisplay. Used as an
  142857. * association point in the Gamepad API.
  142858. */
  142859. readonly displayId: number;
  142860. /**
  142861. * A display name, a user-readable name identifying it.
  142862. */
  142863. readonly displayName: string;
  142864. readonly isConnected: boolean;
  142865. readonly isPresenting: boolean;
  142866. /**
  142867. * If this VRDisplay supports room-scale experiences, the optional
  142868. * stage attribute contains details on the room-scale parameters.
  142869. */
  142870. readonly stageParameters: VRStageParameters | null;
  142871. /**
  142872. * Passing the value returned by `requestAnimationFrame` to
  142873. * `cancelAnimationFrame` will unregister the callback.
  142874. * @param handle Define the hanle of the request to cancel
  142875. */
  142876. cancelAnimationFrame(handle: number): void;
  142877. /**
  142878. * Stops presenting to the VRDisplay.
  142879. * @returns a promise to know when it stopped
  142880. */
  142881. exitPresent(): Promise<void>;
  142882. /**
  142883. * Return the current VREyeParameters for the given eye.
  142884. * @param whichEye Define the eye we want the parameter for
  142885. * @returns the eye parameters
  142886. */
  142887. getEyeParameters(whichEye: string): VREyeParameters;
  142888. /**
  142889. * Populates the passed VRFrameData with the information required to render
  142890. * the current frame.
  142891. * @param frameData Define the data structure to populate
  142892. * @returns true if ok otherwise false
  142893. */
  142894. getFrameData(frameData: VRFrameData): boolean;
  142895. /**
  142896. * Get the layers currently being presented.
  142897. * @returns the list of VR layers
  142898. */
  142899. getLayers(): VRLayer[];
  142900. /**
  142901. * Return a VRPose containing the future predicted pose of the VRDisplay
  142902. * when the current frame will be presented. The value returned will not
  142903. * change until JavaScript has returned control to the browser.
  142904. *
  142905. * The VRPose will contain the position, orientation, velocity,
  142906. * and acceleration of each of these properties.
  142907. * @returns the pose object
  142908. */
  142909. getPose(): VRPose;
  142910. /**
  142911. * Return the current instantaneous pose of the VRDisplay, with no
  142912. * prediction applied.
  142913. * @returns the current instantaneous pose
  142914. */
  142915. getImmediatePose(): VRPose;
  142916. /**
  142917. * The callback passed to `requestAnimationFrame` will be called
  142918. * any time a new frame should be rendered. When the VRDisplay is
  142919. * presenting the callback will be called at the native refresh
  142920. * rate of the HMD. When not presenting this function acts
  142921. * identically to how window.requestAnimationFrame acts. Content should
  142922. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142923. * asynchronously from other displays and at differing refresh rates.
  142924. * @param callback Define the eaction to run next frame
  142925. * @returns the request handle it
  142926. */
  142927. requestAnimationFrame(callback: FrameRequestCallback): number;
  142928. /**
  142929. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142930. * Repeat calls while already presenting will update the VRLayers being displayed.
  142931. * @param layers Define the list of layer to present
  142932. * @returns a promise to know when the request has been fulfilled
  142933. */
  142934. requestPresent(layers: VRLayer[]): Promise<void>;
  142935. /**
  142936. * Reset the pose for this display, treating its current position and
  142937. * orientation as the "origin/zero" values. VRPose.position,
  142938. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142939. * updated when calling resetPose(). This should be called in only
  142940. * sitting-space experiences.
  142941. */
  142942. resetPose(): void;
  142943. /**
  142944. * The VRLayer provided to the VRDisplay will be captured and presented
  142945. * in the HMD. Calling this function has the same effect on the source
  142946. * canvas as any other operation that uses its source image, and canvases
  142947. * created without preserveDrawingBuffer set to true will be cleared.
  142948. * @param pose Define the pose to submit
  142949. */
  142950. submitFrame(pose?: VRPose): void;
  142951. }
  142952. declare var VRDisplay: {
  142953. prototype: VRDisplay;
  142954. new(): VRDisplay;
  142955. };
  142956. interface VRLayer {
  142957. leftBounds?: number[] | Float32Array | null;
  142958. rightBounds?: number[] | Float32Array | null;
  142959. source?: HTMLCanvasElement | null;
  142960. }
  142961. interface VRDisplayCapabilities {
  142962. readonly canPresent: boolean;
  142963. readonly hasExternalDisplay: boolean;
  142964. readonly hasOrientation: boolean;
  142965. readonly hasPosition: boolean;
  142966. readonly maxLayers: number;
  142967. }
  142968. interface VREyeParameters {
  142969. /** @deprecated */
  142970. readonly fieldOfView: VRFieldOfView;
  142971. readonly offset: Float32Array;
  142972. readonly renderHeight: number;
  142973. readonly renderWidth: number;
  142974. }
  142975. interface VRFieldOfView {
  142976. readonly downDegrees: number;
  142977. readonly leftDegrees: number;
  142978. readonly rightDegrees: number;
  142979. readonly upDegrees: number;
  142980. }
  142981. interface VRFrameData {
  142982. readonly leftProjectionMatrix: Float32Array;
  142983. readonly leftViewMatrix: Float32Array;
  142984. readonly pose: VRPose;
  142985. readonly rightProjectionMatrix: Float32Array;
  142986. readonly rightViewMatrix: Float32Array;
  142987. readonly timestamp: number;
  142988. }
  142989. interface VRPose {
  142990. readonly angularAcceleration: Float32Array | null;
  142991. readonly angularVelocity: Float32Array | null;
  142992. readonly linearAcceleration: Float32Array | null;
  142993. readonly linearVelocity: Float32Array | null;
  142994. readonly orientation: Float32Array | null;
  142995. readonly position: Float32Array | null;
  142996. readonly timestamp: number;
  142997. }
  142998. interface VRStageParameters {
  142999. sittingToStandingTransform?: Float32Array;
  143000. sizeX?: number;
  143001. sizeY?: number;
  143002. }
  143003. interface Navigator {
  143004. getVRDisplays(): Promise<VRDisplay[]>;
  143005. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143006. }
  143007. interface Window {
  143008. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143009. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143010. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143011. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143012. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143013. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143014. }
  143015. interface Gamepad {
  143016. readonly displayId: number;
  143017. }
  143018. type XRSessionMode =
  143019. | "inline"
  143020. | "immersive-vr"
  143021. | "immersive-ar";
  143022. type XRReferenceSpaceType =
  143023. | "viewer"
  143024. | "local"
  143025. | "local-floor"
  143026. | "bounded-floor"
  143027. | "unbounded";
  143028. type XREnvironmentBlendMode =
  143029. | "opaque"
  143030. | "additive"
  143031. | "alpha-blend";
  143032. type XRVisibilityState =
  143033. | "visible"
  143034. | "visible-blurred"
  143035. | "hidden";
  143036. type XRHandedness =
  143037. | "none"
  143038. | "left"
  143039. | "right";
  143040. type XRTargetRayMode =
  143041. | "gaze"
  143042. | "tracked-pointer"
  143043. | "screen";
  143044. type XREye =
  143045. | "none"
  143046. | "left"
  143047. | "right";
  143048. interface XRSpace extends EventTarget {
  143049. }
  143050. interface XRRenderState {
  143051. depthNear?: number;
  143052. depthFar?: number;
  143053. inlineVerticalFieldOfView?: number;
  143054. baseLayer?: XRWebGLLayer;
  143055. }
  143056. interface XRInputSource {
  143057. handedness: XRHandedness;
  143058. targetRayMode: XRTargetRayMode;
  143059. targetRaySpace: XRSpace;
  143060. gripSpace: XRSpace | undefined;
  143061. gamepad: Gamepad | undefined;
  143062. profiles: Array<string>;
  143063. }
  143064. interface XRSessionInit {
  143065. optionalFeatures?: XRReferenceSpaceType[];
  143066. requiredFeatures?: XRReferenceSpaceType[];
  143067. }
  143068. interface XRSession extends XRAnchorCreator {
  143069. addEventListener: Function;
  143070. removeEventListener: Function;
  143071. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143072. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143073. requestAnimationFrame: Function;
  143074. end(): Promise<void>;
  143075. renderState: XRRenderState;
  143076. inputSources: Array<XRInputSource>;
  143077. // AR hit test
  143078. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143079. updateWorldTrackingState(options: {
  143080. planeDetectionState?: { enabled: boolean; }
  143081. }): void;
  143082. }
  143083. interface XRReferenceSpace extends XRSpace {
  143084. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143085. onreset: any;
  143086. }
  143087. type XRPlaneSet = Set<XRPlane>;
  143088. type XRAnchorSet = Set<XRAnchor>;
  143089. interface XRFrame {
  143090. session: XRSession;
  143091. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143092. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143093. // Anchors
  143094. trackedAnchors?: XRAnchorSet;
  143095. // Planes
  143096. worldInformation: {
  143097. detectedPlanes?: XRPlaneSet;
  143098. };
  143099. }
  143100. interface XRViewerPose extends XRPose {
  143101. views: Array<XRView>;
  143102. }
  143103. interface XRPose {
  143104. transform: XRRigidTransform;
  143105. emulatedPosition: boolean;
  143106. }
  143107. interface XRWebGLLayerOptions {
  143108. antialias?: boolean;
  143109. depth?: boolean;
  143110. stencil?: boolean;
  143111. alpha?: boolean;
  143112. multiview?: boolean;
  143113. framebufferScaleFactor?: number;
  143114. }
  143115. declare var XRWebGLLayer: {
  143116. prototype: XRWebGLLayer;
  143117. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143118. };
  143119. interface XRWebGLLayer {
  143120. framebuffer: WebGLFramebuffer;
  143121. framebufferWidth: number;
  143122. framebufferHeight: number;
  143123. getViewport: Function;
  143124. }
  143125. declare class XRRigidTransform {
  143126. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143127. position: DOMPointReadOnly;
  143128. orientation: DOMPointReadOnly;
  143129. matrix: Float32Array;
  143130. inverse: XRRigidTransform;
  143131. }
  143132. interface XRView {
  143133. eye: XREye;
  143134. projectionMatrix: Float32Array;
  143135. transform: XRRigidTransform;
  143136. }
  143137. interface XRInputSourceChangeEvent {
  143138. session: XRSession;
  143139. removed: Array<XRInputSource>;
  143140. added: Array<XRInputSource>;
  143141. }
  143142. interface XRInputSourceEvent extends Event {
  143143. readonly frame: XRFrame;
  143144. readonly inputSource: XRInputSource;
  143145. }
  143146. // Experimental(er) features
  143147. declare class XRRay {
  143148. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143149. origin: DOMPointReadOnly;
  143150. direction: DOMPointReadOnly;
  143151. matrix: Float32Array;
  143152. }
  143153. interface XRHitResult {
  143154. hitMatrix: Float32Array;
  143155. }
  143156. interface XRAnchor {
  143157. // remove?
  143158. id?: string;
  143159. anchorSpace: XRSpace;
  143160. lastChangedTime: number;
  143161. detach(): void;
  143162. }
  143163. interface XRPlane extends XRAnchorCreator {
  143164. orientation: "Horizontal" | "Vertical";
  143165. planeSpace: XRSpace;
  143166. polygon: Array<DOMPointReadOnly>;
  143167. lastChangedTime: number;
  143168. }
  143169. interface XRAnchorCreator {
  143170. // AR Anchors
  143171. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143172. }